blob_id
stringlengths
40
40
language
stringclasses
1 value
repo_name
stringlengths
4
137
path
stringlengths
2
355
src_encoding
stringclasses
31 values
length_bytes
int64
11
3.9M
score
float64
2.52
5.47
int_score
int64
3
5
detected_licenses
listlengths
0
49
license_type
stringclasses
2 values
text
stringlengths
11
3.93M
download_success
bool
1 class
ddf43b084e2f69862801f2fac7b50d9677672638
Ruby
eloudon/ruby-instance-variables-lab-online-web-ft-081219
/lib/dog.rb
UTF-8
251
3.921875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# @ symbol = instance variable. Removes the barrier of scope between methods inside a class. class Dog def name=(dog_name) @this_dogs_name = dog_name end def name @this_dogs_name end end lassie = Dog.new lassie.name = "Lassie" puts lassie.name
true
f72168247c23fb2fa873a8cb69c553c44945660e
Ruby
chris-groves/Gilded-Rose-Kata
/ruby/spec/daily_stock_check_spec.rb
UTF-8
3,958
3.09375
3
[ "MIT" ]
permissive
require "daily_stock_check" describe DailyStockCheck do describe "#update_item" do context "when there are no items" do it "returns an empty array" do items = [] expect(described_class.new(items).update_items).to eq [] end end context "when an invalid item is updated" do ...
true
7490f98ae66005427c28dd359cfebad98e0fd051
Ruby
chongct/array-practice-1
/spec/pseudocode.rb
UTF-8
2,086
3.984375
4
[]
no_license
class String def dashes # normal cases # - self must be a string () # - all string must be a digit # - put dash respectively 1357 => 1357 # 0246 = 0-2-4-6 # edge # - if it's not a digit, don't add any dash (edge) #split the string into an Array #run an e...
true
185cae66d446066bbac03cd9ec23d213c509d58b
Ruby
ComaToastUK/pairing_challenges
/week1/array1.rb
UTF-8
89
3.34375
3
[]
no_license
array = [1, 2, 3, 4, 5] def plus_one(array) array.each { |n| n+=1 } return array end
true
10dc1d0cf6b158b51dcb2b5aa56e6273dc3919b2
Ruby
karmajunkie/rollcall
/db/fixtures/schools.rb
UTF-8
908
2.65625
3
[ "MIT" ]
permissive
schools=File.open(File.dirname(__FILE__) + '/schools.csv').read.split("\n").map{|row| row.strip.split(",")} @district = SchoolDistrict.find_or_create_by_name(:name => "Houston ISD") { |district| district.jurisdiction=Jurisdiction.find_or_create_by_name("Harris") } schools.each do |school| if school[0].nil? put...
true
f8fd7f4fe33257d8559a10815e08fa709b0a811d
Ruby
hongtron/betting_game
/game
UTF-8
1,602
3.703125
4
[]
no_license
#!/usr/bin/env ruby class Game attr_reader :game_over def initialize(input) @starting_amount = input[0].to_i @baseline_bet = input[1].to_i @number_of_rounds = input[2].to_i @results = input[3].split(" ").map(&:to_i) @state = [] @current_round = 0 @game_over = false Round.baseline_...
true
a3502adaf795a9d33e8a0217da2e486fe975ebf1
Ruby
DuncanYe/note
/ruby_lesson/oop/Q4.rb
UTF-8
2,291
4
4
[]
no_license
class Hero attr_accessor :hp, :name @@heroes = [] def initialize(name, hp, ap, sp) @name = name @hp = hp @ap = ap @sp = sp @alive = true puts "你的英雄 #{@name}強勢登場!!" puts "生命力(HP) : #{@hp}" puts "攻擊力(AP) : #{@ap}" puts "體力(SP) : #{@sp}" puts "" end def is_alive?...
true
981da95e5d12a78fb172dd039e3b2f8e04b4f06e
Ruby
brundage/packetfu
/lib/packetfu/pcap_packet.rb
UTF-8
1,421
2.890625
3
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
# -*- coding: binary -*- module PacketFu # PcapPacket defines how individual packets are stored in a libpcap-formatted # file. # # ==== Header Definition # # Timestamp :timestamp # Int32 :incl_len # Int32 :orig_len # String :data class PcapPacket < Struct.new(:endian, :timestamp, :inc...
true
9a030e4399ef8231ae54c5a971e924da4a432815
Ruby
brianlamb/TokyoTechX-CS101
/kadai5/ango.rb
UTF-8
560
3.84375
4
[]
no_license
# # ango.rb # # 入力: 文字列 # # 出力: 入力した文字列をシーザー暗号(k 字シフト)で暗号化した文字列 def enc(k, m) code_a = 97 leng = m.length b = Array.new(leng, 0) a = m.unpack("C*") for i in 0..(leng-1) #  ここで a[i] を k シフトした値を b[i] に代入 sa = a[i] - code_a if 0 <= sa && sa <=25 sa = (sa + k) % 26 end b[i]...
true
09b84cea590cd2be07b9fb20703c32e5ec7609bb
Ruby
tacklebox-webhooks/ruby
/lib/tacklebox/components/service.rb
UTF-8
418
2.734375
3
[ "MIT" ]
permissive
require_relative "../apis/service_api" class Service attr_accessor :api def initialize(config) self.api = ServiceApi.new(config) end def list self.api.list_services() end def create(serviceData) self.api.create_service(serviceData) end def get(service_id) self.api.get_servic...
true
773aff857fb151c1c28ad317fe9cb93e2df896b4
Ruby
sonota88/practice-react
/server.rb
UTF-8
1,592
2.921875
3
[]
no_license
require "json" require "sinatra" require "sinatra/reloader" class Items @@items = [ { id: 1, name: "foo", note: "note 1"}, { id: 2, name: "bar", note: "note 2"} ] def self.get id @@items.find{|item| item[:id] == id } end def self.get_all @@items end def self.add item @@i...
true
f852c9e092bfb989c268824d84f8841ed14ce16a
Ruby
jgstern/ruby-challenges
/always_three_def.rb
UTF-8
147
3.390625
3
[]
no_license
def always_three print "Give me a number:" input = gets puts "final num is #{((((input.to_i + 5) * 2) - 4) / 2) - input.to_i}" end always_three
true
94ec329196fba0ddf7d9859b96e65aa5483d1a9d
Ruby
armaanv/fa15-hw1
/foobar.rb
UTF-8
276
3.21875
3
[]
no_license
class Foobar # Q4 CODE HERE def self.baz(array) sum = 0 array= array.map { |e| Integer(e) +2 } array = array.delete_if { |e| e > 10 } array = array.delete_if { |e| e % 2 != 0} array = array.uniq array.each {|e| sum+= e} return sum end end
true
f840fb4906527aff136ed422680a93df46222cb0
Ruby
ReyRizki/prinsip-bahasa-pemrograman
/ruby-oop/3.rb
UTF-8
390
3.609375
4
[]
no_license
class Product def initialize(name, brand, type, price, stock) @name = name @brand = brand @type = type @price = price @stock = stock end attr_accessor :name, :brand, :type, :price, :stock def to_s puts "#{@name} | #{@brand} | #{@type} | #{@price} | #{@stock}" end end product = Produ...
true
fbb4e4201f0b2641df7d342e3f6a0bdb3af84918
Ruby
kyohei-horikawa/sage_ruby
/Algebra.rb
UTF-8
393
3.140625
3
[]
no_license
require "./SageMath.rb" class Algebra < Sage def add(a, b) @command_list << "#{a}+#{b}" end def factor(f) @command_list << "factor(#{f})" end def expand(f) @command_list << "expand(#{f})" end end a = Algebra.new() input = "(y+1)**2" a.define_symbol("x,y,z") a.expand(input) output1 = a.exec...
true
c40f740c39d1ecd08be2878f14fa0bb19708e1e9
Ruby
jameschou93/Rally
/app/views/api/v1/groups/index.json.jbuilder
UTF-8
444
2.515625
3
[]
no_license
json.array! @groups.each do |group| json.id group.id json.name group.name json.bio group.bio json.private group.private? json.mygroup group.mygroup?(current_user) json.categories group.categories.each do |category| json.id category.id json.name category.name end json.members group.users.each do |user| json.id user....
true
725b9c8ef6f05309836f94d139e38ea09d0d077a
Ruby
wvulibraries/aspace_reporting
/init.rb
UTF-8
700
2.765625
3
[]
no_license
#!/usr/bin/env ruby # gems require 'mysql2' require 'rubyXL' # require lib folder Dir['./lib/*.rb'].each {|file| require file } # set the root as a constant global root = File.dirname(__FILE__) # grabs the sql file you want to get form the database to put into the excel file sql_file = FileHelper.new("#{root}/sql/...
true
5026efec917405406d05977c9baa30f367171ae1
Ruby
aweshin/PriorityQueue
/priority_queue.rb
UTF-8
688
3.53125
4
[]
no_license
class PriorityQueue def initialize @n = 0 @heap = [] end def maxHeapify x l = 2*x r = 2*x+1 if l <= @n && @heap[l] > @heap[x] largest = l else largest = x end if r <= @n && @heap[r] > @heap[largest] largest = r end if largest != x @heap[x], @heap[...
true
1f2b40bad7e5213608b5f9463ca2de205fbf179c
Ruby
JonLavi/COFFEE
/models/console.rb
UTF-8
2,221
2.96875
3
[]
no_license
require('pry') require_relative('producer') require_relative('product') require_relative('blend') require_relative('origin') require_relative('roast') require_relative('type') Product.delete_all() Producer.delete_all() blend1 = Blend.new({'name' => 'Arabica'}) blend1.save() blend2 = Blend.new({'name' => 'Robusta'}) b...
true
67e859ed97e1c5934c608910c0a2f9b3086ce9e4
Ruby
adifsgaid/leetCodeExo
/allCounstruct.rb
UTF-8
911
3.234375
3
[]
no_license
def all_contruct(target, wordBank) return [[]] if target == '' result = [] wordBank.each do |word| if target.index(word) == 0 suffix = target.slice(word.length) suffixResult = all_contruct(suffix, wordBank) suffixWay = suffixResult.map { |e| [ word, *e] } result.push(*suffixWay) end...
true
7548118ac0135fb4e3469158258d61bd4ef9916c
Ruby
boogity/ruby
/encrypt.incomplete.rb
UTF-8
1,779
3.921875
4
[]
no_license
#/Cryptologist Bruce Schneier designed the hand cipher "Solitaire" for Neal Stephenson's # book "Cryptonomicon". Created to be the first truly secure hand cipher, # Solitaire requires only a deck of cards for the encryption and decryption of messages. # # While it's true that Solitaire is easily completed by hand give...
true
db2ece8bd56d38c6fc3e9db5f806419e99bcecc8
Ruby
ChikaKanu/Week_02-weekend-homework
/specs/rooms_spec.rb
UTF-8
2,177
3.046875
3
[]
no_license
require("minitest/autorun") require('minitest/rg') require_relative("../rooms.rb") require_relative("../bar") require_relative("../guests") require_relative("../songs") require_relative("../drinks") class RoomsTest < MiniTest::Test def setup @unoccupied_rooms = ["room_1", "room_2", "room_3", "room_4", "room_5"]...
true
980891d2d704a04de7d70a18a2d8c3da46003ccf
Ruby
rogergraves/meetingsurvey
/app/presenters/report_presenter.rb
UTF-8
2,864
2.625
3
[]
no_license
class ReportPresenter < BasePresenter presents :meeting_occurrence def yes_or_no_question_report(question) %Q( <ul class="list-group"> <li class="list-group-item"> <b>#{question[:question]}</b><br> <ul class="list-group"> #{question_report(answers_html(question...
true
1fdefc89d920f0ac737f21d14452b6f101b15ebb
Ruby
syu1/CS1632-Software-QA
/Project-3 Billcoin CryptoCoin Transaction Verifier/person.rb
UTF-8
317
3.703125
4
[]
no_license
class Person def initialize(name, coin_amount) @name = name @coin_amount = coin_amount end def get_name @name end def coin_amount @coin_amount end def add(add_amount) @coin_amount += add_amount end def subtract(subtract_amount) @coin_amount -= subtract_amount end end
true
8926e011fa8452c1488d000e1ddc89a619b8ff32
Ruby
revans/geodesy
/lib/geodesy/latitude.rb
UTF-8
195
2.84375
3
[ "MIT" ]
permissive
module Geodesy class Latitude using FloatExtension attr_reader :angle def initialize(lat) @angle = lat end def to_radians angle.to_radians end end end
true
041e7f59ee5983d9fadf15d8adbf39362fc1a208
Ruby
Derbeth/poeta
/poem_files.rb
UTF-8
1,319
2.8125
3
[ "MIT" ]
permissive
# -*- encoding: utf-8 -*- module Poeta class PoemFiles attr_reader :dictionary_file, :grammar_file, :sentences_file, :title_sentences_file attr_reader :dictionary_config_file, :general_config_file attr_writer :io def initialize(language,dictionary=nil) @io = File @language = language @default_dict =...
true
7390543e4064d75f319a38b809c1a70797d8e8e8
Ruby
rails/rails
/activejob/test/jobs/retry_job.rb
UTF-8
2,497
2.65625
3
[ "MIT", "Ruby" ]
permissive
# frozen_string_literal: true require_relative "../support/job_buffer" require "active_support/core_ext/integer/inflections" class DefaultsError < StandardError; end class DisabledJitterError < StandardError; end class ZeroJitterError < StandardError; end class FirstRetryableErrorOfTwo < StandardError; end class Seco...
true
01c5b0f0335c22489222ec7cf1687e0c29f26c14
Ruby
patrodriguez108/maximum-subarray
/maximum_subarray.rb
UTF-8
306
3.921875
4
[]
no_license
# Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. def max_sub_array(nums) end example_one = [-2, 1, -3, 4, -1, 2, 1, -5, 4] max_sub_array(example_one) # Output: 6 # Explanation: [4,-1,2,1] has the largest sum = 6
true
49580f39ba351681cf3e0a581d2ba285825fdfbc
Ruby
tractorfeed/poligraph-api
/lib/Bill.rb
UTF-8
788
3.140625
3
[]
no_license
require 'pg' # HSW "finder" class. # mostly pseudocode, but probably would work... class Bill # This is a public, 'global' var attr_accessor :hostname # Put whatever you need here to initialize the DB conn. def initialize(hostname="localhost") # localhost is the default if there's no arg @hostname = ...
true
0b69c9bd4e4695a004fb4984ec2b2b87a7c1e688
Ruby
pepijn/qantani
/lib/qantani.rb
UTF-8
1,733
2.546875
3
[ "MIT" ]
permissive
require 'httparty' require 'builder' require 'active_support/core_ext/hash' require 'qantani/response' require 'qantani/request' require 'qantani/bank' module Qantani API_ENDPOINT = 'https://www.qantanipayments.com/api/' DEFAULT_CURRENCY = 'EUR' REQUEST_SETTINGS = :merchant_id, :merchant_key SETTINGS = REQUE...
true
a71af82932881370ae5e778608d0ba893a406131
Ruby
Andyarran/Animal_Shelter_Project
/models/animal.rb
UTF-8
2,126
3.34375
3
[]
no_license
require_relative( '../db/sql_runner' ) class Animal attr_reader( :id, :name, :admission_date, :type_id, :ready, :sex, :age, :description, :owner_id, :image) def initialize(options) @id = options['id'].to_i if options['id'] @name = options['name'] @admission_date = options['admission_date'] ...
true
edc651b7bd1a96179bfa45c9662501c4eb99d5be
Ruby
mirubenstein/say
/say.rb
UTF-8
1,567
3.453125
3
[]
no_license
class Say NUMBERS = { 1_000_000_000 => 'billion', 1_000_000 => 'million', 1000 => 'thousand', 100 => 'hundred', 90 => 'ninety', 80 => 'eighty', 70 => 'seventy', 60 => 'sixty', 50 => 'fifty', 40 => 'forty', 30 => 'thirty', 20 => 'twenty', 19 => 'nineteen', 18 => 'eighteen', 17 => 'seventeen', 16 => 'sixtee...
true
325f1480884dbc3479d49cf3b9338411b9df167b
Ruby
antoniablair/Story-Generator
/Storygenerator.rb
UTF-8
10,797
3.515625
4
[]
no_license
# Storygenerator: creates a story based on the genre the user chooses (using a madlib format) # Get user's story choice. def choosestory(username) storychoice = gets.chomp.downcase case storychoice when 'cop story', 'cop story', 'cop', 'cop' puts " You have chosen Cop Story." copstory(username) when 'rom...
true
f8f4712cc900c15c6943847abe241ce6968fee50
Ruby
leonardbarreto/sgapp
/app/helpers/application_helper.rb
UTF-8
789
2.5625
3
[]
no_license
# encoding: utf-8 module ApplicationHelper def paginate_bootstrap(objeto) will_paginate(objeto, renderer: BootstrapPagination::Rails) end def timeFormat(hora) hora.strftime("%H:%M") end def dateFormat(data) data.strftime("%D/%M%/%Y") end #Contabilizar a quantidade de dias desde o último atendimento até o ...
true
db79571c5b408532140efa65fb4cfca22f2ba8a7
Ruby
KennethEhmsen/vyos-firewall-generator
/lib/vyos-generate-firewall.rb
UTF-8
5,316
2.546875
3
[]
no_license
require 'vyos-config' require 'titleize' class VyOSFirewallGenerator attr_accessor :input attr_accessor :config def initialize(input=nil) @config = VyOSConfig.new @input = input end def aliases input['aliases'] end def zones input['zones'] end def zone_names zones.keys end ...
true
8fc68639c8cfea9ed0b5a6bd39d1fc6568d15666
Ruby
adamkowalczyk/ruby-the-hard-way
/ex17c.rb
UTF-8
351
3.4375
3
[]
no_license
# david wicke's version. looking into it, I discovered that .write and .read close the file automatically. # so, my version passing a block to close the file was redundant File.open(ARGV[1], 'w').write(File.open(ARGV[0]).read) # interestingly, can't call .closed? to check state, as write and read return a string # p...
true
835494d01b04f37ffc261338634a1eb9a920748e
Ruby
seb-faull/sinatra_to_do_app
/ToDoManager.rb
UTF-8
627
3.265625
3
[]
no_license
class ToDoManager @@todos = ["Buy some milk!", "Feed the cat"] #class variable def self.index @@todos.join(" | ") end def self.show (id) @@todos[id] end def self.create (new_todo) @@todos.push(new_todo) #@@todos << new_todo @@todos.join(" | ") end ...
true
29c1c5ce850c306f3609029fc0615f542fe66a7b
Ruby
Hidayat-rivai/ruby_nilclass
/nilclass.rb
UTF-8
474
3.5
4
[]
no_license
def cari(nilai, daftar) hasil = nil daftar.each do |elemen| if elemen == nilai hasil = daftar.index(elemen) end end return hasil end if $0 == __FILE__ array = [100,200,300,400,500] index1 = cari(300,array) if index1 puts "300 ditemukan pada index ke-#{index1}" else puts "300 tidak ditemukan dala...
true
90b9a05f678e0f71f4aebda558b58811fdb08ba1
Ruby
kna9/test
/Test/app/models/result_level2.rb
UTF-8
1,249
2.90625
3
[]
no_license
class ResultLevel2 < ResultClass attr_accessor :orders def initialize(data_struc) @orders = [] data_documents = data_struc.documents data_orders = data_struc.orders promotions = data_struc.promotions data_orders.each do |data_order| document = find_item_by_id(data_order.do...
true
5960de1ad2c418bb3043ba734ae9c0de99df2028
Ruby
marciandmnd/rpncalculator
/test/unit/rpn_calculator/test_rpn_calculator.rb
UTF-8
1,314
2.921875
3
[ "MIT" ]
permissive
require_relative "#{LIB_PATH}/rpn_calculator/rpn_calculator" require 'minitest/autorun' class TestRPNCalculator < Minitest::Test def setup @rpn_calculator = RPNCalculator.new end def test_stack # initial stack stack = @rpn_calculator.stack assert_equal([], stack) # stack with operands e...
true
d0232d2f1dd03c4ce2821c342c8d6e1e1d24bb33
Ruby
armi1401/Udemy-The-Complete-Beginners-Guide-to-Ruby
/grades.rb
UTF-8
340
3.5
4
[]
no_license
student_standing = {} @student_count = 0 until @student_count > 2 puts "Enter name of student: " student_name = gets.chomp puts "Enter grade for the student: " grade = gets.chomp.to_i student_standing[student_name] = grade @student_count += 1 end puts "" puts student_standing.sort_by {|st...
true
96fb5c718770a28f0649e461344c1a8cd8e81317
Ruby
zangzing/zz-chef-repo
/cookbooks/deploy-manager/libraries/photos_config.rb
UTF-8
3,865
2.703125
3
[]
no_license
# do custom environment setup for photos # determine relationship of machines and # store back into zz node, once configured # we output the zz node data as json which # can be used by the app to pull in custom # configuration - this data will hang under # zz{:photos_config] # class Chef::Recipe::PhotosConfig # figur...
true
df104d0ff55a537e31ef90f7eabcae28225bb897
Ruby
gabrielecirulli/supernova
/lib/supernova/remote/fake/operating_system.rb
UTF-8
1,837
2.875
3
[ "MIT" ]
permissive
module Supernova module Remote module Fake # Manage operating system tasks like instlaling packages. # # @abstract Implement the methods in another remote to create # a working operating system module. module OperatingSystem # Creates a user with the given name and option...
true
7d6d5bf18bf5ed44c52976cd067dc82f5b1eb621
Ruby
jvanassche/davieswidgets
/app/models/order.rb
UTF-8
1,757
2.59375
3
[]
no_license
class Order < ActiveRecord::Base attr_accessible :CustomerID, :EmployeeID, :OrderDate, :PurchaseOrderNumber, :ShipDate, :ShippingMethodID, :SalesTaxRate has_many :order_details has_many :payments belongs_to :customer, :foreign_key => 'CustomerID' belongs_to :employee, :foreign_key => 'EmployeeID' belongs_to...
true
c0a4fb5ebbd42d00f51d1da92b77d02ef22bdb34
Ruby
wildfiler/mysqldump-processor
/lib/table_definition.rb
UTF-8
331
2.828125
3
[]
no_license
class TableDefinition attr_reader :name, :fields def initialize(name, fields) @name = name @fields = fields end def [](field) field_index(field) end private def field_index(field) fields_indexes[field.to_s] end def fields_indexes @fields_indexes ||= fields.each.with_index.to_h...
true
775728069784fb425ec8577bc620b550cc90e80b
Ruby
lbvf50mobile/til
/20230626_Monday/20230626.rb
UTF-8
1,164
3.34375
3
[]
no_license
# Leetcode: 2462. Total Cost to Hire K Workers. # https://leetcode.com/problems/total-cost-to-hire-k-workers/ # = = = = = = = = = = = = = = # Thanks God, Jesus Christ! # = = = = = = = = = = = = = = # 2023.06.26 Daily Challenge. # @param {Integer[]} costs # @param {Integer} k # @param {Integer} candidates # @return {Int...
true
d8b84a0fbf720832e23ee309f0c167ea7db7bac0
Ruby
russellvaughan/russellator
/lib/qualifier.rb
UTF-8
3,652
2.5625
3
[]
no_license
require './lib/driver' class Qualifier attr_reader :qualification USER_SYSTEM = %w(sign\ in log\ in LOGIN log_in Login sign\ up register Sign\ In Sign\ Up Log\ in Sign\ in Log\ In signup) def initialize(website) @website = website @qualification = {} end def qualify @user_sites = Driver.new(@...
true
43f0bcf641505256c7e5f908f8e6ecd7c58e8a3d
Ruby
hasumin71/rensyu
/drill_20.rb
UTF-8
585
3.953125
4
[]
no_license
#以下のハッシュから値だけを取り出し、配列にしてください、ただ、hashクラスのvaluesメソッドは使用しないこと =begin values = [] attr.each do |key,value| #ハッシュattrのkeyとvalueを回して #なぜかvalueだけ回して、空の配列に回しても二次元配列になってしまう。なぜ? values << value #取り出したvalueをからの配列 end p values #pは配列のまま返す =end attr = {name: "田中", age: 27, height: 180, weight: 75} values = [] attr.each do |key...
true
dc4ac769bd1ff27fee124c5fdeaa14cc5a51370d
Ruby
ThundaHorse/ruby_practice_problems
/abbreviate.rb
UTF-8
587
4.59375
5
[]
no_license
# Write a function `abbreviate(sentence)` that takes in a sentence string and returns a new sentence where words longer than 4 characters have their vowels removed. Assume the sentence has all lowercase characters. # Feel free to use the array below in your solution: # You may need a helper function vowels = ['a', 'e...
true
d92343b16882617e69a097169ecf6e17f9d4a27a
Ruby
ErikMelton/Full-Fill
/app/helpers/dashboard_helper.rb
UTF-8
1,931
2.640625
3
[]
no_license
module DashboardHelper def calcAllEvents @events = Event.where(person_id: @person.id) @person_grid = initialize_grid(@events, order: 'events.activity_when', order_direction: 'desc') @physical = nil @expressive = nil @creative = nil @abstract = nil @social = nil @physScore = 0 @ex...
true
6886398f98c981edb785a862b8aea8a706731b45
Ruby
jaxdid/rps-challenge
/spec/combat_spec.rb
UTF-8
1,272
2.53125
3
[]
no_license
require 'Combat' describe Combat do subject(:match) { described_class.new } it 'resolves Rock vs Rock' do expect(match.resolve('rock', 'rock')).to eq 'Rock ties with rock!' end it 'resolves Rock vs Paper' do expect(match.resolve('rock', 'paper')).to eq 'Rock loses to paper!' end it 'resolves Roc...
true
df982a6d45092b60062216ed71dfb33173e379e3
Ruby
makotz/CodeCore-Exercises
/4week/7JuneDay17/handytools2.0/app/models/question.rb
UTF-8
1,596
2.6875
3
[]
no_license
class Question < ActiveRecord::Base validates(:title, {presence: {message: "must be present!"}, uniqueness: true }) #by having the option: uniqueness: {scope: :title} it ensures that the hbody must be unique in combination with the title validates :body, presence: true, length: {minimum: 7}, ...
true
75f6924844d01ac96c02d4a714119bf28495a4be
Ruby
conversation/lita-datadog
/lib/lita/datadog.rb
UTF-8
1,505
2.6875
3
[ "MIT" ]
permissive
require "lita" require "lita/datadog_repository" module Lita module Handlers # Listens for `datadog_submit` events on the lita event bus, and sends the details # to datadog. Each event should have four attributes: # # * name (string) # * type (symbol) # * host (string) # * value (...
true
0b305eb4b875b5d08741e97fc62e18d7a4591bef
Ruby
ThriveTRM/class_profiler
/lib/class_profiler/benchmark.rb
UTF-8
1,652
3.140625
3
[ "MIT" ]
permissive
require "class_profiler" class ClassProfiler::Benchmark include Singleton def initialize(options = {}) @options = options @sum_hash = {} @active_labels = [] end def start(label, &block) append_active_label(label) value = nil time = ::Benchmark.measure { value = block.call }...
true
d80f1130c168fb7cbf6858f774c19f9024f8a0c9
Ruby
jordanwa1947/black_thursday
/test/customer_repository_test.rb
UTF-8
2,199
2.9375
3
[]
no_license
require 'simplecov' SimpleCov.start require 'minitest/autorun' require 'minitest/pride' require './lib/customer_repository' class CustomerRepositoryTest < Minitest::Test def test_it_exits cr = CustomerRepository.new("./data/customers.csv") assert_instance_of CustomerRepository, cr end def test_it_init...
true
32a4bb251c839cf10df3c27613d379bb6168a393
Ruby
IcelandicGambit/veterinaryclinic
/test/customer_test.rb
UTF-8
1,060
3.328125
3
[]
no_license
# pry(main)> joel.outstanding_balance # # => 0 # # pry(main)> joel.charge(15) # # pry(main)> joel.charge(7) # # pry(main)> joel.outstanding_balance # # => 22 require 'minitest/autorun' require 'minitest/pride' require './lib/customer' require './lib/pet' class CustomerTest < Minitest::Test def setup @joel...
true
a790387c0ce85795f14e3b03315466f4b8ea7dc8
Ruby
CodeByLine/intro-to-tdd-rspec-and-learn-q-000
/current_age_for_birth_year.rb
UTF-8
196
2.890625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
#age_of_person = current_age_for_birth_year(1984) def current_age_for_birth_year(birth_year) 2015 - birth_year end #def current_age_for_birth_year(birth_year) # Time.now.year - birth_year #end
true
e95d8747a58444c7c45ec6096d90e580ffff2fee
Ruby
dhirabayashi/code_gen
/template/java.rb
UTF-8
1,156
3.390625
3
[]
no_license
def snake2camel(s) return s unless s.include?('_') array = s.split('_') array[0] + array[1..-1].map(&:capitalize).join end def delete_index(type) return type unless type.include?('[') type.split('[')[0] + '[]' end class String def upcase_first self[0].upcase + self[1..-1] end end...
true
e3d804b56be662468d1bad6b908414cd0d67c3ce
Ruby
m4i/xrea-cron
/lib/cron/crontab/line.rb
UTF-8
680
2.78125
3
[]
no_license
require 'cron/crontab' require 'cron/crontab/date_field' module Cron module Crontab class Line class ParseError < Crontab::ParseError; end attr_reader :command def initialize(line) unless match = /^#{'(\S+)\s+' * 5}(\S.*)$/.match(line.strip) raise ParseError end ...
true
619b244a59b0caa4faa6f262fe86f2b67794113e
Ruby
jacoblockard99/models_in_place
/lib/models_in_place/middlewares/options_insert.rb
UTF-8
1,810
2.6875
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'middlegem' require 'deep_merge/rails_compat' module ModelsInPlace module Middlewares # {OptionsInsert} is a middleare class that can dynamically append options to a field's # options hash. This class is used internally for options scoping, but can also be used # di...
true
e038d3e476fc5e55ab858e541ace246e11ecede9
Ruby
StrongMind/canvas_shim
/app/services/pipeline_service/api/publish.rb
UTF-8
1,623
2.53125
3
[ "MIT" ]
permissive
# The API calls Commands # # Class methods map to Commands # ie: PipelineService::API::Publish calls PipelineService::Commands::Publish module PipelineService module API class Publish attr_reader :object def initialize(object, args={}) if object.is_a? PipelineService::Models::Noun @...
true
6c6b049a83e113b60d21ae6d0c77aba3edba652a
Ruby
vic/apricot
/lib/apricot/ast/send.rb
UTF-8
1,130
2.859375
3
[ "ISC" ]
permissive
module Apricot module AST # An auxiliary node for handling special send expression forms: # # (.method) # (Foo. ) # (Foo/bar ) # class Send < Identifier attr_reader :receiver attr_reader :message def initialize(line, receiver, message) rec_name = case receiver...
true
39aa18edeb34f71ecccbff0f6d5909dbc7f50b0e
Ruby
benburkert/schemr
/spec/lib/DOM/element_spec.rb
UTF-8
1,720
2.765625
3
[]
no_license
require File.dirname(__FILE__) + '/../../spec_helper' def new_element(*args) Schemr::DOM::Element.new(*args) end describe Schemr::DOM::Element, "'s new instances" do it "should expect the first argument of the constructor to to be the identifier" do new_element("name").identifier.should == "name" end i...
true
f691b0e9c8dce02362df5c45bac717f2a97fe2e6
Ruby
ngovanhuong94/learn-ruby
/03_simon_says/simon_says.rb
UTF-8
502
4.09375
4
[]
no_license
#write your code here def echo(str) str end def shout(str) str.upcase end def repeat(str, num=2) result = [] num.times { result.push(str)} result.join(" ") end def start_of_word(str, num) str.slice(0, num) end def first_word(str) str.split(' ')[0] end def titleize(str) arr = str.split(' ') result = [] i ...
true
171cd201680078f35a067e50b9426b11acd9190e
Ruby
nanachi772/Rails_programming
/Ruby/lib/redo2.rb
UTF-8
394
3.09375
3
[]
no_license
foods = ['ピーマン', 'トマト', 'セロリ', '人参', 'レタス'] count = 0 foods.each do |food| print "#{food}は好きですか? => " # わざといいえのみに解答をしぼる answer = 'いいえ' puts answer count += 1 # やり直しは二回までにする redo if answer != 'はい' && count < 2 # カウントをリセット count = 0 end
true
55e94bf2833f7ee171c63e98b51fc1cb963a101e
Ruby
volodymyr-mykhailyk/advent-of-code-2020
/lib/computing/structures/double_linked_list.rb
UTF-8
552
3.171875
3
[]
no_license
module Computing module Structures class DoubleLinkedList def initialize(first) @head = Node.new(first) @tail = @head end def append(item) node = Node.new(item) @tail.append(node) end class Node attr_reader :before, :after, :item def...
true
3e10e89d6e93cdcdca3e4d59a846e730d91c32bc
Ruby
golybhe/hello-world
/db/seeds.rb
UTF-8
732
2.59375
3
[]
no_license
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel...
true
5ec1fe71fe4b65cc3440aee074b84a4869936b04
Ruby
kshmir/so-2011
/files/level_generator.rb
UTF-8
4,002
2.65625
3
[]
no_license
# Made by Cristian Pereyra - WTFPL # /* This program is free software. It comes without any warranty, to # * the extent permitted by applicable law. You can redistribute it # * and/or modify it under the terms of the Do What The Fuck You Want # * To Public License, Version 2, as published by Sam Hocevar. See # * ht...
true
4c6d5bb9ed164813aaf7f9bd7f5fef292b059e7b
Ruby
msrashid/intro-to-ruby-launch-school
/ch7_hashes/merge.rb
UTF-8
351
2.9375
3
[]
no_license
family = { uncles: ["bob", "joe", "steve"], sisters: ["jane", "jill", "beth"]} familyone = { brothers: ["frank","rob","david"], aunts: ["mary","sally","susan"]} puts family.merge(familyone) puts puts family puts puts familyone puts puts family.merge!(familyone) puts ...
true
15affe551e6faa2a99e0972f7296221d563f8407
Ruby
shibukk/qiita-advent_calendar-list
/scraping.rb
UTF-8
936
3
3
[]
no_license
require 'mechanize' class Scraping def initialize @agent = Mechanize.new @day = Time.now.day end def exec data = [] # めんどくさいのでハードコーディング 1.upto(24) do |i| page = @agent.get(url(i)) page.search('//td[@class="adventCalendarList_calendarTitle"]/a').each do |calendar| detail =...
true
8f45c2b9fcc103734bd3668b7e6e760e10628f8d
Ruby
lucaminudel/TDDwithMockObjectsAndDesignPrinciples
/TDDMicroExercises/Ruby/unicode_file_to_html_text_converter/unicode_file_to_html_text_converter.rb
UTF-8
335
2.921875
3
[]
no_license
require 'cgi' class UnicodeFileToHtmTextConverter def initialize(file_path) @full_file_name_with_path = file_path end def convert_to_html text = File.open(@full_file_name_with_path).read html = '' text.each_line do |line| html += CGI::escapeHTML(line) html += '<br />' end ...
true
7ae1d7b6f0f501d33baf0bd0907275fdf0bd63ef
Ruby
faisaln/number_puzzle
/spec/lib/print_number_spec.rb
UTF-8
6,906
3.59375
4
[]
no_license
require 'spec_helper' describe PrintNumber do include PrintNumber shared_examples "text for numbers" do it 'prints text for numbers' do for i in 0...numbers.length print(numbers[i]).should == text[i] end end end it 'does not accept numbers with 10 digits or more' do print(1000...
true
3630efd1143477be248e985b74037826a4976a30
Ruby
angusjfw/Boris_Bikes
/spec/feature_test/feature_test.rb
UTF-8
304
2.921875
3
[]
no_license
require '~/boris_bikes/lib/docking_station' station = DockingStation.new puts station.bikes.length 20.times { station.dock(Bike.new) } puts "adding bikes" puts station.bikes.length bike = station.release_bike puts "releasing one bike" puts station.bikes.length puts bike.working? puts "end of script"
true
92d70f244df56755676ba6f932225f06ff7fc037
Ruby
Eksentrysyti/phase_0_unit_2
/week_5/6_validate_credit_card/my_solution.rb
UTF-8
3,953
4.59375
5
[]
no_license
# U2.W5: Class Warfare, Validate a Credit Card Number # I worked on this challenge by myself. # 2. Pseudocode # Input: 16 digit credit card number # Output: true if valid card number, false if invalid card number # Steps: # => Create class CreditCard and initialize with single card number parameter # => Create met...
true
c2661a3b45cffb1a67830d1457df35e75981190f
Ruby
DillonBarker/my_oystercard
/spec/journey_spec.rb
UTF-8
2,165
2.859375
3
[]
no_license
require 'journey.rb' require 'journey_log' require 'station.rb' describe Journey do let(:entry_station) { double(:entry_station) } let(:exit_station) { double(:exit_station) } let(:subject) {described_class.new(entry_station) } describe '#initialize' do it 'stores entry station' do journey = Journey.new(...
true
3c2a694eb7c52bc85078344b85257b1857dfb77a
Ruby
mayank2707/thirdv
/lib/calculate_schedule.rb
UTF-8
3,101
3.1875
3
[]
no_license
class CalculateSchedule def initialize weight, user, exercise_type @weight = weight @user = user @exercise_type = exercise_type end [:week1, :week2, :week3, :week4].each do |week| define_method week.to_s do set1 = set1 week set2 = set2 week set3 = set3 week [set1, set2, se...
true
1f242df16785f485ba0673f071f781e0613eaea5
Ruby
scottberke/algorithms
/algorithms/sort/quick_sort.rb
UTF-8
667
3.53125
4
[]
no_license
def quick_sort(arr, start_index, end_index) if start_index < end_index partition_index = partition(arr, start_index, end_index) quick_sort(arr, start_index, partition_index - 1) quick_sort(arr, partition_index + 1, end_index) end arr end def partition(arr, start_index, end_index) partition_index ...
true
b5c7f26e354b2435f8da78bdcaf19d4eec33ed9c
Ruby
retiman/project-euler
/solns/ruby/67.rb
UTF-8
451
3.046875
3
[ "CC0-1.0" ]
permissive
data = [] file = File.new('/data/67.txt') while (line = file.gets) data << line end file.close data = data.map(&:strip) .reject { |l| l == '' } .map { |l| l.split.map(&:to_i) } (data.length - 2).step(0, -1).each do |i| (0...data[i].length).each do |j| left = data[i + 1][j] right = da...
true
59504e78d33d3a5289c75cadc5c9c0b6654b3df1
Ruby
hollyglot/code-exercises
/ruby-exercises/sketching_examples/static_pages/tree_builder.rb
UTF-8
1,062
2.796875
3
[]
no_license
module Domain module StaticPages class TreeBuilder def self.!(parent) instance = new parent instance.! end def initialize(parent) @parent = parent end def ! build end def parent @parent end def build tree_has...
true
af21b4b9bad5d49c3916b9dd73c066f3801b34ff
Ruby
RISCfuture/giffy
/lib/comic_sans.rb
UTF-8
3,778
2.890625
3
[]
no_license
require 'digest/md5' require 'tempfile' require 'addressable/template' # Interface for rendering strings to images in Comic Sans and uploading them to # AWS S3. # # @example # string= ComicSans.new("Hello, World!") # string.upload # puts string.url class ComicSans attr_reader :string def initialize(string)...
true
81b3700d6a3a8fb99e9ce550b33d4a7c9adb3988
Ruby
ricokareem/git-utils
/lib/git-utils/open.rb
UTF-8
1,226
2.734375
3
[ "MIT" ]
permissive
require 'git-utils/command' class Open < Command def parser OptionParser.new do |opts| opts.banner = "Usage: git open" opts.on_tail("-h", "--help", "this usage guide") do puts opts.to_s; exit 0 end end end # Returns the URL for the repository page. def page_url if servic...
true
b0f316f76f2a734974ad8e9746d2ff9bbe556664
Ruby
q-m/nutriscore-ruby
/lib/nutriscore/common/range.rb
UTF-8
1,906
3.390625
3
[ "MIT" ]
permissive
module Nutriscore module Common # Range class that supports addition, substraction and comparison. # Assumes the objects that the range is composed of is a {{Numeric}}. # # Note that the end range is always included (+exclude_end+ is +false+). class Range < ::Range # Returns a {{Nutriscore::...
true
e8857d09dee8e7473dec6537ba0fa7887977e405
Ruby
idaolson/battleship
/lib/game_processor.rb
UTF-8
1,838
3.546875
4
[]
no_license
require './lib/board' require './lib/cell' require './lib/ship_generator' require './lib/shot_processor' require './lib/intelligent_computer' module GameProcessor include ShipGenerator include ShotProcessor extend self def game_loop loop do process_turns if winner puts display_boards ...
true
2aa07bb3e16dc05be4a3423a193db88151482ddd
Ruby
MicrohexHQ/sp_store
/lib/sp_store/mocks/ram_store.rb
UTF-8
1,402
2.890625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
# :nodoc: namespace module SpStore::Mocks # Memory-backed block store implementation. class RamStore # Creates a new block store with zeroed out blocks. # # Args: # block_size:: the application-desired block size, in bytes # block_count:: number of blocks; caller should make sure blocks fit in RAM de...
true
9ddf6dbd88d809f8b86082e672ccfbca5743665b
Ruby
bruceSz/learnToexcellent
/ruby/meta/blocks/ampersand.rb
UTF-8
275
3.828125
4
[]
no_license
def math(a,b) yield(a,b) end def teach_math(a,b,&operation) puts "let's do the math:" puts math(a,b,&operation) end teach_math(2,3) {|x,y| x*y} def my_method(&the_proc) the_proc end p = my_method{|name| "hello,#{name}!"} puts p.class puts p.call("bill")
true
33e239de5e7be9497052324464255ca6d73372e5
Ruby
taganaka/adventofcode
/day7/day7.rb
UTF-8
970
2.96875
3
[]
no_license
#!/usr/bin/env ruby require 'pp' opcodes = [] File.new(ARGV[0]).each_line do |line| opcodes << line.strip.scan(/(?:(?:(\S+) )?(.*) )?(\S+) -> (\S+)/im).flatten end points = {} loop do opcodes.each do |code| a, op, b, out = code case op when nil if b =~ /\d+/ points[out] = b.to_i else...
true
0d31cfa3a84648b776b10c887cf3762a90fd7181
Ruby
torqueforge/careerbuilder-2014-march
/bottles/lib/miracle.rb
UTF-8
1,373
3.234375
3
[]
no_license
require 'delegate' class Fixnum def to_bottle_number if Object.const_defined?("BottleNumber#{self}") Object.const_get("BottleNumber#{self}").new(self) else BottleNumber.new(self) end end def to_beer_bottle_number if Object.const_defined?("BeerSongNumber#{self}") Object.const_ge...
true
f452a37693178cda9f63a76e54ca282f36c61fda
Ruby
fabn/zend-framework-deploy
/bin/zf-capify
UTF-8
3,096
2.53125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
#!/usr/bin/env ruby require 'optparse' require 'fileutils' CONFIG_DIR = 'application/configs' stages = [] OptionParser.new do |opts| opts.banner = "Usage: #{File.basename($0)} [path]" opts.on("-m [stage1,stage2]", "--multistage [stage1,stage2]", Array, "Uses multistage configuration") do |stges| stages = st...
true
2d1250ef556cc8e86da79293cd54e8969251bc8a
Ruby
abandoned/fassbinder
/lib/fassbinder/book_builder.rb
UTF-8
691
2.671875
3
[ "WTFPL" ]
permissive
require 'kosher' require 'fassbinder/offer_builder' module Fassbinder class BookBuilder attr_reader :book def initialize @book = Kosher::Book.new @book.offers = [] end def add_offer(hash) builder = OfferBuilder.new builder.id = hash['OfferListing']['OfferListingId'] bu...
true
94f53658cd9f7c46d4e3e1c833450f6df3d1fbd3
Ruby
bradgreen3/enigma
/lib/key_generator.rb
UTF-8
281
3.171875
3
[]
no_license
class KeyGenerator attr_reader :numbers, :key def initialize @numbers = [0,1,2,3,4,5,6,7,8,9] @key = [] end def get_key 5.times { @key << @numbers.sample } end def give_key if @key.empty? self.get_key else @key.join end end end
true
cbeb80329bb9a24d5555a8a7311b1bd368e7ded1
Ruby
julik/otoku
/lib/otoku/timecode/.svn/text-base/test_timecode.rb.svn-base
UTF-8
4,007
3.125
3
[]
no_license
require 'test/unit' require 'rubygems' require 'timecode' # for Fixnum#hours require 'active_support' class TimecodeTest < Test::Unit::TestCase def test_basics five_seconds_of_pal = 5.seconds * 25 tc = Timecode.new(five_seconds_of_pal, 25) assert_equal 0, tc.hours assert_equal 0, tc.minutes a...
true
26f73d66798584be961cec7f25b94d49db3b07d2
Ruby
borcun/free
/ruby/hw/6/CharQueue.rb
UTF-8
587
4.25
4
[]
no_license
#!/usr/bin/ruby # CharQueue Class class CharQueue # constructor def initialize @str = String.new end # function that adds a character to end of string def add(chr) @str += chr end # function that adds a character to end of string def +(chr) @str += chr end def del @str.chop! en...
true
0f4eefa726999f6a2cf5b7ba376fcfd68878f1ba
Ruby
etsai/madlib
/tests/words_presenter_test.rb
UTF-8
551
2.53125
3
[]
no_license
require "minitest/autorun" require_relative "../app" class WordPresenterTest < MiniTest::Unit::TestCase def setup @story = Story.new :text => "This is a :word1 story." @sp = StoryPresenter.new @story @word = Word.new :url => "http://www.google.com/foo.mp3" @wp = StoryPresenter.new @word end def ...
true
6b98d9a23292e11320f65ed11d46c48c416eacc6
Ruby
hock478/ruby-project-alt-guidelines-dc-web-030920
/lib/cli.rb
UTF-8
8,737
3.375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class CommandLineInterface def greet puts "Welcome to Spotify" puts "please enter a number to navigate" end def show_logo puts " /$$$$$$ /$$ /$$ /$$$$$$ /$$__ $$ | $$ |__/ /$$__ $$ | $$ ...
true
a8cfb0dad4f212b673e32fc2556767b78a41e41d
Ruby
patsul12/animal_shelter
/spec/animal_spec.rb
UTF-8
1,146
2.75
3
[ "MIT" ]
permissive
require 'rspec' require 'animal' require 'pg' DB = PG.connect({:dbname => 'animal_shelter_test'}) RSpec.configure do |config| config.after(:each) do DB.exec("DELETE FROM animals *;") end end describe Animal do describe '.all' do it 'starts off with no animals' do expect(Animal.all).to(eq([])) ...
true
7449cd3fcdeecf09cc524bdf33d585a423959cf7
Ruby
shsachdev/sinatra_todolist_project
/database_persistence.rb
UTF-8
2,259
2.890625
3
[]
no_license
require 'pg' require 'pry' class DatabasePersistence def initialize(logger) @db = if Sinatra::Base.production? PG.connect(ENV['DATABASE_URL']) else PG.connect(dbname: "todos") end @logger = logger end def disconnect @db.close end def query(statement, *params) @lo...
true
b11a19ab77b249e34f25ccd709a96e740168bbb1
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/kindergarten-garden/3663c5d278e04da1929ff9152af0bcbd.rb
UTF-8
1,078
3.25
3
[]
no_license
class Garden attr_reader :plantings, :students def initialize(diagram, students=default_class) @plantings = parse_diagram(diagram) @students = parse_students(students).sort end private def parse_diagram(diagram) diagram.split("\n").map{ |row| row.chars } end def parse_students(students) ...
true
e5c7e9d6160ad2100b5fcca6757b999a066c8ac6
Ruby
carinah/Test
/whit_w2_d1/employee.rb
UTF-8
473
3.6875
4
[]
no_license
class Employee attr_accessor :name, :title @@employee_count = 0 def initialize(name, title) @name = name @title = title @@employee_count += 1 end def introduce() "Hi, my name is #{name}." end def self.count() @@employee_count #returns the employee_count class variable, #which ges incremented e...
true
cfa7a4beabb2230887fceb5cdfd9ef5e003113f3
Ruby
kawanaka-s-ts/ruby_tutorial
/3-8.rb
UTF-8
616
3.984375
4
[]
no_license
#case式を使って、変数seasonが"春"の時は「アイス買っていこう」、"夏"の時は「かき氷買っていこう」、それ以外の時は「あんまん買っていこう」と表示 #変数seasonは"春"とする season = "春" case season when "春" puts "アイス買っていこう" when "夏" puts "かき氷買っていこう" else puts "あんまん買っていこう" end season = "春" case when season == "春" puts "アイス買っていこう" when season == "夏" puts "かき氷買っていこう" e...
true
ec32793a485d6e97bd362ce1fdcfc2d7a212ab91
Ruby
theoreticaLee/Ruby-Warrior
/theoreticalee-beginner/player.rb
UTF-8
2,325
3.25
3
[]
no_license
require 'ap' class Player MAX_HEALTH = 20 SAFE_MID_HEALTH = 16 SAFE_MIN_HEALTH = 8 def initialize @previous_warrior_health = MAX_HEALTH end def play_turn(warrior) @warrior = warrior attacked = attacked? if enemy_visible? warrior.shoot!(enemy_direction) elsif walking_into_w...
true