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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
f5ad0c4db950fd4877eac195c965fc615baf0d82 | Ruby | eaharonoff/OO_Tic_Tac_Toe | /services/BoardChecker.rb | UTF-8 | 940 | 3.5625 | 4 | [] | no_license | class BoardChecker
attr_accessor :square_hash
def initialize (square_hash)
@square_hash = square_hash
@@winning_moves = [
["A1","A2","A3"],
["B1","B2","B3"],
["C1","C2","C3"],
["A1","B1","C1"],
["A2","B2","C2"],
["A3","B3","C3"],
["A1","B2","C3"],
["A3","B2","C1"]
]
end
... | true |
67971b8869695c8cc633a335849894f330d62254 | Ruby | mass10/ruby.note | /code/variables/array/main.rb | UTF-8 | 219 | 3.09375 | 3 | [] | no_license | #!/usr/bin/env ruby
# coding: utf-8
def _main()
ar = [1, 20, 300, -400, 'abc']
print '配列まるごと表示: ', ar, "\n"
puts ar[-3], "\n"
puts ar[500], "\n"
puts ar[3], "\n"
puts ar[4], "\n"
end
_main()
| true |
95eaf408a9773bbe64167197b1be17d6944df260 | Ruby | adamruzicka/finito | /test/finito/unit/state_transition_test.rb | UTF-8 | 3,688 | 2.625 | 3 | [
"MIT"
] | permissive | module Finito
class StateTransitionTest < Minitest::Test
describe StateTransition do
it 'considers :condition and :if equivalent in options' do
transition = StateTransition.new('from', 'to', { :condition => :a_symbol })
transition2 = StateTransition.new('from', 'to', { :if => :a_symbol })
... | true |
853abb8afcf75a5c388f624545b3aad99fb1be8e | Ruby | Johanu66/dive_ruby_exem1 | /janken.rb | UTF-8 | 1,352 | 3.765625 | 4 | [] | no_license | class Player
def hand
puts "Veuillez saisir un nombre."
puts "0: Pierre\n1: Papier\n2: Ciseaux\n"
input_hand = gets.to_i
while true
if (input_hand == 0) || (input_hand == 1) || (input_hand == 2)
return input_hand
else
puts "Veui... | true |
c552effc2edf6e8734618f22c3815ca2cb4626fc | Ruby | nlogx/snake | /block.rb | UTF-8 | 118 | 3.109375 | 3 | [] | no_license | class Block
attr_reader :x, :y, :dir
def initialize(x, y, dir = 'any')
@x, @y = x, y
@dir = dir
end
end
| true |
5065465dfc1ffd7e3b1774b782d55e4e9307460c | Ruby | gregDrizagit/OO-mini-project-web-103017 | /app/models/Recipe.rb | UTF-8 | 3,160 | 3.453125 | 3 | [] | no_license | #A single Recipe can also belong to many Users
#A Recipe also has many Ingredients, while a single Ingredient can be found in many Recipes
#There are Ingredients that some Users may be allergic to.
class Recipe
@@all = []
attr_reader :name
def initialize(name)
@name = name
@users = []
@ingredients =... | true |
6ee08e8d3adcb39bb553b738db58ded8f5cc6b34 | Ruby | stockholmkid/http-challenge | /code.rb | UTF-8 | 434 | 2.75 | 3 | [] | no_license | require "nokogiri"
require "pry"
require 'net/http'
require 'uri'
source = Net::HTTP.get('launch-academy-chat.herokuapp.com', '/messages')
messages = ""
page = Nokogiri::HTML(source)
page.css("div.pure-u-1-2").each do |content|
messages += content
end
puts messages
##posting a new message
uri = URI.parse("http://l... | true |
a4d2a4d28e6f061b84464e01d95d5c5b8800eb24 | Ruby | KBoffi/phase-0-tracks | /ruby/gps6/my_solution.rb | UTF-8 | 3,910 | 3.90625 | 4 | [] | no_license | # Virus Predictor
# I worked on this challenge [by myself, with: ].
# We spent [#] hours on this challenge.
# EXPLANATION OF require_relative
#
#
require_relative 'state_data'
# Specifies that this file is in the same directory
class VirusPredictor
# Initializes a new instance of class CirusPredictor with three pa... | true |
ab14aab9e3d06c9001890bce93ea9987b2852321 | Ruby | gsilis/market-game | /widgets/account.rb | UTF-8 | 467 | 3.296875 | 3 | [] | no_license | module Game
class Account
attr_reader :balance, :interest
def initialize(initial_balance = 0, interest = 1.0)
@balance = initial_balance
@interest = interest
end
def credit(amount)
@balance += amount
end
def debit(amount)
@balance -= amount
end
def accrue_in... | true |
3a01cbde73de214eb7edfc120541c2333fdaa292 | Ruby | fig/scheduleless | /app/models/shifts/repeating_shifts_populator.rb | UTF-8 | 2,795 | 2.59375 | 3 | [] | no_license | module Shifts
class RepeatingShiftsPopulator
def initialize(end_date: Date.today,
location: nil,
start_date: Date.today,
user: nil)
@end_date = end_date
@location = location
@start_date = start_date
@user = user
if location.bl... | true |
27ba0da374b30f83870ceb42b40a31b1a3042e6d | Ruby | Kat4Kimi/blackjack | /aa.rb | UTF-8 | 780 | 4.59375 | 5 | [] | no_license | # name = "John Doe"
# puts name
# puts name.class
# address = "1778 East 1300 South"
# puts address
# puts address.class
# city = "New York City"
# print city
# state = "New York"
# print state
# This prints like so:
# 1778 East 1300 South - puts
# String - because I asked which class it is
# New York CityNew York... | true |
20ef31d4467343ae6b4881709205ad4ec8f301ef | Ruby | MaximeD/M1-TAL | /Programmation/TD1/max-premier-prog.rb | UTF-8 | 225 | 3.171875 | 3 | [] | no_license | #!/usr/bin/ruby -w
puts "Entrez un nom commun masculin singulier : "
nom = gets.chomp
pluriel = nom + "s" # well, let's say that most of the time it works
puts "Les flexions de #{nom} sont :
un #{nom},
des #{pluriel}\n"
| true |
dbf1cb4afc4d0a1dcdef094beb35bb00136b006c | Ruby | rastasi/cloudline | /lib/check_process.rb | UTF-8 | 1,703 | 2.6875 | 3 | [] | no_license | class CheckProcess
require 'json'
attr_reader :site, :details
def initialize(site)
@site = site
build_response
check_site
build_status
update_site
create_log
@site
end
def ready?
@site_ready
end
private
def build_response
@response = case @site... | true |
ac70c0b050fae3367a82f84772a680b0947205ba | Ruby | daniel-certa-1228/Ruby-More-Test-Scenarios | /developer.rb | UTF-8 | 138 | 2.71875 | 3 | [] | no_license | class Person
end
class Developer < Person
def description
"Nerd. Big, BIG, nerd."
end
def code
puts "Code code code"
end
end | true |
455b411a8f66aa0a082f317bf7e0e2edaf3497eb | Ruby | tinchi/coding_solutions | /cracking_the_coding_interview/2.1.remove_dup.rb | UTF-8 | 953 | 3.53125 | 4 | [] | no_license | class Node < Struct.new(:data, :next)
attr_accessor :size
alias :length :size
def append_to_tail d
e = Node.new(d)
n = self
while n.next != nil
n = n.next
end
n.next = e
end
def length
counter = 1
self.each { counter += 1}
counter
end
def delete d
self.each ... | true |
82a577e0308ef3133368d62c9accec8d66efcd4b | Ruby | tiagorahal/school-library | /classes/student.rb | UTF-8 | 454 | 3.109375 | 3 | [
"MIT"
] | permissive | require_relative 'person'
require_relative 'classroom'
class Student < Person
attr_reader :owner, :classroom
def initialize(age, name = 'Unkown', parent_permission = true, classroom = 'none')
super(age, name, parent_permission)
@classroom = classroom
end
def classroom=(classroom)
@classroom = cla... | true |
03ed631f680e0d996a5e6d44328bd98d8d0c0507 | Ruby | nadavmatalon/takeaway | /lib/order.rb | UTF-8 | 967 | 3.546875 | 4 | [
"MIT"
] | permissive | require_relative "dish.rb"
class Order
def initialize (dish_list = [], total_price = 0.0, delivery_time = nil)
@dish_list = dish_list
@total_price = total_price
@delivery_time = delivery_time
end
def dish_list
@dish_list
end
def add dish
dish_list << dish
end
def total_price
@total_price = dish... | true |
5ab200ee1d78b21ae57a8f18cdd21fedaf60bd55 | Ruby | mindreframer/ruby-stuff | /github.com/coderoshi/dds/04-reqres/example-reqrep.rb | UTF-8 | 671 | 2.5625 | 3 | [] | no_license | require 'zmq'
require './threads'
include Threads
trap("SIGINT") { exit! }
$port = 2200
thread do # server
ctx = ZMQ::Context.new
rep = ctx.socket(ZMQ::REP)
rep.bind( "tcp://127.0.0.1:#{$port}" )
while line = rep.recv
msg, payload = line.split(' ', 2)
if msg == "get"
rep.send("Called 'GET' wi... | true |
ba881d99f4048c2113b3f32e9922f71f09203268 | Ruby | JuanMaLR/BayesNetworks | /run.rb | UTF-8 | 19,821 | 3.46875 | 3 | [] | no_license | ############################################################################
# Global Variables #
# ##########################################################################
Nodes=[] #Constant because of capital
#################################################... | true |
ce32502ff0073f2e1ceaefac8a479cf8bf95c596 | Ruby | mmanousos/ruby-small-problems | /oop_problems/easy1/three_fix_the_books.rb | UTF-8 | 2,138 | 4.28125 | 4 | [] | no_license | # Fix the Program - Books (Part 1)
# Complete this program so that it produces the expected output:
#
# class Book
# def initialize(author, title)
# @author = author
# @title = title
# end
#
# def to_s
# %("#{title}", by #{author})
# end
# end
#
# book = Book.new("Neil Stephenson", "Snow Crash")
# p... | true |
459722ff5ca1e09fdaa5af02eab90034676a963c | Ruby | colindean/homebrew-bundle | /lib/bundle/brew_dumper.rb | UTF-8 | 3,514 | 2.75 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require "json"
require "tsort"
module Bundle
class BrewDumper
def self.reset!
@formulae = nil
@formula_aliases = nil
end
def self.formulae
@formulae ||= begin
@formulae = formulae_info
sort!
end
end
def self.dump
formulae.map do |f|
if f[:ar... | true |
f69990ea90dbead00de4891df252585d35e2c144 | Ruby | rafadc/Gomoku-strategy-helper | /spec/board_spec.rb | UTF-8 | 2,219 | 2.796875 | 3 | [] | no_license | # encoding: UTF-8
require "rspec"
require_relative "../lib/gomoku.rb"
describe Gomoku::Board do
BOARDS_FOLDER = "spec/boards"
let(:board_with_rival_stone_in_center) do
File.open("#{BOARDS_FOLDER}/board_with_rival_stone_in_center", "r") do |file|
file.read.force_encoding("UTF-8")
end
end
let(... | true |
07536184d1935f3d0f68761703acc2701721a1d8 | Ruby | NANCYVALDEBENITO/E6CP1A1 | /2 ciclos/ejercicio2.rb | UTF-8 | 128 | 3.171875 | 3 | [] | no_license | # En el siguiente codigo reemplaza la instruccion 'while' por 'times'.
i = 0
10.times do
i += 1
puts "Iteración #{i}"
end
| true |
3ae1f68acbb71662597edaafd64dfe6cc97acb18 | Ruby | rabadan/magic_ball | /main.rb | UTF-8 | 510 | 3.21875 | 3 | [
"MIT"
] | permissive | # Program MagicBall
# version 0.1
current_path = File.dirname(__FILE__)
def load_file(file_path)
puts "error read file: #{file_path}" unless File.exist?(file_path)
f = File.new(file_path, 'r:UTF-8')
data = f.readlines.map(&:chomp)
f.close
data
end
welcome_texts = load_file("#{current_path}/data/welcome_te... | true |
842efe7bd49ad44697002541107ce8ad5e7be97b | Ruby | RobertStoelhorst/seic-38 | /05-ruby/classes.rb | UTF-8 | 1,110 | 3.703125 | 4 | [] | no_license | # An object is kind of like a strict hash -- it stores keys/values.
# BUT you must predefine the keys that are going to be used.
# (you have to predefine the shape)
# ALSO: unlike a hash, objects are designed to store functionality (methods).
# Inheritance
class Actor
def award_speech
"I would like to thank my p... | true |
a8173f39dbba325ef1b20dfac842bb0b4cd72a14 | Ruby | mikegw/minesweeper | /minesweeper_board.rb | UTF-8 | 3,566 | 3.5625 | 4 | [] | no_license | require_relative "minesweeper_tile"
class Board
attr_accessor :tiles, :game_over, :play_time, :moves
def initialize(height, width, mines, play_time = 0, moves = 0)
@tiles = Array.new(height) { Array.new(width) }
@play_time = play_time
@moves = moves
fill_board(mines)
end
def height
@tile... | true |
2e79661d83f5a40cc01d07705c5b53276295f5de | Ruby | junchoi/appium-youiengine-ruby-sample | /unit_test_sample/video_player_tests.rb | UTF-8 | 2,963 | 2.578125 | 3 | [] | no_license | require_relative "test_helper"
require_relative "../common/common"
require 'selenium-webdriver'
require "awesome_print"
class VideoPlayerTests < AppiumTest
include Common
def before_all
platform = ENV["APPIUM_PLATFORM"] || "Android"
capabilities = load_caps_for platform
Appium::Driver.new(capab... | true |
52d3e6be1c01ee9ef5148da27b7abe639b4fa37c | Ruby | KikoH/learn_ruby | /09_array_extensions/array_extensions.rb | UTF-8 | 208 | 3.875 | 4 | [] | no_license | class Array
#
def sum
self.inject(0) {|x,y| x + y}
end
#Creates a new array
def square
self.map {|x| x ** 2}
end
#Replaces existing array because of !
def square!
self.map! {|x| x ** 2}
end
end | true |
6748203fcec0604d6f05a51f05c312c091989533 | Ruby | InhamulHassan/Maze_Runner | /app/helpers/maze_helper.rb | UTF-8 | 5,222 | 3.328125 | 3 | [] | no_license | # frozen_string_literal: true
# --------------------------------------------------------------------
# Recursive backtracking algorithm for maze generation. Requires that
# the entire maze be stored in memory, but is quite fast, easy to
# learn and implement, and (with a few tweaks) gives fairly good mazes.
# Can also... | true |
b29b63b8ae0fc7fb91035469f0c2d52c002e9d79 | Ruby | Meredith-Leep/Intro_to_Programming | /CH3_Methods/CH3_2.rb | UTF-8 | 212 | 3.5 | 4 | [] | no_license | 1. x = 2
# evaluates to 2
2. puts x = 2
# returns 2, evaluates to nil
3. p name = "Joe"
# returns "Joe", evaluates to "Joe"
4. four = "four"
# evaluates to "four"
5. print something = "nothing"
# evaluates to nil | true |
87dc1a8241584899a9242d5d6bcc750b730f4f39 | Ruby | sabazusi/redux-todo | /app/api/v1/todos.rb | UTF-8 | 1,231 | 2.515625 | 3 | [] | no_license | module V1
class Todos < Grape::API
resource ":todos" do
desc "return todo items."
params do
optional :limit, type: Integer, default: 5
end
get do
Todo.order("date ASC").offset(0).limit(params[:limit])
end
desc "return todo items on specified month."
param... | true |
524ab07b0bc83e389ea7d3b74894bb745b527a28 | Ruby | ajnikrant/blank-activerecord | /app/models/interface.rb | UTF-8 | 9,729 | 2.796875 | 3 | [] | no_license | class Interface
attr_accessor :athlete
attr_reader :prompt
def initialize
@prompt = TTY::Prompt.new
end
def run
welcome
ask_for_login_or_register
main_menu
end
def welcome
colorizer = Lolize::Colorizer.new
colorizer.write "\nWelcome to Ful... | true |
bfce8418d89b2898f16b57e457e2f65c82043632 | Ruby | dottdogtag/migration | /species_breed/species_yml_creator.rb | UTF-8 | 1,821 | 2.984375 | 3 | [] | no_license | require 'json'
def format_string_with_underscore(natural_str)
natural_str.downcase.tr(" ","_")
end
def get_species_key(species)
species.downcase
end
write_array = []
write_json_hash = {}
file = File.read("#{File.dirname(__FILE__)}/../species_breed/pet_species.json")
file_hash = JSON.parse(file)
species_array = f... | true |
dabcdc02a45467a5ff11a3beec9dcbde73fa4b11 | Ruby | wvw999/fizbuz | /tester.rb | UTF-8 | 837 | 3.265625 | 3 | [] | no_license | require 'uri'
require 'net/http'
quit = 0
until quit == 1 do
puts "\n\nSelect a.) Manual, b.) auto test, or q.) quit:"
input = gets.chomp
if ["a", "b", "q"].include? input
if input == "a"
puts "Input a value to test:"
test = gets.chomp
uri = URI('http://127.0.0.... | true |
37bb6cbab412a6c5406c7ddb2ac15513e905ec78 | Ruby | bartoszwais/bartoszwais.github.io | /tools/number_roman_price_with_no_minimum_20_1000000000initial_cost.rb | UTF-8 | 133 | 3.34375 | 3 | [] | no_license | require 'roman-numerals'
100001.times { |x|
price = 1000000000.00/x
puts "#{x} #{RomanNumerals.to_roman(x)} : #{price}"
puts " "
} | true |
a2fb9fe73f191f5dd79b0c04e3b372f78aeda1fd | Ruby | murtazabasrai/phone-number-to-words-converter | /spec/converter_spec.rb | UTF-8 | 1,656 | 2.921875 | 3 | [
"MIT"
] | permissive | ENV["CONVERTER_ENV"] = "test"
require "converter"
describe Converter do
describe "Number to convert into words: 7463981023" do
it "Should raise an exception as number contains 0 and 1 digits" do
expect { Converter.new.get_key_combinations("7463981023") }.to raise_error("The given number is not valid. Pleas... | true |
77f260037d32b610cc7fe6443d58f589be081953 | Ruby | cyberfined/qna | /app/models/link.rb | UTF-8 | 733 | 2.6875 | 3 | [
"WTFPL"
] | permissive | require 'octokit'
require 'uri'
class Link < ApplicationRecord
URL_REGEXP = /\A(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?\z/ix
GIST_REGEXP = /\Ahttps:\/\/gist\.github\.com\/\w+\/\w+(\/)?\z/ix
GistFile = Struct.new(:filename, :content)
belongs_to :linkable, polymorphic: tr... | true |
767dc25e91a1c30cb91311639bbfd82b385b6bd8 | Ruby | jrogalka/Rails-Library | /db/seeds.rb | UTF-8 | 1,380 | 3.125 | 3 | [] | no_license | require "csv"
BookSubject.delete_all
Subject.delete_all
Book.delete_all
Author.delete_all
filename = Rails.root.join("db/books.csv")
puts "Loading movies from #{filename}"
csv_data = File.read(filename)
books = CSV.parse(csv_data, headers: true, encoding: "utf-8", quote_char: "|")
books[1..300].each do |b|
autho... | true |
131483685a12a18e5487424ddad85d944efa73c4 | Ruby | vijayj/programming_items | /edit_distance.rb | UTF-8 | 915 | 3.34375 | 3 | [] | no_license |
def isEditDistanceMatch(source, destination)
if (source.length < destination.length)
temp = source
source = destination
destination = temp
end
i = 0;j = 0;cost = 0;
while(i < source.length)
break if cost > 1
if match?(source[i], destination[j])
i += 1
j += 1
next
els... | true |
b8cce7c33e1b670f51b1a4bd7fb0bee49ea144c5 | Ruby | manjuk1/spotify-service | /app/services/recent_concert_read_service.rb | UTF-8 | 596 | 2.53125 | 3 | [] | no_license | class RecentConcertReadService
attr_reader :artist_name
def initialize artist_name
@artist_name = artist_name
end
def read
recent_concert(concerts)
rescue Exception => error
Rails.logger.info "RecentConcertSetlistReadservice: Unable to get setlist for artist #{artist_name}"
Rails.logger.... | true |
895e904c8f40f688df2c67bf1a6525b9efd7e51e | Ruby | jroesch/woven | /lib/stream.rb | UTF-8 | 277 | 2.875 | 3 | [] | no_license | class Process
def halt?
case self
when Halt
true
else
false
end
end
end
class Emit < Process
attr_reader :head, :tail
def initialize(head, tail); end
end
class Await < Process
def initialize(receiver); end
end
class Halt < Process; end
| true |
1df5c1ba7e8e5b9b097c15bdc700e0c2a2be3f2a | Ruby | txlabx/hydepark | /app/models/comment_like.rb | UTF-8 | 1,461 | 2.53125 | 3 | [] | no_license | class CommentLike < ActiveRecord::Base
belongs_to :comment
#----------------------------------------------------------------------------------------------------------
# Comment Like
#------------------------------------------------------------------------------------------------------... | true |
eb43ccbb03af630a3e3c0cef7fc10bfa02402d48 | Ruby | ttuffy/docker_design_pattern | /app/models/observer/old/employee_old.rb | UTF-8 | 976 | 3.546875 | 4 | [] | no_license | class Payroll
def update(changed_employee)
puts("cut a check for #{changed_employee.name}")
puts("his salary is #{changed_employee.salary} now")
end
end
class TaxMan
def update(changed_employee)
puts("send a new tax invoice to #{changed_employee.name}")
end
end
class Employee
attr_reader :name, ... | true |
365a0aebbd33e6b4a845a2e8e466aaeabfc23e8d | Ruby | Suave/1kg.org | /vendor/plugins/acts_as_state_machine/lib/acts_as_state_machine.rb | UTF-8 | 9,401 | 2.6875 | 3 | [
"MIT"
] | permissive | module ScottBarron #:nodoc:
module Acts #:nodoc:
module StateMachine #:nodoc:
class InvalidState < Exception #:nodoc:
end
class NoInitialState < Exception #:nodoc:
end
def self.included(base) #:nodoc:
... | true |
65bb30321cbd20c355d6c350b09787cd0fb5b537 | Ruby | famished-tiger/Zenlish | /spec/zenlish/inflect/method_heading_spec.rb | UTF-8 | 1,172 | 2.625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# Load the class under test
require_relative '../../../lib/zenlish/inflect/method_heading'
module Zenlish
module Inflect
describe MethodHeading do
let(:method_name) { 'base_form' }
subject { MethodHeading.new(method_name) }
context 'Initialization:' do
it... | true |
dd9bcb1f5d76c24135ccc465eaa295a3af499072 | Ruby | cflee/is103 | /project2/p2q3.rb | UTF-8 | 2,705 | 3.203125 | 3 | [
"MIT"
] | permissive | # p2q3.rb as submitted
def plan_tour(adj_matrix, node_value, node_time, origin, dest, time_limit)
# number of nodes in the graph
n = adj_matrix.size
result = nil
node_value[dest] = 0
# impute node_time into adj_matrix, by attributing half the node time
# to the edges surrounding each node.
# in other wor... | true |
8589339bc8142674d82983e0abd3415d78e5272a | Ruby | SleepySheepZZZ/atcorder_archive | /code_festival_2017/B/prob.rb | UTF-8 | 779 | 3.265625 | 3 | [] | no_license | NUM_OF_IDEAS = STDIN.gets.to_i
ideas_difficulties = STDIN.gets.split(' ').map(&:to_i).sort!
NUM_OF_PROBS = STDIN.gets.to_i
target_difficulties = STDIN.gets.split(' ').map(&:to_i).sort!
def arrange_probs (ideas, targets)
prev_target = nil
targets.each do |target|
# puts 'target= ' + target.to_s
# puts 'prev_... | true |
538d946c317b21076513463319ab08c2b27e5ea1 | Ruby | onlinecursos/coursera-2016 | /prog-Ruby19-20/chapter02/023a-if-elsif.rb | UTF-8 | 143 | 2.609375 | 3 | [] | no_license | today = Time.now
if today.saturday?
puts "Do chores around the house"
elsif today.sunday?
puts "Relax"
else
puts "Go to work"
end
| true |
12193d1d41682cff0c475a185a42e726b48bb892 | Ruby | xumi/wrongDarkSoulsSubBot | /lib/formatter.rb | UTF-8 | 1,176 | 2.8125 | 3 | [
"MIT"
] | permissive | require 'uri'
class Formatter
def self.as_comment ( post, results )
# Get the list of games mentioned
names = results.map{|result| result[:game]}.uniq
# Get the list of target subreddits
targets = results.map{|result| result[:target]}.uniq
# Create the report link
report_link = "https://www.... | true |
ee9bb9da95e491468771ca35130a7f5d132f9593 | Ruby | ICanDoAllThingThroughChrist/ttt-7-valid-move-v-000 | /lib/valid_move.rb | UTF-8 | 572 | 3.53125 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # code your #valid_move? method here
def valid_move?(board, index)
# re-define your #position_taken? method here, so that you can use it in the #valid_move? method above.
# remember to check position_taken_spec.rb for syntax of the conditions
if board[index] == " "
#checks to see user entered "index" value is co... | true |
7a82925f792c9df5dafcffa2a099d3554293dd52 | Ruby | AaronCHH/B_RUBY | /鍛鍊你的數學腦/SF_RUBY/ch02/q15_03.rb | UTF-8 | 534 | 3.015625 | 3 | [] | no_license | N = 10 # 樓梯的階數
STEPS = 4 # 一口氣前進的階數
dp = Array.new(N + 1, 0) # 統計於t次的移動之中,移動的位置
cnt = 0
dp[N] = 1 # 設定初始值
N.times{|i| # 移動次數(N的最大數)
(N + 1).times{|j| # 移動起點的樓梯
(1..STEPS).each{|k|
break if k > j
dp[j - k] += dp[j]
}
dp[j] = 0 ... | true |
419788ec7f5963f3f592f47295a8bfaaeb720f2b | Ruby | rkstarnerd/tealeaf_intro_precourse_work | /hashes_ex2.rb | UTF-8 | 462 | 3.4375 | 3 | [] | no_license | hash = {
"a" => 1, "b" => 2, "c" => 3
}
hash2 = {
"d" => 4, "e" => 5, "f" => 6
}
p hash.merge(hash2) #This creates a new hash
p hash #This hash has not been changed/mutated
p hash2 #This hash has not been changed/mutated
p hash.merge!(hash2) # The bang operator (!) permanently mutates the... | true |
95f1ec7a7afec4fd10ad08462ee34e7614de7279 | Ruby | acearth/LeetCodePractice | /is_valid_sudoku_0915.rb | UTF-8 | 580 | 3.234375 | 3 | [] | no_license | def is_valid_sudoku(board)
9.times do |i|
return false if not check_line(board[i])
return false if not check_column(board,i)
return false if not check_block(board,i)
end
true
end
def check_block(board, i)
loc_i, loc_j = (i/3)*3, (i%3)*3
str=""
3.times{|i| 3.times {|j| str+=board[loc_i+i][loc_... | true |
520090c8a7219f4d3fb32c4f5c68e11544637bbe | Ruby | tmm1/rbtrace | /lib/rbtrace/cli.rb | UTF-8 | 16,566 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'optimist'
require 'rbtrace/rbtracer'
require 'rbtrace/version'
class RBTraceCLI
singleton_class.send(:attr_accessor, :tracer)
# Suggest increasing the maximum number of bytes allowed on
# a message queue to 1MB.
#
# This defaults to 16k on Linux, and is hardcoded to 2k in OSX kernel.
#
# Return... | true |
2e88fcf6fba8ed5928afa69cb4946d19715f6eda | Ruby | jpsypek/cartoon-collections-denver-web-career-031119 | /cartoon_collections.rb | UTF-8 | 419 | 3.109375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(dwarves)
dwarves.each_with_index{|name, i| puts "#{i + 1}. #{name}"}
end
def summon_captain_planet(planteer_calls)
planteer_calls.collect{|x| x.capitalize + "!"}
end
def long_planeteer_calls(calls_long)
calls_long.any?{|x| x.length > 4}
end
def find_the_cheese(contains_cheddar)
cheese_t... | true |
120bd982bda00f64a9a32bdef8b679da7e6e61c5 | Ruby | vilelajonas/launch_school | /programming_foundations/exercises/easy_1/2.rb | UTF-8 | 939 | 4.46875 | 4 | [] | no_license | # Write a method that takes one argument in the form of an integer or
# a float; this argument may be either positive or negative. This method
# should check if a number is odd, returning true if its absolute value
# is odd. Floats should only return true if the number is equal to its
# integer part and the integer... | true |
93a67add868d9d69e1b83e415e6556c027754570 | Ruby | AliOsm/ruby3arabi-programs | /p064.rb | UTF-8 | 467 | 4 | 4 | [] | no_license | # p064.rb
class Dog
def initialize(breed, name)
@breed = breed
@name = name
end
def bark
puts 'Ruff! Ruff!'
end
def display
puts "I am of #{@breed} breed and my name is #{@name}"
end
end
d1 = Dog.new('Labrador', 'Benzy')
puts "The id of d is #{d1.object_id}."
if d1.respond_to?("talk")
... | true |
820ffb965c223e46c746df750bba6cd6a6c7d063 | Ruby | joskel/jos_composer | /app/models/appointment.rb | UTF-8 | 454 | 2.609375 | 3 | [] | no_license | class Appointment < ActiveRecord::Base
belongs_to :schedule
belongs_to :user
validates_presence_of :date, :start_time, :stop_time
def in_schedule?
if schedule.weekday == date.cwday
if ((start_time > schedule.start_time_1) && (stop_time < schedule.stop_time_1)) || ((start_time > schedule... | true |
04d398e3bde56c3b342ddff256e51f0c349135d3 | Ruby | eddbrown/tictactoeRuby | /lib/game.rb | UTF-8 | 345 | 3.453125 | 3 | [] | no_license | class Game
attr_reader :turn_count
attr_reader :turn
def initialize
@turn_count = 1
@turn = :player_1
end
def update_turn
@turn_count += 1
self.turn_toggle
end
def turn_toggle
@turn == :player_2 ? @turn = :player_1 : @turn = :player_2
end
def reset!
@turn = :player_1
@... | true |
dbe8b09739d2d474c5f1412b706787f95967b167 | Ruby | fdelache/adventofcode2018 | /puzzle_15.rb | UTF-8 | 8,273 | 3.046875 | 3 | [] | no_license | require 'pry-byebug'
module Enumerable
def mins_by
minimums = []
min_value = nil
self.each do |e|
value = yield e
if minimums.empty?
minimums << e
min_value = value
else
if value < min_value
minimums.clear
minimums << e
min_value = ... | true |
f3a41c893fb836bf6c8a02982750132653c99130 | Ruby | health-connector/quoting_tool | /app/models/products/actuarial_factors/participation_rate_actuarial_factor.rb | UTF-8 | 813 | 2.734375 | 3 | [
"MIT"
] | permissive | module Products
module ActuarialFactors
class ParticipationRateActuarialFactor < ActuarialFactor
def self.value_for(issuer_hios_id, year, val)
record = self.where(issuer_hios_id: issuer_hios_id, active_year: year).first
record.lookup(val)
end
# Expects a number out of 100, NOT a... | true |
e0c70c424acf1a74d38c1372b0c296fa510ec2d5 | Ruby | Zrp200/gamefic | /import/debug.rb | UTF-8 | 1,926 | 2.671875 | 3 | [
"MIT"
] | permissive | options Character, :not_debugging, :debugging
meta :debug do |actor|
current = actor.is?(:debugging) ? 'ON' : 'OFF'
actor.tell "Debugging is currently #{current}."
end
meta :debug, Query::Text.new() do |actor, selection|
entered = selection.to_s.downcase
if entered == 'on'
actor.is :debugging
actor.te... | true |
e61b2b7fbc65d60810da9c5c41ac56d61a799179 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/prime-factors/68aa4a80aa904b63a25f2e41b5bce888.rb | UTF-8 | 289 | 3.296875 | 3 | [] | no_license | class PrimeFactors
def self.for(n)
res = []
i = 2
limit = Math.sqrt(n)
while i <= limit
if n % i == 0
res << i
n /= i
limit = Math.sqrt(n)
else
i += 1
end
end
res << n if n > 1
res
end
end
| true |
2f6c350a15dfba0f1f08ab6d6b63fa2cbc37fb84 | Ruby | amandeep1420/RB101 | /RB101/Small Problems/M1r2/8_fibrec.rb | UTF-8 | 303 | 3.25 | 3 | [] | no_license | =begin
P
- write a method the computes the nth fib number, where nth is an arg.
- input: integer
- output: integer repping fib sum
- note: input is always a positive integer
E
- see book
D
- n/a
A
-
C
=end
def fib_sum(n)
n < 2 ? n : fib_sum(n-1) + fib_sum(n - 2)
end
p fib_sum(10) | true |
a54367acfa1143bb56ab0fe72b0bebe919e19b4c | Ruby | JRoyWirth/hello-ruby | /learn/3.rb | UTF-8 | 610 | 4.0625 | 4 | [] | no_license | # Run the code in this file by typing:
# ruby 3.rb
# into your command-line interface.
# learning arrays
delsih_foods = ["pizza", "tacos", "ice cream"]
# puts delsih_foods
numbers = [4, 8, 15, 16, 23, 42]
# puts numbers
mixed_things = ["tacos", 5, "me like"]
# puts mixed_things
shopping_list = [["apples", "bananas"... | true |
04d07aa9dedc992bc89fdb5650920f1761a845ed | Ruby | danielharan/hansard_scraper | /toc_link.rb | UTF-8 | 394 | 2.546875 | 3 | [] | no_license | class TocLink
# header1 TocObTitle inner_text
# header2 TocSbTitle inner_text
# header3 #toc_SOBQualifier
# anchor #toc_Intervention
# ignore everything else
attr_accessor :header1, :header2, :header3, :anchor
def initialize(header1, header2, header3, anchor)
self.header1 = header1
self.header... | true |
3aad93b5d0258f9e31ca8734d331c39dec04e47e | Ruby | morganpstanley/ttt-with-ai-project-online-web-sp-000 | /lib/board.rb | UTF-8 | 950 | 3.859375 | 4 | [] | no_license | class Board
attr_accessor :cells
def initialize
@cells = Array.new(9, " ")
end
def reset!
@cells = Array.new(9, " ")
end
def display
puts " "
puts " #{@cells[0]} | #{@cells[1]} | #{@cells[2]} "
puts '-----------'
puts " #{@cells[3]} | #{@... | true |
bc66c8570bfdacda8752b5e2011d1c25211e1083 | Ruby | alouiscious/dynamic-orms-readme-online-web-pt-071519 | /bin/run | UTF-8 | 386 | 2.8125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #!/usr/bin/env ruby
require 'sqlite3'
require_relative "../lib/song.rb"
require_relative "../config/environment.rb"
song = Song.new(name: "Hello", album: "25", length: "(227/60)", format: "frac")
puts "song name: " + song.name
puts "song album: " + song.album
puts "song length: " + song.length
puts "song format: " ... | true |
d86f162645fd3290ccb32f7410127d295ad83ed1 | Ruby | cyberflamingo/cryptonestegg | /test/api_test.rb | UTF-8 | 880 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
require_relative 'test_helper'
class CoinGeckoAPITest < Minitest::Test
def setup
toml = PROJECT_ROOT.join('test/config_tests')
.join('config_simple.toml').freeze
@config = ConfigFile.new(toml)
@portfolio = @config.portfolio.keys.map(&:downcase)
@... | true |
801f405b9c3d524ce967e157d171aeb99838cbd3 | Ruby | felinebabies/moviefile_digest | /main.rb | UTF-8 | 2,956 | 2.75 | 3 | [] | no_license | require 'bundler'
Bundler.require
require 'optparse'
require 'yaml'
require_relative 'digest_catalog_generator.rb'
# 探査する対象のディレクトリ一覧
$inputdirlist = []
# 出力先ディレクトリ
$outputdir = ""
$inputrecursive = false
opt = OptionParser.new
$optionerror = false
$extensionlist = [
"mp4",
"mov"
]... | true |
15948f86f86cce6b3d201cb6c041066639f8194e | Ruby | junqueira/data-engineering | /app/models/data_importer.rb | UTF-8 | 1,401 | 2.953125 | 3 | [] | no_license | require 'csv'
class DataImporter < ActiveRecord::Base
class << self
def import(filepath)
total_amount_gross_revenue = BigDecimal.new("0")
CSV.foreach(filepath, headers: true, header_converters: :symbol, converters: :numeric, col_sep: "\t") do |row|
row_total_amount_gross_revenue = import_row... | true |
85768273be1690471af96e0036ec7b4653584eb3 | Ruby | rgarner/PlainTextOffenders | /spec/models/offending_site_spec.rb | UTF-8 | 7,219 | 2.546875 | 3 | [] | no_license | require 'spec_helper'
describe OffendingSite do
describe "url" do
it "is present" do
error_message = "can't be blank"
site = OffendingSite.new :url => 'http://www.google.com'
site.valid?
site.errors[:url].should_not include(error_message)
site.url = nil
site.should_not be_va... | true |
d697275fe3ddcd0d12c42d4abb8dfed85f74f64a | Ruby | erimicel/ruby_dersleri | /regex2.rb | UTF-8 | 246 | 2.875 | 3 | [] | no_license | yazi = "Bugun hava yildizlari gozlemlemek icin cok guzel."
p yazi.scan(/\./)
p yazi.scan(/\s/).length
numara = "Telefon numarasi 00-90-555-66-77"
p numara.scan(/[a-z]/)
p "Bugun hava (cok) guzel.".scan(/\(([^()]+)\)/)
# \( \)
# ()
# []
# ^
| true |
35f2d2c382efaf790b3fe51cd25d2831bfd9ab0a | Ruby | wofockham/wdi-9 | /04-ruby/basics/functions.rb | UTF-8 | 772 | 4.09375 | 4 | [] | no_license | require 'pry'
# calculates area of a rectangle
def area(length, width)
length * width # Implicit return
end
def volume(length, width, height)
length * width * height
end
def double(n)
n * 2
end
def square(n)
n * n # n ** 2
end
def cube(n)
n * n * n # n ** 3
end
def name_tag_generator(first, last, gender... | true |
2cd8e6681693862d091cea7466321c3a220c9302 | Ruby | timfesta/loopyruby | /loopyruby.rb | UTF-8 | 165 | 2.703125 | 3 | [] | no_license | neighborhoods = ['soma', 'pac hights', 'north beach', 'russian hill']
neighborhoods.each do |neighborhood|
puts "This is a cool neighborhood - #{neighborhood}"
end | true |
5ab9550f31706824f1f73e6a61ea11791ffae762 | Ruby | aetzion1/nearest-fuel-station | /app/controllers/search_controller.rb | UTF-8 | 1,501 | 2.640625 | 3 | [] | no_license | class SearchController < ApplicationController
def index
address = params[:location]
data = nearest_station(address)
@station = Station.new(data)
@travel_time = travel_time(@station.address, address),
@directions = directions(@station.address, address)
end
private
def nearest_station(addre... | true |
3658f6abb27a32baeab735e680c9a772bcb28cca | Ruby | OSSahota/student-directory | /interactive_menu.rb | UTF-8 | 4,873 | 4.28125 | 4 | [] | no_license | require 'csv' # using csv standard library (step 14 ex 7)
# an empty array accessible to all methods (global variable)
@students = []
#global variable to store default student file.
@students_default_filename = "students.csv"
def interactive_menu
loop do
# 1. print the menu and ask the user what to do
print... | true |
b181942f4e4c652302ff260cc2b8525992cdb179 | Ruby | tinanwlin/ar-exercises | /exercises/exercise_7.rb | UTF-8 | 403 | 2.875 | 3 | [] | no_license | require_relative '../setup'
require_relative './exercise_1'
require_relative './exercise_2'
require_relative './exercise_3'
require_relative './exercise_4'
require_relative './exercise_5'
require_relative './exercise_6'
puts "Exercise 7"
puts "----------"
puts "Which store do you usually go?"
user_store = gets.chomp... | true |
e1e64d55fb57e8c367c6bb0af2b48ad0a8558d6d | Ruby | awoo300/usergenerator | /testusers.rb | UTF-8 | 420 | 2.59375 | 3 | [] | no_license | require 'test/unit'
require_relative 'users'
class TestUsers < Test::Unit::TestCase
def test_open_file
myusers = Users.new
myusers.openfile
assert(true,"File not created")
end
def test_file_exists
assert(File.exist?("user.csv"), "File not available")
end
def test_create_email
myusers = Users.new... | true |
f1237d469a72f136e9656b745a52ff21535d34d8 | Ruby | s-rayed/W2D3 | /lighthouse-test-oop-RETEST_rev1/spec/11_sale_of_cargo.rb | UTF-8 | 1,146 | 2.96875 | 3 | [] | no_license | require_relative 'spec_helper'
describe Submarine do
before :each do
@submarine = Submarine.new
end
describe "#total_revenue" do
it "should be 0" do
expect(@submarine.total_revenue).to eq(0)
end
end
describe '#sell_cargo' do
it 'is allowed on the surface' do
expect(@submarine.se... | true |
d3a6cafe6f3453a436430e1f1a32c3cc656024e4 | Ruby | FernandaFranco/exercises | /challenges/easy_1/point_mutations.rb | UTF-8 | 885 | 4 | 4 | [] | no_license | # compare two strings
# if different lengths, compare over the shorter length
# for each index, check if different chars
# sum amount of differences
# select shorter
# iterate through the shorter string
# each char: equal? do not count : count
# end iteration
# return count
class DNA
def initialize(strand_1)
@... | true |
c0deee95f9e17d5b123a3d94cc8c5ea68a7ddf96 | Ruby | dediane/Gossip_project_OOP | /lib/gossip.rb | UTF-8 | 668 | 3.109375 | 3 | [] | no_license | require 'pry'
require 'csv'
class Gossip
attr_accessor :content, :author
def initialize (author, content)
@content = content
@author = author
end
def save
CSV.open("db/gossip.csv", "a") do |csv|
csv << [author, content]
end
end
def self.all
all_gossips = Array.new
csv = C... | true |
63b05502f75c37ed07ce402dd564df546ce19046 | Ruby | gstaicu/square_array-cb-000 | /square_array.rb | UTF-8 | 137 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
# your code here
squares = []
array.each do |number|
squares << number** 2
end
return squares
end
| true |
709bac13cc32b0725ca5ed2b9bcdf97fe79444b7 | Ruby | de-farias/exercism-ruby | /space-age/space_age.rb | UTF-8 | 564 | 3.40625 | 3 | [] | no_license | class SpaceAge
ON_MERCURY_FACTOR = 0.2408467
ON_VENUS_FACTOR = 0.61519726
ON_MARS_FACTOR = 1.8808158
ON_JUPITER_FACTOR = 11.862615
ON_SATURN_FACTOR = 29.447498
ON_URANUS_FACTOR = 84.016846
ON_NEPTUNE_FACTOR = 164.79132
def initialize(seconds_old)
@seconds_old = seconds_old
end
def on_ea... | true |
d090e47130e60c2c7ad0eba437df7ca0c0698f4a | Ruby | objo/ruby_playground | /old_guess_a_number.rb | UTF-8 | 404 | 3.96875 | 4 | [] | no_license | lottery = rand(9) + 1
puts "Enter a number between #{ 1 } and #{ 10 }"
number = gets.to_i
if (number < 1)
puts "Sorry, we asked you for a number greater than #{ 1 }"
elsif number > 10
puts "Sorry, we asked you for a number less than #{ 10 }"
elsif number == lottery
puts "YAY!!! YOU GUESSED IT"
else
puts "Sor... | true |
2e9ac18a2ddfb18ec37b02bdee58bb5dedee6cf0 | Ruby | bgates/littleredbrick | /app/models/seating_chart.rb | UTF-8 | 1,192 | 2.921875 | 3 | [] | no_license | require 'active_model'
class SeatingChart
include ActiveModel::Validations
validate :check_uniqueness_and_completeness
def initialize(section, seats)
@section = section
@seats = seats
end
def save
return unless valid?
@seats.each do |x, row|
row.each do |y, entry|
next unless r... | true |
47f6e3261de4af221412ccf1a2cf6c5618220993 | Ruby | adam-granieri/CS1632_Software_QA | /D4/file_reader_test.rb | UTF-8 | 721 | 2.546875 | 3 | [] | no_license | # frozen_string_literal: true
require 'minitest/autorun'
require_relative 'file_reader'
# this class is for testing file_reader.rb
class FileReadTest < Minitest::Test
def test_get_file_no_input
fr = FileReader.new
refute fr.get_file([])
end
def test_get_file_no_file
fr = FileReader.new
refute f... | true |
8ff1de2463e40be403eb85a20e7d319b543853ac | Ruby | samiulsyed/terminalapp | /models/tradie_record.rb | UTF-8 | 1,128 | 2.75 | 3 | [] | no_license |
require 'yaml'
class TradieRecord
class RecordNotFound < StandardError; end
attr_reader :id
def self.db
@db ||= YAML.load(File.read('tradie.yml')) rescue []
end
def self.file_name
"#{self.name.downcase}.yml"
end
def self.all
self.db
end
def sel... | true |
d4d27d578f47b7ea5026c9ece1afff40164b9b2f | Ruby | chrisrusselldigital/bank_tech_test | /spec/account_spec.rb | UTF-8 | 1,338 | 3.078125 | 3 | [] | no_license | require 'account'
describe Account do
it "withdraws money from an account" do
# setup
account = Account.new
# exercise
account.credit("10/01/2012", 500)
# verify
expect(account.debit("10/01/2012", 500)).to eq([{ :Date => "10/01/2012", :Deposit => 500, :Balance => 500 }, { :Date => "10/01/201... | true |
92f63c3c416bff8ca676168b53de853f9eb4c468 | Ruby | joseroubert08/samson | /app/models/job_queue.rb | UTF-8 | 2,181 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
# make jobs with the same queue run in serial and track their status
class JobQueue
LOCK = Mutex.new
def initialize
@queue = Hash.new { |h, q| h[q] = [] }
@active = {}
end
def active
@active.values
end
def active?(id)
active.detect { |je| je.id == id }
end
... | true |
4f8171bbf00bcc2013b5a1c5093b037e19ac87b3 | Ruby | vviilloovv/object-oriented_design_practice | /revealing_references.rb | UTF-8 | 373 | 3.3125 | 3 | [] | no_license | class RevealingReferences
attr_reader :wheels
def initialize(data)
@wheels = wheelify(data)
end
def diameters
wheels.map { |wheel| deameter(wheel) }
end
def diameter(wheel)
wheel.rim + (wheel.tire * 2)
end
Wheel = Struct.new(:rim, :tire)
def wheelify(data)
data.map {... | true |
1632c4df2c4a93a672f93be60f32be2933dc3cdd | Ruby | olliedavis/ruby-chess | /lib/modules/checkmate.rb | UTF-8 | 751 | 3.21875 | 3 | [] | no_license | module Checkmate
def checkmate?(colour)
king_location = locate_king(colour)
king = '♔' if colour == 'black'
king = '♚' if colour == 'white'
king_class = piece_to_class(king, king_location)
king_moves = king_class.moves
opp_moves = opposition_moves(colour)
# true if all of the kings moves a... | true |
4d6329ab0074ec29a103fdc133b475ea03473e8d | Ruby | roy-miller/war | /spec/card_deck_spec.rb | UTF-8 | 2,396 | 3.171875 | 3 | [] | no_license | require 'spec_helper'
describe CardDeck do
let(:deck) { CardDeck.new }
describe '#new' do
it 'has a full set of playing cards' do
deck = CardDeck.new
expect(deck.cards.count).to eq 52
end
end
describe '#add' do
it 'adds a card' do
deck.add(PlayingCard.new(rank: 'rank', s... | true |
1d2bfd06c6917d32947e7671331f2fc5625676c9 | Ruby | Kry256/Rubustrings | /rubustrings | UTF-8 | 3,508 | 3.25 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# Rubustrings
# A format validator for Localizable.strings files.
# The MIT License (MIT) Copyright (c) 2014 @dcordero
# https://github.com/dcordero/Rubustrings
%w[colored].each do |this_gem|
begin
require this_gem
rescue LoadError
abort "Please install the '#{this_gem}' gem."
end
en... | true |
ca1d04647e5a0cb75705d4231875a719c0a79e3f | Ruby | sadhasivam3288/ruby-asignment_sadhasivam | /ex12.rb | UTF-8 | 354 | 4.125 | 4 | [] | no_license | print "Give me a number: "
number = gets.chomp.to_i
bigger = number * 100
puts "A bigger number is #{bigger}."
print "Give me another number: "
another = gets.chomp
number = another.to_i
smaller = number / 100
puts "A smaller number is #{smaller}."
print "Enter a money"
mny =gets.chomp.to_f
mny = mny/10
put... | true |
cc3796d49b9f0ebfc12362d00186701e57eb7c05 | Ruby | Timdavidcole/Boris_Bikes | /lib/docking_station.rb | UTF-8 | 634 | 3.15625 | 3 | [] | no_license | DockingStation = Class.new
class DockingStation
def initialize(newcap = 20)
@CAPACITY = newcap
@docked_bikes = []
end
attr_reader :docked_bikes
# attr_reader currently does the same thing as check_bikes
def release_bike
fail "no bikes docked" if empty?(@docked_bikes)
@docked_bikes.pop
e... | true |
ccbd075e657eadd39764b2cbd2c5bab5bee59f0f | Ruby | trizen/sidef | /scripts/Tests/classes_and_objects.sf | UTF-8 | 589 | 3.515625 | 4 | [
"Artistic-2.0"
] | permissive | #!/usr/bin/ruby
# Classes and objects
class Task(callback, dependencies=[]) {
method perform {
dependencies.each { .perform };
callback.run;
}
}
var eat = (
Task.new({ say 'eating dinner. NOM!' },
[
Task.new({ say 'making dinner' },
[
Task.new({ say... | true |
1920c224cfec9ed13380799cd5706d151b228a16 | Ruby | Willardgmoore/practice | /17.rb | UTF-8 | 2,600 | 4.40625 | 4 | [] | no_license | #Number letter counts
#Problem 17
#If the idxs 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
#If all the idxs from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?
#NOTE: Do not count spaces or h... | true |
c7ec84ead9b8cc4c84c7d18e0b7661a587160114 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/5b1dafafa4204b8e8437bc77281c45b8.rb | UTF-8 | 337 | 3.5 | 4 | [] | no_license | class Hamming
class Error < StandardError; end
class ArgumentError < StandardError; end
def self.compute(a, b)
unless a.length == b.length
raise ArgumentError, "Expected strands of the same length, got #{a} and #{b}"
end
a.split('').each_with_index.map { |_, i| a[i] != b[i] }.select { |n| n }.... | true |
68f855a002dcd9158395fc17b68537631980cc62 | Ruby | evansenter/ucsb | /school/CS165B/GA/cell_map_test.rb | UTF-8 | 1,370 | 2.859375 | 3 | [] | no_license | require 'test/unit'
require 'cell_map.rb'
class CellMapTest < Test::Unit::TestCase
def setup
@cells = CellMap.new(10, 0.25, 0.0, 0.0)
@cells2 = CellMap.new(10, 0.0, 0.0, 0.0)
end
def test_true
assert @cells != nil
end
def test_print_cell_grid
@cells.print_cell_grid
end
def test_to_... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.