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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
7272a5480f04c04a77af00597636b100e86f28a1 | Ruby | zb-coder/oystercard | /spec/oystercard_spec.rb | UTF-8 | 3,898 | 3.109375 | 3 | [] | no_license | require 'oystercard'
describe Oystercard do
let(:station) {double :station}
it 'should have a new balance' do
expect(subject.balance).to eq(DEFAULT_BALANCE)
end
#instant variable - List of journey's
#attr_reader
#What it should do?
#What is should return?
describe '#initialize' do
i... | true |
8f27287d83d86464f2a252f0d9b5ee179ebadad8 | Ruby | Alex-Swann/Well-Grounded-Rubyist-2nd-Edition | /Chapter-15 (Callbacks, hooks and runtime introspection)/cont_missing.rb | UTF-8 | 223 | 3.296875 | 3 | [] | no_license |
# const_missing is used to define a constant that might not have been
# set yet.
class C
def self.const_missing(const)
puts "#{const} is undefined; setting it to 1."
const_set(const, 1)
end
end
puts C::A
puts C::A
| true |
13cce27716454cbe3b177b5fddf3fb670442badf | Ruby | EMG114/ruby-lecture-fixing-our-broken-program-001-prework-web | /lib/a_working_program.rb | UTF-8 | 57 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
# Your entire program should read:
puts "Hello World!"
| true |
2f3e96d7bf5e5e9f9ffae02b6512ae1f493e94fb | Ruby | matteo-bottini/public | /Ruby/willYou.rb | UTF-8 | 306 | 3.1875 | 3 | [] | no_license | def willYou(young, beautiful, loved)
a = [young, beautiful, loved]
return true if (loved == false && a.count(true) == 2) || (loved == true && a.count(false) >= 1)
else false
end
willYou(true, false, true)
# best solution
#def willYou(young, beautiful, loved)
# (young && beautiful) != loved
#end
| true |
f426666f61c3e9f3bec73a492131edf9a990b4e5 | Ruby | GalacticPlastic/ironhack | /Week1/Day3/Lesson_DataStructures/hashes.rb | UTF-8 | 1,828 | 3.734375 | 4 | [] | no_license | puts ""
puts "Superman sucks."
puts "Batman is my sample hash instead. ;)"
puts ""
# name
# superpowers
# real_name
# city
# comic_company
# rogues_gallery
batman = ["Batman", ["master detective", "wealth"], "Bruce Wayne", "Gotham", "DC", ["Joker", "Catwoman", "Clayface", "The Penguin", "Poison Ivy" "Deadshot", "Kille... | true |
26adfc89a480b589655c1356ac11f4682df91303 | Ruby | steveafrost/tic-tac-toe-rb-q-000 | /lib/tic_tac_toe.rb | UTF-8 | 2,126 | 4.03125 | 4 | [] | no_license | WIN_COMBINATIONS = [
[0,1,2],
[3,4,5],
[6,7,8],
[0,3,6],
[1,4,7],
[2,5,8],
[0,4,8],
[2,4,6]
]
board = [" "," "," "," "," "," "," "," "," "]
def display_board(board)
puts " #{board[0]} | #{board[1]} | #{board[2]} "
puts "-----------"
puts " #{board[3]} | #{board[4]} | #{board[5]} "
puts "------... | true |
7f86fa7b4dffdd5c4b4b19b997da3c47c467dd47 | Ruby | diazgio/Ruby-for-Beginers | /1_integers_y_floats.rb | UTF-8 | 495 | 3.734375 | 4 | [] | no_license | # Ejecuta estas líneas en `irb` para ver el resultado de cada instrucción
# Integers y floats
# Operadores
x = 4 + 5 - 1
y = x * 20 / 5
z = 5%2
9%3
pi = 3.14
2 < 3
2 ** 8
# Métodos utilitarios
2.even?
x.odd?
(2 ** 8).digits
(2 ** 8).digits.reverse
2 ** 5000
# Inspeccionamos el tipo o la clase de las variables `x` y... | true |
b1df1c10b9078b428926064db8fc6abb56edc7e2 | Ruby | philiprlarie/project_euler | /problems_40-49/problem45.rb | UTF-8 | 1,347 | 3.765625 | 4 | [] | no_license | # Hash lookups
# Triangle, pentagonal, and hexagonal numbers are generated by the following formulae:
#
# Triangle Tn=n(n+1)/2 1, 3, 6, 10, 15, ...
# Pentagonal Pn=n(3n−1)/2 1, 5, 12, 22, 35, ...
# Hexagonal Hn=n(2n−1) 1, 6, 15, 28, 45, ...
# It can be verified that T285 = P165 = H143 = 40755.
#
# Find the... | true |
c9137713c9e3c4b30255d896d7c947382c663af6 | Ruby | bdombrow/CS-510_Cassandra | /chris/bridges.rb | UTF-8 | 1,145 | 2.84375 | 3 | [] | no_license | # bridges
# generate adjacency matrix
graph = Array.new(node_count + 1) { Array.new(node_count + 1).fill 0 }
edge_keys.each do |ek|
estart, eend = ek.split('-')
row = client.get(:Edges, ek)
graph[estart.to_i][eend.to_i] = ek['weight'] || 1
end
index = 0
stack = []
bridges = []
def run(graph)
b... | true |
74d1a1630e1f1da4f5b5b1aa524e6b0e8a12aff1 | Ruby | david-mccullars/line_learn | /lib/line_learn/character_set.rb | UTF-8 | 1,005 | 2.953125 | 3 | [
"MIT"
] | permissive | module LineLearn
class CharacterSet < Hash
def max_name_size
@max_name_size ||= names.map(&:size).max
end
alias :names :keys
alias :valid? :has_key?
def [](name)
super(name) or self[name] = Character.new(self, name)
end
def color_map
@color_map ||= Hash[self.keys.sor... | true |
ba34d266906ee70f800a04852e7e26e41b2b6eae | Ruby | neelsun15/ChrisPine | /ch5/fav_number.rb | UTF-8 | 167 | 3.75 | 4 | [] | no_license | puts 'Hi there, what\'s your favorite number?'
f_number = gets.chomp.to_i
better_number = f_number + 1
puts 'Sounds great, but how about ' + better_number.to_s + ' ?'
| true |
51ae3948752f373a9549e0b7aec5144e612f1f3f | Ruby | atomical/hedgerow | /lib/hedgerow.rb | UTF-8 | 1,346 | 2.796875 | 3 | [] | no_license | require "hedgerow/version"
class Hedgerow
class << self
def with(name, opts = {})
if status = lock(name, opts[:timeout] || 10)
yield
else
raise LockFailure.new("Could not acquire lock.")
end
ensure
release(name) if status
end
def lock(name, timeout)
vali... | true |
0d23d4eb281b3ec492d691c2108490a3cb3283ef | Ruby | vladveterok/codebreaker-console | /lib/states/game_state.rb | UTF-8 | 1,170 | 2.921875 | 3 | [] | no_license | # frozen_string_literal: true
class GameState < ConsoleState
def interact
@console.game.start_new_game
play_game
end
def play_game
loop do
puts I18n.t(:ask_guess, length: CODE_LENGTH, min: DIGIT_MIN_MAX[0],
max: DIGIT_MIN_MAX[-1], hint: COMMANDS[:hint],
... | true |
33f1218897d9e8a7b25d987f516e80c654f49aa2 | Ruby | marcandre/backports | /lib/backports/random/MT19937.rb | UTF-8 | 2,380 | 3.15625 | 3 | [
"MIT"
] | permissive | module Backports
class Random
# An implementation of Mersenne Twister MT19937 in Ruby
class MT19937
STATE_SIZE = 624
LAST_STATE = STATE_SIZE - 1
PAD_32_BITS = 0xffffffff
# See seed=
def initialize(seed)
self.seed = seed
end
LAST_31_BITS = 0x7fffffff
OF... | true |
fe91c7cfad9e58ffc17db63902dad952300ffcce | Ruby | willmcneilly/chart-scraper | /top-40-scraper.rb | UTF-8 | 1,531 | 2.71875 | 3 | [] | no_license | require 'rubygems'
require 'bundler/setup'
require 'nokogiri'
require 'open-uri'
require 'json'
@charts = []
@lower_limit = 2501
@upper_limit = 2807
def url_for_page(options={})
base_url = "http://www.officialcharts.com"
url = "#{base_url}#{@week_url}"
return url
end
def open_page(url)
chart_entries = []
... | true |
2b4241f884f1bf952c0bbc331bfecd55fc38d445 | Ruby | QPC-WORLDWIDE/rubinius | /preinstalled-gems/data/gems/rdoc-2.5.1/test/test_rdoc_class_module.rb | UTF-8 | 2,546 | 2.53125 | 3 | [
"GPL-1.0-or-later",
"GPL-2.0-only",
"Ruby",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.expand_path '../xref_test_case', __FILE__
class TestRDocClassModule < XrefTestCase
def setup
super
@RM = RDoc::Markup
end
def test_comment_equals
cm = RDoc::ClassModule.new 'Klass'
cm.comment = '# comment 1'
assert_equal 'comment 1', cm.comment
cm.comment = '# comment 2'... | true |
536d5b7870af85eedd733de90a4214aa5770d375 | Ruby | a14m/EGP-Rates | /lib/egp_rates/suez_canal_bank.rb | UTF-8 | 2,091 | 3.203125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module EGPRates
# Suez Canal Bank
class SuezCanalBank < EGPRates::Bank
def initialize
@sym = :SuezCanalBank
@uri = URI.parse('http://scbank.com.eg/CurrencyAll.aspx')
end
# @return [Hash] of exchange rates for selling and buying
# {
# { sell: { SYM... | true |
e7ad4932b57de1f9717ab551d76e67a2a418571c | Ruby | machinio/solrb | /lib/solr/grouped_document_collection.rb | UTF-8 | 1,121 | 2.515625 | 3 | [
"MIT"
] | permissive | module Solr
class GroupedDocumentCollection < DocumentCollection
attr_reader :group_counts
def self.empty
new(documents: [], total_count: 0, group_counts: {})
end
def initialize(documents:, total_count:, group_counts:)
super(documents: documents, total_count: total_count)
@group_co... | true |
1db618725efdfd774863cb3c6889b21191192910 | Ruby | horizon67/cryptocoin | /lib/exchange/bitmex.rb | UTF-8 | 1,689 | 2.515625 | 3 | [] | no_license | module Exchange
class Bitmex
def initialize(key, secret)
@private_client = ::Bitmex.http_private_client(key, secret)
@public_client = ::Bitmex.http_public_client
end
# amount: USD
def limit_buy(amount, price)
@private_client.create_order("XBTUSD", amount.to_f.to_s, { side: "Buy", p... | true |
70fb4866e3ebc52666e1887ecdfdb727b62a7979 | Ruby | chandlerkelley/recipes_app_rails | /db/seeds.rb | UTF-8 | 2,318 | 2.640625 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
be80607562164f535cb6b842539c144b2182dc46 | Ruby | Kryndex/bolt-1 | /modules/boltlib/lib/puppet/functions/run_script.rb | UTF-8 | 2,632 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | # Uploads the given script to the given set of targets and returns the result of having each target execute the script.
#
# * This function does nothing if the list of targets is empty.
# * It is possible to run on the target 'localhost'
# * A target is a String with a targets's hostname or a Target.
# * The returned v... | true |
11f68a4ae12cb653131ea2c0c82224a651683546 | Ruby | kevxo/toolsdev-project-2021-07-09 | /app/poros/forecast.rb | UTF-8 | 352 | 3.375 | 3 | [] | no_license | class Forecast
attr_reader :date, :hourly_temps
def initialize(data)
@date = data[:date]
@hourly_temps = temps(data)
end
def temps(data)
hash = {}
data[:hourly].each do |value|
hour = value[:time].to_i / 100
time = "#{hour}:00"
temp = value[:tempF]
hash[time] = temp
... | true |
d40165a91b8f5bf8480fe9b22e128cef4d3e3b94 | Ruby | mavendan/Tealeaf_Assignment | /calculator1.rb | UTF-8 | 7,159 | 3.859375 | 4 | [] | no_license | ##---------------------------------------------------------------
## Calculator.rb
## First assignment on the tealeaf Ruby course
## This class perform the following maths operations:
## add, substract, multiply and divide
##---------------------------------------------------------------
... | true |
2d1dc13c72ab4291bfcbd772f53a1881f00b15e7 | Ruby | salmanllhdata/Whitepages-Pro-API-Examples | /How To Reverse Phone/Ruby/WhitePages-PhoneLookup/lib/api_response.rb | UTF-8 | 417 | 2.609375 | 3 | [
"MIT"
] | permissive | # This class handles for api request and response.
class ApiResponse
include HTTParty
def initialize(phone)
@phone_uri = 'https://proapi.whitepages.com/2.0/phone.json?'
@options = { query: { phone: phone, api_key: ENV['API_KEY'] } }
end
# get api response
def json_response
begin
self.class.... | true |
5605526bce6f7864824d17b4f3dd7bea66818dc4 | Ruby | lbrnmdev/audrey | /app/models/concerns/sanitizable.rb | UTF-8 | 573 | 2.578125 | 3 | [] | no_license | module Sanitizable
extend ActiveSupport::Concern
private
def downcase_attributes
self.attributes.each {|attribute, value| self[attribute] = value.downcase if value.respond_to? 'downcase'}
end
def nil_if_blank
self.attributes.each do |key, value|
self[key] = nil if (value.respond_t... | true |
0ba900e7d6ea857f31b40d2db09d03bfb464c12d | Ruby | meganemura/piler | /lib/piler/project.rb | UTF-8 | 539 | 2.671875 | 3 | [
"MIT"
] | permissive | module Piler
class Project
attr_reader :client
attr_reader :project
def initialize(client, project)
@client = client
@project = project
end
def name
project.name
end
def number
project.number
end
def columns
@columns ||= client.project_columns(proj... | true |
b391c4d0548f5f4be3a369387c208aca2edd3cf4 | Ruby | HelloPleaseHireMe/AutomationTestTest | /Work Submit/problem1_stepdefinitions.rb | UTF-8 | 865 | 2.671875 | 3 | [] | no_license | #The Feature file calls upon functions in the Step Definitions which then call functions in the Page Object Page
browser = Watir::Browser.new:chrome
#This is pretty old school but I just wrote a simple test for the practice problem
#Let me know if you want me to do this with Browserstack or any other App Integra... | true |
457a7dc2119a59f5f00f99aeb64e615abd628b81 | Ruby | stamppot/cbcl4 | /lib/export_csv_helper.rb | UTF-8 | 3,342 | 2.71875 | 3 | [] | no_license | # encoding: utf-8
require 'csv'
# require 'FasterCSV'
class ExportCsvHelper
def to_danish(str)
if str.respond_to? :gsub
str.gsub("ø", "ø").gsub("æ", "æ").gsub("Ã…", "Å")
else
str
end
end
def to_csv(rows, separator = ";")
return "" unless rows.any?
return rows.first.join(";")... | true |
955bc92b49502e3b5f0b683d0560ecfa1a50e7b4 | Ruby | hathach/tinyusb | /test/unit-test/vendor/ceedling/lib/ceedling/file_finder_helper.rb | UTF-8 | 1,394 | 3 | 3 | [
"MIT"
] | permissive | require 'fileutils'
require 'ceedling/constants' # for Verbosity enumeration
class FileFinderHelper
constructor :streaminator
def find_file_in_collection(file_name, file_list, complain, extra_message="")
file_to_find = nil
file_list.each do |item|
base_file = File.basename(item)
# case ins... | true |
93cae7ff86fbfbdc71aae280c1ec182dcacb3671 | Ruby | sahidursuman/flex_commerce | /app/services/reward_service.rb | UTF-8 | 2,385 | 2.890625 | 3 | [] | no_license | class RewardService
attr_accessor :order, :referral_amount, :cash_back_amount
def initialize(order_id: nil)
@order = Order.find(order_id)
@referral_amount = Money.new(0)
@cash_back_amount = Money.new(0)
end
def distribute
@order.inventories.each do |inv|
inv.product.reward_methods.each d... | true |
0f1a06c9214a26445a9735b34196c7688270bf5c | Ruby | a1153tm/aoj | /doubly_linked_list.rb | UTF-8 | 1,382 | 3.6875 | 4 | [] | no_license | class List
def initialize
@head = Node.new
@tail = Node.new(@head)
@head.nxt = @tail
end
def insert(val)
nxt_old = @head.nxt
node = Node.new(@head, nxt_old, val)
@head.nxt = node
nxt_old.prv = node
end
def delete(val)
node = @head.nxt
while node.val
if node.val == v... | true |
19d3deebdf3ec3e07be7b09e58bc2d64039866cc | Ruby | jmhar3/apocalypto2 | /lib/apocalypto/cli.rb | UTF-8 | 1,605 | 3.234375 | 3 | [] | no_license | class ApocalyptoApp::CLI
def initialize
ApocalyptoApp::Scraper.new.get_locations
end
def start
system("clear")
puts "Welcome to Apocalypto"
divider
puts "It's the end of days. A plague has taken over the world, turning people into vicious, flesh eating zombies. The w... | true |
b305534cee412e1531a6846fa3391d9ebe9b79a9 | Ruby | cmonty/puzzles | /braintree.rb | UTF-8 | 903 | 3.1875 | 3 | [] | no_license | class BrainTree
def self.luhn?(n)
sum = 0
n.reverse.chars.with_index do |c, i|
d = c.to_i
if i % 2 == 1
d *= 2
d -= 9 if d > 9
end
sum += d
end
sum % 10 == 0
end
def self.ccexp?(d)
m, y = d.split '/'
if y.to_i > 2010
... | true |
d42c20a5b0145add8caec5b8a5e377797ec5882f | Ruby | greglockwood/CrusadeMT | /test/unit/person_test.rb | UTF-8 | 6,220 | 2.796875 | 3 | [] | no_license | require 'test_helper'
class PersonTest < ActiveSupport::TestCase
# relationships
test "person has a spouse property" do
person = create
assert(person.respond_to?('spouse'), "Person does not have a spouse property (has the relationship been set?).")
begin
person.spouse
rescue
assert(fals... | true |
1fd4b36985a8db011392ee0e3327aa7866003208 | Ruby | porusan/Euler | /006/006.rb | UTF-8 | 409 | 3.265625 | 3 | [] | no_license | require './lib006'
n = 100
puts 'making calculations up to n=' + n.to_s
puts 'attempting via loops:'
start = Time.new
puts squareOfSum(n) - sumOfSquares(n)
finish = Time.new
puts 'it took ' + (finish - start).to_s + ' seconds'
puts ''
puts 'attempting via formulae:'
start = Time.new
puts squareOfSumMath(n) - sumO... | true |
177dc2834a0673cd68f6ad49e619fe1ce458add8 | Ruby | byojelly/my-collect-v-000 | /lib/my_collect.rb | UTF-8 | 253 | 3.578125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_collect(collection)
counter = 0
new_array = []
while collection.length > counter
new_array << yield(collection[counter])
counter +=1
end
new_array
end
my_collect(["Tim Jones", "Tom Smith", "Jim Campagno"]) {|name| name.split(" ").first }
| true |
c058f7cbd5b6a20c5826638a17cdaa190d77743e | Ruby | brand-it/plex_the_ripper | /app/services/mkv_installer/base.rb | UTF-8 | 1,142 | 2.515625 | 3 | [] | no_license | # frozen_string_literal: true
module MkvInstaller
class Base
include Shell
DOWNLOAD_URI = URI('http://www.makemkv.com/download/')
VERSION_PATTERN = /.*_v(\d*\.\d*\.\d*)/.freeze
private
def files
return @files if @files
@files = download_paths.map do |path|
download(path)
... | true |
75a2bfe7eeda10fef58e57b23881956572a361cb | Ruby | geeksam/ladds_graph | /tests/test_helper.rb | UTF-8 | 2,792 | 2.671875 | 3 | [] | no_license | $: << File.expand_path(File.join(File.dirname(__FILE__), *%w[.. lib]))
require 'rubygems'
require 'minitest/spec'
require 'minitest/autorun'
require 'graph'
require 'map'
def build_square
@square = Graph.new
@ab = @ba = @square.edge(:a, :b, 1)
@bc = @cb = @square.edge(:b, :c, 1)
@cd = @dc = @square.edge(:c,... | true |
fb232429ee01a57c065e048e80b021fa7933a5de | Ruby | learningtapestry/unbounded-lcms | /lib/resources_json_importer.rb | UTF-8 | 1,991 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
#
# Import resources from db/data/v1-exports/*.json files
# see more on: https://github.com/learningtapestry/unbounded/issues/953
#
class ResourcesJsonImporter
def initialize(slug)
s, g = slug.split('/')
@params = OpenStruct.new subject: s, grade: g
end
def run
puts "==... | true |
316a1f823d9f76303f770ea75df8d7c7153400eb | Ruby | crmcleod/lab_w2d3 | /specs/pub_spec.rb | UTF-8 | 4,029 | 3.296875 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/reporters')
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
require_relative("../customer")
require_relative("../drinks")
require_relative("../pub")
require_relative("../food")
class TestPub < Minitest::Test
def setup
@drink1 = Drink.new("Beer"... | true |
dc8f4f1af7e6d09da17aa97abed9ffa63502551f | Ruby | VerityA/multiple_classes_lab_work_6thfeb | /bus_stop.rb | UTF-8 | 255 | 3.5 | 4 | [] | no_license | class BusStop
attr_reader :queue
def initialize(name)
@name = name
@queue = []
end
def queue_length
return @queue.length()
end
def add_to_queue(person)
@queue << person
end
def empty_queue
@queue = []
end
end
| true |
204d7e5096bcd0c559b1c46abbae48dbcfd183e5 | Ruby | jenpoole/school-domain-cb-000 | /lib/school.rb | UTF-8 | 2,922 | 4.71875 | 5 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class School
attr_accessor :name, :roster
def initialize(name)
@name = name # initialize with a name
@roster = {} # has an empty roster when initialized. keys will be grade level; values will be an array of student names
end
# add a student to the school by calling the add_student method and giving it... | true |
2abf776eac3b27564547a3fdcde341ee6ded8cb9 | Ruby | kulkarni-rajas/fest-coins | /app/controllers/transcation_controller.rb | UTF-8 | 2,459 | 2.609375 | 3 | [] | no_license | class TranscationController < ApplicationController
def transfer
if params[:email].nil? || params[:email].blank?
flash[:danger] = "No valid destination user"
puts "ERR DEST USER1"
redirect_to root_path
return
end
dest = User.where(email:params[:email]).first
if dest.nil?
... | true |
8ebfbfcbe78d9821b5c42e664441c0d4955843c7 | Ruby | mgsterling11/taxi_fare_app | /app/models/adapters/uber_client.rb | UTF-8 | 928 | 2.703125 | 3 | [] | no_license | module Adapters
class UberClient
def connection
@connection = Adapters::DataConnection.new
end
def build_uber_url(trip)
params = {pickup_latitude: trip.origin.latitude, pickup_longitude: trip.origin.longitude, dropoff_longitude: trip.destination.longitude, dropoff_latitude: trip.destinat... | true |
78185d273f123f1074d7c9daf48de531ae2fa0f1 | Ruby | codingdojoinstructor/coding_11_11_13 | /afternoon_session/ruby/ass-3.rb | UTF-8 | 621 | 3.53125 | 4 | [] | no_license | a = {:first_name => "Michael", :last_name => "Choi"}
b = {:first_name => "John", :last_name => "Supsupin"}
c = {:first_name => "KB", :last_name => "Tonel"}
d = {:first_name => "Mikee", :last_name => "Buyco"}
e = {:first_name => "Diana", :last_name => "Manlulu"}
names = [a, b, c, d, e]
puts %{you have #{names.length} ... | true |
bfc58d585d8a1b7c928ce9a45f9c693b7c923794 | Ruby | pongnguy/bigdata-1 | /scripts/to_gv.rb | UTF-8 | 638 | 2.921875 | 3 | [] | no_license | #! /usr/bin/ruby
require 'json'
def link_all(id, fn, isfwd)
f = open(fn)
entry = JSON.parse(f.gets)
f.close
arrow = (isfwd) ? "->" : "<-"
entry.each do |x|
puts " #{id} -> #{x};"
end
end
print <<EOH
digraph G {
size="8,10.5"
node[shape=circle,width=.04,height=.04,fixedsize=tru... | true |
a259f0003240b689abfab0befdb1250980c2f397 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/1130/source/12983.rb | UTF-8 | 619 | 3.53125 | 4 | [] | no_license |
def combine_anagrams(words)
h = {}
words.each do |single|
downcased=single.downcase();
splited=downcased.split(//);
sorted = splited.sort()
joined = sorted.join();
if(h.has_key?(joined))
h[joined] += [single];
else
h[joined] = [single];
end
end
r = h.flatten;
#print ... | true |
d2d17a9953ed2256659d6f81041edc3db74df878 | Ruby | eitan-spitz/ruby-project-guidelines | /app/models/game.rb | UTF-8 | 6,265 | 2.796875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'ruby2d'
class Game < ActiveRecord::Base
has_many :asteroids
has_many :ships
has_many :users, through: :ships
has_many :highscores
has_many :users, through: :highscores
# attr_accessor :players, :start_timer, :started, :finish_flag
# attr_reader :starting_sound, :music, :game_over_s... | true |
a847913b50b0032f862cbceef63d0a318792183a | Ruby | code-builders/far_mar | /khambro/lib/far_mar/vendor.rb | UTF-8 | 1,317 | 2.78125 | 3 | [] | no_license | class FarMar::Vendor < FarMar::Base
attr_accessor :id, :name, :no_of_employees, :market_id
FILE = ("support/vendors.csv")
def initialize(attrs)
@id= attrs[0].to_i
@name = attrs[1]
@no_of_employees = attrs[2].to_i
@market_id = attrs[3].to_i
end
def market
markets = FarMar::Market.all
all... | true |
512dea2a2541188ec069a0820bc7dd36b2291e79 | Ruby | EdwardAndress/codespy | /spec/mission_spec.rb | UTF-8 | 1,701 | 2.765625 | 3 | [] | no_license | require_relative '../lib/mission.rb'
RSpec.describe Mission do
let(:spyclass) { double 'SpyClass', new: spy }
let(:spy) { double 'Spy', report: {"EdwardAndress" => [40.00, 70.00, 90.00, 100.00]} }
subject do
described_class.new(
targets:[
{id: 'EdwardAndress', start_date: '2015-01-31'},
... | true |
6beacf2ec2541e0754fd84b6798bf8825e22c6c3 | Ruby | kkkraj/ruby-oo-practice-relationships-silicon-valley-exercise-sfo01-seng-ft-042020 | /app/models/startup.rb | UTF-8 | 1,446 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Startup
attr_accessor :name, :domain
attr_reader :founder
@@all = []
def initialize(name, founder, domain)
@name = name
@founder = founder
@domain = domain
@@all << self
end
def self.all
@@all
end
def pivot(new_domain, new_name)
@d... | true |
d61c596df4e8b16a1fd5df17ff0efddc5cf5552f | Ruby | JYip93/chitter-challenge | /spec/unit/peep_spec.rb | UTF-8 | 417 | 2.671875 | 3 | [] | no_license | require 'peep'
describe Peep do
describe '#add' do
it 'Add a peep' do
peep = Peep.add('Hello World')
expect(peep.content).to eq('Hello World')
end
end
describe '#show' do
it 'Return list of peeps when called'do
Peep.add('This is a test peep')
... | true |
fea08159851f8c50d34d6263050f78bf1a230c38 | Ruby | whittlbc/os | /app/services/general_date_formatter_service.rb | UTF-8 | 711 | 3.109375 | 3 | [] | no_license | class GeneralDateFormatterService
attr_reader :date_ago
def initialize(date)
@date = date
end
def perform
min_diff = (Time.now - @date) / 60
if min_diff > 60
hour_diff = min_diff / 60
if hour_diff > 24
day_diff = hour_diff / 24
if day_diff > 365
year_diff = da... | true |
055fe5cce5c7dd4274dbfdbdafc59e1c4d5b7353 | Ruby | mihir787/enigma | /test/rotation_calculator_test.rb | UTF-8 | 1,728 | 2.8125 | 3 | [] | no_license | require_relative 'test_helper'
require_relative '../lib/rotation_calculator'
class RotationCalculatorTest < Minitest::Test
def test_it_exists
rot_calc = RotationCalculator.new
assert rot_calc
end
def test_it_takes_in_key_and_date_offset
date_offset = %w(0 2 3 9)
key = %w(1 8 7 9 4)
rot_calc... | true |
3d790cf2cea0d5e0a2c620592d9222bc356c2707 | Ruby | spdonovan/boris_bikes_challenge_3 | /spec/docking_station_spec.rb | UTF-8 | 1,794 | 3.171875 | 3 | [] | no_license | require "docking_station.rb"
describe DockingStation do
bike = DockingStation.new
it 'DockingStation releases bike' do
expect(bike.respond_to?(:release_bike)).to eq(true)
end
describe '#release_bike' do
it 'raises an error when there are no bikes available' do
# Let's not dock a bike first:
... | true |
fcf7abf0e37005226f5686ceb2651d62921e449b | Ruby | easyhappy/showbuilder | /lib/showbuilder/builders/model_table_row_builder.rb | UTF-8 | 6,749 | 2.65625 | 3 | [] | no_license | require 'showbuilder/builders/template_methods'
require 'showbuilder/i18n_text'
module Showbuilder
module Builders
class ShowModelTableRowBuilder
include Showbuilder::Builders::TemplateMethods
include Showbuilder::I18nText
attr_accessor :is_header
attr_accessor :itext_base
attr_acc... | true |
100834807f9bb01170e2588a89a5184ed70ce39e | Ruby | darnold001/badges-and-schedules-prework | /conference_badges.rb | UTF-8 | 713 | 3.671875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
#presenters = ["Edsger", "Ada", "Charles", "Alan", "Grace", "Linus", "Matz"]
def badge_maker (name)
return "Hello, my name is #{name}."
end
def batch_badge_creator (person)
talkers = []
person.each do |p|
speaker = "Hello, my name is #{p}."
talkers.push(speaker)
#puts speaker
e... | true |
54fc222629562e8b6243f6a5bf86c49c4139f904 | Ruby | Shendidy/dice_app | /spec/dice_spec.rb | UTF-8 | 1,669 | 3.65625 | 4 | [] | no_license | require 'dice'
RSpec.describe Dice do
context "V1.1: Roll a dice" do
dice = Dice.new
it "1. Should respond to .roll" do
# dice = Dice.new
expect(dice).to respond_to :roll
end
it "2. Should return a random number between 1 & 6" do
# dice = Dice.new
expect(dice.roll).to be_betw... | true |
3f7ffbc71395b76ee49330433cebdcbc8a00bfe4 | Ruby | malfix/kata-maxValueSubArray | /exercise.rb | UTF-8 | 596 | 3.703125 | 4 | [] | no_license | class Exercise
def initialize(k)
@k = k
@elements = []
end
def max_length(elements)
max = []
elements.each_with_index do |el, i_el|
(@k-1).downto(0) do |i_k|
current_index = i_el - i_k
if check_lower_bound(current_index) && check_upper_bound(current_index, elements)
... | true |
5c9a72bf625adb94c944858d6f38e799371d75c6 | Ruby | Calvin0125/launch_school_rb101 | /lesson_4/problem_7.rb | UTF-8 | 141 | 2.890625 | 3 | [] | no_license | statement = "The Flintstones Rock"
frequency = statement.chars.each_with_object(Hash.new(0)) { |letter, hash| hash[letter] += 1 }
p frequency | true |
2f45bf856a5a78cad58dbb9b4f00c60764cfbe97 | Ruby | Alex1100/codewars | /ruby/return_two_highest_values_in_list.rb | UTF-8 | 665 | 3.484375 | 3 | [] | no_license | #Refactored
def two_highest(list)
list.class != Array ? false : list.max(2)
end
#Basic
def two_highest(list)
if list.length == 0 then return [] end
if !list.kind_of?(Array) then return false end
list = list.sort.uniq
return list.length > 1 ? [list[-1], list[-2]] : [list.last]
end
#tests
describe "Solution"... | true |
bc18f15bf38b7740b4eb23cb177b070a974cf24f | Ruby | mauricioszabo/random_stuff | /cinemas/buscar_e_salvar.rb | UTF-8 | 1,233 | 2.796875 | 3 | [] | no_license | require 'rubygems'
require 'google_spreadsheet'
require 'yaml'
require 'playarte'
require 'cinemark'
require 'unibanco'
require 'sinopse'
require 'active_support'
config = YAML.load_file('config.yml')
session = GoogleSpreadsheet.login(config['login'], config['senha'])
planilha = session.spreadsheets.find { |x| x.ti... | true |
7077a0fa215c0ab5aa76c1082b7050ad93ecb7a2 | Ruby | xDD-CLE/katas | /trigrams/samjones/rubyOO/spec/rearranger/text_rearranger_spec.rb | UTF-8 | 2,146 | 2.875 | 3 | [] | no_license | require 'rearranger/text_rearranger'
require 'trigramerator/simple_trigramerator'
require 'trigramerator/persisted_trigramerator'
require 'tokenizer/string_tokenizer'
require 'tokenizer/file_tokenizer'
describe "TextRearranger" do
context "when I trigramerate some text" do
it "should be rearranged" do
trigramera... | true |
71071084dac34a4aff8bb26e7b14ca155786c663 | Ruby | HCLarsen/ical_parser | /test/properties/boolean_parser_test.rb | UTF-8 | 502 | 2.671875 | 3 | [
"MIT"
] | permissive | require "test_helper"
class BooleanParserTest < Minitest::Test
include IcalParser
def test_returns_true_for_true_value
string = "TRUE"
assert BooleanParser.parse(string)
end
def test_returns_false_for_false_value
string = "FALSE"
refute BooleanParser.parse(string)
end
def test_raises_for... | true |
1cf7ddef2a290fbc80a78802a61e179b62841e81 | Ruby | albertbahia/wdi_june_2014 | /w02/d02/gadi_gottlieb/class_work/cars/lib/police_car.rb | UTF-8 | 797 | 3.625 | 4 | [] | no_license | class PoliceCar < Car
attr_reader(:arsenal)
def initialize(horsepower, fuel)
@horsepower = horsepower
if fuel > 5
@fuel = 5
elsif fuel < 0
@fuel = 0
else
@fuel = fuel
end
@arsenal = []
end
def add_to_arsenal(weapon)
@arsenal.push(weapon)
end
end
# * Car
# ... | true |
de5c9ca37510525d869d79db0518e3853cbbc85d | Ruby | melvincruz/learning | /print_evens.rb | UTF-8 | 46 | 3.3125 | 3 | [] | no_license | for x in (1..10)
if x%2 ==0
puts x
end
end | true |
c60a946408e739852d69817204ac8fa902d16012 | Ruby | rlavang/launch-school | /101-programming-foundations/small_problems/medium_1_6.rb | UTF-8 | 612 | 3.59375 | 4 | [] | no_license | NUMBERS = {'one' => 1, 'two'=> 2, 'three' => 3, 'four' => 4, 'five' => 5, 'six' => 6, 'seven' => 7, 'eight' => 8, 'nine' => 9}
def word_to_digit(phrase)
rephrase = phrase.split(' ').map do |word|
if NUMBERS[word]
NUMBERS[word].to_s
else
word
end
end
rephrase.join(' ')
end
def word_to_digi... | true |
9894334781632e9c9e0025c2db190d5faacecdf3 | Ruby | meganii/ruby-playground | /get-stock-list-from-xls/readear.rb | UTF-8 | 405 | 2.71875 | 3 | [] | no_license | require 'json'
require 'spreadsheet'
book = Spreadsheet.open('data_j.xls')
sheet = book.worksheet('Sheet1')
stock = {}
sheet.each do |row|
stock[row[1].to_i] = {
'code' => row[1].to_i,
'name' => row[2],
'category' => row[3],
'industry_code' => row[4],
'industry_classification' => row[5]
}
end
... | true |
a11c1949d9fb314f5d68bf98bcd236ad4d49d914 | Ruby | Kphillycat/pokemon | /lib/Jynx.rb | UTF-8 | 718 | 3.375 | 3 | [] | no_license | class Jynx
attr_accessor :type, :abilities, :catch_rate, :entry, :hp, :level, :exp
def initialize
@level = 0
@catch_rate = .059
@entry = "It seductively wiggles its hips as it walks. It can cause people to dance in unison with it."
@hp = 65
@exp = 159
@type = ["Ice", "Psychic"]
@ability = ["Oblivious ... | true |
d1f7b4cb7392d8aa6bb517c3bf2778782985e6de | Ruby | ErikSchierboom/exercism | /ruby/all-your-base/all_your_base.rb | UTF-8 | 778 | 3.5 | 4 | [
"Apache-2.0"
] | permissive | module BaseConverter
def self.convert(input_base, digits, output_base)
raise ArgumentError if input_base < 2 || output_base < 2
return [0] unless digits.any?(&:positive?)
from_decimal(output_base, to_decimal(input_base, digits.drop_while(&:zero?)))
end
def self.to_decimal(from_base, digits)
dig... | true |
ce2c4b57d7a3c715cd52323674c7c44b458321b9 | Ruby | appriss/labrea | /rubygem/lib/labrea.rb | UTF-8 | 3,346 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | require 'rubygems'
require 'bundler/setup'
require 'digest/sha1'
require 'json'
class Labrea
# Class initialization
def initialize(filename, install_dir, opts)
@filename = filename
@install_dir = install_dir
@exclude = exclude
@working_dir = Dir.pwd()
@changeset = Array.new
defaults = ... | true |
9ae9cc8546f6d125a64d273a83e2ebb8562afc81 | Ruby | CodeCoreYVR/oct-2015-ruby-and-html | /day_2/hash_iteration.rb | UTF-8 | 141 | 3.015625 | 3 | [] | no_license | cars = {"Nissan" => "Ultima", "Toyota" => "Corolla", "Dodge" => "Caravan"}
cars.each do |brand, model|
puts "#{brand} makes #{model}"
end
| true |
a700da109b4e79f764031c6c6165ef2d6bf5dcb5 | Ruby | marczych/sudoku | /tests/solver_test.rb | UTF-8 | 1,490 | 2.78125 | 3 | [] | no_license | require 'test/unit'
require_relative '../src/sudoku/brute_force_strategy.rb'
require_relative '../src/sudoku/hidden_singles_strategy.rb'
require_relative '../src/sudoku/locked_candidates_strategy.rb'
require_relative '../src/sudoku/singles_strategy.rb'
require_relative '../src/sudoku/solver.rb'
class SolverTest < Test... | true |
b7e2fca6ed27f051396faf0715e3805c94b9d956 | Ruby | petrgazarov/keyword-crawler | /lib/website_parser.rb | UTF-8 | 1,462 | 2.96875 | 3 | [
"MIT"
] | permissive | require 'nokogiri'
require 'active_support'
require 'active_support/core_ext'
class WebsiteParser
# keywords to scan websites for
KEYWORDS = [
'search',
'privacy',
'terms',
'about',
'github'
]
attr_accessor :status, :keywords
def self.parse(html:, url_address:)
new(html: html, url_a... | true |
13b9e42792931df2656d6334b5dd42234c8c831d | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/luhn/44e9295d93bb460dadbda8b915c19ec3.rb | UTF-8 | 630 | 3.65625 | 4 | [] | no_license | class Luhn
def initialize(num)
@arr = num.to_s.split('').map { |c| c.to_i }
end
def addends
@arr.reverse!.each_with_index do |digit, index|
@arr[index] = digit * 2 if index.odd?
@arr[index] = @arr[index] - 9 if @arr[index] >= 10
end
@arr.reverse!
end
def checksum
sum = 0
... | true |
52c32d10a6bb8413e5dd309503046d04e7a9b4cc | Ruby | magomi/twavs | /lib/twavs.rb | UTF-8 | 1,634 | 2.984375 | 3 | [] | no_license | require 'oauth'
require 'json'
require 'date'
class Twavs
attr_accessor :year, :mon, :screen_name, :favs, :oauth_token, :oauth_token_secret
# Exchange your oauth_token and oauth_token_secret for an AccessToken instance.
def prepare_access_token(oauth_token, oauth_token_secret)
consumer = OAuth::Consumer.ne... | true |
8ea11be8f64d77cd4d8869360d092ee8803e2169 | Ruby | eicca/rtf-templater | /showcase/showcase.rb | UTF-8 | 942 | 2.515625 | 3 | [
"MIT"
] | permissive | $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
require 'rtf-templater'
class Showcase
include RtfTemplater::Generator
Person = Struct.new(:name, :items)
Item = Struct.new(:name, :usage)
def generate_showcase
@title = 'Serenity inventory'
mals_items = [Item.new('Moses Brothers Self-Defen... | true |
91e5652f49489554435d9f0a391bba883c7fc61a | Ruby | matthewford/dm-forum-slice | /app/models/forum.rb | UTF-8 | 1,086 | 2.515625 | 3 | [
"MIT"
] | permissive | class Forum
include DataMapper::Resource
property :slug, String, :key => true
property :title, String
property :description, Text
property :description_html, Text
property :position, Integer
property :created_at, DateTime
property :updated_at, DateTime
has n, :discussions
# belongs_to :user
... | true |
9adc15633a8e78daaf26aae55c03d105d3b722d9 | Ruby | michellejanosi/programming-with-ruby | /flow_control/all_caps.rb | UTF-8 | 358 | 4.4375 | 4 | [] | no_license | # Write a method that takes a string as argument. The method should return the
# all-caps version of the string, only if the string is longer than 10
# characters. Example: change "hello world" to "HELLO WORLD".
def all_caps(str)
if str.length > 10
str.upcase
else
str
end
end
puts all_caps("Hey there br... | true |
9949bb7e1e22be6a6e992e4f38173064bc3632bb | Ruby | nrgamble/goals | /app/models/goal.rb | UTF-8 | 1,971 | 2.53125 | 3 | [] | no_license | class Goal < ActiveRecord::Base
# The events and their values accumulated for this goal
has_many :progress, class_name: 'Progress', inverse_of: :goal
# The goals which need to be completed for this goal to be available
has_many :goal_deps
has_many :deps, through: :goal_deps, source: :dep
# The goals wh... | true |
af02db82aa11d3bbac0e2849c3c33226c9016410 | Ruby | JasonGL123/my-dcoder-solutions | /Easy/exponentia.rb | UTF-8 | 198 | 2.9375 | 3 | [] | no_license | # Pass 3/4
# If anyone known how to fix this, please send me pull request! Thanks!
puts ((a = gets.to_i) >= 0? [*(0..a)] : [*(0.downto(a))]).map{|n|2**n}.map{|n| n < 1? '%.15f'%n.to_f : n}.join(",") | true |
d1d2ac8a9618bcd628fcc5059e2fd1bf0335c1b3 | Ruby | katepdonahue/Arp_Larpang | /spec.rb | UTF-8 | 1,165 | 3.46875 | 3 | [] | no_license | require './arp_larpang'
describe String do
describe "#arp" do
it "should insert an arp between a consonant and a set of vowels" do
expect("Sarah".arp).to eq("Sarpararpah")
# expect("Kate".arp).to eq("Karpate")
end
end
describe "#pig_latin" do
it "should take the first consonant off... | true |
3fb3f472a87094af376c7ae0b604d2454e2a325b | Ruby | corinnekunze/csv_stat_parser | /lib/csv_stat_parser/record.rb | UTF-8 | 639 | 2.859375 | 3 | [
"MIT"
] | permissive | module CsvStatParser
class Record
def initialize(data, id)
# Adds record_id to beginning of data set
@data = id_hash(id).merge(data)
assign_attributes
end
def set(attribute, value)
instance_variable_set("@#{attribute}", value)
end
private
# Set attr_acessor sets gett... | true |
1c15e504fa8a1e1a35a22dac1ec03b2e5da7798e | Ruby | scupoflo/learn-co-sandbox | /hello.rb | UTF-8 | 350 | 3.203125 | 3 | [] | no_license | puts "Hello, Flatiron Programming Fasttrack!"
# print out a welcome message
# it should appear on multiple lines
# it should have your name, where you are from, and a short greeting
puts "My name is Shinik and I'm from South Florida."
puts "I'm super excited that this can be a new career that will allow me to travel an... | true |
b6678a472f8f2f3261f779940eef0f37d6da359e | Ruby | r-craig73/twg_rubyist | /ch02/ticket_using_send_method.rb | UTF-8 | 479 | 3.546875 | 4 | [
"MIT"
] | permissive | # ticket object and sending messages using the send method
ticket = Object.new
def ticket.date
'01/02/03'
end
def ticket.venue
'Town Hall'
end
def ticket.event
"Author's reading"
end
def ticket.performer
'Mark Twain'
end
def ticket.seat
'Second Balcony, row J, seat 12'
end
def ticket.price
5.50
end
... | true |
137582fc7a232036789c2d8e03d1c2375b81fc33 | Ruby | nome/ruby-cells | /model-view.rb | UTF-8 | 1,635 | 2.734375 | 3 | [
"MIT"
] | permissive | $:.unshift '.'
require 'cells'
require 'Qt4'
class Object
include Cells
end
# A simple model class.
# Imagine some interesting domain logic here.
class Model
cell :name, :email, :role
def initialize
self.role = :name_only
self.name = "Your Name"
self.email = "user@example.com"
end
end
# A simple view to ma... | true |
8b02a486835e89c5f8617eb815668b16b5319d2f | Ruby | gioevan/DemoApp | /script/hello_world.rb | UTF-8 | 82 | 3.34375 | 3 | [] | no_license | puts "Hello"
message = if true
"Hello Again"
else
"Shalom!"
end
puts message | true |
9718122c6fd2b3dcb67cd54bffe07d5439194ccd | Ruby | knoaman/test | /flow_control/all-caps.rb | UTF-8 | 175 | 4.09375 | 4 | [] | no_license | # all-caps.rb
def all_caps(words)
words.length > 10 ? words.upcase : words
end
def get_words()
puts "Enter a short sentence"
gets.chomp
end
puts all_caps(get_words()) | true |
8da53842460b778f2d9fe9ae1be6bd4a0b6b10ea | Ruby | davidjoserodriguez/aa_classwork | /Exercises/WEEK4/w4d5/execution_time.rb | UTF-8 | 1,275 | 3.9375 | 4 | [] | no_license | require 'byebug'
#PHASE I
def my_min(arr)
sorted = false
until sorted
sorted = true
(0...arr.length - 1).each do |i|
if arr[i] > arr[i+1]
sorted = false
arr[i], arr[i+1] = arr[i+1], arr[1]
end
end
end
arr.first
end
# PHASE II
# def my_min(arr)
# smallest = arr[0]
#... | true |
736ba332653ffd9c71da6f8d9cdd7261c0e6a67e | Ruby | pmacaluso3/espark_challenge | /lib/learning_path_manager.rb | UTF-8 | 768 | 2.828125 | 3 | [] | no_license | class LearningPathManager
attr_reader :student_test_filename, :domain_order_filename
def initialize(student_test_filename, domain_order_filename)
@student_test_filename = student_test_filename
@domain_order_filename = domain_order_filename
end
def student_scores
@student_scores ||= if student_test... | true |
68e4faf50c1402e5b439087a39c367c62870e517 | Ruby | Anhmike/mikon | /spec/core/dataframe_spec.rb | UTF-8 | 5,648 | 3 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Mikon::DataFrame do
before(:each) do
@df = Mikon::DataFrame.new([{a: 1, b: 5}, {a: 2, b: 2}, {a: 3, b: 4}])
end
context ".new" do
{
hash_in_array: [{a: 1, b: 2}, {a: 2, b: 3}, {a: 3, b: 4}],
darray_in_array: [[1, 2, 3], [2, 3, 4]].map{|column| Mikon::DArray.new... | true |
ce88e2e6b39089de02f9512c1abb22b4e491c584 | Ruby | yielding/code | /0.education/sum_mean.rb | UTF-8 | 242 | 3.1875 | 3 | [] | no_license | #!/usr/bin/env ruby -wKU
class Array
def sum
reduce(0.0, :+)
end
def mean
sum / size
end
end
arr = []
10.times {
arr << Random.rand(100)
puts "arr: #{arr.to_s}"
printf "sum: %d\navr: %5.2f\n", arr.sum, arr.mean
}
| true |
a6252c26c3091a3c4de1a22ae8a59a676c0c2295 | Ruby | co2co2/rocket | /rocket_test.rb | UTF-8 | 1,539 | 3 | 3 | [] | no_license | require "minitest/autorun"
require_relative "rocket"
class RocketTest < Minitest::Test
# Write your tests here!
def setup
@rocket = Rocket.new
end
def test_initialize_name_option
@rocket = Rocket.new(name: "coco")
assert_equal "coco" , @rocket.name
end
def test_initialize_name_random
rand... | true |
3b886367edb599c0edfb02243de430561785fc69 | Ruby | olssonr/advent-of-code-2020 | /day3.rb | UTF-8 | 1,607 | 3.59375 | 4 | [] | no_license | # frozen_string_literal: true
# Class for storing and checking positions on the map
class Map
attr_reader :map, :column_length, :row_length
def initialize(rows:)
@rows = rows
@row_length = @rows[0].length
@column_length = @rows.length
end
def get_position(x_coordinate:, y_coordinate:)
repeate... | true |
cf11d12e875cc759dd43a25c5c75f0d1559f9cfb | Ruby | mokagio/tech-debt-collector | /spec/tech_debt_collector_spec.rb | UTF-8 | 3,551 | 2.59375 | 3 | [] | no_license | require "spec_helper"
describe TechDebtCollector do
it "has a version number" do
expect(TechDebtCollector::VERSION).not_to be nil
end
describe 'collect_file_paths' do
it 'returns all the files matching the given path' do
files = TechDebtCollector::collect_file_paths('./spec/fixtures/*.rb')
e... | true |
fc0fc0ce329576a5f29257234097b67e9f3325d4 | Ruby | nareshnavinash/rest-api-automation-framework-ruby | /libraries/config.rb | UTF-8 | 1,032 | 2.515625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'yaml'
module Libraries
# All the methods under this config class are class methods
# This gives us flexibility in fethching the values directly across the framework
class Config
# To parse and read the run config files
# Files will be parsed only once irrespective ... | true |
7544e3e14337beea7d52c1be97f2eeb3d63b354e | Ruby | CodeCoreYVR/april_2015_fundamentals | /day_2_ruby/var_multiply.rb | UTF-8 | 173 | 3.28125 | 3 | [] | no_license | def multiply(*b)
result = 1
b.each {|x| result *= x }
result
end
puts multiply(3, 4, 5, 5,5 ,5 ,5 ,5)
puts multiply(3, 4)
puts multiply(3, 4, 12, 14)
puts multiply()
| true |
39c7eda64d8bd6e6be3d0c3c2b0f96dfbd7300b9 | Ruby | AfonsoTsukamoto/football_api | /lib/football_api/mixins/symbolizer.rb | UTF-8 | 1,604 | 3.078125 | 3 | [
"MIT"
] | permissive | module FootballApi
module Symbolizer
def self.included(base)
base.extend(ClassMethods)
end
HASH_OR_ARRAY_KEYS = [:player, :substitution, :comment, :match_events].freeze
module ClassMethods
# Custom deep symbolize of an hash
# So we can override the mess of some footbal-api arrays
... | true |
60787d1d67e9c4ac761bdc3258e3db2a253acecf | Ruby | jerryzlau/july_cohort | /w2d1/chess/board.rb | UTF-8 | 989 | 3.578125 | 4 | [] | no_license | require_relative 'piece.rb'
require 'colorize'
require_relative 'display'
class Board
attr_reader :grid
def initialize
@grid = initialize_grid
end
def initialize_grid(type = :standard)
null_piece = NullPiece.instance
if type == :standard
grid = Array.new(8) {Array.new(8) {null_piece}}
... | true |
8d7d241a762eda821c627957f064c69b899b22b6 | Ruby | web-ascender/serp-tracker | /spec/requests/page_urls_spec.rb | UTF-8 | 2,470 | 2.578125 | 3 | [] | no_license | require 'spec_helper'
describe "PageUrls" do
describe "set page and path" do
it "path equals /about/company" do
p = Page.new
p.url = "https://localhost:3000/about/company"
p.path == "/about/company" ? true : raise('about/company not found')
end
it "path equals /about/company.aspx" do... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.