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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
7d9d79f1d908cf08eb824474573c330ea8a816a0 | Ruby | costolo/chain | /spec/model_specs/skill_spec.rb | UTF-8 | 1,150 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'rails_helper'
describe Skill do
let(:valid_skill) { Skill.create(title: "valid skill") }
let(:invalid_skill) { Skill.create(title: "invalid skill") }
let(:streak_test) { Skill.create(title: "testing", longest_streak: 7)}
it "is valid with a title" do
expect(valid_skill.valid?).to be true
end
... | true |
c6c3e4eaf3564b44108335a36c30455e2d2f1067 | Ruby | pkenrick/bank_tech_test | /spec/transaction_spec.rb | UTF-8 | 347 | 2.53125 | 3 | [] | no_license | require 'transaction'
describe Transaction do
subject(:transaction){described_class.new(100, 100, date_class)}
let(:date_class){double :date_class, today: date}
let(:date){double :date}
it 'initialises with a date, and the correct amount' do
expect(transaction.date).to eq(date)
expect(transaction.cre... | true |
aad3815bb7ac00d8f6b90ddd955ba85a9e12a2b0 | Ruby | eadz/design_patterns_in_ruby | /behavioral/observer2.rb | UTF-8 | 1,031 | 3.765625 | 4 | [] | no_license | # observer2.rb
# Define a one-to-many dependency between objects so that when one object
# changes state, all it's dependents are notified and updated automatically
require 'observer'
# 1. observer
class Observer
def initialize(name)
@name = name
end
def update(value)
puts "updated " + @name + ". Ne... | true |
f27602da39beebc8863bb1f9ee9d4846492e1f66 | Ruby | baakkoun/coderbyte | /09_TimeConver.rb | UTF-8 | 326 | 3.28125 | 3 | [] | no_license | def TimeConvert(num)
if num >= 60
hour = num/60
minute = num.modulo(60)
else num < 60
hour = "0"
minute = num
end
# code goes here
return "#{hour}:#{minute}"
end
# keep this function call here
# to see how to enter arguments in Ruby scroll down
TimeConvert(STDIN.g... | true |
dbdb2859b828f1ddf1bb10704b7b007adebe10bd | Ruby | robsonmarques/mascherari | /spec/formatter_spec.rb | UTF-8 | 1,844 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Mascherari::Formatter do
subject do
described_class.new :format => "(##) ####-####"
end
describe '#mask' do
context 'when value is unmasked' do
it 'returns value with mask' do
expect(subject.mask "1234567890").to eq "(12) 3456-7890"
end
end
con... | true |
c4371b415292990a6e9e30d1c95deada696eadfe | Ruby | meh/worb | /lib/worb.rb | UTF-8 | 1,438 | 2.53125 | 3 | [] | no_license | #--
# Copyleft meh. [http://meh.doesntexist.org | meh@paranoici.org]
#
# This file is part of worb.
#
# worb is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at you... | true |
2aef47ee713dbd59ebf3e4b54563588917e1c52d | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/filtered-submissions/c35a230135e04372aa7a031b79c63cf4.rb | UTF-8 | 144 | 2.84375 | 3 | [] | no_license | def compute(str_1, str_2)
str_1.length.times.inject(0) do |dist, index|
str_1[index] != str_2[index] ? dist += 1 : dist
end
end | true |
3c51f07c425163ab9b84300ff8fedad470cfb31e | Ruby | dvmtn/github-favelang | /lib/github_favelang.rb | UTF-8 | 1,552 | 3.046875 | 3 | [] | no_license | require 'octokit'
class GithubFaveLang
def favourite_language username
repos = repos_for_user username
languages = repos_per_language(repos)
most_popular languages
end
def repos_for_user username
user = get_user(username)
user_repos = user.rels[:repos].get
user_repos.data
end
def r... | true |
c054f250b8971e70d153f566015b32534184743c | Ruby | ttscoff/snibbets | /spec/string_spec.rb | UTF-8 | 2,821 | 2.984375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
RSpec.describe Snibbets do
string1 = <<~EOSTRING1
This is a note
this is indented code
* on the other hand
* this is a list
* with indentation
This, however, is indented code
And here's a little note
> This is a block quote note
... | true |
f70d802600ec55bbcc3667bfa298b64c3eaaf94c | Ruby | nodunayo/heathrow | /lib/airport.rb | UTF-8 | 585 | 3.140625 | 3 | [] | no_license | require_relative 'weather'
class Airport
include Weather
attr_reader :capacity, :planes
def initialize planes = [], capacity = 20
@planes = planes
@capacity = capacity
end
def plane_count
@planes.count
end
def capacity
@capacity
end
def full?
plane_count == @capacity
end
... | true |
e257c0eb643fddc86f1bc4439caa91958bd20a02 | Ruby | IceDragon200/moon-lunar_metal | /scripts/views/map_view.rb | UTF-8 | 2,288 | 2.671875 | 3 | [] | no_license | class MapView < StateView
attr_reader :tilemap # Moon::Tilemap
attr_reader :cursor # CursorRenderer
attr_reader :units # RenderArray<UnitRenderer>
def initialize_elements
super
@tilemap = Moon::Tilemap.new
@cursor = MappingCursorRenderer.new
@units = Moon::RenderArray.new
@cursor.mappin... | true |
cd474228c190ba874f54376696b75b5fe1953ad5 | Ruby | eslifreitas/TrelloESL | /app/models/history_validator.rb | UTF-8 | 1,887 | 3 | 3 | [] | no_license | class HistoryValidator < ActiveModel::Validator
def validate(record)
if record.points > 13
record.errors.add(:points.to_s(),"Points deve ser menor ou igual a 13")
elsif !is_fibonacci?(record.points)
record.errors.add(:points.to_s(), "Points inválido")
end
i... | true |
015ed6870a581c2c93d39d762fec56341b742ece | Ruby | amelie314/ruby_basic | /guess.rb | UTF-8 | 422 | 4.21875 | 4 | [] | no_license | # 產生一個數字讓使用者猜
# 如果使用者猜對了->輸出 '猜對了'
# 不然 -> 輸出 '猜錯了'
number = Random.rand(9)+1
while true
print '請猜一個1~10之間的數字:'
guess = gets.chomp.to_i
if guess == number
puts '你猜對了,答案是' + number.to_s
break
elsif guess > number
puts '猜太大了!'
else
puts '猜太小了!'
end
end | true |
0ea56e4fd2fb872ebd2c1935d504a8c164af4201 | Ruby | DanielZwijnenburg/Daily-Kata | /2012/November/20-11-2012/string_calculator_spec.rb | UTF-8 | 1,143 | 3.125 | 3 | [] | no_license | require_relative 'string_calculator'
describe 'StringCalculator' do
let(:calc) {StringCalculator.new}
describe "#add" do
it 'returns 0' do
calc.add("").should == 0
end
it 'returns 1' do
calc.add("1").should == 1
end
it 'returns 3' do
calc.add("1,2").should == 3
end
it 'r... | true |
f5c61e39257b8ab67608aedc4c129f665393e88d | Ruby | KyleRombach/phase-0 | /week-4/simple-substrings/my_solution.rb | UTF-8 | 143 | 2.875 | 3 | [
"MIT"
] | permissive | def welcome(address)
if address.include?("CA")
return "Welcome to California"
else return "You should move to California"
end
end | true |
19f247233ccea3c94194f1dab17e61bbcd5ac4ab | Ruby | cuteofdragon/obscurejs | /2017/fib.rb | UTF-8 | 197 | 3.0625 | 3 | [
"MIT"
] | permissive | # Related to the ruby in JS post which is implemented in ruby.js
def fib(n)
if (n < 2)
return n
end
fib(n - 1) + fib(n - 2)
end
puts fib 0
puts fib 1
puts fib 2
puts fib 11
puts fib 17
| true |
f006d417f4c9741f3864f6aba334037135c06a02 | Ruby | sleepingkingstudios/bronze | /spec/bronze/errors_spec.rb | UTF-8 | 37,454 | 2.59375 | 3 | [
"MIT"
] | permissive | # spec/bronze/errors_spec.rb
require 'bronze/errors'
RSpec.describe Bronze::Errors do
shared_context 'when there are many errors' do
let(:errors) do
{
:must_be_present => {},
:must_be_numeric => {},
:must_be_greater_than => { :value => 0 }
} # end hash
end # let... | true |
e4385489fbd443267a5ebf10c1218ab6f0bf35bb | Ruby | Gamoundo/ttt-8-turn-ruby-intro-000 | /lib/turn.rb | UTF-8 | 1,144 | 4.25 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def turn(board)
display_board(board)
puts "Please enter 1-9:"
input = gets.strip
integer = input_to_index(input)
if valid_move?(board, integer) == true
move(board, integer)
display_board(board)
else valid_move?(board, integer) == false
turn(board)
end
end
def valid_move?(board, index)
if ind... | true |
f3bc3c93fe1853823a87d3f8a486222cc4d0c8cd | Ruby | sonota88/plumo | /examples/random.rb | UTF-8 | 859 | 2.90625 | 3 | [
"BSD-2-Clause"
] | permissive | load File.join(__dir__, "helper.rb")
require 'plumo'
def rand_color
"rgba(%f, %f, %f, %f)" % [
rand * 240,
rand * 200,
rand * 120,
0.5 + rand / 2
]
end
def rand_x
rand * $canvas_w
end
def rand_y
rand * $canvas_h
end
# --------------------------------
$canvas_w = 400
$canvas_h = 200
plumo... | true |
91211f7ef661d64face15b588195a0566b44bb03 | Ruby | h4ppyr0gu3/montecinema | /app/concepts/screenings/screening_repository.rb | UTF-8 | 900 | 2.6875 | 3 | [] | no_license | module Screenings
class ScreeningRepository
ScreeningNotFound = Class.new(StandardError)
attr_reader :repository
def initialize
@repository = Screenings::Model
end
def create_screening(params)
repository.create(params)
end
def destroy_screening id
screening = repository.find(id)
screening.d... | true |
20c40df1918f943a9d1b28c9a1e31ecfacefb47f | Ruby | aksentyev/letsencrypt_standalone | /lib/letsencrypt_standalone/client.rb | UTF-8 | 1,323 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'letsencrypt_standalone'
require 'acme/client'
require 'openssl'
module LetsencryptStandalone
class Client < Base
attr_reader :account, :email, :acme_client
def initialize(account: nil, email:)
@email = email
@account = account
@acme_client = Acme::Client.new(private_key: private_k... | true |
2a784f313e1caceff77156f103de26427704f9d4 | Ruby | marcomanomat/phase-0-tracks | /ruby/santa.rb | UTF-8 | 2,046 | 3.671875 | 4 | [] | no_license | #6.3 Attributes
class Santa
attr_accessor :gender, :ethnicity, :age
attr_reader :reindeer_ranking
def initialize(gender, ethnicity)
puts "Initializing Santa instance..."
@gender = gender
@ethnicity = ethnicity
@reindeer_ranking = ["Rudolph", "Dasher", "Dancer", "Prancer", "Vixen", "Comet", "Cupid", "Donner",... | true |
84f448584887ef7d8e150d53c050706872f82dea | Ruby | michaelsabo/ci | /app/features/build_runner/remote_runner.rb | UTF-8 | 13,340 | 2.546875 | 3 | [
"MIT"
] | permissive | require_relative "../../../agent/client"
require_relative "../../../lib/notifications"
module FastlaneCI
##
# RemoteRunner
#
# This class will connect to a running Agent (provided by the grpc parameter)
# and execute a fastlane command, streaming back the responses.
# It can also provide an interface for a... | true |
20d1eb4a65012651447cb8fa2c558dd716ec3d62 | Ruby | lucyfox4131/Battleship | /lib/check_validity.rb | UTF-8 | 1,181 | 4.375 | 4 | [] | no_license | #the input I get is in terms of....coordinates are A1, A2
#when getting this input from the user I should change it into the format ["A", 1], ["A", 2]
#That should be what gets input to this method for a validity check
#if the guess is valid then return that it is to the main method to continue into the section
#that ... | true |
4a0daab7f26af9f6132936c8cf1fac011ac68ac2 | Ruby | arbonap/exercism-ruby | /sum-of-multiples/sum_of_multiples.rb | UTF-8 | 950 | 2.84375 | 3 | [] | no_license | class SumOfMultiples
attr_reader :multiple_one, :multiple_two, :multiple_three
def initialize(multiple_one=nil, multiple_two=nil, multiple_three=nil)
@multiple_one = multiple_one
@multiple_two = multiple_two
@multiple_three = multiple_three
end
def to(num)
multiples = [multiple_one, multiple_tw... | true |
4ff744ce4e7b0b6ec315d4d565adbae5213fd7d4 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/beer-song/720638d346e54793bc05d2d9fd3e7f22.rb | UTF-8 | 836 | 3.90625 | 4 | [] | no_license | class Beer
def verse(n)
if n > 0
construct_verse n
else
final_verse
end
end
def sing(first, last=0)
first.downto(last).each_with_object("") { |n, s| s << verse(n) + "\n" }
end
private
def construct_verse(n)
bottles(n) + " of beer on the wall, " + \
bottles(n) + " of be... | true |
d89899f8e0bff0bc0751100f124536ab0d40239e | Ruby | topofocus/active-orient | /lib/rest/create.rb | UTF-8 | 9,725 | 2.6875 | 3 | [
"MIT"
] | permissive | module RestCreate
######### DATABASE ##########
=begin
Creates a database with the given name and switches to this database as working-database. Types are either 'plocal' or 'memory'
Returns the name of the working-database
=end
def create_database type: 'plocal', database:
logger.progname = 'RestCreate#C... | true |
e4e21e2d28d128476be8c8cbaf365d7b901ac60f | Ruby | anlijiu/ruby-core-api-study | /include_extend_test.rb | UTF-8 | 1,532 | 3.90625 | 4 | [] | no_license | #!/usr/bin/env ruby -w
# include主要用来将一个模块插入(mix)到一个类或者其它模块。
# extend 用来在一个对象(object,或者说是instance)中引入一个模块,这个类从而也具备了这个模块的方法。
# 通常引用模块有以下3种情况:
# 1.在类定义中引入模块,使模块中的方法成为类的实例方法
# 这种情况是最常见的
# 直接 include <module name>即可 , 实例可调用该模块定义的方法
#
# 2.在类定义中引入模块,使模块中的方法成为类的类方法
# 这种情况也是比较常见的
# 直接 extend <module name>即可 , 类可调用该模块定义... | true |
558616c01837910987c2b96a84dd23aa06117124 | Ruby | nyarlarla/practice_ruby | /2-7/file1.rb | UTF-8 | 549 | 3.8125 | 4 | [] | no_license | apple=100
if apple>=100
puts"リンゴの値段は100円以上です"
end
if apple<=100
puts"リンゴの値段は100円以下です"
end
tall=180
if tall>=170 && tall<=190
puts"身長は170以上190以下です"
end
apple="Aomori"
if apple=="Nagano"
puts "リンゴの生産地は長野です"
else
puts "リンゴの生産地は青森です"
end
if apple=="yamagata"
puts "リンゴの生産地は長野です"
elsif apple=="yamagata"
puts"リン... | true |
843374e134fbe95ce879ba0cb30c703e25a487b8 | Ruby | lockstep/open_play | /app/models/concerns/schedulable.rb | UTF-8 | 1,133 | 2.53125 | 3 | [] | no_license | module Schedulable
extend ActiveSupport::Concern
include DateTimeUtilities
included do
def day_is_in_range_of_schedule?(days, day)
days.include?(day)
end
def checking_all_day_schedule(date, scheduled_on, scheduled_specific_day, scheduled_days)
booking_date = Date.parse(date)
retur... | true |
e20aacdfe0fd838a2e22c5219e0d35063817acbe | Ruby | natalieytan/ruby-fundamentals | /solutions/11.rb | UTF-8 | 960 | 4.21875 | 4 | [] | no_license | # Your shop sells bespoke solid wood right-angled-triangular tables (because you are a hipster).
# The client is charged for the volume of the table. Write a function that takes two arguments,
# and works out the area of the triangle.
# Write a second function that takes two arguments, one representing the area of th... | true |
9d1dbdf87cb08d15e1b22dfbb7ea33617603ebca | Ruby | loiemilio/clio | /lib/log_utils.rb | UTF-8 | 239 | 2.53125 | 3 | [] | no_license | class SilenceLogger
def method_missing(*)
# just eats it
end
end
class PrettyFormatter
def call(severity, time, program_name, message)
"#{time.strftime('%d %b %H:%M:%S')} #{severity}: #{message}\n"
end
end
| true |
85e2e772cd347d99eb10c0c11b4a0f5178f7ad91 | Ruby | sormgabriel/eis | /stone_paper_scissors_monkey/spec/elements_behaviour_spec.rb | UTF-8 | 829 | 2.578125 | 3 | [] | no_license | require 'rspec'
require_relative '../model/stone'
require_relative '../model/paper'
require_relative '../model/scissor'
describe 'Behaviour of the elements' do
let (:paper){Paper.new}
let (:stone){Stone.new}
let (:scissor) {Scissor.new}
it 'the paper wins the stone' do
(paper.doesWin?(stone)).should be_tr... | true |
4e72dca09663d7ded12bfb6d13fe587d93e16e03 | Ruby | yiyi1026/projecteuler_ruby | /leetcode/92.reverse_linked_list.rb | UTF-8 | 984 | 4.375 | 4 | [] | no_license | '''
Reverse a linked list from position m to n. Do it in-place and in one-pass.
For example:
Given 1->2->3->4->5->NULL, m = 2 and n = 4,
return 1->4->3->2->5->NULL.
Note:
Given m, n satisfy the following condition:
1 ≤ m ≤ n ≤ length of list.
'''
# Definition for singly-linked list.
class ListNode
attr_accessor... | true |
2a8a9b4eeb7255c9e3524f3413472f08088c1a99 | Ruby | AShedko/ruby_stuff | /lab01/frnat.rb | UTF-8 | 383 | 3.4375 | 3 | [] | no_license | # French natural numbers (including 0)
class FrNat
DEF_MAX = 20
def initialize(max = DEF_MAX)
@max = max
empty
end
def add(val)
raise 'Max value error' if val > @max
@num |= 1 << val
end
def remove(val)
@num &= ~(1 << val)
end
def find(val)
@num & (1 << val) == 1 << val
end... | true |
0babc13d945407a3a052a215a504a8b7993ea849 | Ruby | number61971/ruby_quiz | /y_combinator_2012-09-26/y_combinator_spec.rb | UTF-8 | 582 | 2.65625 | 3 | [] | no_license | require_relative './y_combinator'
include RSpec::Matchers
describe 'factorial' do
it 'should correctly calculate the factorial of positive integers' do
factorial(0).should == 1
factorial(3).should == 6
factorial(4).should == 24
factorial(5).should == 120
end
end
describe 'fibonacci' do
it 'shoul... | true |
d40e635da86648f090890add08dd5f7ce599be89 | Ruby | aquila/omf-integrates-confine | /omf-expctl/ruby/omf-expctl/node/abstractGroupNodeSet.rb | UTF-8 | 2,936 | 2.609375 | 3 | [
"MIT"
] | permissive | #
# Copyright (c) 2006-2009 National ICT Australia (NICTA), Australia
#
# Copyright (c) 2004-2009 WINLAB, Rutgers University, USA
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without res... | true |
0b29a3e1f446574235735af981b20e450586bcd9 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/house/5440b8820a1b4c4b9c1cb8d9c6f94bc9.rb | UTF-8 | 950 | 3.578125 | 4 | [] | no_license | class House
def verse number
embed = number.downto(1).map do |clause_no|
clauses[clause_no]
end.join(' ')
phrase % embed
end
def verses from, to
(from..to).map do |no|
verse(no) + "\n"
end.join('')
end
private
def phrase
"This is %s.\n"
end
def clauses... | true |
9217c0397e2769ac899b5d650893447a6fc10734 | Ruby | paulccarey/kata | /spec/line_item_spec.rb | UTF-8 | 407 | 2.546875 | 3 | [] | no_license | require 'spec_helper'
describe LineItem do
describe '.new' do
it 'assigns values based during initialize/setup' do
item = LineItem.new('A', 10, 3)
expect(item.name).to eq('A')
expect(item.unit_price).to eq(10)
expect(item.quantity).to eq(3)
end
it 'default quantity to 1' do
... | true |
c382cbd41119e0550dc7950728df6ce27ed85ce1 | Ruby | syakimov/ruby | /challenges/ordinal_number_convertor.rb | UTF-8 | 237 | 3.21875 | 3 | [] | no_license | # frozen_string_literal: true
def ordinalize(num)
if !num.abs.between?(1, 3)
num.to_s + 'th'
else
case num.abs
when 1 then num.to_s + 'st'
when 2 then num.to_s + 'nd'
when 3 then num.to_s + 'rd'
end
end
end
| true |
f0805227e964df5d50c645cc83fea32518d465e9 | Ruby | padrino/padrino-framework | /padrino-core/test/fixtures/apps/stealthy/helpers/stealthy_class_helpers.rb | UTF-8 | 117 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Boo
def self.class_method
"BooClass"
end
end
class Woo < Boo
def poo
end
end
class Soo < Boo
end
| true |
32e4646b79617f7a9cef958687aefecc15668ed1 | Ruby | hwangjf/pokemon-scraper-nyc-web-042318 | /lib/pokemon.rb | UTF-8 | 776 | 3.390625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Pokemon
attr_accessor :name, :type, :db, :id, :hp
@@all = []
def initialize(name)
@name = name
# @type = type
# @db = db
end
def alter_hp(hp, db)
db.execute("UPDATE pokemon SET hp = ? WHERE id = ?", hp, self.id)
end
def self.save(name, type, db)
a = db.execute("INSERT INTO po... | true |
aadcdaf12a20fed884e23fbdedc57876875d2bac | Ruby | peterayeniofficial/OO-FlatironMifflin-london-web-100719 | /run.rb | UTF-8 | 556 | 3.046875 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'lib/Manager'
require_relative 'lib/Employee'
require 'pry'
# Test your code here
manager1 = Manager.new("Peter", "IT", 25)
manager3 = Manager.new("Akim", "IT TEC", 20)
manager4 = Manager.new("Kamel", "DOS", 33)
manager5 = Manager.new("Hakil", "POS", 45)
emp1 = Employee... | true |
0a8ca5e1c507df68060a132121dc03a93e7a2369 | Ruby | dmbf29/flow-condition-595 | /method.rb | UTF-8 | 155 | 2.96875 | 3 | [] | no_license | def hello
'test sting'
return 'test sting2' # stop the method
puts 'hello' # show 'hello' in Terminal and return nil
end
# why is this nil?
p hello
| true |
b1533662d1ceeecf5cfa21306ebc48e6d0ad1307 | Ruby | thisdotrob/boris-bikes | /spec/feature_spec.rb | UTF-8 | 611 | 2.609375 | 3 | [] | no_license | require 'docking_station'
require 'garage'
require 'van'
require 'bike'
describe 'Feature' do
it 'feature test' do
station1 = DockingStation.new
station2 = DockingStation.new(capacity: 5)
van = Van.new
garage = Garage.new
19.times { station1.dock_bike(Bike.new) }
2.times { station2.dock_bike(... | true |
e0df7680f574698e92a7b633d6a83492a5ef12c7 | Ruby | phillbaker/rubystats | /test/tc_gamma.rb | UTF-8 | 1,239 | 2.875 | 3 | [
"MIT"
] | permissive | $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
require 'minitest/autorun'
require 'rubystats/gamma_distribution'
class TestGamma < MiniTest::Unit::TestCase
def test_simple
shape = 3.0
scale = 2.0
gamma = Rubystats::GammaDistribution.new(shape,scale)
#check properties
assert_in_delt... | true |
1d47ccbba1a086471f3c02c91a113cfcc24d209a | Ruby | shuma/Web-Scraping | /all-uni-swe/all_uni_swe.rb | UTF-8 | 2,212 | 2.9375 | 3 | [] | no_license | require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'csv'
#Hämtar alla länkar till uni/hog
doc = Nokogiri::HTML(open('http://testnavet.skolverket.se/SusaNavExport/EmilExporter?GetEvent&EMILVersion=1.1&NotExpired&EIAcademicType=UoH&SelectEP'))
# URLS - array för att lagrar alla länkar
@urls = Array.new
# ... | true |
d777b7c5f3bf6989dccae8ecf8b38dd9167ea521 | Ruby | hlandgar/tradedb | /app/helpers/application_helper.rb | UTF-8 | 3,984 | 2.625 | 3 | [] | no_license | module ApplicationHelper
# Returns the full title on a per-page basis
def full_title(page_title)
base_title = "TradeanEdge.com"
if page_title.empty?
base_title
else
"#{base_title} | #{page_title}"
end
end
def setup_entry(trade)
trade.entries.build if trade.entries.empty?
return trade
end
d... | true |
8b8853b6f8b2898eb1ea268568a79900a314e27f | Ruby | siakaramalegos/learn_ruby | /09_timer/timer.rb | UTF-8 | 275 | 3.265625 | 3 | [] | no_license | class Timer
attr_accessor :seconds
def initialize
@seconds = 0
end
def time_string
time = [@seconds / 3600, @seconds / 60 % 60, @seconds % 60]
puts time.to_s
time.collect! { |term| term > 9 ? term.to_s : '0' + term.to_s}
time.join(':')
end
end | true |
49afebe72db838dfc8049a3e28aa5cecca7876b6 | Ruby | troygnichols/car_wash | /test/models/car_test.rb | UTF-8 | 617 | 2.515625 | 3 | [] | no_license | require 'test_helper'
class CarTest < ActiveSupport::TestCase
test 'create valid car' do
car = Car.new(license_plate: '12345')
assert car.valid?
assert_difference 'Car.count', +1 do
car.save!
end
end
test 'car is a type of vehicle' do
cars(:one).is_a?(Vehicle)
end
test 'require li... | true |
9c601ecc7b07e492e950d5fe79bd1b1e28346359 | Ruby | mmmmmrob/commendo | /test/tests_for_tag_sets.rb | UTF-8 | 3,804 | 2.796875 | 3 | [
"MIT"
] | permissive | module TestsForTagSets
def test_adds_tags_for_resource
assert_equal [], @ts.get(1)
@ts.add(1, 'foo', 'bar', 'baz')
expected = @ts.get(1)
assert_equal %w(bar baz foo).sort, expected.sort
@ts.add(1, 'qux', 'qip')
expected = @ts.get(1)
assert_equal %w(bar baz foo qip qux).sort, expected.sort... | true |
6049d8eb66aaee60ab2a92ee5818e500f42b81ec | Ruby | User4574/Advent-of-Code-2020 | /day05/part1.rb | UTF-8 | 86 | 2.90625 | 3 | [
"BSD-2-Clause"
] | permissive | puts $stdin.readlines.map { |seat| seat.strip.upcase.tr("FBLR", "0101").to_i(2) }.max
| true |
79b817e60093fdbc09d9a7e6d7470f7132718f00 | Ruby | reedns/data-structures | /lib/radix_sort.rb | UTF-8 | 397 | 3.375 | 3 | [] | no_license | class RadixSort
def sort(arr)
rounds = arr.max.to_s.length
rounds.times do |round|
create_buckets_arr
arr.each do |ele|
bucket_number = (ele / 10**round) % 10
@buckets[bucket_number] << ele
arr = @buckets.flatten
end
end
arr.flatten
end
private
def cr... | true |
12b1b3a08307a92269530e44c96842b00778f126 | Ruby | hey927/Ruby | /sorting.rb | UTF-8 | 380 | 3.6875 | 4 | [] | no_license | def alphabetize(arr, rev=false)
if rev
arr.sort { |item1, item2| item2 <=> item1 }
else
arr.sort { |item1, item2| item1 <=> item2 }
end
end
books = ["Believe in the God who believes in you", "The Wolf of Wall Street", "Lean In", "Lila", "Not that kind of Girl", "The Immortals of Meluha"]
puts "A-Z: #{al... | true |
41af89ebbc446c47fc490ad0aa49a7de4d6b6020 | Ruby | wtfspm/advent_of_code | /2020/15/recitation.rb | UTF-8 | 862 | 3.40625 | 3 | [] | no_license | #!/usr/bin/env ruby
def way_the_first(numbers, times)
nums = numbers.dup
(times - nums.size).times do
last = nums[0..-2].rindex(nums.last) || (nums.size - 1)
nums.push(nums.size - last - 1)
end
nums.last
end
def way_the_second(numbers, times)
h = numbers.map.with_index.to_h
next_number = 0 # a... | true |
dd0716c1df879b51d47d74dc6c6e9d00195cf605 | Ruby | sommelyay/main-site | /snooth-testing/lib/wine.rb | UTF-8 | 873 | 3.109375 | 3 | [] | no_license | # define class Wine
class Wine
def initialize(name, code, region, winery, winery_id, varietal, price, vintage, type, link, tags, image, snoothrank, available, num_merchants, num_reviews)
# Instance variables
@name= name
@code= code
@region= region
@winery= winery
@winery_id= winery_id
@varietal= ... | true |
5f6dd58e711c58c854199af0c7b4c97c845f0ca1 | Ruby | yskuniv/raccor | /lib/raccor/proc_code_extractor.rb | UTF-8 | 8,844 | 2.9375 | 3 | [] | no_license | module ProcCodeExtractor
require 'ripper'
class ParseHelper
module Enumerable
class EnumerableBuffer
def initialize(enum)
@enum_wrapper = Enumerator.new { |y|
enum.each do |item| y << item; end
}
@buffer = []
end
def fetch(nth)
... | true |
cd8f2dc4430a774e905bef138b4fd8eb3ac687f5 | Ruby | soph-g/testing_classes_in_isolation_examples | /spec/exercise_2_spec.rb | UTF-8 | 695 | 3.078125 | 3 | [] | no_license | require 'exercise_2'
describe Greeter do
subject(:greeter) { described_class.new(kernel_double) }
let(:kernel_double) { double(:kernel) }
describe "#greet" do
it "asks for the users name" do
expect(kernel_double).to receive(:puts).with("What is your name?")
expect(kernel_double).to receive(:get... | true |
75db3276e80cd8f02fd0c72b2a0bafc94e5ceb00 | Ruby | AndrewBelt/pandemic | /lib/field.rb | UTF-8 | 1,321 | 3.46875 | 3 | [] | no_license |
class Field
attr_reader :width
attr_reader :height
attr_accessor :values
def initialize(width, height)
@width = width
@height = height
@values = Array.new(@width * @height, 0.0)
end
def map
other = Field.new(@width, @height)
@height.times do |y|
@width.times do |x|
other[x, y] = yield(x, ... | true |
1382446868c54ef14d8753149176f51dcc3b0e94 | Ruby | jhubbardsf/checkout-scanner | /models/checkout.rb | UTF-8 | 658 | 3.03125 | 3 | [] | no_license | class Checkout
def initialize(pricing_rules)
@pricing_rules = pricing_rules
@items = []
end
def scan(item)
product = @pricing_rules.find_product(item)
@items << product
end
def total
cost = 0
@items_duplicate = @items.dup
@items.each do |item|
amount = @items_duplicate.count(item)
if item.di... | true |
cd202e041011dd7b1d42d601c7771a80d8541df4 | Ruby | bookmate/axlsx | /lib/axlsx/workbook/worksheet/worksheet.rb | UTF-8 | 17,272 | 3.0625 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
module Axlsx
# The Worksheet class represents a worksheet in the workbook.
class Worksheet
# The name of the worksheet
# @return [String]
attr_reader :name
# The workbook that owns this worksheet
# @return [Workbook]
attr_reader :workbook
# The rows in this workshe... | true |
586f235ae0fcb6d2a417e82089a64658fb93bb00 | Ruby | kaitai-io/formats-kaitai-io.github.io | /vlq_base128_be/src/ruby/vlq_base128_be.rb | UTF-8 | 2,500 | 2.890625 | 3 | [
"ISC"
] | permissive | # This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
require 'kaitai/struct/struct'
unless Gem::Version.new(Kaitai::Struct::VERSION) >= Gem::Version.new('0.9')
raise "Incompatible Kaitai Struct Ruby API: 0.9 or later is required, but you have #{Kaitai::Struct::VERSION}"... | true |
98a710f12a2a44fb072353cca6b1da796f807685 | Ruby | arielleramirez/OO-Get-Swole-nyc-web-080618 | /app/models/gym.rb | UTF-8 | 1,175 | 3.703125 | 4 | [] | no_license | require 'pry'
class Gym
#returns an array of all gyms
@@all = []
#initalizes with a name
attr_accessor :name
#initalizes with a name
def initialize(name)
@name = name
#returns an array of all gyms
@@all << self
end
#all returns an array of all gyms
def self.all
@@all
end
#memberships return... | true |
0a84f72254bd83b9565d41d3cb8f05a730527cd2 | Ruby | katpadi/cc | /lib/cc/parser.rb | UTF-8 | 3,880 | 2.765625 | 3 | [
"MIT"
] | permissive | module Cc
class Parser
PATTERN = /\d{6}-\d-\d{2}-\d{7}\s+-/
PATTERN2 = 'Installment Amortization:'.freeze
FIRST_PAGE_PATTERN = 'S T A T E M E N T D A T E'.freeze
START_PAGE = 3
attr_reader :statements, :output_file
def initialize(input_path, output_dir: nil)
@statements = Dir["#{input_... | true |
2cc47e79d38f282115ca668eeac8bfab14d5217d | Ruby | nahi/pkcs12 | /lib/pkcs12/asn1/taginfo.rb | UTF-8 | 2,813 | 2.71875 | 3 | [
"Ruby"
] | permissive | require 'pkcs12/asn1/object'
require 'pkcs12/asn1/boolean'
require 'pkcs12/asn1/integer'
require 'pkcs12/asn1/objectIdentifier'
require 'pkcs12/asn1/bitString'
module PKCS12
module ASN1
TAGS = {
:UNKNOWN => [0x00, PKCS12::ASN1::Object],
:BOOLEAN => [0x01, PKCS12::ASN1::Boolean],
... | true |
c626d79673e728400e7d02494c4ac2a3919fd536 | Ruby | tomoyukikubota/stdin_sample | /Paiza/189~180/paiza7.rb | UTF-8 | 129 | 2.703125 | 3 | [] | no_license | # 問題D184: 縦に表示
# 入力例: 5 ↓ Paiza = 出力例: P ↓ A ↓ I ↓ Z ↓ A
n = gets.to_i
s = gets.chars
puts s
| true |
503c66f266519a59449f29650d4fb84907c5c06f | Ruby | thomd/rails-templates | /things.template.rb | UTF-8 | 4,648 | 2.5625 | 3 | [] | no_license | #
# rails template for things application
#
# usage:
# rails things -m "things.template.rm"
#
run "rm public/index.html"
# create things controller
file "app/controllers/things_controller.rb", <<-HTML
class ThingsController < ApplicationController
# call-seq:
# GET http://domain.tld/things
#
def index
... | true |
c61483da7aaadea29a58c5dcb7ad9e74422a429a | Ruby | ga-wolf/WDI10-Homework | /vaibhav-namburi/week_04/2/exercise1/hashExercise.rb | UTF-8 | 691 | 3.171875 | 3 | [] | no_license | a = ["Anil", "Erik", "Jonathan"]
puts a[1]
a<<"Vaibhav"
puts a
###########
puts "!"*30
h = {0 => "Zero", 1 => "One", :two => "Two", "two" => 2}
puts h[1]
puts h[:two]
is = {true => "It's true!", false => "It's false"}
users = {
"Jonathan" => {
:twitter => "tronathan",
:favorite_numbers => [12, 42, 75],... | true |
28414f7f36ef8b84c7984787f935e4a3b8217133 | Ruby | killy971/project-euler | /ruby/097.rb | UTF-8 | 189 | 3 | 3 | [] | no_license | #!/usr/bin/ruby
# vim:set ts=2 sw=2:
prime = 28433
7830457.times do |i|
prime *= 2
prime %= 10_000_000_000 if prime > 1_000_000_000_000_000
end
prime += 1
puts prime % 10_000_000_000
| true |
445e1fa330d93cb10055c1963561d5572b8a40a0 | Ruby | samholst/Exercises | /august_2017/cloned_cycle.rb | UTF-8 | 471 | 3.546875 | 4 | [] | no_license | require 'rspec'
def cloned_cycle collection, num
# Array.new(num, collection).flatten
final_items = []
num.times do
collection.each do |x|
final_items << x
end
end
final_items
end
arr = [1..3]
p cloned_cycle(arr, 3)
describe 'Cloned cycle' do
it 'Iterates through an array a variable numb... | true |
a190c76220d26e591fd827896f2de30de95d030a | Ruby | AaronLasseigne/active_interaction | /lib/active_interaction/filters/time_filter.rb | UTF-8 | 1,744 | 2.984375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module ActiveInteraction
class Base # rubocop:disable Lint/EmptyClass
# @!method self.time(*attributes, options = {})
# Creates accessors for the attributes and ensures that values passed to
# the attributes are Times. Numeric values are processed using `at`.
# ... | true |
7c12b3e3e6abaad3299f2f994149b66afaab24bb | Ruby | cabb/worklog | /lib/worklog/entity/day.rb | UTF-8 | 3,283 | 3.140625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Worklog
# a day can contain multiple activities
class Day
include Comparable
def initialize(start: Time.now)
@start = start
@activities = []
@work_time = Duration.new
@pause_time = Duration.new
end
def <=>(other)
@start <=> other... | true |
8ff33bdc3ee497d1c2aa0d0f5c3a0f2974a344f5 | Ruby | mneumann/extract-imprint-contacts | /extract.rb | UTF-8 | 9,991 | 2.859375 | 3 | [
"Unlicense"
] | permissive | #
# Howto decrypt "pseudo-encrypted" mailto: links taken from [1] and [2].
#
# [1]: http://www.communitygrove.com/guides/avoiding-obfuscated-email-addresses
# [2]: https://stackoverflow.com/questions/65725064/typo3-encrypted-mailto-link-javascriptlinkto-uncryptmailto-not-working-with-s
#
require 'cgi'
require 'seleniu... | true |
1351a2fe8b60560de5b4e2b9ec0e972b7c71cda3 | Ruby | gichuru/gigs | /app/models/gig.rb | UTF-8 | 566 | 2.640625 | 3 | [] | no_license | class Gig < ActiveRecord::Base
belongs_to :company
has_many :proposals
belongs_to :category
has_many :abilities
has_many :skills, through: :abilities
validates :name, :description, :budget, :startdate, :duration, presence: true
def skill_list=(skills_string)
skill_names = skills_string.split(",").collect{ |... | true |
d064187f8090302c22cd9cc6a797766f9fed27f5 | Ruby | KSET/foto-kset-org | /app/models/application.rb | UTF-8 | 1,042 | 2.59375 | 3 | [] | no_license | # == Schema Information
#
# Table name: applications
#
# id :integer not null, primary key
# first_name :string default(""), not null
# last_name :string default(""), not null
# email :string default(""), not null
# mobile_phone :string default... | true |
acd560c32ff99ba9d1cf0debacb9b18372364a69 | Ruby | Schr0dinger1/codingclass-1 | /ruby/lessons/10-Classes/3-building_a_class.rb | UTF-8 | 187 | 2.578125 | 3 | [] | no_license | # =========================
# Building a Class
# =========================
# Build a class called Name that gives
# the first name, middle name, last name, and title
# of the person.
| true |
805e920cbfb7359c4abab4dad3d2ebd881a9a52f | Ruby | aha-app/aha-services | /lib/services/github/github_resource.rb | UTF-8 | 1,146 | 2.578125 | 3 | [
"MIT"
] | permissive | class GithubResource < GenericResource
API_URL = "https://api.github.com"
def faraday_builder(builder)
builder.request(:authorization, :basic, @service.data.username, @service.data.password)
end
def github_http_get_paginated(url, page = 1, previous_response = [], &block)
response = http_get("#{url}?pe... | true |
1ca98bb75929efc7181f88534b7739a7fec8168b | Ruby | unalterable/learn_to_program | /ch10-nothing-new/ninety_nine_bottles_of_beer.rb | UTF-8 | 313 | 3.84375 | 4 | [] | no_license | require './english_number.rb'
def word n
word = english_number(n).capitalize
word = "No more" if word == "Zero"
word + " bottle" + (n==1 ? "" : "s") + " of beer"
end
while n > 0
puts word(n) +" on the wall"
puts word(n)
puts "Take one down and pass it around"
puts word(n-=1) +" on the wall"
puts
end
| true |
a07ef3ead002f14025e0e5e4ed28291389a07b15 | Ruby | karn09/test-first-ruby | /lib/05_silly_blocks.rb | UTF-8 | 220 | 2.71875 | 3 | [] | no_license | def reverser
# left = 0
# right = yield.length
# while left < right
# temp = yield[left]
# yield[left] = yield[right]
# yield[right] = temp
# right -= 1
# left += 1
# end
yield.reverse
end
| true |
8e310ed1b74b2ce5df9745e91a25aea693b7b594 | Ruby | andresideus/shinpan | /shinpan.rb | UTF-8 | 2,342 | 3.78125 | 4 | [] | no_license | #!/usr/bin/ruby
require 'pp'
# have a scoreboard data structure
scoreboard = {
"red" => {
"men" => 0,
"kote" => 0,
"do" => 0,
"tsuki" => 0,
"hansoku" => {
"current" => 0,
"total" => 0
},
"points" => 0
},
"white" => {
"men" => 0,
"kote" => 0,
"do" => 0,
"ts... | true |
14ca384394fbf8f7a16afc5eda51b1c20fe6bbf1 | Ruby | dixiqi/Ruby | /05/modleY.rb | UTF-8 | 274 | 2.640625 | 3 | [] | no_license | =begin
#load方法应用
module ModuleName
def go
puts "汽车正在公路上行驶"
end
def self.show
puts "我是rubyspace文件下的05文件中的moduleY.rb文件中的内容"
end
end
ModuleName.show
=end
#require方法应用
def modulea
puts "hello world!"
end
| true |
96bf259ea630304763a21470bcf55184d7ef3b66 | Ruby | DavidBarriga-Gomez/library_1908 | /lib/author.rb | UTF-8 | 394 | 3.171875 | 3 | [] | no_license | class Author
attr_reader :name, :books
def initialize(author_info)
@name = author_info[:first_name] + " " + author_info[:last_name]
@books = []
end
def write(title, publication_year)
new_book = Book.new({author_first_name: @name.split[0], author_last_name: @name.split[-1], title: title, publication... | true |
af772f739ff143d0366cfd3e24535975875d129a | Ruby | mygittyhubby/TO-Chinese-School | /chineseschool/app/models/family.rb | UTF-8 | 860 | 2.6875 | 3 | [] | no_license | class Family < ActiveRecord::Base
belongs_to :address
belongs_to :parent_one, class_name: 'Person', foreign_key: 'parent_one_id'
belongs_to :parent_two, class_name: 'Person', foreign_key: 'parent_two_id'
has_and_belongs_to_many :children, class_name: 'Person',
foreign_key: 'family_id', association_forei... | true |
3378e884213c7782f533bf83e466cfc4c9ca5e75 | Ruby | sylviakinosian/tyrell | /src/tyrell-util.rb | UTF-8 | 714 | 2.671875 | 3 | [] | no_license | require 'fileutils'
require 'yaml'
require 'zip'
require 'open-uri'
require 'selenium-webdriver'
def stream_file(url, save_name)
download = open(url)
IO.copy_stream(download, save_name)
return save_name
end
def unzip(file)
Zip::File.open(file) do |zip_file|
zip_file.each {|x| x.extract}
end
end
def dat... | true |
cc83c28ada66fc99833f6a055b0b89dd60bac4f4 | Ruby | MarcPer/cs-algorithms | /data-structures/week6_binary_search_trees/3_is_bst_advanced/is_bst_hard_test.rb | UTF-8 | 4,081 | 2.921875 | 3 | [] | no_license | require_relative './is_bst_hard.rb'
require 'minitest/autorun'
class TestSolution < Minitest::Test
def test_solution
specs = [
{input: ["1 -1 1", "2 -1 2", "3 -1 3", "4 -1 4", "5 -1 -1"], want: true},
{input: ["4 1 2","2 3 4","6 5 6","1 -1 -1","3 -1 -1","5 -1 -1","7 -1 -1"], want: true},
{input... | true |
ca0917875a02fe08bfad547cd80612e71e7ccf56 | Ruby | AndyGuppy/CodeClan_caraoke | /song_class.rb | UTF-8 | 628 | 3.671875 | 4 | [] | no_license | class Song
#create a song class to take in 4 arguments and
#allow then to be viewed as a hash, the 4 arguments
#INPUTS
#--------
#Title: string
#Artist: string
#Year: string
#Duration: fixnum ( seconds )
#OUTPUT
#--------
#song as a hash of all inputs
#EXTRA
#--------
#Method .to_s created to be called as required
... | true |
16cf3181c1541bdf65fbb02bf84a71d62b7b725c | Ruby | Jon2041/LS-ruby-challenges | /easy_1/series.rb | UTF-8 | 254 | 3.265625 | 3 | [] | no_license | class Series
def initialize(string)
@string = string
end
def slices(size)
raise ArgumentError if size > @string.length
results = []
@string.split('').map(&:to_i).each_cons(size) { |subset| results << subset }
results
end
end
| true |
a64ddefb2eb55fc46885e7c86eecd41de58f0162 | Ruby | raymh2002/Ruby | /Code_with_Ruby/video17_variable.rb | UTF-8 | 268 | 3.390625 | 3 | [] | no_license | name = "Ray"
last_name = "Harvey"
handsome = true
age = 25 + 31
puts name
puts last_name
puts name + " " + last_name
puts handsome
puts age
puts age - 31
age = 50
puts age
favorite_number = 24
p favorite_number
favorite_number = "Twenty-Four"
p favorite_number
| true |
8897b7ac749cb03ede1cc07107461949c8dbc231 | Ruby | sureshbabuG4/coderbyte | /DashInsert.rb | UTF-8 | 343 | 3.0625 | 3 | [] | no_license | def DashInsert(str)
# code goes here
str = str.to_s.split('')
str.each_with_index{|a,i|
if(a.to_i % 2 == 1 && i != 0 && str[i - 1].to_i % 2 == 1)
str.insert(i, '-')
end
}
return str.join('')
end
# keep this function call here
# to see how to enter arguments in Ruby scroll down
DashInsert(... | true |
b878c83f764712e1664ea57c2f05ea5afe8cbb04 | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz119_sols/solutions/Ruben Medellin/to_100.rb | UTF-8 | 5,420 | 3.40625 | 3 | [
"MIT"
] | permissive | require 'optparse'
require 'mathn' #Handles integer divisions
$options = {}
begin
optparser = OptionParser.new do |opts|
opts.banner = "Usage: "
opts.on("--d [DIGITS]", "Single number containing possible digits") do |num|
$options[:digits] = num
end
opts.on("--t [TARGET]", "Target number") do |t|
$op... | true |
63841a62a773444efc6f896362cbc085eb5b537e | Ruby | vocentoLab/BotEslang | /lib/telegram_bot/api_response.rb | UTF-8 | 470 | 2.90625 | 3 | [
"MIT"
] | permissive | module TelegramBot
class ApiResponse
attr_reader :body, :ok, :result, :description, :error_code
def initialize(res)
@body = res.body
if res.status == 200
data = JSON.parse(body)
@ok = data["ok"]
@result = data["result"]
else
data = JSON.parse(body)
@o... | true |
e2a23f749d536e4fb64311f0f61e6a559639823e | Ruby | chugah/W4D7 | /midterm-FINAL/app/ai4r.rb | UTF-8 | 1,691 | 2.578125 | 3 | [] | no_license | require 'rubygems'
require 'ai4r'
include Ai4r::Classifiers
include Ai4r::Data
include Ai4r::Clusterers
DATA_LABELS = [ 'Coffee', 'Discount', 'Time', 'Revenue_Goes' ]
DATA_ITEMS = [
['AMERICANO', '<30', 'MORNING', 'UP'],
['CUPPACCINO', '<30', 'MORNING', 'UP'],
['CUPPACCINO', ... | true |
c9d464ee653a22afeb420460d41b09176048f463 | Ruby | Sarahabogabir1/Ironhack-Bootcamp-8-weeks | /week_2/Day_1/StringCalculator/spec/string_calculation_spec.rb | UTF-8 | 611 | 3.578125 | 4 | [] | no_license | require_relative("../lib/string_calculator.rb")
RSpec.describe "String calculation" do
it "returns 0 for empty string" do
calculator = string_calculator.new
expect (calculator.add("1,2,3,4") ).to eq(13) #puts calculator.add ("1,2,3,4") = 10
expect( calculator.add("25,25,25") ).to eq(75) #puts calculator.... | true |
5ab3e0eb37564c1739df1f8170d48fe36237ec1f | Ruby | AhmedIraqi/ttt-6-position-taken-rb-re-coded-000 | /lib/position_taken.rb | UTF-8 | 330 | 3.21875 | 3 | [] | no_license | # code your #position_taken? method here!
def position_taken? (board,index)
if ((board[index] == "X") || (board[index] == "O"))
true
elsif ((board[index] == "") || (board[index] == " "))
false
elsif ((board[index] != "") || (board[index] != " ") || (board[index] != "X") || (board[index] != "O"))
false
... | true |
b1f27661638390149083d0da4f944f28997b1ef1 | Ruby | watashi/AlgoSolution | /codeforces/ac/0/068/A.ac.rb | UTF-8 | 96 | 2.65625 | 3 | [] | no_license | p1, p2, p3, p4, a, b = gets.split.map(&:to_i)
p [*a .. b].count{|_| _ % p1 % p2 % p3 % p4 == _}
| true |
752015d9364d4fe05f558f715262a417ba3f9099 | Ruby | vsevolod/organizer24 | /config/initializers/fixnum.rb | UTF-8 | 167 | 2.75 | 3 | [] | no_license | class Integer
def to_moment
el = self
result = []
3.times do
result.unshift('%02.f' % (el % 60))
el /= 60
end
result * ':'
end
end
| true |
7f296c5ee3fbc6451384ff6c4af0552bf3889af2 | Ruby | aguestuser/drivetrain | /app/models/account.rb | UTF-8 | 887 | 2.515625 | 3 | [
"MIT"
] | permissive | # == Schema Information
#
# Table name: accounts
#
# id :integer not null, primary key
# user_id :integer
# created_at :datetime
# updated_at :datetime
# user_type :string(255)
# password_digest :string(255)
# remember_token :string(255)
#
class Account < ActiveRec... | true |
384dd3173232bc7ebd43045dd9f915f157750167 | Ruby | matthew-r-clark/launch-school-exercises | /edabit/tictactoe_check.rb | UTF-8 | 2,015 | 3.828125 | 4 | [] | no_license | # Rules
# 1) Return true if player 1 or player 2 win the game.
# 2) Return false if nobody won the game.
# 3) Return "Nobody moved" if nobody made a move.
# 4) Return "No/Incomplete game" if no value was received / all received arrays are void / type of any given value is not "array".
# 5) Return "Corrupted game" if an... | true |
1106b861f8cdcb2db3d18a0c0e9e737e28c4d090 | Ruby | chrisd1dev/my-first-repository | /TeaLeaf_Exercises/Loops_Iterators/loops_ex1.rb | UTF-8 | 77 | 3.0625 | 3 | [] | no_license | # exercise 1
x = [1,2,3,4,5]
x.each do |a|
puts a + 1
end
| true |
caf22f3ac43fc83ba8a9659490a2a185a826c57c | Ruby | deborahc/friend-split | /test/models/event_test.rb | UTF-8 | 1,255 | 2.515625 | 3 | [] | no_license | require 'test_helper'
class EventTest < ActiveSupport::TestCase
test "event closes when closed" do
event = events(:FirstEvent)
event.close_event
assert(event.closed == true, "event should be closed")
end
test "find proper user event balance" do
event = events(:FirstEvent)
userA = users(:A)
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.