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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
5846e554e649490111a8bc75421f8394d4180f5e | Ruby | kieran-lockyer/morning-challenges | /tests/23_high_scores_tests.rb | UTF-8 | 1,103 | 2.953125 | 3 | [] | no_license | require 'test/unit'
require_relative '../23_high_scores'
class CardSuitTest < Test::Unit::TestCase
# Initialize a high score table with a limit of 3 scores
@@high_scores = HighScoreTable.new(3)
def test_all
assert_equal([], @@high_scores.scores)
@@high_scores.update(10)
assert... | true |
8e5909a3ac48e1e02840e36b2b215758c3ff93d7 | Ruby | JustineGB/ttt-7-valid-move-v-000 | /lib/valid_move.rb | UTF-8 | 285 | 3.1875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def valid_move?(board, index)
if index.between?(0, 8) && !position_taken?(board, index)
valid = true
end
end
def position_taken?(board, index)
taken = nil
if (board[index] == " " || board[index] == "" || board[index] == nil)
taken = false
else
taken = true
end
end
| true |
fd56a3c4ba00ef5838662c9d9a89f3bbcabe3b27 | Ruby | dediane/RubyBasics03 | /spec/caesar_cipher_spec.rb | UTF-8 | 1,419 | 3.4375 | 3 | [] | no_license | require_relative '../lib/caesar_cipher.rb'
describe "isalpha? method" do
it "should return TRUE if a char is an alpha caractere" do
expect(isalpha?('a')).to eq(true)
expect(isalpha?('3')).to eq(false)
expect(isalpha?('&')).to eq(false)
end
end
describe "isupper? method" do
it "shoudl return TRUE if ... | true |
ab204638d9f16291408cb2dcca7d59281324c5af | Ruby | LobeliaUshtar/Tealeaf-IRWD-Precourse | /Basics/exercise1.rb | UTF-8 | 52 | 2.640625 | 3 | [] | no_license | # first + last name combining
puts "Joe" + " Schmo" | true |
8280ae9c06fb6740f746eab7483a64a6f12d2603 | Ruby | codeforamerica/balance | /spec/lib/balance_log_analyzer_spec.rb | UTF-8 | 1,709 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require File.expand_path('../../../lib/balance_log_analyzer', __FILE__)
describe BalanceLogAnalyzer::MessageAnalyzer do
describe '#contains_balance_response?' do
it 'returns true for valid English balance responses' do
helper = BalanceLogAnalyzer::MessageAnalyzer.new
ex1 = "Hi!... | true |
3e764de022675bdc67cb9a5e32754e64ca69ad0d | Ruby | onyxrev/library_of_congress_classification_outline_json | /parse.rb | UTF-8 | 2,228 | 3.25 | 3 | [] | no_license | require 'pry'
require 'json'
class LocParser
def initialize(loc_file_location)
@loc_file_location = loc_file_location
@current_class = nil
@current_subclass = nil
@current_level = nil
@last_node = nil
@current_depth = 1
@last_nodes_at_depth = {}
end
def to_nodes
@file = File.ope... | true |
8d785acdc88f416224967d651bc0c7437e44443e | Ruby | copelandbrandon/Jungle-rails | /spec/models/user_spec.rb | UTF-8 | 3,140 | 2.828125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
describe 'Validations' do
before(:each) do
@user_params = { first_name:"Shmee", last_name:"Jibbly", email:"Sjibbly@gmail.com", password:"daChosenMum", password_confirmation:"daChosenMum" }
@user = User.new(@user_params)
end
it 'sho... | true |
da6dd380bb7fbe1da6ce7afba946adae728f4fbc | Ruby | hdanziger/school-domain-v-000 | /lib/school.rb | UTF-8 | 373 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # code here!
class School
attr_accessor :name, :roster
def initialize(name)
@name = name
@roster = {}
end
def add_student (name, grade)
roster[grade] ||= []
roster[grade] << name
end
def grade (grade)
roster[grade]
end
def sort
list = {}
roster.each do |grade, name|
... | true |
671aafd43f64b662a3b11a0313f391865582facb | Ruby | xtina-starr/congo | /spec/models/category_model_spec.rb | UTF-8 | 664 | 2.578125 | 3 | [] | no_license | require 'spec_helper'
describe Category do
describe "validations" do
# Basic Attribute Validations
it "must have a name" do
expect(Category.new(:name => nil)).to be_invalid
end
# Tests uniqueness of name, but doesn't dynamically come up with testing name
it "has a unique name" do
... | true |
07596d4e024fc887ea707e06c927cc94904d7ed3 | Ruby | BottosWorld/flatironCLI | /lib/recipeCLI/cli.rb | UTF-8 | 1,469 | 3.65625 | 4 | [
"MIT"
] | permissive | class RecipeCLI::CLI
def start
puts "Hello there!"
puts "Please enter what kind of recipe you're looking for:"
input = gets.strip.downcase
if (input != "quit")
@data = RecipeCLI::API.get_recipes(input)
@objects = RecipeCLI::Recipes.all
display
else
quit
end
end
... | true |
318e81411b13636a006abcb8ea555681747e05b7 | Ruby | moskyt/imf | /2014_2015/03/ruby/search.rb | UTF-8 | 1,123 | 2.921875 | 3 | [] | no_license | X = 0.4
Dir["../package/search/*.csv"].each do |fn|
x, y = [], []
IO.foreach(fn) do |line|
x << line.strip.split[ 0].to_f
y << line.strip.split[-1].to_f
end
dy = (1...y.size).map{|i| (y[i]-y[i-1]) / (x[i]-x[i-1])}
delta1 = (dy.max-dy.min) / dy.min
delta2 = (dy[-1]-dy[0]) / dy[0]
if delta1.a... | true |
766fde9051e040e1e913051854796634f700f721 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/robot-name/6017badd5e784d47a87efcbef88f10cf.rb | UTF-8 | 347 | 3.375 | 3 | [] | no_license | class Robot
attr_reader :name
@@taken_names = []
def initialize
rand_letters = (1..2).map { ('A'..'Z').to_a[rand(26)] }.join
rand_numbers = (1..3).map { rand(0..9) }.join
@name = rand_letters + rand_numbers
initialize if @@taken_names.include?(@name)
@@taken_names << @name
end
def rese... | true |
670dbb2b83c3c10f4aa1c5a5fee0661f1efdb713 | Ruby | scottzero/enigma- | /lib/offset.rb | UTF-8 | 520 | 3.25 | 3 | [] | no_license | class Offset
attr_reader :date
def initialize(date = nil)
@date = date
end
def current_date
Date.today.strftime('%d%m%y')
end
def square_numeric_date
(@date.to_i ** 2).to_s # ** exponent^...it WORKS! Big NUMBER, reminder ask meg or ian about doubles or longs :)
end
def offset_a
squar... | true |
5c64becdaba94ac11e4c10a31287370e17a5ed95 | Ruby | PhilippePerret/Proximites | /lib/Extensions/ask.rb | UTF-8 | 2,610 | 3.21875 | 3 | [] | no_license | # encoding: utf-8
#
# ask
# v. 1.2
#
# Voir aussi le module ask_for_test.rb qui fonctionne en parallèle de celui-ci
#
def getc message
print "#{message} : "
begin
system('stty raw -echo')
str = STDIN.getc
ensure
system('stty -raw echo')
end
return str
end
# Pose la +question+ est retourne TRUE s... | true |
329bd23c53bf3875511c615bbbc69207ee671919 | Ruby | nashby/ms-capi | /hmac/hmac.rb | UTF-8 | 1,720 | 2.90625 | 3 | [] | no_license | require 'java'
require_relative '../JCAPI.jar'
module Java
import 'java.security'
import 'java.security.MessageDigest'
import 'com.pheox.jcapi'
Security.add_provider JCAPIProvider.new
class HMAC
BLOCK_SIZE = 64
def initialize(message, password, hmac_file)
@message = message
@password... | true |
59573570520910e8c184f6c0dc3f37b09f985af1 | Ruby | BenNoonan1991/lrthw | /ex30/ex30.rb | UTF-8 | 934 | 4.5625 | 5 | [] | no_license | # Assigns values to the variables.
people = 30
cars = 40
trucks = 15
# The block tell Ruby what to evalvuate, and then
# to run the code if they evalvuate to true.
if cars > people
puts "We should take the cars."
elsif cars < people
"We should not take the cars"
else
puts "We can't decide"
end
# The block tell ... | true |
a35c2019d6651703c2bedfec7f6d15ca6fed9ebb | Ruby | babun52/Week2-Ruby-Independent-Project | /lib/definition.rb | UTF-8 | 715 | 2.75 | 3 | [
"MIT"
] | permissive | class Definition
attr_reader(:description)
@@definitions = []
define_method(:initialize) do |attributes|
@description = attributes.fetch(:description)
@id = @@definitions.length() + 1
end
define_method(:description) do
@description
end
define_singleton_method(:all) do
@@definitions
e... | true |
fb2b3a96851e563f1869bebf75b8c4fd67c54bf0 | Ruby | GetsuKami-Hao/my_ruby | /program/088_getsockopt_socket.rb | UTF-8 | 522 | 2.875 | 3 | [] | no_license | require 'socket'
socket = TCPSocket.new('www.baidu.com' , 80)
#获得一个描述套接字类型的Socket::Option 实例
opt1 = socket.getsockopt(Socket::SOL_SOCKET, Socket::SO_TYPE)
#将描述该选项的整数值同存储在Socket::SOCK_STREAM中的整数值进行比较。
p opt1.int == Socket::SOCK_STREAM # => true
p opt1.int == Socket::SOCK_DGRAM # => false
opt2 = socket.getsocko... | true |
f229f28a9d92d144b14acbc836881f801a2f89aa | Ruby | 140ch204/06-tests-ruby-JB | /lib/01_temperature.rb | UTF-8 | 165 | 3.59375 | 4 | [] | no_license | def ftoc(tempF)
# Convert °F into °C
return ((tempF-32)/1.8).round(1)
end
def ctof(tempC)
# Convert °C into °F
return (tempC*1.8+32)
end | true |
c796fa7c8e92d85d37c61e09d21023bad93bdf78 | Ruby | mwharvey/ls-programming-foundations | /lesson_4/selection.rb | UTF-8 | 1,503 | 4.0625 | 4 | [] | no_license | # select_fruit method
produce = {
'apple' => 'Fruit',
'carrot' => 'Vegetable',
'pear' => 'Fruit',
'broccoli' => 'Vegetable'
}
def select_fruit(hash)
hash_key = hash.keys
counter = 0
selected_fruits = {}
loop do
current_key = hash_key[counter]
current_value = hash[current_key]
if current_... | true |
485fa7f7eb211eb933ae6a281e76b3925e447a20 | Ruby | acastemoreno/c2-module2 | /week-2/day-2/fix-map.rb | UTF-8 | 453 | 4.0625 | 4 | [] | no_license | def map(array)
if block_given?
resp = []
for n in array
resp << yield(n)
end
resp
else
array
end
end
arr = [1, 2, 3]
p map(arr) { |el| el * 2 } # Returns [2, 4, 6]
# With no block
p new_arr = map(arr) # Returns [1, 2, 3]
p arr.equal?(new_arr) # Returns false, new_arr is a copy of arr. ... | true |
1a96a2bbbba057650643ddccce675d6d69295522 | Ruby | Adrian1707/jellyfish_challenge | /reporter.rb | UTF-8 | 1,498 | 3.484375 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative "lib/tank"
require_relative "lib/jellyfish"
require_relative "lib/jellyfish_mover"
require_relative "lib/jellyfish_reporter"
require_relative "lib/tank_remote"
def set_up
read_file_and_set_data_to_array
@num_of_fish = @input_arr.count/2
@tank = Tank.new(@input_arr[0][1].to_i,... | true |
89b813925344c86ee7b4a8c87ac35af6360973d3 | Ruby | alirezarahmani/board-game | /spec/rooms_spec.rb | UTF-8 | 3,024 | 2.921875 | 3 | [] | no_license | require_relative 'Base'
player = Base.new.reset_player
describe EmptyRoom do
describe 'player reactions' do
context 'send wrong reaction' do
it 'throws Exception' do
expect { EmptyRoom.new.player_reaction('no where', player) }.to raise_error(InvalidDirectionError)
end
end
context 'mov... | true |
167809c6d8f3a0b64a03942fe415f47291cebd90 | Ruby | ScottKolo/suitesparse-matrix-collection-website | /db/collection_data/groups/JGD_Trefethen.rb | UTF-8 | 644 | 2.59375 | 3 | [
"BSD-3-Clause",
"MIT",
"CC-BY-4.0"
] | permissive | {
name: 'JGD_Trefethen',
num_matrices: '11',
notes: 'Diagonal matrices with primes, Nick Trefethen, Oxford Univ.
From Jean-Guillaume Dumas\' Sparse Integer Matrix Collection,
http://ljk.imag.fr/membres/Jean-Guillaume.Dumas/simc.html
Problem 7 of the Hundred-dollar, Hundred-digit Challenge Problems,
SIAM Ne... | true |
a2d06979b63bcb02adb2ea86391ef492e3494ede | Ruby | ehernandez/kata-contacorrente | /ruby/conta.rb | UTF-8 | 781 | 3.125 | 3 | [] | no_license | # frozen_string_literal: true
class Conta
class SaldoInsuficienteError < StandardError; end
attr_reader :saldo, :limite, :operacoes
def initialize(saldo: 0, limite: 0)
@saldo = saldo
@limite = limite
@operacoes = []
end
def depositar(valor)
@saldo += valor
@operacoes << format('Valor d... | true |
f8a167d8877562fd8a57c4bb62101915af88cf35 | Ruby | MBennettLowe/RoR-Prepwork | /exercises_ex4.rb | UTF-8 | 149 | 4.21875 | 4 | [] | no_license | # Append "11" to the end of the original array. Prepend "0" to the beginning.
arr = [1,2,3,4,5,6,7,8,9,10]
arr.push(11)
arr.insert(0, 0)
puts arr | true |
ce0cefe7ebbf6e3e211df7ab346d2b33b2132159 | Ruby | mac718/Launch_School | /small_problems/easy_4/short_long_short.rb | UTF-8 | 279 | 3.625 | 4 | [] | no_license | def short_long_short(str1, str2)
comparison = str1.length <=> str2.length
if comparison == 1
puts str1 + str2
else
puts str2 + str1
end
end
# or
def short_long_short(str1, str2)
str1.length > str2.length ?
str2 + str1 + str2 : str1 + str2 + str1
end
| true |
92b162ccdbf376f9b20e285aa77b9cc09adad3c6 | Ruby | tsmith1024/exercism | /ruby/word-count/word_count.rb | UTF-8 | 480 | 3.046875 | 3 | [] | no_license | class Phrase
attr_reader :phrase
def initialize(phrase)
@phrase = phrase
end
def word_count
split
end
private
def split
list = {}
phrase.split(/[,\s]/).each do |word|
word = word.gsub(/([^A-Za-z0-9']|(^[']|['+]$))/, '').downcase
list[word] = add_word(word, list) unless word.... | true |
90c393c30ea60c0c96ff4707598b4090159568e5 | Ruby | jasemagee/FlyingSheepHunt | /menu_item.rb | UTF-8 | 673 | 3.0625 | 3 | [] | no_license | require 'gosu'
require_relative 'shared'
require_relative 'main_menu_state'
class MenuItem
attr_accessor :x, :y
def initialize(window, text, &action)
@window = window
@text = text
@action = action
self.x = self.y = 0
end
def draw(font)
font.draw(@text, self.x, self.y, 0, 1, 1, Shared::COLOR)
end
... | true |
a142a8da94606c70340dd4e84dee366d9455b207 | Ruby | ysei/befunge-ruby-1 | /spec/pointer_spec.rb | UTF-8 | 3,937 | 3.0625 | 3 | [] | no_license | require 'spec_helper'
describe Pointer do
before(:each) { @pointer = Pointer.new }
describe 'direction' do
it 'initially gets a direction of east' do
expect(@pointer.direction).to eq(:e)
end
it 'can be set post initialization' do
@pointer.direction = :s
expect(@pointer.direction).to... | true |
5fa8edeb998d7f24acdfdbb47f0b59ed9c044bc6 | Ruby | gsorokolit/how_to_test_robot | /test_robot.rb | UTF-8 | 1,915 | 3.140625 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './robot.rb'
class TestRobot < MiniTest::Test
def test_that_foreign_robot_needing_repairs_sent_to_station_1
# arrange
#is robot foreign, does it need repairs
# act
foreign_damaged = Robot.new
foreign_damaged.needs_repairs = true
f... | true |
3173e6fb0b8b73278feb27ddff240898c118b59a | Ruby | cookpad/kuroko2 | /lib/autoload/kuroko2/execution_logger/cloud_watch_logs.rb | UTF-8 | 2,920 | 2.5625 | 3 | [
"MIT"
] | permissive | module Kuroko2
class ExecutionLogger::CloudWatchLogs
MAX_RETRY_COUNT = 5
RETRY_ERRORS = [
Aws::CloudWatchLogs::Errors::InvalidSequenceTokenException,
Aws::CloudWatchLogs::Errors::ThrottlingException,
Aws::CloudWatchLogs::Errors::ResourceNotFoundException,
]
attr_reader :client
... | true |
77a39d0f721575885f53af8e81a21a1358d603ed | Ruby | bv-saurabh/training | /binary_tree.rb | UTF-8 | 2,199 | 3.734375 | 4 | [] | no_license | class BSTNode
attr_accessor :left, :right, :value
def initialize(value)
@value = value
@left = nil
@right = nil
end
end
class BST
attr_accessor :root
def initialize
@root = BSTNode.new(nil)
end
def insert(value, node = @root)
if node
if node.value
if value < node.value
if node.left
... | true |
2bfeff08ba39dcb46e31f07973984e7ad58a7127 | Ruby | rcgutierrez/ruby-exercises | /17-ruby-excercise-guessing-game.rb | UTF-8 | 690 | 4.21875 | 4 | [] | no_license | # Guessing Game
# My guess
# secret_word = "excelsior"
# guess = ""
# index = 5
#
# while guess != secret_word and index > 0
# puts "Guess the secret word, you have " + index.to_s + " guesses left: "
# guess = gets.chomp
# index -= 1
# end
#
# if guess == secret_word
# puts "You got it kid!"
# else
# puts "Y... | true |
eca6046ce4474e2c8056ffcbaa5e16451826c89e | Ruby | Oceansaway/simple-blackjack-cli-online-web-prework | /lib/blackjack.rb | UTF-8 | 948 | 3.921875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def welcome
puts "Welcome to the Blackjack Table"
end
def deal_card
rand(1..11)
end
def display_card_total(x)
puts "Your cards add up to #{x}"
end
def prompt_user
puts "Type 'h' to hit or 's' to stay"
end
def get_user_input
gets.chomp
end
def end_game(x)
puts "Sorry, you hit #{x}. Thanks for playing!"
end
def ... | true |
515b44007977114cd3100eaf8d60139748be802b | Ruby | parisestmagique/learn_ruby_rspec | /01_temperature/temperature.rb | UTF-8 | 102 | 2.84375 | 3 | [] | no_license | def ftoc(f)
d=((f - 32) / 1.8).round
return d
end
def ctof(c)
z=((c * 1.8) + 32)
return z
end
| true |
c0243cab1f4af1756f3c072e5e7ade8c6fd71f2e | Ruby | josephferrairo/number-counter | /app/app.rb | UTF-8 | 762 | 2.859375 | 3 | [] | no_license | # frozen_string_literal: true
require 'rubygems'
require 'bundler'
Bundler.require
class NumberCounter < Sinatra::Base
post '/' do
user_choice = user_choice(request)
increment = increment(user_choice)
if an_integer?(user_choice) || a_number?(user_choice)
{ user_choice => increment }.to_json
e... | true |
9c5cc5ddacc52e0b026dd5e229c0c03e0a9c4bf3 | Ruby | airled/image_optimizer_web | /helpers/helpers.rb | UTF-8 | 548 | 2.59375 | 3 | [] | no_license | require 'zip'
require 'addressable'
require 'securerandom'
require_relative './constants'
module Helpers
class Zipper
def self.zip_from(links)
zip_path = "#{Constants::KEEP_FOLDER_PATH}/#{SecureRandom.hex}.zip"
Zip::File.open(zip_path, Zip::File::CREATE) do |zipfile|
links.each do |link|
... | true |
bdcc0279f572f8bb13f380806adde0ad11e85722 | Ruby | moltentheory/DesertFalcon-P3 | /spec/lib/spec_sprite.rb | UTF-8 | 783 | 2.609375 | 3 | [] | no_license | require 'spec_helper'
require 'sprite'
RSpec.describe Sprite do
describe '#initialize' do
it 'erros de entrada' do
expect{ Sprite.new("./Assets/Images/falcon.png", 32, 22, 100) }.not_to raise_error ArgumentError
expect{ Sprite.new("", 32, 22, 100) }.to raise_error
expect{ Sprite.new(999, 32, 22, 100) }.to ... | true |
46008c10ae3771604ff61a67e3a16cd57d64b25e | Ruby | justinleveck/classes-exercises | /flight_test.rb | UTF-8 | 6,550 | 2.90625 | 3 | [] | no_license | gem 'minitest'
require 'minitest/autorun'
require 'minitest/pride'
class FlightTest < Minitest::Test
# McDonnell XP-67 "MoonBat"
#
# |
# |
# .''. .''. `._ _|_ _.' .''. .''.
# ... | true |
47feb987f41504c1d20182f37a9f8302cfa872d0 | Ruby | abrhambas01/ruby-notes | /basics/4-comments.rb | UTF-8 | 205 | 3.0625 | 3 | [] | no_license | # comments will start like this
=begin
this is a multiline comment in ruby, it starts with =begin & ends with =end
x = 3
y = 35.32
x+y
=end
# single line coment
print "Comments are explained already here" | true |
112b781fb744e5b9fd393dc4e868a8e78379f882 | Ruby | bfetler/stockton | /spec/models/stock_spec.rb | UTF-8 | 6,830 | 2.734375 | 3 | [] | no_license | require 'rails_helper'
describe Stock do
# need stock.rb model w/ validations, migration, rake db:test:prepare to pass
before(:each) do
@attr = { :companyname => "Google",
:companysymbol => "GOOG",
:value => "567.8",
:delta => "12.3"
}
end
des... | true |
01b6098ee04adf53bc0131fbc09466a7f555a80c | Ruby | MargoSolo/stared-repos-p2 | /AppAcademy/Homework/W_5D5/Data Structures Notes.rb | UTF-8 | 8,083 | 3.984375 | 4 | [] | no_license | # Data structures
# Some you know:
# [], {}, "", class
# How about an Abstract Data Type (ADT)?
# ADTs are more general than these other data types
# Consider the 'set'
# 'Set' is an ADT which is a collection of objects such that each object
# exists in the set or doesn't, and all are unique -- no duplicates
# Suppor... | true |
d81409ff8e06cdd2c32ffa3b6df7a70c031caaf1 | Ruby | ryouichi0618/Ruby_review | /practice_exercise/practice3.rb | UTF-8 | 156 | 3.125 | 3 | [] | no_license | # 最大公約数を求めるプログラム
# 再起処理で実装
def gcd(a, b)
return a.abs if b == 0
return gcd(b, a % b)
end
p gcd(1920, 1080) | true |
40d87bed2072f46e36bea78f696b99c59981aa50 | Ruby | fdm1/conway_ruby | /spec/conway_spec.rb | UTF-8 | 3,773 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Conway::Grid do
let(:sample_grid) { described_class.new(1, 1, [[1,1]]) }
let(:single_row_grid) { described_class.new(3, 3, [[1,1], [1,2], [1,3]]) }
let (:small_grid) { described_class.new(2, 2, [[0,0],[1,1],[2,2]]) }
let(:populated_grid) { described_class.new(100, 100, [[0,1], [1... | true |
09798b396a8b2903604f3f464094e4e69079a4bc | Ruby | karaken12/bbc6musicaotd | /site/_scripts/SpotifyCache.rb | UTF-8 | 893 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | class SpotifyCache
CACHE_FILE_NAME = '_data/cache/spotify.yml'
def initialize()
#config_path = File.expand_path('app_secret.yml', File.dirname(__FILE__))
#$app_config = YAML.load_file(config_path)
@cache = YAML.load_file(CACHE_FILE_NAME)
end
def is_cached?(album_id)
return @cache.has_key?(albu... | true |
6e5a6272aedd5c4251a8dc2cd69e969586a40cf0 | Ruby | jasonmwnf/programming_and_backend_development | /lesson_3/easy1/question_2.rb | UTF-8 | 742 | 3.84375 | 4 | [] | no_license | # Describe the difference between ! and ? in Ruby. And explain what would happen in the following scenarios:
#
# what is != and where should you use it?
# put ! before something, like !user_name
# put ! after something, like words.uniq!
# put ? before something
# put ? after something
# put !! before something, like !!... | true |
5a80a78b0eeb681978a634841d9cd58dd41d5bb2 | Ruby | mvassaramo/my-select-prework | /lib/my_select.rb | UTF-8 | 77 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_select(collection)
collection.select { |i| yield(i) }
end
| true |
257b8e8e55b8520103b52e8c002edbfa7dbdbc62 | Ruby | harr1193/badges-and-schedules-cb-gh-000 | /conference_badges.rb | UTF-8 | 629 | 3.84375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def badge_maker(name)
return "Hello, my name is #{name}."
end
def batch_badge_creator(name_arr)
badge_arr = []
name_arr.each do |name|
badge_arr << badge_maker(name)
end
badge_arr
end
def assign_rooms(name_arr)
room_assignments = []
name_arr.each_with_index { | name, i |
... | true |
d1a17e124a469622553f4636218bd158d271b297 | Ruby | maxsunnyday/appster | /db/seeds.rb | UTF-8 | 1,172 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain",
"MIT"
] | permissive | json_results = []
for i in 0..23
response = HTTParty.get("https://api.data.gov/ed/collegescorecard/v1/schools?2017.student.size__range=1000..&fields=2013.admissions.act_scores.midpoint.cumulative,2017.admissions.admission_rate.overall,2017.admissions.sat_scores.average.overall,school.name,id,school.city,school.sta... | true |
62e8ee0b64178cf97384870ec3580c29db656339 | Ruby | mgmilton/ruby_challenge | /lib/violation.rb | UTF-8 | 762 | 3 | 3 | [] | no_license | require 'time'
class Violation
attr_reader :violation_id,
:inspection_id,
:violation_category,
:violation_date,
:violation_date_closed,
:violation_type
def initialize(info)
@violation_id = info[:violation_id].to_i
... | true |
6b999e8fae0f7e9c87979fba3defc6e9fdba03cc | Ruby | floresfreddy/orms-pokemon-scraper-hou01-seng-ft-042020 | /lib/pokemon.rb | UTF-8 | 572 | 3.265625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Pokemon
attr_accessor :id, :name, :type, :db
def initialize(id:, name:, type:, db:)
@id = id
@name = name
@type = type
@db = db
end
def self.save(poke_name, poke_type, poke_db)
poke_db.execute("INSERT INTO pokemon (name, type) VALUES (?, ?)", poke_na... | true |
1350c0a8623ef41dcacdbe8bdbcf92b7066da65b | Ruby | BenRKarl/WDI_work | /w03/d03/Nathaniel_Tuvera/morning/kittens/models/Kitten.rb | UTF-8 | 149 | 2.703125 | 3 | [] | no_license | class Kitten
def initialize
@height
@width
def random
@height = rand(100..500)
@width = rand(100..500)
end
end
end
| true |
96a33dbb8ebf0214e6a208af8d03ee0416394773 | Ruby | vrunda2712/assignment_roll-of-the-die | /doubles.rb | UTF-8 | 215 | 3.859375 | 4 | [] | no_license | #display "doubles" if two numbers are same
die1 = Random.rand(6) + 1
die2 = Random.rand(6) + 1
puts "You rolled #{die1} and #{die2}."
if (die1 == die2)
puts "Doubles!"
end
puts "Your total is #{die1 + die2}."
| true |
997ec379ae3e06583a664244f753d155a2c852d7 | Ruby | mixelpixel/LearnRubyTheHardWay | /ex38.rb | UTF-8 | 948 | 4.46875 | 4 | [] | no_license | # http://learnrubythehardway.org/book/ex38.html
# Exercise 38: Doing Things to Arrays
ten_things = "Apples Oranges Crows Telephone Light Sugar"
puts ten_things
p ten_things + ": this is how a 'p' print handles strings"
puts "Is ten_things a String? "
puts ten_things.is_a?(String)
puts "Wait there are not 10 ... | true |
509833c6b8606949796639770ea8d994768f74df | Ruby | dgsuarez/reruby | /spec/reruby/parser_wrappers/code_region_spec.rb | UTF-8 | 2,062 | 2.671875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'spec_helper'
describe Reruby::ParserWrappers::CodeRegion do
def region_to_source(code_region)
sources = code_region.nodes.map do |node|
node.loc.expression.source
end
sources.join("\n")
end
before :each do
# rubocop:disable Layout/HeredocIndentatio... | true |
9510636e7d19f97bf1d62f6c32117c60d2f1d106 | Ruby | concow/artist-song-modules-online-web-sp-000 | /lib/concerns/memorable.rb | UTF-8 | 300 | 2.703125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | module Memorable
module ClassMethods
def reset_all #remember to remove .self from method declaration in here
self.all.clear
end
def count
self.all.count
end
end
module InstanceMethods
def initialize
self.class.all << self
end
end
end
| true |
8711bd66f6ac0b9657c9a2bab33eeddbb0cec73d | Ruby | Rmole57/launch-school | /rb120/rb120-OOP_exercises/oo_basics_accessor_methods/reading_and_writing.rb | UTF-8 | 357 | 3.921875 | 4 | [] | no_license | class Person
attr_accessor :name
end
person1 = Person.new
person1.name = 'Jessica'
puts person1.name
# ALTERNATIVE SOLUTIONS:
# 1)
# class Person
# attr_writer :name
# attr_reader :name
# end
# 2) - Manually writing the getter/setter methods.
# class Person
# def name
# @name
# end
# def name=(valu... | true |
c9d5b0a1383f4b0fb9a2d149177d0048c304cfff | Ruby | bpieck/rubyx | /test/ruby/test_while_statement1.rb | UTF-8 | 1,121 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require_relative 'helper'
module Ruby
class TestWhileStatementVool < MiniTest::Test
include RubyTests
def setup
@lst = compile( "while(@arg) ; @arg = 1 ; end" ).to_vool
end
def test_class
assert_equal Vool::WhileStatement , @lst.class
end
def test_body_class
assert_equal Voo... | true |
4c8c0118c04e93483a4a3360decc8d5fde1d82a4 | Ruby | miriamhit02/craft_time_2105 | /lib/person.rb | UTF-8 | 368 | 3.34375 | 3 | [] | no_license | class Person
attr_reader :name, :interests, :supplies
def initialize(info)
@name = info[:name]
@interests = info[:interests]
@supplies = {}
end
def add_supply(supply, amount)
# p @supplies
# p @supplies[supply]
current_amount = @supplies[:supply]
new_amount = current_amount + amou... | true |
c280530e419124ebf5c132304a50c7482170a6c0 | Ruby | Janderson406/bloccit | /spec/models/label_spec.rb | UTF-8 | 1,632 | 3 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Label, type: :model do
let(:topic) { create(:topic) }
let(:user) { create(:user) }
let(:post) { create(:post) }
# ^ changed all of our model specs to use our new factories
let(:label) { Label.create!(name: 'Label') }
let(:label2) { Label.create!(name: 'Label2') ... | true |
007bd8ce86caf54cbb0a1a8a641553a68b64d99d | Ruby | kuldeepyadavky/simple-ruby | /session_4/closure/04-cat-usage.rb | UTF-8 | 269 | 2.9375 | 3 | [] | no_license | class Object
def self.const_missing(c)
puts "#{c} is missing. So lets, load it dynamically"
require_relative "04-cat" #require "./04-cat"
Cat
end
end
# Dog #dog missing will return cat as it loaded in the overriden method
Cat.new.talk
| true |
ba5de2c9e1bc2f63f078e818660c62cd6dc28b87 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/e690f3e0ad034e1cb69de4938f62f6f6.rb | UTF-8 | 795 | 3.46875 | 3 | [] | no_license | class Bob
def hey message
message_intent = InterpretedMessage.new message
case
when message_intent.yelling_at_me? then "Woah, chill out!"
when message_intent.asking_a_question? then "Sure."
when message_intent.saying_nothing? then "Fine. Be that way!"
else
"Whatever."
... | true |
f39c860a25ff4c9f1ffa01277e4ca65b1619a082 | Ruby | guardian/multimedia-cloudworkflow-scripts | /s3_cloudsearch/import_s3_to_cloudsearch.rb | UTF-8 | 3,155 | 2.59375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'aws-sdk'
require 'aws-sdk-core'
require 'trollop'
require 'json'
class CloudSearchS3Committer
def initialize(endpointname)
@endpointname = endpointname
@cs = Aws::CloudSearchDomain::Client.new(endpoint: endpointname)
@awaitingCommitList = []
@awaitingCommitString = "["
@csSizeLi... | true |
e8677a9e62a1f19a2e4c9ef8318a7a5f743fc120 | Ruby | jerrytx214/sample1 | /some_file.rb | UTF-8 | 211 | 3.90625 | 4 | [] | no_license | puts "Quieres agregar nuevo?"
puts "Si o no"
puts "Nombre:Gerardo Rivera"
print "Ano:2002"
# Methods cant be placed on a 'puts'
def short_age(birth_year)
Time.new.year - birth_year
end
puts "Edad:#{short_age(2002)}" | true |
55bb1428b28c5fa0c6a47b52e3514b2df0b102dc | Ruby | daiki21/message-board | /app/models/message.rb | UTF-8 | 397 | 2.828125 | 3 | [] | no_license | class Message < ActiveRecord::Base
#名前は必須入力かつ20文字いない
validates :name, length: { maximum:20 }, presence: true
#内容は必須入力かつ2文字以上30文字以下
validates :body, length: { minimum:2, maximum:30 }, presence: true
#年齢は0以上の数値だけ入力
validates :age, numericality: { only_integer: true, greater_than: 0 }
end
| true |
c3b9e70b2891b0c87f58fd6443a574a2aa8ba39c | Ruby | doctordeep/arachni | /modules/audit/csrf.rb | UTF-8 | 9,434 | 2.59375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | =begin
Copyright 2010-2014 Tasos Laskos <tasos.laskos@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless requi... | true |
25e80b478ec4d14fd3d5450edef7fc07ecbaffd9 | Ruby | tianxiaoxi1113/ruby-excise | /ruby/array2.rb | UTF-8 | 266 | 3.421875 | 3 | [] | no_license | #!/usr/bin/ruby
arr=["a","b", "c","d","e"]
arr.pop
arr.pop
arr.each{|i| print i, "\n"}
print "==============","\n"
arr.unshift("f")
arr.unshift("g")
arr.unshift("h")
arr.unshift("i")
arr.each{|i| print i, "\n"}
arr.push("l")
arr.shift
arr.each{|i| print i, "\n"}
| true |
0e060c21500e8f5efbefbccc575b075c9f12bf98 | Ruby | denissellu/unistats | /lib/unistats.rb | UTF-8 | 3,998 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'httparty'
class Unistats
include HTTParty
format :json
base_uri 'data.unistats.ac.uk/api/V3/KIS'
# Initialises the Unistats class and configures authentication with an
# access token - obtain one at http://dataportal.unistats.ac.uk/Account/Register
# Params:
# +access_token+... | true |
0e6a12af8351cf6849c1da96a90241f63a645d8d | Ruby | lair001/poetic-rivals | /spec/models/genre_spec.rb | UTF-8 | 1,258 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'rails_helper'
RSpec.describe Genre, type: :model do
it 'knows its name' do
genre = fake_genre
expect(build_stubbed(:genre, name: genre).name).to eq(genre)
end
it 'it validates its name for uniqueness regardless of letter case' do
save_models genre
expect(build(:genre, name: genre.name.upcase).sav... | true |
16daaf6b0a67b1780ac8896cf7a4cc52d71bf9a7 | Ruby | mcasey8540/abodya | /db/seeds.rb | UTF-8 | 5,869 | 2.515625 | 3 | [] | no_license | require 'csv'
class CountyAssessment
def initialize
line_number = 0
get_csv(line_number.to_i)
#get_muni_code
end
def get_csv(line_number)
CSV.foreach("#{Rails.root}/db/data/nj/monmouth.csv") do |row|
# city = ""
# case row[0].to_i
# when 201
# city... | true |
a1bb4e49ad3b8b0080ef53add625e4664264b421 | Ruby | hecpolanco/ruby-advanced-class-methods-lab-nyc-web-102819 | /lib/song.rb | UTF-8 | 1,336 | 3.53125 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry'
class Song
attr_accessor :name, :artist_name
@@all = []
# def initialize(artist_name, name)
# @artist_name = artist_name
# @name = name
# end
def self.all
@@all
end
def self.create
@s = Song.new
@s.save
@s
end
def self.new_by_name(song_name)
@s
@s.nam... | true |
078b21a318929ca8979c1a97ec62923f7ea968ea | Ruby | AmishNinja/codility_exercises | /codility3.rb | UTF-8 | 177 | 3.15625 | 3 | [] | no_license | def solution(a)
return 1 if a.empty?
Array.new(a.length + 1) {|i| i + 1}.inject(:+) - a.inject(:+)
end
arr = [2,3,1,5]
p solution(arr)
arr = [1,2,8,4,6,7,3]
p solution(arr) | true |
493a2f9598466658483fd214330f4ef27258a312 | Ruby | bencefulop/surveyor-challenge | /lib/surveyor/response.rb | UTF-8 | 425 | 3.140625 | 3 | [] | no_license | module Surveyor
class Response
attr_reader :email
attr_accessor :answers
def initialize(email:)
@email = email
# Answers are added to responses instead of Surveys
@answers = []
end
def valid_email?(email)
email_regex = /\A[^@\s]+@[^@\s]+\z/
email.class == String && ... | true |
f9870205ccc2667a07e523524a029017dac1cdd6 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/gigasecond/104f2b038db14af5963d833e3d6ec69b.rb | UTF-8 | 228 | 3.34375 | 3 | [] | no_license | class Gigasecond
SECONDS = 10**9
SECONDS_IN_A_DAY = 60 * 60 * 24
ONE_GIGASECOND_IN_DAYS = SECONDS / SECONDS_IN_A_DAY
def initialize(date)
@date = date
end
def date
@date + ONE_GIGASECOND_IN_DAYS
end
end
| true |
274b2e3b7db41f2f7b9d7df9832a8436b2c261ce | Ruby | jsguru-git/scheduler | /app/models/invoice_item_track.rb | UTF-8 | 3,718 | 2.78125 | 3 | [] | no_license | class InvoiceItemTrack
# External libs
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
# Validation
validates :start_date, :end_date, :payment_profile_id, :project_id, :presence => true
validate :check_dates_are_valid
validate :check_associated
validate ... | true |
0ca442075b9d2b65f3c08f76f5d680b3dc089326 | Ruby | erikasnts22/Ruby-Activities | /polymorphism.rb | UTF-8 | 337 | 3.71875 | 4 | [] | no_license |
class Toyota
def car_name
"Corolla"
end
end
class Ford
def car_name
"Everest"
end
end
class Honda
def car_name
"Civic"
end
end
class Cars
def my_car(list)
puts list.car_name
end
end
list = Cars.new
list.my_car(Toyota.new)
list.my_car(Ford.new)
list.m... | true |
a62dedb31766aff35f5c02835e7d01374932e170 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/6ad06e1245dc4e0a9350cf2e5e015bf4.rb | UTF-8 | 330 | 3.46875 | 3 | [] | no_license | module Hamming
def self.compute(first, second)
first, second = equalize_lengths(first, second)
first.chars.zip(second.chars).count { |tuple| tuple[0] != tuple[1] }
end
def self.equalize_lengths(first, second)
shorter = [first.length, second.length].min
[first[0..shorter-1], second[0..shorter-1]]
... | true |
153e23bb2d77a148d13d6528019df459247b3428 | Ruby | RabeaGleissner/mvc_animal_shelter | /view.rb | UTF-8 | 688 | 3.546875 | 4 | [] | no_license | class View
def list_all_animals(animals)
animals.each_with_index do |animal, index|
puts "#{index}: #{animal.name} (#{animal.type})"
end
end
def ask_for_animal_id
puts "Please enter the animal id"
return gets.chomp
end
def ask_for_animal_type
puts "What type of animal would you lik... | true |
8a189034ddad53b3f7294579a93d349318441d89 | Ruby | harishraisinghani/ar-exercises | /exercises/exercise_6.rb | UTF-8 | 761 | 2.96875 | 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'
puts "Exercise 6"
puts "----------"
# Your code goes here ...
@store1.employees.create(first_name: "Harish", last_name: "Raisingha... | true |
7eea76b05e0d79c4f2277cde5357b7892a5d08a7 | Ruby | crystalcommerce/page_token | /lib/page_token/saved_search.rb | UTF-8 | 521 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'multi_json'
class PageToken
class SavedSearch
def self.parse(token, json)
new(token, MultiJson.decode(json))
end
attr_reader :token, :limit, :order, :search, :last_id
def initialize(token, attrs = {})
@token = token
@limit = attrs.fetch('limit')
@order = attr... | true |
f85290730965e836f911e0aff45d16d4caa90fb2 | Ruby | algoregalore/beginning-ruby | /hw/hwcolor.rb | UTF-8 | 409 | 3.984375 | 4 | [] | no_license | def favorite_color
# ask favorite color
puts "what's your favorite color?"
fav_color = gets.chomp
# blue or green, say that's a great color
if
fav_color == "blue" or fav_color == "green"
puts "that's a great color!"
else
puts "really? #{fav_color} isn't really your favorite color!"
favorite... | true |
53d7c254d59156b67186535d13ef7f03d7be17de | Ruby | Jake0Miller/battleship | /test/coordinate_generator_test.rb | UTF-8 | 534 | 2.859375 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/ship'
require './lib/cell'
require './lib/board'
require './lib/coordinate_generator'
require 'pry'
class CoordinateGeneratorTest < MiniTest::Test
def setup
@board = Board.new(4)
@sub = Ship.new("Sub", 2)
@gen = CoordinateGenerator.new
... | true |
0f362c555da5f629be3c33cd5af24d45a6af7830 | Ruby | rcm32000/mythical-creatures | /unicorn/unicorn.rb | UTF-8 | 240 | 3.546875 | 4 | [] | no_license | class Unicorn
attr_reader :name,
:color
def initialize (name, color)
@name = name
@color = color
end
def white?
@color == "White"
end
def say(input)
string = "**;* #{input} **;*"
end
end
| true |
d98734a87a044569b1617d4666d271d2e6624c5c | Ruby | ontarionick/orbital_example | /lib/astrodynamics/astronomical_object.rb | UTF-8 | 1,860 | 3.34375 | 3 | [] | no_license | require 'matrix'
module Astrodynamics
class AstronomicalObject
attr_accessor :name, :current_x, :current_y, :current_z, :mass, :radius, :dx, :dy, :dz
G = 6.67384e-11
def initialize name, x, y, z, m, r, dx = 0, dy = 0, dz = 0
@name = name
@current_x = x
@current_y = y
@current_z ... | true |
3b108fc3ea1f07a259cfb95942a0cee0eaf3f697 | Ruby | hockey809/software_engineering_2015 | /VhodnoNivo/Nikolay_Danailov/Nikolay_Danailov_{13}.rb | UTF-8 | 313 | 3.75 | 4 | [] | no_license | x = 0
loop do
puts "Enter a number between 0 and 10"
x = gets.to_i
break if x > 0 and x < 10
end
arr = []
(0..9).each{ |i|
current_range_bottom = i * x
current_range_top = (i + 1) * x
sum = 0
(current_range_bottom..(current_range_top - 1)).each{ |j|
sum += Math::cos(j)
}
arr[i] = sum
}
puts arr | true |
4b08c6a734c7b8f854ed4d1d07d91b1500b2aec2 | Ruby | KT-Viktar/fullstack-challenges | /02-OOP/05-Food-Delivery-Day-One/01-Food-Delivery/app/models/employee.rb | UTF-8 | 314 | 2.90625 | 3 | [] | no_license | # Modeling the manager
class Employee
attr_reader :name, :password, :title
attr_accessor :id
def initialize(banana)
@id = banana[:id] ? banana[:id].to_i : nil
@name = banana[:name]
@password = banana[:password]
@title = banana[:title]
end
def manager?
@title == 'manager'
end
end
| true |
f8160fac42183dd4fed922076eb04cbc3baf8645 | Ruby | iddumied/Tag2Name | /M3U-SHA512-Comments.rb | UTF-8 | 5,132 | 3.109375 | 3 | [] | no_license | require 'digest'
require './Dir.rb'
require './SHA512-Database.rb'
##
# Just a little script to add SHA512 summs to a playlist, and restore
# pathes with it
#
class M3U
class Entry
def initialize
@comments, @sha512, @file = "", "", ""
end
attr_reader :comments, :sha512, :file
def add_comme... | true |
14fcc9737643e6986319da94e9ebac5944eeaa4f | Ruby | parabuzzle/spunk | /lib/spunk/helpers.rb | UTF-8 | 455 | 2.515625 | 3 | [] | no_license | module Spunk
module Helpers
def Helpers.parse_room(command)
if command.nil?
return nil
end
command.match(/(\#\S+\b)/i)
return $1
end
def Helpers.hashify(bot, origin, command, parameters, logger)
hash = {:bot=>bot, :origin=>origin, :command => command, :msg => parameters, :... | true |
1ad961c051d22153c78aa5ea2e7a24ed8378f98a | Ruby | thib123/TPJ | /Notes/Ruby/sample_code/ex0666.rb | UTF-8 | 186 | 2.984375 | 3 | [
"MIT"
] | permissive | # Sample code from Programing Ruby, page 386
klass = Fixnum
begin
print klass
klass = klass.superclass
print " < " if klass
end while klass
puts
p Fixnum.ancestors
| true |
a1363aa89d5e33b4ef6f488062c3acc8d8b5ff54 | Ruby | moemenhusseinshaaban/labforward-challenge | /labforward-docker/labforward/lib/numeric_array_calculation.rb | UTF-8 | 3,131 | 3.078125 | 3 | [] | no_license | class NumericArrayCalculation < Array
APPROXIMATE_STANDARD_DEVIATION_MEAN_AD = 1.253314
APPROXIMATE_STANDARD_DEVIATION_MEDIAN_AD = 1.486
MOVING_Z_SCORE_IITIALIZE_LAG = 2
class << self
def z_score(score, array_mean, array_standerd_deviation)
return 0 if array_standerd_deviation == 0
(score - arr... | true |
68a4329fc8a72694886c513cdc16786dd64f6306 | Ruby | Notoriousjayy/Programming-Language-Pragmatics | /code/14-scripting/example_14.27/skill.rb | UTF-8 | 1,078 | 3.078125 | 3 | [] | no_license | #! /usr/bin/ruby
# Example 14.27 (Figure 14.7)
# To use, start a bunch of process you don't care about (loop.c in this
# directory makes a good candidate) then run: ./skill.rb <pattern>
ARGV.length() == 1 or begin
$stderr.print("usage: #{$0} pattern\n"); exit(1)
end
pat = Regexp.new(ARGV[0]) # treat command-li... | true |
bd19590d2fb880ea211616de2654b633a8d13fa8 | Ruby | indiepop/Foglight_Examples | /config/linux564/filters/camstudio.rb | UTF-8 | 1,741 | 2.765625 | 3 | [] | no_license | class CamStudio
require 'Win32API'
require 'timeout'
# Click the rec button
MOUSEEVENTF_LEFTDOWN = 0x0002
MOUSEEVENTF_LEFTUP = 0x0004
SW_RESTORE = 9
@@find_window = Win32API.new 'user32', 'FindWindow', ['P' , 'P' ], 'L'
@@set_foreground_window = Win32API.new 'user32', 'SetForegr... | true |
bbabafaa9557ddde928c9df2e0a4c8111e516431 | Ruby | annabush092/looping-while-until-prework | /lib/while.rb | UTF-8 | 125 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def using_while
levitation_force = 6
while levitation_force<10
levitation_force +=1
puts "Wingardium Leviosa"
end
end
| true |
8f742cf5c346871ca3cb095eb9400e7b5772576a | Ruby | twhitinger/ruby | /excercise256.rb | UTF-8 | 301 | 2.828125 | 3 | [] | no_license | def create(options = {})
puts "Creating #{options[:database]} for owner #{options[:user]}..."
end
def connect(database:, host: "localhost", port: 3306, user: "root")
puts "Connecting to #{database} on #{host} port #{port} as #{user}..."
end
Creating catalog for owner carl.
| true |
b098e104e075b27c8d37e2caf545bd1dd9dd6d57 | Ruby | Yolantele/ruby-kickstart | /session2/challenge/11_classes.rb | UTF-8 | 1,073 | 3.859375 | 4 | [
"MIT"
] | permissive |
class BeerSong
attr_accessor :bottle_num
def initialize(bottle_num)
bottle_num = 0 if bottle_num < 0
bottle_num = 99 if bottle_num > 99
self.bottle_num = bottle_num #not sure why do we need to put self.beers here.. #referencing BeerSong?
end
def print_song
bottle_num.downto 1 do |i|
print_stanza... | true |
00d345bd25ed44a0c689e99f04d90f62e7394d26 | Ruby | kembo-net/new-numeric | /test.rb | UTF-8 | 1,548 | 3.15625 | 3 | [] | no_license | require_relative "new_num.rb"
require "minitest/unit"
MiniTest::Unit.autorun
class Test自然数 < MiniTest::Unit::TestCase
def setup
@zero = NewNum::N.Zero
@a = NewNum::N[13]
@b = NewNum::N[4]
end
def test_自然数には0がある
assert_kind_of(NewNum::N, @zero)
end
def test_各自然数には「次の数」が存在する
assert_kind_of... | true |
e3c83cc796f53cfa2c5c832bc6cb61e9ce0c9f26 | Ruby | davidacosta25081/looping-times-online-web-pt-011419 | /times.rb | UTF-8 | 67 | 2.578125 | 3 | [] | no_license | def using_times
7.times do
puts "Wingardium Leviosa"
end
end
using_times
| true |
0be67d56d71385b15d2a79d5337a6e29f944886d | Ruby | mogest/prawn-svg | /spec/prawn/svg/attributes/opacity_spec.rb | UTF-8 | 2,442 | 2.75 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Prawn::SVG::Attributes::Opacity do
class OpacityTestElement
include Prawn::SVG::Attributes::Opacity
attr_accessor :properties, :state
def initialize
@properties = ::Prawn::SVG::Properties.new
@state = ::Prawn::SVG::State.new
end
def clamp(value, min_v... | true |
4210116a5fcc006e83f4c1ab49d4c26856d82a0e | Ruby | Philip-Nunoo/silverbird | /lib/silverbird.rb | UTF-8 | 3,323 | 3 | 3 | [
"MIT"
] | permissive | require 'silverbird/version'
require 'open-uri'
require 'nokogiri'
module Silverbird
# Your code goes here...
def self.theatres cinema
theatres = Array.new
if cinema.downcase.to_sym.eql? :silverbird # Silverbird
# .moduletable_content #k2ModuleBox131 ul li
url = 'http://silverbirdcinemas.com'
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.