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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
bc4cc20c7d5c3edfbef76033fc13cad730c248e7 | Ruby | jamiebell941/karaoke_hw | /specs/bar_spec.rb | UTF-8 | 583 | 2.5625 | 3 | [] | no_license |
require('minitest/autorun')
require('minitest/reporters')
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
require_relative("../bar")
require_relative("../drink")
require_relative("../guests")
require_relative("../rooms")
class TestBar < Minitest::Test
def setup
@bar1 = Bar.new(1000, [], [])
e... | true |
593f6bcce1d778e77eead954d80930871ae4108a | Ruby | Vadimka2603/test | /sp/ruby/exam11.rb | UTF-8 | 876 | 4.09375 | 4 | [] | no_license | # Упражнение 11
# Реализуйте класс Dessert c геттерами и сеттерами для полей класса name и
# calories, конструктором, принимающим на вход name и calories, а также двумя
# методами healthy? (возвращает true при условии калорийности десерта менее 200)
# и delicious? (возвращает true для всех десертов)
class Desert
att... | true |
fc92b1e3b6647859eef1865cdf72bb937c0fbf7d | Ruby | ged/fluent_fixtures | /spec/fluent_fixtures/factory_spec.rb | UTF-8 | 13,282 | 2.8125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env rspec -cfd
require_relative '../spec_helper'
require 'faker'
require 'fluent_fixtures/factory'
RSpec.describe FluentFixtures::Factory do
let( :collection ) { Module.new {extend FluentFixtures::Collection} }
let( :fixtured_class ) do
Class.new do
def initialize( params={} )
@saved = false... | true |
1167a83384ac67e5681ac69e35d275fa1e5bce2f | Ruby | CoralineAda/sophia | /lib/gramercy/constructors/verb.rb | UTF-8 | 263 | 2.609375 | 3 | [
"MIT"
] | permissive | module Gramercy
module Constructors
class Verb
attr_reader :verb, :adverb
def initialize(verb:, adverb:)
@verb = verb
@adverb = adverb
end
def in_form
verb.inject_adverb(adverb)
end
end
end
end | true |
02e46910843af3959516886225f55232d3fff4ea | Ruby | avr567/citySim9006 | /player_test.rb | UTF-8 | 316 | 2.53125 | 3 | [] | no_license | require 'minitest/autorun'
require_relative 'player'
class PlayerTest < Minitest::Test
#only test for this class is to see that we are creating an instance of a Player object
def test_test_player_is_player
test_player = Player::new "test_player"
assert test_player.is_a?(Player)
end
end
| true |
139af9af7ea8223ee674fd78e4ae03ddaac27cd6 | Ruby | d-theus/ruby-svgplot | /test/plot.rb | UTF-8 | 632 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'ruby/svgplot'
p = Svgplot::FPlot.new(:w => 800, :h => 500, :grid => true) do
plot :f => lambda{|x| return Math.cos(x)}
plot :f => lambda{|x| return Math.atan(x)},
:style => {"stroke" => "blue"},
:desc => "atan x"
plot :pairs => [1.1, 2.5, -1.3].zip([1.5,-1,2.3]),
:desc => "cross"
plot :pairs => [1.... | true |
735538b656057a577eb2a7f2793670239112ec5b | Ruby | GeoffCrittenden/football | /lib/division_standings.rb | UTF-8 | 1,316 | 2.984375 | 3 | [
"MIT"
] | permissive | class DivisionStandings
attr_reader :division_name
def initialize(info)
@info = info
@division_name = info.first.first
end
def team_names
@info[2..5].map(&:first)
end
def longest_team_name
team_names.map(&:length).sort.last
end
def padded_team_name(team_name)
team_name +... | true |
3408f90bc279e13a51ab76fef6c08a31f8b37ce0 | Ruby | jgrams/twitter_tool | /app/models/search.rb | UTF-8 | 5,197 | 3.21875 | 3 | [] | no_license |
#should make the search a has and belongs to many relationship.
class Search < ActiveRecord::Base
belongs_to :user
has_many :tweets
validates :twitter_id, presence:true, uniqueness:true
validates :screen_name, presence:true, uniqueness:true
#takes a array of hashes and deletes words matching the regex
#ag... | true |
d5cd8056ef2b40086c06175e136eb46bab560f50 | Ruby | tatums/syp7 | /app/helpers/products_helper.rb | UTF-8 | 296 | 2.625 | 3 | [] | no_license | module ProductsHelper
#Translates true to Active and false to Deactive
def status(product)
if product.active == true
return "Active"
else
return "Deactive"
end
end
def yes_no_status(product)
if product.active == true
return "Yes"
else
return "No"
end
end
end
| true |
207bf564612198591beb53be57ab1bc030d36bf6 | Ruby | ronakvsoni/sea-sfo-071320 | /05-intro-to-many-to-many/models/person.rb | UTF-8 | 661 | 3.75 | 4 | [] | no_license | class Person
attr_accessor :name, :location
@@all = [ ]
def initialize(name, location)
@name = name
@location = location
@@all << self
end
def self.all
@@all
end
def find_mountain(mountain_name) #mountain_name
#which class do I need to talk to
... | true |
aaad3fa59ea32271539b8f9a7f9f0d1834a4293d | Ruby | anbupro/chessdb | /lib/configuration.rb | UTF-8 | 761 | 2.578125 | 3 | [] | no_license | require 'app_configuration'
# chessdb configuration based on config file + environment variables
class Configuration
# The root directory of the project
PROJECT_ROOT = File.join(File.dirname(__FILE__), '..').freeze
# The config file path
CONFIG_PATH = File.join(PROJECT_ROOT, 'config').freeze
DEFAULT_APP_CO... | true |
a8aefe82ef12e841f7df702ae10b96d34c6be3f2 | Ruby | JuanFPelaez/CursoRoR5 | /ej de clase/ej7.rb | UTF-8 | 216 | 3.3125 | 3 | [] | no_license | #ej7.rb
#comprobar si la cadena de texto es un palindromo, se lee igual comenzando por el principio que por el final
def palindromo? sentence
sentence.downcase.gsub(" ","")reverse==sentence.downcase.gsub(" ","")
end | true |
c54f5afe05bd4b2128fbfb7a1f52bc7501b238c8 | Ruby | SurajG/codeeval | /hard/minimum-path-sum/minimum-path-sum.rb | UTF-8 | 1,484 | 3.8125 | 4 | [] | no_license | # You are given an n*n matrix of integers. You can move only right and down.
# Calculate the minimal path sum from the top left to the bottom right
#
# Your program should accept as its first argument a path to a filename. The
# first line will have the value of n (the size of the square matrix). This will
# be followe... | true |
a0f794de061f0d1ece22c40074fb68e26ac39493 | Ruby | pain2k/29-2 | /lib/question.rb | UTF-8 | 679 | 3.375 | 3 | [] | no_license | class Question
attr_reader :timer, :text, :answers, :right_answer
def initialize(params)
@timer = params.attributes["timer"].to_i
@text = params.elements["text"].text
@answers = []
params.elements.each("variants/variant") do |item|
@answers << item.text
@right_answer = item.text if item.... | true |
b059ed9bced1d5e9cce67b6bfb7faa2ddef0ffc0 | Ruby | jayczech23/cryptopunks | /cryptopunks/lib/cryptopunks/image.rb | UTF-8 | 648 | 2.953125 | 3 | [
"LicenseRef-scancode-public-domain",
"CC0-1.0"
] | permissive | module Cryptopunks
class Image
def self.read( path ) ## convenience helper
img = ChunkyPNG::Image.from_file( path )
new( img )
end
### keep design & colors keyword args in c'tor here
## or use parse() like in pixelart - why? why not?
def initialize( initial=nil, design: nil,
... | true |
1fecfcab3cd6ce42a4a0f56eca685f309b79b2ff | Ruby | luontola/cygwin-deployer | /spec/template_copier_spec.rb | UTF-8 | 3,134 | 2.625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | # Copyright © 2012 Esko Luontola <www.orfjackal.net>
# This software is released under the Apache License 2.0.
# The license text is at http://www.apache.org/licenses/LICENSE-2.0
require_relative 'test_helpers'
require 'fileutils'
describe TemplateCopier do
before(:all) do
@sandbox = 'sandbox.tmp'
@cygwin_... | true |
2d184423236f89f49ade296890f0edebb2bb3114 | Ruby | AlanGabbianelli/boris-bikes-2 | /spec/docking_station_spec.rb | UTF-8 | 2,205 | 2.8125 | 3 | [] | no_license | require 'docking_station'
describe DockingStation do
let(:docking_station) { described_class.new }
let(:bike) { double(:bike) }
let(:van) { double(:van) }
it 'can release working bikes' do
allow(bike).to receive(:working?).and_return true
docking_station.dock(bike)
docking_station.release_bike
... | true |
0e9b684c128cbf18d8f7950bdebaf67b02002807 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/raindrops/94bf61eb888144cfa429154f9fa27f96.rb | UTF-8 | 358 | 3.28125 | 3 | [] | no_license | require 'prime'
class Raindrops
@raindrop_speak = { 3 => "Pling", 5 => "Plang", 7 => "Plong" }
def self.convert(number)
drops = ""
number.prime_division.flatten.uniq.sort.each do |factor|
if @raindrop_speak[factor] != nil
drops << @raindrop_speak[factor].to_s
end
end
drops.e... | true |
b943a48d0218584d2e52ca2a419ff8dde3e06649 | Ruby | ranknc/refactor | /utilities.rb | UTF-8 | 1,430 | 3.390625 | 3 | [] | no_license | module Utilities
SECONDS_IN_A_YEAR = 60 * 60 * 24 * 365.0
def leap_year(year)
(yearA(year) && yearB(year) ) || (leap(year) )
end
def year_percent(a)
('%.1f'% ((a / SECONDS_IN_A_YEAR) * 100)) + '%'
end
def military_time(x)
am(x) ? convert_am(x) : convert_pm(x)
end
def convert2(x)
a, b = x.split(":"... | true |
4526a346e07251aaa3887a0c684cd072ae0757aa | Ruby | tanna1001/learn_ruby | /03_simon_says/simon_says.rb | UTF-8 | 413 | 3.65625 | 4 | [] | no_license |
def echo(speak)
speak
end
def shout(speak)
speak.upcase
end
def repeat(speak, num=2)
output1=(1..num).map{speak}.join(" ")
return output1
end
def start_of_word(name, num)
name[0..num-1]
end
def first_word(word)
word.split(" ")[0]
end
def titleize(phrase)
x=phrase.split(" "... | true |
1dc1d4fcfb1ba6d99be2bcf0cac9d59352f0fc58 | Ruby | weathermaker/sketchup-console-plus | /src/ae_console/features/tokenclassification.rb | UTF-8 | 16,033 | 3.046875 | 3 | [
"MIT"
] | permissive | module AE
module ConsolePlugin
require(File.join(PATH, 'features', 'docprovider.rb'))
# TokenClassification identifies a token and the object (or type) that it
# refers to or returns.
#
# Here we make use of polymorphism to handle the different kind of
# information that we may have about... | true |
3ee6f4be53f1546b709a5d60e4445843a6d72c26 | Ruby | daachi/ruby-blockchain | /lib/blockchain.rb | UTF-8 | 533 | 3.046875 | 3 | [] | no_license | class Blockchain
attr_reader :blocks
def initialize(blocks = [])
@blocks = blocks
end
def head
blocks.last
end
def add_block!(block)
blocks << block if block_valid?(block)
end
#
# Is the new block valid?
#
# Does its digest start with the required number of zeroes?
#
# Does its... | true |
4994d03ad80a0a59e220841fe766bb256b3cd995 | Ruby | billwestfall/ruby | /miscellaneous/lilypond/lilypond.rb | UTF-8 | 277 | 2.640625 | 3 | [] | no_license | #!/usr/bin/ruby
$i = 0
while $i < 80 do
print " "
print [ "a", "b", "c", "d", "e", "f", "g" ].sample
print [ "is", "es", "", "" ].sample
print [ "2", "4", "8", "16", "32", "", "", "" ].sample
# print [ "'", "," ].sample
$i +=1
end
| true |
99746c50306883ff2ef2d79043dc198d352c4981 | Ruby | TertiumQuid/Whatser | /lib/whatser/resources/resource.rb | UTF-8 | 1,296 | 2.671875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Whatser
class Resource
attr_accessor :json
class << self
def client
@client
end
def set(client)
@client = client
self
end
def api_request(verb, path, params={}, opts={})
res = client.request(verb, path, params)
... | true |
09cf24d1ef722f9d76cf0e50ff1e2409d5d475de | Ruby | axpepper/sql-crowdfunding-lab-v-000 | /lib/sql_queries.rb | UTF-8 | 1,757 | 3.078125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your sql queries in this file in the appropriate method like the example below:
#
# def select_category_from_projects
# "SELECT category FROM projects;"
# end
# Make sure each ruby method returns a string containing a valid SQL statement.
def selects_the_titles_of_all_projects_and_their_pledge_amounts
"SELEC... | true |
a6e3615394cfd3fbab6d6dd4d6b9c5e2d53d7f53 | Ruby | akinov/masu | /lib/masu.rb | UTF-8 | 939 | 3.1875 | 3 | [
"MIT"
] | permissive | require 'masu/version'
module Masu
class Error < StandardError; end
def to_masu(type = :default)
method_name = "to_masu_#{type}"
unless self.class.private_method_defined? method_name
raise ArgumentError.new, "Undefined Masu type #{type}."
end
send method_name
end
private
def to_mas... | true |
202bb1d530597fd4f14af6a93a3c41c00b1ffc81 | Ruby | pedrolinhares/cbo | /lib/cbo/base.rb | UTF-8 | 1,219 | 2.90625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #encoding: UTF-8
module CBO
class Base
def initialize
carregar_ocupacoes
carregar_familias
end
def ocupacao(codigo)
@ocupacoes[codigo]
end
def familia(codigo)
@familias[codigo[0..3]]
end
def buscar_ocupacoes(nome_ocupacao)
nome_ocupacao = limpar_para_regex... | true |
b659a7070c61728c6a3241825e57c54446ca9d05 | Ruby | annacarey/ruby-boating-school-nyc-web-111819 | /app/models/instructor.rb | UTF-8 | 699 | 3.359375 | 3 | [] | no_license | class Instructor
attr_reader :name
@@all = []
def initialize(name)
@name = name
self.class.all << self
end
def self.all
@@all
end
def pass_student(student, name)
test = student.boating_tests.find {|test| test.name == name }
if test
... | true |
2dd328f2d72dddb85b46e79fa9db199dc9eb76ac | Ruby | jmcolella/phase-0 | /week-5/acct_groups.rb | UTF-8 | 6,613 | 4.4375 | 4 | [
"MIT"
] | permissive | # Create Accountability Groups
# I spent 3.5 hours on this challenge.
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented in the file.
# 0. Pseudocode
# define a method to take a variable with a container of names a... | true |
524ab182d89584775863d3afba42fa25d79eb60c | Ruby | rongxanh88/sorting_suite_practice | /lib/bubble_sort.rb | UTF-8 | 340 | 3.578125 | 4 | [] | no_license | class BubbleSort
def self.sort(numbers)
result = Array.new(numbers)
swap = nil
(result.length).times do
for i in 0...(result.length - 1)
if (result[i] > result[i + 1])
swap = result[i + 1]
result[i + 1] = result[i]
result[i] = swap
end
end
end
... | true |
cabcd3ed76c211012aefe213d751da42f238785e | Ruby | swapnildoshi2015/MyProject | /Excel/database/database.rb | UTF-8 | 417 | 2.53125 | 3 | [] | no_license | require 'mysql2'
client = Mysql2::Client.new(
host: "192.168.1.79",
username: "swapnil",
password:"",
database: "testlink",
)
baba = Array.new
client.query("SELECT * FROM users").each do |row|
#puts row['Sr.no'].to_s+" "+row['Name'].to_s+" "+row['Hydraulic machinary'].to_s+" "+row['Mechanical Vibra... | true |
8a0bf87c4f9dad75f2fa8544f0a8fe705485d7f2 | Ruby | achpsident/rails-longest-word-game | /app/controllers/games_controller.rb | UTF-8 | 986 | 2.953125 | 3 | [] | no_license | # start of file
require 'open-uri'
require 'json'
# filler comment
class GamesController < ApplicationController
LEWAGON_URL = "https://wagon-dictionary.herokuapp.com/"
def new
session[:high_score] = 0 unless session[:high_score]
alphabet = ("a".."z").to_a
grid_array = []
(grid_array << alphabet.... | true |
b0c332dc492e4ea8a27b2b76909683e4b14d5357 | Ruby | marianodominguez/samples | /ruby_prog/pairs.rb | UTF-8 | 283 | 3.203125 | 3 | [] | no_license | n=24
l=8
r=16
o=0
for i in (r-l..n) do
x = n-i
puts "#{i}+#{x}" if i+x == n and l<=x and x<=r and i<=x
o+=1
end
puts o
# notes for optimization
#r=58
#l=24
#n-r = 93-58 = 35
#range = l, r/2
#n=93
#
#93 = 35,58, 36,57 37,56 ...43,50 44,49 45,48 46,47
#r = 46-35 = 11
#
| true |
459ad992b31eaea5a0fe2d3ca2d14b0a8548fefb | Ruby | lishulongVI/leetcode | /ruby/717.1-bit and 2-bit Characters(1比特与2比特字符).rb | UTF-8 | 3,182 | 3.890625 | 4 | [
"MIT"
] | permissive | =begin
<p>We have two special characters. The first character can be represented by one bit <code>0</code>. The second character can be represented by two bits (<code>10</code> or <code>11</code>). </p>
<p>Now given a string represented by several bits. Return whether the last character must be a one-bit character or... | true |
879f80c2f1dee493475b8291a6d5ed9fbec320bb | Ruby | dupjpr/saludame2 | /solution.rb | UTF-8 | 428 | 2.875 | 3 | [] | no_license | # require"sinatra"
# get '/' do
# unknown = "desconocido"
# unless params[:nombre]
# @nombre = unknown
# else
# @nombre = params[:nombre].empty? ? unknown : params[:nombre].capitalize
# end
# erb :index
# end
require"sinatra"
get "/" do
"Hola desconocido... | true |
976a1853e03b9283ee82eac350c0f2f88d68953a | Ruby | kelvin8773/data-algorithm | /8-leetcode/155-mini_stack.rb | UTF-8 | 605 | 3.84375 | 4 | [
"MIT"
] | permissive | class MinStack
=begin
initialize your data structure here.
=end
def initialize()
@data = Array.new
end
=begin
:type x: Integer
:rtype: Void
=end
def push(x)
@data.push(x)
end
=begin
:rtype: Void
=end
def pop()
@data.pop
end
=begin
:rtype: Integer
=... | true |
64703befb46ac7b9808222a818ad58737a7ab49d | Ruby | vadivelan-k/trello-integration | /lib/trello_connector.rb | UTF-8 | 4,998 | 2.765625 | 3 | [] | no_license | require 'rubygems'
require 'trello'
class TrelloConnector
attr_accessor :status
def initialize(oauth_token, oauth_secret, consumer_key = "d3d7c12c7047fd57f55953bd2e30e145", consumer_secret = "47322f44d31bd153c0c67773740fc7780f930328c02075d8d73aa423c87018ff")
@status = true
begin
Trello.configure do |... | true |
12beb6a123a929f9548b504b9198b911fdae095f | Ruby | rvachon1/launch-school-intro | /RB100/loops_2/first_to_five.rb | UTF-8 | 163 | 3.453125 | 3 | [] | no_license | number_a = 0
number_b = 0
loop do
number_a += rand(2)
number_b += rand(2)
break if number_a > 5 || number_b > 5
puts "a: #{number_a} | b: #{number_b}"
end | true |
027f8d9959c0a9cce97899bd875b1b144f436690 | Ruby | hectorlopezmonroy/HackerRank | /Contests/ProjectEuler+/Project Euler #2: Even Fibonacci Numbers/Solution.rb | UTF-8 | 1,189 | 3.921875 | 4 | [] | no_license | # Each new term in the Fibonacci sequence is generated by adding the previous
# two terms. By starting with '1' and '2', the first 10 terms will be:
#
# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
#
# By considering the terms in the Fibonacci sequence whose values do not exceed
# 'N', find the sum of the even-valued terms.
... | true |
0f1e0537aa52c2d9a75a5524915ad33100cd0962 | Ruby | venriq/neo4j | /lib/neo4j/active_node/property.rb | UTF-8 | 3,437 | 2.6875 | 3 | [
"MIT"
] | permissive | module Neo4j::ActiveNode
module Property
extend ActiveSupport::Concern
include ActiveAttr::Attributes
include ActiveAttr::MassAssignment
include ActiveAttr::TypecastedAttributes
include ActiveAttr::AttributeDefaults
include ActiveAttr::QueryAttributes
include ActiveModel::Dirty
class... | true |
f44d2fc062ae4bce141882d2ac3938cfd1783a2b | Ruby | dkymd0712/study-rails | /_study/topics_exe.rb | UTF-8 | 364 | 3.75 | 4 | [] | no_license | # Taroオブジェクトの定義
class Taro
def name
name = "山田太郎"
end
end
#Topicオブジェクトの定義
class Topic
def show_name
puts "Taroの名前を表示します"
taro = Taro.new
puts taro.name
end
end
#Topicクラスをインスタンス化してshow_nameメソッドを実行する
topic = Topic.new
topic.show_name
| true |
446de744152aec091fcad7ff72fb58332a1f47a9 | Ruby | singpolyma/RPNR | /rpnr-runtime.rb | UTF-8 | 1,734 | 3.53125 | 4 | [
"ISC"
] | permissive | class NilClass
def +(b); b; end # Make + work with nil
def method_missing(name, *args)
[].send(name, *args) # Proxy nil onto []
rescue NoMethodError
super
end
end
# List building conveniance
Object.send(:define_method, :',', lambda {|b| [self, b]})
Array.send(:define_method, :',', lambda {|b| self + [b]})
# M... | true |
d3bd4d03d2f7d56b69e2b800438723c5832a0fbd | Ruby | elle/language_guesser | /test/bloom_test.rb | UTF-8 | 871 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'test_helper'
describe Bloom do
it 'initialises with a filter array' do
b = Bloom.new
assert_equal 1000, b.filter.size
end
it 'initialises with array of zeros' do
b = Bloom.new
assert b.filter.select { |v| v == 1 }.size == 0
end
it 'can set a diffenet filter size' do
b = Bloom.n... | true |
a29615cf92114724b43fc0ab95199ab6f17f02fc | Ruby | hiimchinh/rb101 | /medium_2/lettercase_percentage_ratio.rb | UTF-8 | 717 | 3.8125 | 4 | [] | no_license | require 'pry'
def letter_percentages(string)
lowercase_num = string.count 'a-z'
uppercase_num = string.count 'A-Z'
lowercase_percentage = lowercase_num.to_f * 100 / string.size
uppercase_percentage = uppercase_num.to_f * 100 / string.size
neithercase_percentage = 100 - (lowercase_percentage + uppercase_perce... | true |
0fb8e9710506f1a7559402a729feec0295b6850c | Ruby | zhaoxuan/ruby_test | /time_now.rb | UTF-8 | 44 | 2.640625 | 3 | [] | no_license |
100000.times do |variable|
p Time.now
end | true |
bd0f20a969824f057557aa9f455cfbec804ccbbe | Ruby | jeantroiani/vending_machine | /lib/product.rb | UTF-8 | 136 | 3.09375 | 3 | [] | no_license | class Product
attr_accessor :price
attr_reader :name
def initialize(name, price = 1)
@price = price
@name = name
end
end
| true |
99898396ff17dea7e229bba14ef8ff8268f2f168 | Ruby | MarcusBullock/takeaway-challenge | /lib/order.rb | UTF-8 | 183 | 2.875 | 3 | [] | no_license | require_relative 'takeaway'
class Order
attr_reader :total
def initialize
@total = 0
end
def add(price)
@total += price
end
def reset
@total = 0
end
end
| true |
0fcb6b243d40068276b09a2f6b79c0f38f86bddd | Ruby | rickypchen/functionallyruby | /FifaStats.rb | UTF-8 | 1,281 | 3.3125 | 3 | [] | no_license | require 'csv'
class FifaLeaderBoard
def initialize(csv_file)
@csv_file = csv_file
@csv_data = nil
end
def load
@csv_data = CSV.read(@csv_file, {
headers: true,
header_converters: lambda { |h| h.downcase.gsub(' ', '_') }
})
end
def display
if !@csv_data.nil?
array_of_ha... | true |
69da2fcf7be30f0cf0dbd1fc1b22fc091a3ae0c6 | Ruby | CodingDojoDallas/ruby_dec_2018 | /kristen_martino/ruby_stack/3_Ruby_TDD/apple_tree/apple_tree_spec.rb | UTF-8 | 1,067 | 2.8125 | 3 | [] | no_license | require 'rspec'
require_relative 'apple_tree'
describe AppleTree do
before(:each) do
# Prepare an apple tree for all of the tests
@tree = AppleTree.new
end
context 'when age < 3' do
it 'should not grow any apples' do
expect(@tree.apple_count).to equal(0)
expect(@tree.year_gone_by.apple_c... | true |
e460f12e7b4a7561537c27fdcf466d688eafbffd | Ruby | freebz/Beginning-Ruby | /ch11/ex11-1.rb | UTF-8 | 130 | 2.84375 | 3 | [] | no_license | # Dynamic Code Execution
eval "puts 2 + 2"
puts eval("2 + 2")
my_number = 15
my_code = %{#{my_number} * 2}
puts eval(my_code)
| true |
e757e2fe3d9c38653261d8ecef50f123b5b6565b | Ruby | adrianpearman/Collections-and-Iteration | /exercise3.rb | UTF-8 | 1,029 | 3.984375 | 4 | [] | no_license | fav_movie = {:title => "Rush", :Director => "Ron Howard", :year => 2013 }
fav_movie2 = {:title => "Terminator", :Director => "James Cameron", :year => 1984 }
fav_movie3 = {:title => "Rocky", :Director => "John G.Alildsen", :year => 1976 }
#Arrays
favourite_artists = ["Kanye West", "Childish Gambino", "Drake"]
age = [... | true |
ac13f727c2662f9ee42b6e2c68256882a8e0ec7f | Ruby | Kish-Siva-1/ruby-music-library-cli-online-web-ft-041519 | /lib/music_importer.rb | UTF-8 | 292 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MusicImporter
attr_accessor :path, :files
def initialize(music_path)
@path = music_path
end
def files
@files = Dir.glob("#{path}/*.mp3").collect!{|x| x.sub("#{path}/","")}
end
def import
files.each{|x| Song.create_from_filename(x)}
end
end | true |
1e84cdf70d47b3fa950c899f3e0c03a479cca71b | Ruby | RebecCairns/looping-for-prework | /for.rb | UTF-8 | 94 | 2.96875 | 3 | [] | no_license |
def using_for
checklist = 1..10
for ckeck in checklist do
puts "Wingardium Leviosa\n"
end
end
| true |
77f25b41dd16245e6a1ea056462a44f84ff658ca | Ruby | ape-box/crawler | /test/crawlers/html_crawler_test.rb | UTF-8 | 3,130 | 2.546875 | 3 | [] | no_license | require 'minitest/autorun'
class HtmlCrawlerTest < Minitest::Test
@@content = <<-HEREDOC
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="/style.css" type="text/css" media="screen" />
<script type="text/javascript" src="/app.js"></script>
</head>
<body>
<d... | true |
1fd9ebe3f2bc0208ade871dd1a2283a814a821e1 | Ruby | AgeVitam/project-euler | /peuler56.rb | UTF-8 | 462 | 3.671875 | 4 | [] | no_license | =begin
A googol (10^100) is a massive number: one followed by one-hundred zeros; 100^100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits in each number is only 1.
Considering natural numbers of the form, a^b, where a, b < 100, what is the maximum digital sum?
... | true |
4e9b8e1fcffdf0e076de917253c94b6a66ab3206 | Ruby | morales257/crime-analysis | /test/neighborhood_test_helper.rb | UTF-8 | 319 | 2.671875 | 3 | [] | no_license | module NeighborhoodTestHelper
def create_polygon
points = self.geolocate
boundary = Geokit::Polygon.new(points)
end
def geolocate
coords = []
self.coordinates.each do |coords|
lat = coords[1]
lng = coords[0]
coords << Geokit::LatLng.new(lat, lng)
end
coords
end
end
| true |
d8378e752c08ceb4eed68942eae3b0b6596d6c0c | Ruby | philosophie/spree-product-assembly | /app/models/spree/inventory_unit_decorator.rb | UTF-8 | 426 | 2.578125 | 3 | [
"BSD-3-Clause"
] | permissive | module Spree
InventoryUnit.class_eval do
def percentage_of_line_item
product = line_item.product
if product.collection?
variant.price / line_item_total_value
else
1 / BigDecimal.new(line_item.quantity)
end
end
private
def line_item_total_value
line_item.... | true |
a8dbcbb4db92ef68335e63fa0094841165178b9a | Ruby | cjmarkham/profanity-gem | /lib/profanity_filter/symbol.rb | UTF-8 | 265 | 3.078125 | 3 | [
"MIT"
] | permissive | module ProfanityFilter
class Symbol
@@symbols = ["$","!"]
@@letters = ["s","i"]
def sanitize(string)
@@symbols.each_with_index do |symbol, index|
string = string.gsub(symbol, @@letters[index])
end
string
end
end
end
| true |
97d5465f381bc19eb82fa888a5256e13f8d5bbdf | Ruby | matthew/urcpu | /spec/helpers/ext/kernel.rb | UTF-8 | 767 | 2.703125 | 3 | [] | no_license | def running_under_textmate?
ENV.keys.detect { |key| key =~ /^TM_/ }
end
if running_under_textmate?
require 'cgi'
module Kernel
alias :original_puts :puts
def puts(*args)
args = ["\n"] if args.empty?
args = args.map {|arg| convert_to_html(arg.to_s + "\n") }
original_print *args
en... | true |
883ae28456c29d033720286a4afaecf899aa38e3 | Ruby | MC4517/ScrapperFou | /lib/app.rb | UTF-8 | 483 | 2.640625 | 3 | [] | no_license |
require 'nokogiri'
require 'open-uri'
def cours_crypto
doc = Nokogiri::HTML(URI.open('https://coinmarketcap.com/all/views/all'))
crypto_symbol = doc.xpath("//td[3]| //td[5]").map do |crypto|
crypto.text
end
end
def array(crypto_symbol)
i = 0
a = []
while i < 399
a <<... | true |
57016a91aa693f8cb4234ad976a364d34c5cba46 | Ruby | Akash1996z/Ruby-basics | /test.rb | UTF-8 | 404 | 4 | 4 | [] | no_license |
puts "Once there was a man named jhon"
puts "He was 70 years old"
puts "He really liked his name"
puts "but didn't like being 70"
puts "\n"
character_name = "jhon"
character_age = "70"
puts ("Once there was man named "+character_name)
puts ("He was " + character_age +" years old")
character_name = "Mike"
puts ("He r... | true |
4bde1804218d906037d0e5f1bebd1150d13cfe43 | Ruby | sanchaya/patrikasanchaya | /app/models/book.rb | UTF-8 | 1,555 | 2.53125 | 3 | [] | no_license | class Book
BASE_URL = Rails.env == "development" ? 'http://localhost:3001' : 'http://samooha.sanchaya.net'
BASE_SEARCH_URL = Rails.env == "development" ? 'http://localhost:3001/search.json?search=' : 'http://samooha.sanchaya.net/search_patrike.json?search='
# BASE_SEARCH_URL = 'http://samooha.sanchaya.net/search... | true |
b91a42abc4a4155f3c2fed19405365e593931bf6 | Ruby | sebastienbruno122/rails-longest-word-game | /app/controllers/games_controller.rb | UTF-8 | 672 | 2.96875 | 3 | [] | no_license | require 'json'
require 'open-uri'
class GamesController < ApplicationController
def new
@letters = [*('A'..'Z')].sample(10)
end
def score
word = params[:word].chars #["A", "B", "B"]
grid = params[:grid].chars #["A", "B", "C"]
results = word.all? {|letter| word.count(letter) <= grid.count(letter)}
... | true |
af491870ddb47e5285e60131612774f9b60ed994 | Ruby | hasumin71/rensyu | /ABC172C.rb | UTF-8 | 617 | 3.375 | 3 | [] | no_license | N, M, K = gets.chomp.split.map(&:to_i)
AS = gets.chomp.split.map(&:to_i) #Aに積読されている各本の所要時間
BS = gets.chomp.split.map(&:to_i) #Bに ””
a_sum = [0]
b_sum = [0]
AS.each { |a| a_sum << a_sum[-1] + a } #一番後ろの要素に足していく
#入力が60 90 120の場合=>[0, 60, 150, 270]
BS.each { |b| b_sum << b_sum[-1] + b }
#入力が80 150 80 150 =>[0, 80, 230... | true |
883d7ee03042d44089dd016e969ebd9c32ef7b14 | Ruby | mt-aya/shift-app | /spec/models/staff_user_spec.rb | UTF-8 | 5,190 | 2.515625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe StaffUser, type: :model do
describe 'staff_user新規登録' do
let(:staff) { build(:staff_user) }
let(:another_staff) { build(:staff_user) }
context '登録できる時' do
it '全てのカラムに値が存在すれば登録できる' do
expect(staff).to be_valid
end
it 'passwordは英・数字の両方が含まれており6... | true |
ea71ec8d930dc462b0f13ee2665f6c45ad59f35a | Ruby | fguillen/SpaceshipWar | /enemies/blaster.rb | UTF-8 | 844 | 2.84375 | 3 | [] | no_license | module Enemy
class Blaster
attr_reader :x, :y
def initialize(x, y)
@image = Gosu::Image.new("#{__dir__}/../images/enemyBlack4.png")
@x = x
@original_x = x
@y = y
@velocity = Configuration::ENEMY_VELOCITY
EnemiesBasket.enemies.push(self)
end
def update
@y += ... | true |
773ab9bfca7dc86ed3953a051e464ecca91d95a5 | Ruby | TsubasaMatsuura/vendingmachine-sample | /lib/function.rb | UTF-8 | 1,172 | 3.515625 | 4 | [] | no_license | require "../lib/vending_machine"
require "pry"
class Function
attr_reader :vending_machine
def initialize
@vending_machine = VendingMachine.new
end
def input
str = gets.chomp
str = '0' if str !~ /^\d+$/
str.to_i
end
def insert
puts "投入金額を入力して下さい"
change = @vending_machine.insert(... | true |
70c4d958635b5aa01d05c312139b871fe7185e77 | Ruby | KenzoM/AppAcademyPrep | /week2/w2d3/lib/io_exercises.rb | UTF-8 | 1,877 | 4.375 | 4 | [] | no_license | # I/O Exercises
#
# * Write a `guessing_game` method. The computer should choose a number between
# 1 and 100. Prompt the user to `guess a number`. Each time through a play loop,
# get a guess from the user. Print the number guessed and whether it was `too
# high` or `too low`. Track the number of guesses the pla... | true |
e690c94c3a53aa4d4790aac1e65f3496f0a2ccdb | Ruby | mister-hsiao/warcraft3 | /spec/test_11.rb | UTF-8 | 608 | 2.59375 | 3 | [] | no_license | require_relative 'spec_helper'
describe Barracks do
before :each do
@footman = Footman.new
#@peasant = Peasant.new
@super_saiyan = Unit.new(1000000, 499)
@barracks = Barracks.new
end
describe "#new" do
it "should create a new barracks with hp of 500" do
expect(@barracks.health_points).... | true |
444a5280b22895ec8fbb2c92d4659a12ab1c4d98 | Ruby | netelder/ar-sunlight-legislators | /app/main.rb | UTF-8 | 2,642 | 3.34375 | 3 | [] | no_license | require_relative '../db/config'
require_relative 'models/legislator'
require 'awesome_print'
# the Munger gem looks like it would make this all much easier:
# https://github.com/schacon/munger/wiki/MungerData
ALL_STATES = ["AK","AL","AR","AZ","CA","CO","CT","DE","FL","GA","HI","IA","ID","IL","IN","KS","KY","LA","MA",... | true |
dfad359556b199a287eaaab97098bae3923ca669 | Ruby | DingChiLin/RubyExercise | /BasicLanguageProperty/dynamic_connectivity.rb | UTF-8 | 833 | 3.234375 | 3 | [] | no_license | class Quick_Union
def initialize(num)
@num = num
@dotList = *(0..num.to_i-1)
@size = Array.new(num.to_i,1);
end
private
def root(p)
until p == @dotList[p] do
@dotList[p] = @dotList[@dotList[p]]
p = @dotList[p]
end
puts @size.inspect
return p;
end
public
def union(p1,p2)
root1 = r... | true |
8b73aad308bbe661f31bc6538527e40e12d6278f | Ruby | xiagu/2015-advent-of-code | /day1/solver.rb | UTF-8 | 175 | 3.65625 | 4 | [] | no_license |
floor = 0
open("input.txt", "r") do |file|
file.each_char do |char|
case char
when "("
floor += 1
when ")"
floor -= 1
end
end
end
puts floor
| true |
1974bd7b7d928c9999db783d6793b6a4ecd4f87b | Ruby | TheKnowles/cminus-compiler | /src/main.rb | UTF-8 | 1,371 | 2.765625 | 3 | [] | no_license | #!/usr/env/ruby
# Developed with 1.9.3
# Knowles Atchison, Jr.
# Spring 2013
# Compiler Design
# to run:
# command line: ruby main.rb /path/to/file
# all additional srcs in same directory
require_relative "utils"
require_relative "codegen"
class CminusCompiler
def initialize(filename, debug=false)
@debug = ... | true |
b1a53c69b7788b04ae8adb2526a164ef5b701648 | Ruby | michael-huang/Learn-To-Program | /14/better_logger.rb | UTF-8 | 330 | 3.609375 | 4 | [] | no_license | $depth = 0
def log description, &block
puts " "*$depth + "Begining: #{description}..."
$depth += 1
result = block.call
$depth -= 1
puts " "*$depth + "... #{description} finished, returning #{result}"
end
log 'outer block' do
log 'some little block' do
"little"
end
log 'yet another block' do
"another"
end
"o... | true |
036e5daeeb9a76ea9c63dc27caaa9131ec40d861 | Ruby | takkkun/peeek | /lib/peeek/cli.rb | UTF-8 | 3,033 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'peeek/cli/options'
require 'peeek'
class Peeek
class CLI
# Initialize the CLI object.
#
# @param [IO] input source to input
# @param [IO] output destination to output the execution result
# @param [Array<String>] argv arguments that is given from command line
def initialize(input, o... | true |
b4f5e8339b62e3e1976505a2d6feb956576b7290 | Ruby | jjardine85/snowman-lab-attempt | /specs/game_spec.rb | UTF-8 | 993 | 3.171875 | 3 | [] | no_license | require("minitest/autorun")
require("minitest/rg")
require_relative("../game")
require_relative("../player")
require_relative("../hiddenword")
class GameTest < Minitest::Test
def setup
@player0 = Player.new("John", 6)
@word0 = HiddenWord.new("TestworD")
@word1 = HiddenWord.new("Another test")
@game = Game.new(@player... | true |
1ec492cf06b21d353eef8f81809681194b7c07f6 | Ruby | debugging/ruby-quickstart | /point.rb | UTF-8 | 1,295 | 3.765625 | 4 | [] | no_license | class Point
include Comparable
attr_accessor :x, :y
alias eql? ==
@n = 0 # how many points we have created
@totalX = 0 # sum of all x cords
@totalY = 0 # sum of all y cords
def initialize(x,y)
@x, @y = x,y
end
ORIGIN = Point.new(0,0)
UNIT_X = Point.new(1,0)
UNIT_Y = ... | true |
8705b95a8a278d7e70fb593804c04d3894f76ed6 | Ruby | BBSQ/notepad | /notepad.rb | UTF-8 | 517 | 2.953125 | 3 | [] | no_license | require_relative 'post'
require_relative 'link'
require_relative 'task'
require_relative 'memo'
puts "Привет, я твой блокнот!"
puts "Что хотите записать в блокнот?"
choices = Post.post_types
choice = -1
until choice >= 0 && choice < choices.size
choices.each_with_index do |type, index|
puts "\t#{index}: #{typ... | true |
858a624287674a1a226f542878973ee10c3425f3 | Ruby | robbbowes/SQL-Ruby-Lab | /models/space_cowboy.rb | UTF-8 | 3,221 | 3.046875 | 3 | [] | no_license | require("pg")
class SpaceCowboy
attr_accessor( :name, :species, :bounty_value, :danger_level, :last_known_location, :homeworld, :favourite_weapon, :cashed_in, :collected_by )
def initialize( cowboy_details )
@id = cowboy_details["id"].to_i() if cowboy_details["id"]
@name = cowboy_details["name"]
@s... | true |
7454b9557fe796e707ad389e06d04b29729bc363 | Ruby | anattrass/cx3_8 | /week_2/day_4/modules/modules.rb | UTF-8 | 435 | 3.84375 | 4 | [] | no_license | # module BethsCrazyArray
# class Array
# def length
# return 100
# end
# end
# end
# my_array = BethsCrazyArray::Array.new
# puts my_array.length
# normal_array = Array.new
# puts normal_array.length
# puts Math::PI
# puts Math::sqrt(49)
module BethsCrazyMath
PI = "A slice of apple pie"
... | true |
cc36122630934bf918b0068ea7af89f96710547c | Ruby | ChristopherMaierInc/S1-Ruby-Revision | /ex12.rb | UTF-8 | 386 | 4.0625 | 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 "give me another number bro: "
num2 = gets.chomp.to_f
print... | true |
959dcb91511d304094bca03c13bffab13d0c97ed | Ruby | kannancet/import-app | /app/models/concerns/importable.rb | UTF-8 | 2,642 | 2.703125 | 3 | [] | no_license | #This module implements import data
module Importable
extend ActiveSupport::Concern
#All class methods are defined here.
module ClassMethods
#Function to import operations from CSV.
def import
notify_on_parsing_log
SmarterCSV.process(IMPORT_OPERATION_FILE) do |data|
data = data.f... | true |
df3706f9b8ed189962ba7be39fdd1dc2ac294bdc | Ruby | donsalvadori/Ruby-Repo | /practice/uri.rb | UTF-8 | 182 | 2.515625 | 3 | [] | no_license | require 'uri'
require 'open-uri'
url = URI.parse('http://teamtreehouse.com')
puts url.inspect
url.hostname
puts url.path
puts URI.split('http://teamtreehouse.com').inspect
| true |
8556a3ee471e9bbd79104c3232b631ee55aa914a | Ruby | Bumsuk/MyRubyBase | /08-011-freeze.rb | UTF-8 | 104 | 2.625 | 3 | [] | no_license | Fixnum.freeze
class Fixnum
def +(rhs); return 5 end #=> TypeError(can't modify frozen class) †
end
| true |
b58763423119bce12dcef71667daeef6e7508390 | Ruby | sarahemm/ruby-zwaveascii | /lib/zwaveascii/devices.rb | UTF-8 | 1,566 | 2.859375 | 3 | [
"MIT"
] | permissive | module ZWave
class Node
def initialize(controller, address)
@controller = controller
@address = address
end
end
class BatteryNode < Node
def initialize(controller, address)
super controller, address
end
def battery_level
response = @controller.send_cmd ">N#{@add... | true |
f6e631b06ad28c118b503789e19236798b7117f1 | Ruby | gtrujillop/graped_moviez | /lib/graped_moviez/api/v1/operations_helper.rb | UTF-8 | 1,218 | 2.625 | 3 | [
"MIT"
] | permissive | require "graped_moviez/models/movie"
require "graped_moviez/models/day"
require "graped_moviez/models/function"
require "graped_moviez/models/reservation"
module GrapedMoviez
module Api
module V1
module OperationsHelper
def save(object)
if object.save
key = object.class.name.s... | true |
1f015dea1d97635bef7c81371a1f89d5460ec158 | Ruby | mruttan/ar-exercises | /exercises/exercise_1.rb | UTF-8 | 398 | 2.8125 | 3 | [] | no_license | require_relative '../setup'
puts "Exercise 1"
puts "----------"
# Your code goes below here ...
Store.create(name: 'Sears', annual_revenue: 1000000, mens_apparel: false, womens_apparel: true)
Store.create(name: 'Zellers', annual_revenue: 0, mens_apparel: true, womens_apparel: true)
Store.create(name: 'Metro', annual_... | true |
3888ccb76cf63efcadbc1c8d852404ee4130325b | Ruby | petrsigut/czech_names_vocative | /test/test_czech_names_vocative.rb | UTF-8 | 592 | 2.578125 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require 'test/unit'
require 'czech_names_vocative'
class CzechNamesVocativeTest < Test::Unit::TestCase
def test_few_names_vocative
assert_equal "Petře", "Petr".vocative
assert_equal "Josefe", "joSef".vocative
assert_equal nil, "NONAME".vocative
assert_not_equal "Veronika", "Veronik... | true |
1d1937a50063a8f98baad10987800815e3dfa96f | Ruby | bisdeep/W3D1 | /enumerables_project/enumerables.rb | UTF-8 | 639 | 3.828125 | 4 | [] | no_license | class Array
def my_each(&block)
self.map! {|ele| block.call(ele) }
end
def my_select(&block)
newArr = []
newArr << block.call(self.my_each(&block))
return newArr
end
def my_reject(&block)
newArr =[]
self.each do |ele|
if !block.call(ele)... | true |
b370ae0ed04a7fe44d4721d60444de38040deb7b | Ruby | seachel/sorbet | /test/testdata/parser/compare_overload_parse_error.rb | UTF-8 | 361 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | # typed: false
class A # error: class definition in method body
def greater_eqaul>=(foo) # error: unexpected token tGEQ
end
end
class B # error: class definition in method body
def less_equal<=(foo) # error: unexpected token tLEQ
end
end
class C # error: class definition in method body
def not_equal!=(foo) ... | true |
76f79f46e27bf735c32bfb48fed5d1abd26ac6f8 | Ruby | ajcf/sudoku | /sudoku.rb | UTF-8 | 4,958 | 3.484375 | 3 | [] | no_license | class Node
attr_accessor :row, :column, :fixed, :value, :possible_values, :square
def initialize(row, col, is_fixed, value, *possible_values)
self.row = row
self.column = col
self.fixed = is_fixed
self.value = value
self.possible_values = possible_values if possible_values
end
def check_val... | true |
5cb1bd156906f25e000053abc38deebbe5a60ea2 | Ruby | hosomi/auth0-rails-api | /app/services/authorization_service.rb | UTF-8 | 381 | 2.671875 | 3 | [
"MIT"
] | permissive | class AuthorizationService
def initialize(headers = {})
@headers = headers
end
def authenticate_request!
verify_token
end
private
def http_token
if @headers['Authorization'].present?
@headers['Authorization'].split(' ').last
end
end
def verify... | true |
fd3bb7fb58929676386a1908b08af38aec392ff4 | Ruby | pjmcaleavey/bowling_game_kata | /spec/bowling_tests_spec.rb | UTF-8 | 962 | 3.140625 | 3 | [] | no_license | require 'rspec'
require './game' # require_relative 'game' - also works
describe 'Game' do
let(:game) { Game.new }
#could also do:
# subject { Game.new }
#since Game is the subject
it 'can score a gutter ball game' do
20.times do
game.roll(0)
end
expect(game.score).to eq(0)
end
it 'c... | true |
90e238dfe46687e384a3830c5cbefedca3d05b0b | Ruby | lmuhammad1/codewars | /kyu5/largest_5_digit_number_in_a_series.rb | UTF-8 | 472 | 3.125 | 3 | [] | no_license | def solution(digits)
counter = 0
temp_char = '0'
temp_number = ''
final_number = ''
digits.each_char do |num|
if num >= temp_char
temp_char = num
temp_number = digits.slice(counter, 5)
if temp_number > final_number
final_number = temp_number
end
end
counter = counter + 1
end
return f... | true |
c17ce544ac5151c9efb301df0fbb26788abd0062 | Ruby | Sts0mrg0/rimdb | /spec/utils.rb | UTF-8 | 243 | 2.515625 | 3 | [
"MIT"
] | permissive | module Utils
def self.load_fixture(name)
path = File.join(File.dirname(File.expand_path(__FILE__)), 'fixtures', name)
raise StandardError.new "Unable to locate fixture #{path}" unless File.exists? path
File.read path
end
end
| true |
2c51d3f8f1e1b5135340978b066e6d88fa0ebaaa | Ruby | drucee/phase-0 | /week-4/factorial/my_solution.rb | UTF-8 | 207 | 3.203125 | 3 | [
"MIT"
] | permissive | # Factorial
# I worked on this challenge with Bill Deng.
# Your Solution Below
def factorial(number)
result = 1
while number >= 1
result = result * number
number = number - 1
end
p result
end | true |
fb8e088009f9e37ddc53879a0c62614f46628c51 | Ruby | Lenam80/oo-meowing-cat-online-web-pt-021119 | /lib/meowing_cat.rb | UTF-8 | 88 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | ## code your solution here.
maru = Cat.new
maru.name = "Maru"
maru.name
maru.meow
end
| true |
0070e7c7f66135225316f3e64c0d012d8a560a6d | Ruby | codeunion/fundamentals-of-web-development | /session-notes/03-cohort/session-8-10-31-2014/waffles.rb | UTF-8 | 1,449 | 2.6875 | 3 | [] | no_license | require 'sinatra'
require 'data_mapper'
DataMapper::Logger.new(STDOUT, :debug)
DataMapper.setup(:default, "sqlite:waffles.db")
class Waffle
include DataMapper::Resource
property :id, Serial
property :description, String
has n, :comments
end
class Comment
include DataMapper::Resource
property :id... | true |
83930741b80e71a595fcd95a1da80c4fca3376f2 | Ruby | xarisd/ruby-basics | /source/01_taste/11d_io_gets.rb | UTF-8 | 444 | 4.21875 | 4 | [
"MIT"
] | permissive | # gets reads from the STDIN (usually the console or a file) a whole line of input (until it sees a newline)
# uses arg.inspect internally
print "Please write your name: "
name = gets
# it contains the new line
puts "Hello #{name}! What a wonderfull name"
p name
puts
puts "--------------------------"
puts
# Use Str... | true |
6bcd1dc81d46d9a96244f70ddd73ff6993732ab6 | Ruby | Darep/opbeat_ruby | /lib/opbeat/better_attr_accessor.rb | UTF-8 | 912 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | require 'set'
module Opbeat
module BetterAttrAccessor
def attributes
Hash[
self.class.attributes.map do |attr|
[attr, send(attr)]
end
]
end
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def attributes
@attribu... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.