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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
28de3efc3989bc5995021027e707c9bb52d717d9 | Ruby | mongodb/mongoid | /lib/mongoid/extensions/binary.rb | UTF-8 | 1,196 | 2.890625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# rubocop:todo all
module Mongoid
module Extensions
# Adds type-casting behavior to BSON::Binary class.
module Binary
# Turn the object from the ruby type we deal with to a Mongo friendly
# type.
#
# @example Mongoize the object.
# object.mongoi... | true |
03cd277508c6f926e933a98b8af30e7302f9ef5b | Ruby | simplay/daily_quests | /src/quest.rb | UTF-8 | 1,058 | 2.796875 | 3 | [
"MIT"
] | permissive | # == Schema Information
#
# Table name: quests
#
# id :integer not null, primary key
# title :string
# description :string
# due :datetime
# finished :boolean
# created_at :datetime not null
# updated_at :datetime not null
#
# A Quest models a task which shou... | true |
6017b79452ab10f14ba39007f6588b48671ea0e5 | Ruby | mellejwz/ruby-opdrachten | /10.2.rb | UTF-8 | 425 | 3.625 | 4 | [] | no_license | system('clear')
system('cls')
word = nil
words_unsorted = []
words_sorted = []
puts 'Type some words and press enter after each one,'
puts 'press enter without entering a word to continue.'
puts
while word != ''
word = gets.chomp
words_unsorted.push word
end
words_unsorted.delete('')
while words_unsorted.length>... | true |
12ddda485963d9d30036b38129fa53d9369f130b | Ruby | qqlive/rails-api | /lib/json_web_token.rb | UTF-8 | 598 | 2.59375 | 3 | [
"MIT"
] | permissive | class JsonWebToken
SECRET_KEY = Rails.application.credentials.secret_key_base.to_s
def self.encode(payload, exp = 24.hours.from_now)
payload[:exp] = exp.to_i
JWT.encode(payload, SECRET_KEY)
end
def self.decode(token)
decoded = JWT.decode(token, SECRET_KEY).first
HashWithIndifferentAccess.new decoded
end
... | true |
5ca638618ba12ec969cd2a02b6ff61c6f29beaca | Ruby | thesedatedprince/learn-to-program | /chap07/ex6_AFewThingsToTryDeafGrandma.rb | UTF-8 | 250 | 3.703125 | 4 | [] | no_license | puts "Speak to grandma!"
while true
year = (1950 + rand(30)).to_s
speech = gets.chomp
if speech != speech.upcase
puts "HUH?! SPEAK UP, SONNY!"
elsif speech == speech.upcase && speech == 'BYE'
break
else
puts 'NO, NOT SINCE ' + year
end
end | true |
514f4051c5d6f6524c9ed7773ab8f543a2e64708 | Ruby | ulices/algorithms | /binary_tree/binary_tree_test.rb | UTF-8 | 4,317 | 3.375 | 3 | [] | no_license | require 'minitest/autorun'
require './binary_tree'
describe BinaryTree do
def populate_tree(values)
values.each{|value| @binary_tree.add(value) }
end
before do
@binary_tree = BinaryTree.new()
end
describe "When binary tree is empty" do
it "must add a new node as head" do
@binary_tree.add... | true |
df5d97540d652257ebfb9d9ada351c14e30f78c3 | Ruby | SeattleSlough/ruby-boating-school-seattle-web-060319 | /app/models/boatingtest.rb | UTF-8 | 270 | 2.84375 | 3 | [] | no_license | class BoatingTest
attr_accessor :student, :test, :status, :instructor
@@all = []
def initialize(student, test, status, instructor)
@student = student
@test = test
@status = status
@instructor = instructor
@@all.push(self)
end
def self.all
@@all
end
end
| true |
a6dd7e0269c6daf55afa7796b69bd0c2dff7e5cf | Ruby | justonemorecommit/puppet | /lib/puppet/pops/model/model_tree_dumper.rb | UTF-8 | 10,557 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | # Dumps a Pops::Model in reverse polish notation; i.e. LISP style
# The intention is to use this for debugging output
# TODO: BAD NAME - A DUMP is a Ruby Serialization
#
class Puppet::Pops::Model::ModelTreeDumper < Puppet::Pops::Model::TreeDumper
def dump_Array o
o.collect {|e| do_dump(e) }
end
def dump_Lite... | true |
f6b688ff1f6d4e4dd30ce438c05786ebf771e4c2 | Ruby | anthonymjimenez/ruby-oo-object-relationships-collaborating-objects-lab | /lib/mp3_importer.rb | UTF-8 | 293 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MP3Importer
attr_accessor :path
@@all = []
def initialize(file_path)
@path = file_path
@@all.push(self)
end
def files
Dir.children(@path)
end
def import
files.map { |element| Song.new_by_filename(element)}
end
end | true |
434d774ac6c3b86f9cb0a512c8cf31efde4158ff | Ruby | avjohnston/rails-engine | /spec/models/merchant_spec.rb | UTF-8 | 3,040 | 2.625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Merchant, type: :model do
describe 'relationships' do
it { should have_many(:items) }
it { should have_many(:invoice_items).through(:items) }
it { should have_many(:invoices).through(:invoice_items) }
it { should have_many(:customers).through(:invoices) }
it ... | true |
3b468c3528cda80c5f98d0dc0dcf27822415ee6a | Ruby | vishnugopal/colloquy | /lib/colloquy/paginator/menu.rb | UTF-8 | 2,456 | 2.625 | 3 | [] | no_license |
module Colloquy::Paginator::Menu
private
def paginate
assemble unless @assembled_strings
@pages = []
if @assembled_strings.join("\n").length + (3 * @assembled_strings.length) < allowed_menu_length(:without_more => true)
@pages << @keys.compact
else
accumulator = []
accumulat... | true |
c9808e101659d27cc0e115c8843578ed43f64f47 | Ruby | AlexTheKing/digital-hospital | /app/models/patient_info.rb | UTF-8 | 451 | 2.671875 | 3 | [] | no_license | class PatientInfo < ApplicationRecord
def has_nil?
self[:birthday].nil? or self[:address].nil?
end
def error_messages
messages = []
if self[:birthday].nil?
messages += ["Date of birth"]
end
if self[:address].nil?
messages += ["Address"]
end
messages
end
def get_title(... | true |
4ce3c36c6f0135ebcac0d4b0280182403562eb15 | Ruby | axenictech/ruby-programming | /kanishk4/29_july/swapping.rb | UTF-8 | 308 | 3.296875 | 3 | [] | no_license | def swap
puts "\nEnter the first digit: "
k=gets.to_i
puts "Enter the second digit No: "
p=gets.to_i
puts "\n these is Before swaping"
puts "first no. #{k}"
puts "second no. #{p}"
k= k+p
p= k-p
k= k-p
puts "\n these is After swaping"
puts "first no. #{k}"
puts "second no. #{p}"
end
swap | true |
bfa804473f741d71bed27686184e60b773f7bf01 | Ruby | aaduru/technical_interview_problems | /3sum_closest.rb | UTF-8 | 1,155 | 3.59375 | 4 | [] | no_license | # Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution
def three_sum_closest(nums, target)
result_array = {}
i = 0
while i < (nums.length - 2)
... | true |
043acb510471dcba08fd7e93665ab2c2ba811f9f | Ruby | MarlonnCarvalhosa/teste-e-qualidade-de-software | /#7 contagem_palavras/2019-2/Marlonn/marlonn.rb | UTF-8 | 307 | 3.1875 | 3 | [] | no_license | class Frase
def initialize(palavras)
@palavras = frase
end
def contar_palavra
contar = Hash.new(0)
filtrar_palavras.split.each {
|palavra| contador[palavra] += 1
}
return contar
end
def filtro_palavras
@palavras.downcase.gsub(/[^a-z0-9]/, ' ')
end
end
| true |
ede71d5fc3ac3838e4f03c3ed4fc0cc06cc8e68d | Ruby | Lindsay-c-Dennis/intro-to-tdd-rspec-and-learn-bootcamp-prep-000 | /current_age_for_birth_year.rb | UTF-8 | 103 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def current_age_for_birth_year(birth_year)
age_of_person = 2003-birth_year
return age_of_person
end | true |
e9173797699c1a84cf52a94c102a764681b27974 | Ruby | jessethebuilder/farm_slugs | /spec/lib/farm_slug_spec.rb | UTF-8 | 5,104 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe 'FarmSlugs' do
#FarmSlugs is provided through a monkey patch on ActiveRecord::Base
let(:fso){ FactoryGirl.build :farm_slug_object }
let(:fso_alt){ FactoryGirl.build :farm_slug_object_alt }
describe '#use_farm_slugs' do
describe 'Validations' do
# it 'should validate p... | true |
f1b9acac68c6184b2c10ad2373707872369f60f0 | Ruby | skobaken7/mp3tag | /lib/mp3tag/music_info.rb | UTF-8 | 431 | 2.65625 | 3 | [] | no_license | module Mp3tag
module MusicInfo
VARIOUS_ARTISTS = "VariousArtists"
UNKNOWN = "Unkown"
def children
nil
end
def artist
if children.nil?
UNKNOWN
else
artists = children.map{|a| a.artist}.uniq
if artists.size == 0
UNKNOWN
elsif artists... | true |
3c33ea00abf8a68510cb475b5c6ff46390ba24cc | Ruby | reidjs/week1 | /w1d1/eightqueens.rb | UTF-8 | 4,278 | 3.703125 | 4 | [] | no_license | require 'byebug'
require_relative 'chessboard'
'''
8 queens and 8 rows means there MUST be one queen on every row and every column. If
1. Place a queen at a starting position
This blocks off the rows and columns associated with that starting position so the field of possibilities is smaller
2. Go to the next row
3. Tr... | true |
9ec340ba1a7f58bbba98825bf6d7fe36f33d8362 | Ruby | Ramaze/ramaze | /lib/ramaze/helper/auth.rb | UTF-8 | 3,494 | 2.71875 | 3 | [
"MIT"
] | permissive | # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the MIT license.
module Ramaze
module Helper
##
# The Auth helper can be used for authentication without using a model.
# This can be useful when working with very basic appl... | true |
facd85dd76d69446581fb44efbf8ac26f309694c | Ruby | chad/rubinius | /spec/subtend/class_spec.rb | UTF-8 | 1,962 | 2.828125 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../spec_helper'
require File.dirname(__FILE__) + '/subtend_helper'
compile_extension('subtend_class')
require File.dirname(__FILE__) + '/ext/subtend_class'
module SubtendModuleTest
def im_included
"YEP"
end
end
class SubtendClassTest
attr_reader :foo
def initialize(v)
... | true |
733e5e8dd8523412fb06138fe0651b4de64c8f27 | Ruby | LaZlat/RoR | /rectangle_zemaitis/test_rectangle.rb | UTF-8 | 1,031 | 2.6875 | 3 | [] | no_license | # frozen_string_literal: true
require 'test/unit'
require_relative 'rectangle.rb'
# pagrindine testavimo clase
class TestAdd < Test::Unit::TestCase
# inicializuojame staciakampio klase kuria naudosime visiem testam
def setup
@rect = Rectangle.new(10, 10, 0, 0)
end
# testuojame staciakampio ploto skaiciav... | true |
94cc0bfe904270c75fd75cdf2310c668096ab5ae | Ruby | vilelajonas/launch_school | /programming_foundations/lesson_3/easy_3/6.rb | UTF-8 | 294 | 3.5625 | 4 | [] | no_license | # Question 6
# Back in the stone age (before CSS) we used spaces to align things on
# the screen. If we had a 40 character wide table of Flintstone family
# members, how could we easily center that title above the table
# with spaces?
title = "Flintstone Family Members"
p title.center(40) | true |
b8b7729a6c790f2fc88a5c89feb15ebaf84bb24e | Ruby | Bumsuk/MyRubyBase | /09-006-instance_eval.rb | UTF-8 | 437 | 3.203125 | 3 | [] | no_license | class CybernatedAndroid
def initialize(name) @name = name end
end
proc = Proc.new {
p self
p @name
}
proc.call
#=> main: procの本来のself
# nil: インスタンス変数
dicey = CybernatedAndroid.new("dicey1")
dicey.instance_eval(&proc)
#=> #<CybernatedAndroid:0x29108 ...>: selfをすり替えてブロックを評価
# "dicey1" ... | true |
dc4fec48554ed659cd63aeb1f011b5f08870ba76 | Ruby | Y-Zett/SecondTest | /Threeruby/Trash.rb | UTF-8 | 1,261 | 2.96875 | 3 | [] | no_license | data = gets.chomp.split.map(&:to_i)
n = data[0], k = data[1]
Arr = gets.chomp.split.map(&:to_i)
Arr.sort!
leftBorder = 0
rightBorder = Arr.length - 1
lastElem = Arr[rightBorder]
lastMinus = lastElem < 0
multiplication = 1
if k % 2 == 1
if lastElem > 0
multiplication *= lastElem
rightBorder -= 1
k -= 1
... | true |
524c729c9f4e4c71813e922b7c79c7b5f143ecfd | Ruby | ianvermeulen/goatbot | /picturebot.rb | UTF-8 | 542 | 2.78125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
require_relative 'imessage.rb'
include IMessage
options = {}
OptionParser.new do |opts|
opts.on("--noun NOUN", "noun to search for, can be multiple words") { |noun| options[:noun] = noun }
opts.on("--adjectives ADJECTIVE", Array, "adjectives to search for") { |adjectives| opt... | true |
a6b28590d44e5b6ee9145eedec757b3cab8a1f8c | Ruby | skmichaelson/fitnessapp | /app/models/goal.rb | UTF-8 | 2,064 | 2.828125 | 3 | [] | no_license | class Goal < ActiveRecord::Base
ACTIVITY_MULTIPLIERS = {
0 => 1.2,
1 => 1.375,
2 => 1.725,
3 => 1.9
}
attr_accessible :user_id,
:bmr,
:calorie_goal,
:fat_ratio,
:carb_ratio,
:protein_ratio,
... | true |
2a12b3b25d5ecf00459679421fb8f229a2e7d218 | Ruby | Ckimnay/lib | /01_pyramids.rb | UTF-8 | 510 | 3.25 | 3 | [] | no_license | def half_pyramid
puts "Salut, bienvenue dans ma super pyramide ! Combien d'étages veux-tu? "
print ">"
floor = gets.chomp.to_i
if ((1 <= floor)) && (floor <= 25)) then
(1..level).each do |i|
(level -i).times do
print " "
end
i.times do
print "#"
end
puts "#"
end
else
puts "choisis un nombre entre 1 et ... | true |
1d82d18a7cb1f61ea5c9648f81979c571c12f92d | Ruby | cwhitey/ruby-robot | /spec/table_spec.rb | UTF-8 | 831 | 2.90625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require_relative '../lib/coordinate.rb'
describe Table do
let(:robot_table) { Table.new(4, 4) }
describe "#on_top?" do
context "on the table" do
it "returns true for coordinates on the table" do
expect(robot_table.on_top?(Coordinate.new(0,0))).to be true
expect(robo... | true |
b05619852bc48f538332f1a08bfc4b3c1db280e3 | Ruby | nathilen/slug | /lib/slug.rb | UTF-8 | 283 | 3 | 3 | [] | no_license | class Slug
def initialize(text)
@text = text
end
def transformed
replacements = {' ' => '/\s{2,}/', '-' => '/\s/', '' => '/[^a-z\d+-]/'}
slug = @text.downcase
replacements.each_pair do |key, value|
slug.gsub!(eval(value), key)
end
slug
end
end
| true |
c38a9a7d28508005dd7f36b6db1c743766136166 | Ruby | hoardhq/hoard-app | /lib/hql/query.rb | UTF-8 | 1,618 | 2.78125 | 3 | [] | no_license | module HQL
class Query
def initialize(query_string)
@query_string = query_string || ""
@pairs = {}
end
def valid?
build
@pairs.length > 0
end
def uuid
Digest::SHA1.hexdigest(canonical)[0..15] if canonical
end
def to_sql
return nil unless valid?
... | true |
c0e819f2438564691ac80b99e1f832005474db03 | Ruby | maiya777/playlister-rb-001 | /lib/artist.rb | UTF-8 | 408 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Artist
attr_accessor :name, :songs
Artists = []
def initialize
@songs = []
@genres = []
Artists << self
end
def add_song (song)
self.songs << song
song.artist = self
end
def genres
@songs.each {|song| @genres << song.genre unless @genres.include?(song.genre)}
@genres
end
def self.reset_artists
... | true |
b5bf04d454539613f8dceb3058b057cf45a146f3 | Ruby | tk0358/nattoku_alogorithm | /04-01_sum.rb | UTF-8 | 98 | 3.140625 | 3 | [] | no_license | def sum(ary)
if ary.size == 0
0
else
ary.shift + sum(ary)
end
end
p sum([2, 4, 6])
| true |
08ce965731057ac1e932f8a5e0876c7225afcd75 | Ruby | varsitytutors/makara | /lib/makara/context.rb | UTF-8 | 2,415 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'digest/md5'
# Keeps track of the current and previous context (hexdigests)
# If a new context is needed it can be generated via Makara::Context.generate
module Makara
class Context
class << self
def generate(seed = nil)
seed ||= "#{Time.now.to_i}#{Thread.current.object_id}#{rand(99999)}"... | true |
2f2e7ef2d7e7b09b44d1e9352479fb7b281d5061 | Ruby | NegativeKarma/basic_ruby | /my_group.rb | UTF-8 | 1,378 | 3.390625 | 3 | [] | no_license | my_group = []
person_1 = { name: 'Bob', gender: 'm', age: 24 }
person_2 = { name: 'Lucy', gender: 'f', age: 32 }
person_3 = { name: 'Ken', gender: 'm', age: 64 }
my_group = %w[Bob Lucy Ken]
my_group = [person_1, person_2, person_3]
names.each do |name|
puts name.to_s
end
my_group = []
person_1 = { name: 'Bob'... | true |
19a59d7d445a555148d75a72664871ef6161619d | Ruby | Linzeur/codeable-exercises | /week-3/day-2/cristian-granda/highscore_table.rb | UTF-8 | 638 | 3.421875 | 3 | [] | no_license | class HighScoreTable
def initialize(table_length)
@table_length = table_length
@highscore_table = []
@highscore
end
def scores
@highscore_table
end
def update(num)
@highscore_table << num
@highscore_table = @highscore_table.sort.reverse
p @highscore_table
if @highscore_ta... | true |
de7db81718d4c27aba521865e97e99e91acbb7ee | Ruby | fh-salzburg/mmtm-cd-phone-normalizer | /phone_number.rb | UTF-8 | 126 | 2.796875 | 3 | [] | no_license | class PhoneNumber
def initialize(number)
@number = number
end
def normalized
@number.gsub(/\D+/, "")
end
end
| true |
6490a70865dd5963559e07d0098a3311f0111f63 | Ruby | mberrueta/uade_sem_int_tpo | /app/models/course.rb | UTF-8 | 701 | 2.609375 | 3 | [] | no_license | class Course < ApplicationRecord
SHIFTS = %w[morning evening night].freeze
validates :name, :max_students, presence: true
validate :valid_shift
belongs_to :academic_calendar
belongs_to :manager, optional: true
has_many :subjects, dependent: :destroy
has_many :students
has_many :attendances, dependent:... | true |
c4bed880f9c4faf662cd0b7674361f445965b156 | Ruby | Colin-Suckow/bend-bike-shop | /bicycle.rb | UTF-8 | 121 | 2.5625 | 3 | [] | no_license | class Bicycle
include Rentable
TYPES = [:mountain, :bmx, :road]
def to_s
"Bicycle: #{type}"
end
end
| true |
3013918fa8e93e9fbc1ed9bcb07ecaa8f721e08b | Ruby | camwiese/RB101 | /medium-1/exercise-7.rb | UTF-8 | 641 | 3.546875 | 4 | [] | no_license | def word_to_digit(string)
string.split('').each do |word|
case word
when "one" then string.sub!("one", "1")
when "two" then string.sub!("two", "2")
when "three" then string.sub!("three","3")
when "four" then string.sub!("four", "4")
when "five" then string.sub!("five", "5")
when "six" the... | true |
97e886c69946ee46057283940ccd5ae2b82d4b49 | Ruby | msomji/typescript | /Dangerfile | UTF-8 | 1,945 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'pathname';
# Ensure a clean commits history
if git.commits.any? { |c| c.message =~ /^Merge branch '#{github.branch_for_base}'/ }
warn('Please rebase to get rid of the merge commits in this PR, otherwise, if this PR is small, this should be squash-merged so the merge commit is squashed.')
end
can_merge = git... | true |
6e8a0c0fc7db9323ec36ce953bbb95100f7bd041 | Ruby | QEDio/redis-bloomfilter | /spec/redis_bloomfilter_spec.rb | UTF-8 | 5,129 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require "spec_helper"
require "set"
def test_error_rate(bf,elems)
visited = Set.new
error = 0
elems.times do |i|
a = rand(elems)
error += 1 if bf.include?(a) != visited.include?(a)
visited << a
bf.insert a
end
error.to_f / elems
end
def factory options, driver
options[:driver] = driver
... | true |
5dd0bc4a28d9118bc68aa20d42c0b8dab3d3f490 | Ruby | NikolaiKor/Seo_Instrument | /lib/model/site_info.rb | UTF-8 | 1,118 | 3.015625 | 3 | [] | no_license | require_relative 'link'
#Include all info about site: url, headers, ip, country, hyperlinks.
class SiteInfo
attr_reader :headers, :links, :ip, :country, :url, :domain, :date, :user_id
attr_accessor :title, :identifier
def initialize(url, headers, ip, country, date, user_id = nil)
@url = url
@title = ''
... | true |
72cf026d2d79816441ccca35aaaf49b9ba132626 | Ruby | Chilinot/uC | /bin/ucc | UTF-8 | 2,327 | 2.953125 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative "../lib/parser/parser.rb"
require_relative "../lib/semantic/semantic_analysis.rb"
require_relative "../lib/utils.rb"
require_relative "../lib/ir/ir.rb"
require_relative "../lib/code/code_generation.rb"
require 'ostruct'
require 'optparse'
require 'fileutils'
def parse_args args
... | true |
1abdb511541d255cf40cd748d3ba614e5d7227ca | Ruby | FangedParakeet/hashpageme | /lib/twitter/fetches_tweets.rb | UTF-8 | 641 | 2.734375 | 3 | [] | no_license | require 'open-uri'
require 'json'
class Twitter::FetchesTweets
def self.fetch(name, page)
result = []
tweets = JSON.parse(open("http://api.twitter.com/1/statuses/user_timeline.json?screen_name=#{name}&count=100&page=#{page}&include_rts=1&trim_user=true&include_entities=false&callback=?").read)
begin... | true |
a6d489fc164184e22f480af8442eb068fa5b825a | Ruby | jacindaz/movies-ratings | /server.rb | UTF-8 | 1,726 | 3.375 | 3 | [] | no_license | require 'sinatra'
require 'rubygems'
require 'csv'
require 'pry'
#METHODS--------------------------------------------------------------
def load_movies(file_name)
movies = []
CSV.foreach(file_name, headers: true, header_converters: :symbol) do |movie|
movies << movie.to_hash
end
movies.sort_by{|movie| mov... | true |
2080c99693b43ab1b4b32cc1c96befacf1354632 | Ruby | conery89/rspec-fizzbuzz-cb-000 | /fizzbuzz.rb | UTF-8 | 140 | 2.984375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def fizzbuzz(int)
if int == 3
"Fizz"
elsif int / 5 == 1
"Buzz"
elsif int % 15 == 0
"FizzBuzz"
else puts "Nil"
end
end
| true |
e8d548f6ffdb81396e457f8f2251eda56aa727e6 | Ruby | genericname92/app-academy | /week2/poker-app/poker/spec/deck_spec.rb | UTF-8 | 1,627 | 3.296875 | 3 | [] | no_license | require 'rspec'
require 'deck'
describe Deck do
subject { Deck.new }
describe "#deck" do
it "Should have 52 cards" do
expect(subject.pack.length).to eq(52)
end
it "Should have 13 of each suit" do
expect(
Card.suits.all? do |test_suit|
subject.pack.select {|card| card.suit ... | true |
0ce3057282a7e41ce360398c1201a4c827dcb2bc | Ruby | chadc76/tic_tac_toe_AI | /lib/tic_tac_toe_node.rb | UTF-8 | 1,443 | 3.484375 | 3 | [] | no_license | require_relative 'tic_tac_toe'
class TicTacToeNode
attr_reader :board, :next_mover_mark, :prev_move_pos
def initialize(board, next_mover_mark, prev_move_pos = nil)
@board = board
@next_mover_mark = next_mover_mark
@prev_move_pos = prev_move_pos
end
def losing_node?(evaluator)
return (board.won... | true |
2dd50da74a7365a558e0ac59130e8eb493d8417a | Ruby | mandalashwini/My_training | /Ruby/Ruby_basics/moduleEx.rb | UTF-8 | 198 | 2.90625 | 3 | [] | no_license | module First
def self.dis
i="ashwinidkfdsfdskj"
if i.class==String && i.length < 10
puts "Hello"
else
puts "byee"
end
end
puts "abc".class
end
First.dis
| true |
b1ac54b38827b8c69f0692fe18686aeebd48bbd3 | Ruby | jrbean/atm | /atm.rb | UTF-8 | 1,829 | 3.703125 | 4 | [] | no_license | require "csv"
require "pry"
class ATM
# attr_accessor :user_data
def initialize
@user_data = []
@exit = false
users
end
def users
CSV.foreach("bank_users.csv", headers: true, header_converters: :symbol) do |row|
@user_data.push row.to_hash
# @user_data.push row[:balance].to_i
e... | true |
dcb37ec0c908d2d0163f1522b5fe1568b8b79611 | Ruby | bdwain/PayrollDateCalculator | /lib/date_calculator_factory.rb | UTF-8 | 660 | 3 | 3 | [] | no_license | require_relative 'daily_date_calculator'
require_relative 'weekly_date_calculator'
require_relative 'semi_monthly_date_calculator'
require_relative 'monthly_date_calculator'
class DateCalculatorFactory
def self.get_calculator(interval)
case interval
when :daily
DailyDateCalculator.new
whe... | true |
c07dd938d33e398dd8f8b83b238bf3283c2abcff | Ruby | picatz/falconz | /lib/falconz/apis/system.rb | UTF-8 | 6,486 | 2.78125 | 3 | [
"MIT"
] | permissive | module Falconz
module APIs
module System
# return heartbeat
#
# == Example
# client = Falconz.client.new
#
# client.system_heartbeat do |response|
# # do something with the response
# puts response.to_json
# end
#
# == Example without... | true |
665e18ee94cbef090d38f925c0c7105fd43ba497 | Ruby | benlangfeld/Tropo-Examples | /easySMS-Tropo-Scripting.rb | UTF-8 | 704 | 2.734375 | 3 | [] | no_license | #----------
# Easy SMS Send Example Written in Ruby and Runs on Tropo Scripting Platform
#
# Create a new Tropo Scripting App, copy/paste this code and assign a U.S. or Candian phone number
# Send an SMS using the Tropo API key assigned to this app like this:
# http://api.tropo.com/1.0/sessions?action=create&token=myA... | true |
e4ce7c0f16c03b048f7f199d24348856e3983a50 | Ruby | jeffwilliams/quartz-torrent | /lib/quartz_torrent/timermanager.rb | UTF-8 | 3,607 | 3.234375 | 3 | [
"MIT"
] | permissive | require 'pqueue'
module QuartzTorrent
# Class used to manage timers.
class TimerManager
class TimerInfo
def initialize(duration, recurring, metainfo)
@duration = duration
@recurring = recurring
@metainfo = metainfo
@cancelled = false
refresh
end
attr_ac... | true |
883f8969dbf692bdcc4b9d85c62a41fc707984e4 | Ruby | mariozig/tomato_paste | /lib/tomato_paste/vine.rb | UTF-8 | 368 | 2.890625 | 3 | [
"MIT"
] | permissive | module TomatoPaste
class Vine
attr_reader :pomodori
def initialize()
@pomodori = []
end
def add(pomodoro)
@pomodori << pomodoro
end
def current_pomodoro
@pomodori.last
end
def big_break_time?
# a big break should happen every 4 pomodori
!@pomodori.empt... | true |
acfb2e1882bb5208a4ac1c66b273da6b66c1f7fe | Ruby | terceiro/egypt | /features/support/egypt_exception.rb | UTF-8 | 515 | 2.75 | 3 | [] | no_license | class EgyptException < Exception
def initialize(stdout, stderr)
delimiter_line = "-------------------------------------------------\n"
report = []
report.push "Standard output:\n"
report.push delimiter_line
report.push stdout
report.push delimiter_line
if !stderr.empty?
report.push "... | true |
a5b6cbc45bf138c5cc94f2843935524b08d339ec | Ruby | santiruizt/ironhack | /Week1/movie_ratings.rb | UTF-8 | 1,337 | 3.859375 | 4 | [] | no_license | require "Imdb"
require 'colorize'
#Class to search films at the doc
class Seach
def initialize(route)
@route = route
@array = []
f = File.open(@route, "r")
f.each_line do |element|
@array.push(element.chomp)
end
f.close
end
def get_films_array
@array
end
end
#Class to creat... | true |
104067fbf8175f8e89c7fb547c4631f88d4c2542 | Ruby | joshuaaweisman/evolution_of_a_coder | /practice_problems/iteration/array_doubler.rb | UTF-8 | 108 | 3.28125 | 3 | [] | no_license | # Write a method that doubles each element in an array
def doubler(array)
array.map {|num| num * 2}
end
| true |
b230b6a855eec0fe8f348e65835dbf6c37e666eb | Ruby | Jbern16/black_thursday_complete | /lib/sales_analyst_basic_operations.rb | UTF-8 | 143 | 2.78125 | 3 | [] | no_license | class BasicOperations
def self.average_by_quantity(repo_1, repo_2)
(repo_1.all.length.to_f / repo_2.all.length.to_f).round(2)
end
end
| true |
13bea41fa1919ea868c21d84f0c348aa7e973bc5 | Ruby | djberg96/win32-xpath | /spec/win32_xpath_spec.rb | UTF-8 | 7,845 | 2.625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | require 'rspec'
require 'tmpdir'
require 'win32/xpath'
require 'etc'
RSpec.describe 'win32-xpath' do
let!(:login) { Etc.getlogin }
let!(:env){ ENV.to_h }
before do
@pwd = Dir.pwd
@tmp = 'C:/Temp'
@root = 'C:/'
@drive = Dir.pwd[0,2]
@home = env['HOME'].tr('\\', '/')
@unc = "//foo/bar"
... | true |
4b1cb1a518161f177e39b0649433e73b734cef3a | Ruby | dzrw/knock | /scripts/tsvhelper.rb | UTF-8 | 550 | 2.625 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
h = {}
ARGF.each do |line|
line.strip!.tr!("\t", '')
m = /^\s*(.*):\s*(\d+(\.\d+)?)(μs)?$/.match(line)
if m
k = case m[1]
when "Run Time (s)"; "Time"
when "Throughput (ops/sec)"; "Tput"
when "Mean Response Time (μs)"; next
when "Load Efficiency (%)"; "Efcy"... | true |
7dd66eb6ad28bef8bfe1924c390ae159b8bbc08a | Ruby | dbaruahtcd/Algorithms-and-Data-structure | /exercises/5.coding_challenge/8.majority_element.rb | UTF-8 | 3,452 | 4.40625 | 4 | [] | no_license | =begin
Given an array of size n, find the majority element. The majority element is the element
that appears more than ⌊ n/2 ⌋ times.
You may assume that the array is non-empty and the majority element always exist in
the array.
Example 1:
Input: [3,2,3]
Output: 3
Example 2:
Input: [2,2,1,1,1,2,2]
Output: 2
=end
... | true |
c40d33aabc5378eb62f7291bda983f5ef0d55ab7 | Ruby | ColinOsborn/robots | /app/models/robot_repository.rb | UTF-8 | 780 | 2.90625 | 3 | [] | no_license |
class RobotRepository
attr_reader :database
def initialize(database)
@database = database
end
def table
database.from(:robots).order(:id)
end
def create(robot)
table.insert(name: robot[:name], city: robot[:city], state: robot[:state], avatar: robot[:avatar], birthdate: robot[:birthdate], dat... | true |
0a7af68506dc2122b3715bc1959e5a25cfab4291 | Ruby | Carolinahgor/voters_sim | /questionsvs.rb | UTF-8 | 1,175 | 3.625 | 4 | [] | no_license | # # puts "With this game you can simulate who will be winning the next election"
# def main_menu
# puts "What would you like to do?"
# puts "(C)reate, (L)ist, (U)pdate, or (V)ote"
# firstquestion = gets.chomp.downcase
# if firstquestion == "c"
# create
# # elsif firstquestion == "v"
# #here goes the ... | true |
8c4dbb260f1a6e113f3f43f653d7075a10e1c075 | Ruby | voscarmv/stackbot | /slack-stackbot/commands/help.rb | UTF-8 | 638 | 2.546875 | 3 | [
"MIT"
] | permissive | module SlackStackbot
module Commands
class Help < SlackRubyBot::Commands::Base
command 'help' do |client, data, _match|
help_message = 'Give me commands by typing _*@Stackbot command [arguments]*_
Here\'s a complete list of my available commands:
*help* Display this help message.
*search* _your se... | true |
be275d2c598eb9e57cf90af0c37e0e84d70c0395 | Ruby | amyhlt/mathgame | /player.rb | UTF-8 | 169 | 2.828125 | 3 | [] | no_license | class Player
attr_reader:number
attr_reader:live
attr_writer:live
def initialize(number,live)
@number = number
@live = live
end
end
| true |
7e5bfb154447957105b8885b4baed210e011fa8c | Ruby | elzbyfar/ruby-oo-relationships-practice-mini-mock-code-challenge | /author.rb | UTF-8 | 945 | 3.84375 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive |
class Author
attr_accessor :name, :word_count
@@all = []
def initialize(name)
@name = name
@@all << self
end
#CLASS METHODS#
def self.all
@@all
end
def self.most_words
max_words = @@all.map do |author|
author.total_words
end.max
... | true |
9f4f3c77425e695c6612bec13c1d490749e2c82b | Ruby | Jcornick21/string_reverse | /lib/string_reverse.rb | UTF-8 | 406 | 3.78125 | 4 | [] | no_license | # A method to reverse a string in place.
def string_reverse(my_string)
if my_string == "" && my_string.length <= 1
return my_string
elsif my_string == nil
return my_string
end
a = 0
b = my_string.length - 1
while a < b
c = my_string[a]
my_string[a] = my_string[b]
my_strin... | true |
63c81598fd0a84f42a1ce37c6cbaa7ee7041d41b | Ruby | sjacodes/cartoon-collections-london-web-071618 | /cartoon_collections.rb | UTF-8 | 602 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll_call_dwarves(dwarf_names)
list_of_dwarf_names = []
dwarf_names.each_with_index do |name, index|
list_of_dwarf_names.push("#{index.to_i + 1}. #{name}")
end
puts list_of_dwarf_names
end
def summon_captain_planet(planeteer_calls)
planeteer_calls.collect do |call|
call.capitalize + "!"
end
... | true |
adcc1cf689d3004d25177679e61d4e0b36e818f7 | Ruby | geoffdb/headspace | /includes/hardware/io_controller.rb | UTF-8 | 683 | 2.578125 | 3 | [] | no_license | class IOController < MatrixController
# Controlls all IO to do with the servo cards, and possibly any other hardware
def get_pir
[0, 1, 2, 3].map {|x| read_input(x)}
end
def led_on(n)
send_command(n, "set_modes", [76, :on, 1])
end
def led_off(n)
send_command(n, "set_modes", [76, :off, 1... | true |
2bcb90dcbf0595399efaf7c71d5b7a8a975ee1a2 | Ruby | NadimRai/word_definition-accelhk | /lib/dictionary.rb | UTF-8 | 599 | 3.515625 | 4 | [] | no_license | class Dictionary
@@dictionary = []
def initialize(name)
@name = name
@id = @@dictionary.length().+(1)
@word_list = []
end
def name
@name
end
def id
@id
end
def word_list
@word_list
end
def self.all
@@dictionary
end
def save
@@dictionary.push(self)
end
def self.clear
... | true |
1d317a2ff6a358c81e70ece5212dfd376c4abf9c | Ruby | lyuehh/program_exercise | /ruby/closure.rb | UTF-8 | 118 | 2.875 | 3 | [] | no_license | def extent
n = 0
lambda {
n += 1
printf "n=%d\n", n
}
end
f = extent()
f.call()
f.call()
| true |
b91679c973597bfd78d035db10f7eda983783803 | Ruby | JattCoder/sinatra-mvc-lab-onl01-seng-ft-012120 | /models/piglatinizer.rb | UTF-8 | 785 | 3.671875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class PigLatinizer
attr_accessor :text
def initialize(text = nil)
@text = text
end
def piglatinize(text)
@text = text
words = @text.split(" ")
arr_words = []
words.map do |word|
firstchar = word[0].downcase.scan(/[aeiou]/).count
... | true |
556e68871220c51f46bb246dc9dbd2e5aa0e64e6 | Ruby | brontes3d/define_permissions | /lib/define_permissions/actor.rb | UTF-8 | 4,570 | 2.6875 | 3 | [
"MIT"
] | permissive | # If you are using AuthorizedActor, this module is automatically included.
#
# If you wanted to use DefinePermissions without AuthorizedActor,
# your actors would have to include this module.
#
# DefinePermissions::Actor defines all the permission checking methods that can be called
# on a particular actor to determi... | true |
811a11f6d59c24920745ea942632af56ea6e3c39 | Ruby | trizen/sidef | /scripts/Tests/def_primitive_type_2.sf | UTF-8 | 1,318 | 3.875 | 4 | [
"Artistic-2.0"
] | permissive | #!/usr/bin/ruby
#
## http://rosettacode.org/wiki/Define_a_primitive_data_type
#
subset Integer < Number { .is_int }
subset MyIntLimit < Integer { . ~~ (1 ..^ 10) }
class MyInt(value < MyIntLimit) {
method ==(Number x) { value == x }
method ==(MyInt x) { value == x.value }
method to_s { value.... | true |
042f9aff516156be1a75fa53db9d1d5f5e9e65d7 | Ruby | JTSwisher/reverse-each-word-onl01-seng-pt-100619 | /reverse_each_word.rb | UTF-8 | 382 | 3.6875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(sentence1)
current_array = sentence1.split(" ")
new_array = []
current_array.each do |sentence1|
new_array << sentence1.reverse
end
new_array.join(" ")
end
def reverse_each_word(sentence2)
array = sentence2.split(" ")
new_array = []
array.collect do |sentence2|
new_... | true |
6ff9055800c84925bfdda216812994ec28129103 | Ruby | dinjas/grocer | /spec/models/product_spec.rb | UTF-8 | 3,321 | 2.640625 | 3 | [] | no_license | require 'rails_helper'
describe Product do
it 'has a valid factory' do
expect(build(:product)).to be_valid
end
it 'is invalid without a name' do
product = build(:product, name: nil)
product.valid?
expect(product.errors[:name]).to include("can't be blank")
end
let(:user) { create(:user) }
... | true |
4b9dd3a5458cb2cf0f9409be43f17f65b30bb915 | Ruby | reidka/Markus | /test/unit/section_test.rb | UTF-8 | 1,517 | 2.71875 | 3 | [
"MIT"
] | permissive | # Context architecture
#
# - A section with no student associated to
# - A section with student associated to
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'blueprints', 'helper'))
require 'shoulda'
class SectionTest ... | true |
057af3c0b891c81cb93471aaa1aa265bb714fd2d | Ruby | xsmet/Divelog | /test/integration/users_login_test.rb | UTF-8 | 2,611 | 2.640625 | 3 | [] | no_license | require 'test_helper'
class UsersLoginTest < ActionDispatch::IntegrationTest
# 1. Visit the login path.
# 2. Verify that the new sessions form renders properly.
# 3. Post to the sessions path with an invalid params hash.
# 4. Verify that the new sessions form gets re-rendered and that a flash message appears.... | true |
ea1370518a3d96d483e61816a25c9b52d23915a7 | Ruby | randallpink/webdevclass | /Week3/luckyseven.rb | UTF-8 | 342 | 4.0625 | 4 | [] | no_license | x = 0
puts "Welcome to the lucky seven game!"
thenumber = 0
until thenumber == 7
thenumber = rand(11)
if thenumber == 7 then
puts "You've won! Congratulations!! The number was #{thenumber}."
x = x + 1
else
puts "Unlucky, the number was #{thenumber}"
x = x+ 1
end
end
puts "It only took you #{x} tries to... | true |
a5e8249ac87b2c14db2adc39ec1bf9a0678644e6 | Ruby | accua/scrabble | /lib/scrabble.rb | UTF-8 | 1,007 | 3.328125 | 3 | [] | no_license |
class String
define_method(:scrabble) do
score_board = Hash.new()
score_board.store("A", 1)
score_board.store("E", 1)
score_board.store("I", 1)
score_board.store("O", 1)
score_board.store("U", 1)
score_board.store("L", 1)
score_board.store("N", 1)
score_board.store("R", 1)
sco... | true |
94c5091a1cf8909d4e3466da1073ad36f7588e5e | Ruby | kharigai/ruby | /puzzle/09_man_and_woman.rb | UTF-8 | 96 | 2.875 | 3 | [] | no_license |
a = Array.new(3).map { Array.new(3){0} }
a[0][0] = 1
a[1][1] = 1
p a
a.each do |d|
p d
end
| true |
2a2bd3fdf5314b1db5f117ad40a3c359f55444c9 | Ruby | rajsolanki/homework_assignments | /tdd_calculator/lib/calculator.rb | UTF-8 | 309 | 3.59375 | 4 | [] | no_license | #!/usr/bin/env ruby
# Calculator class
class Calculator
def addition(number1, number2)
number1 + number2
end
def subtraction(number1, number2)
number1 - number2
end
def multiply(number1, number2)
number1 * number2
end
def divide(number1, number2)
number1 / number2
end
end
| true |
947c364b94d439042f432b25328400170e749621 | Ruby | awslabs/cloud-templates-ruby | /lib/aws/templates/utils/parametrized/transformation/as_json.rb | UTF-8 | 1,169 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | require 'aws/templates/utils'
require 'json'
module Aws
module Templates
module Utils
module Parametrized
class Transformation
##
# Convert input into JSON string
#
# Input value can be anything implementing :to_json method.
#
# === Exampl... | true |
9074441e4490cd488c030d271cd2c7ecb3fe685a | Ruby | BabyBG/mastermind | /mastermind.rb | UTF-8 | 12,729 | 3.75 | 4 | [] | no_license | require 'io/console'
############################
## Board & Player classes ##
############################
# stores a 12x4 array containing all response pegs and ability to represent this in console with .show_board
class GameBoard
attr_accessor :rows
def initialize
@rows = Array.new(12, [".", ".", ".", "."])... | true |
626cd1b963065408608d725f761b2a027055156e | Ruby | mag725/sculptor | /lib/sculptures/hash.rb | UTF-8 | 919 | 2.671875 | 3 | [] | no_license | module Sculptor
class Hash < Sculptor::Sculpture
def initialze
# constraints
@_required_sub_sculptures = {}
@_optional_sub_sculptures = {}
@_non_empty = false
end
#
# setters / getters
#
def required_sub_sculptures
@_required_sub_sculptures
end
... | true |
fd716f0d8f56177e4b6e6095578e24d92b6706e0 | Ruby | kaymach/launch-school-core | /rb101/lesson6/21.rb | UTF-8 | 6,604 | 3.765625 | 4 | [] | no_license | KEEP_PLAYING = %w(y n)
GAME_TYPE = 21
DEALER_STOP = GAME_TYPE - 4
scores = { player: 0, dealer: 0 }
player_hand = []
dealer_hand = []
current_card = []
def prompt(msg)
puts "=> #{msg}"
end
def greeting_message
loop do
prompt "Welcome to #{GAME_TYPE}. Win 5 rounds to be the grand winner!"
sleep 1
pr... | true |
5452e28807d1d52e44c5fd8447b8bdc5347fa2fe | Ruby | norman/babosa | /spec/transliterators/swedish_spec.rb | UTF-8 | 449 | 2.609375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "spec_helper"
describe Babosa::Transliterator::Swedish do
let(:t) { described_class.instance }
it_behaves_like "a latin transliterator"
it "should transliterate various characters" do
examples = {
"Räksmörgås" => "Raeksmoergaas",
"Öre" => "Oere",
"Åre... | true |
bbbd1d9e144cd7074a41bc867d4918f80a8d200a | Ruby | sam-david/algorithms | /challenges/project-euler/factorial_digit_sum.rb | UTF-8 | 193 | 3.5 | 4 | [] | no_license | # https://projecteuler.net/problem=20
# sum of digits in 100 factorial
# SOLVED
def factorial(n)
(1..n).reduce(&:*)
end
p factorial(100).to_s.split("").reduce {|sum, n| sum.to_i + n.to_i }
| true |
12b554a6c24216c0135ba380ac5d2a4417bd5b46 | Ruby | jasonkaskel/projecteuler | /45/solution.rb | UTF-8 | 1,130 | 4 | 4 | [] | no_license | # 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 next triangle... | true |
30423526a30a3d0f22cc9e196bb32212ee584b1f | Ruby | emanuelbierman/ruby-music-library-cli-v-000 | /lib/genre.rb | UTF-8 | 626 | 2.96875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Genre
extend Concerns::Findable
attr_accessor :name
@@all = []
def initialize(name)
@name = name
@songs = []
end
def self.all
@@all
end
def self.destroy_all
@@all.clear
end
def save
@@all << self
end
def self.create(name)
Genre.new(name).save
@@all.last
... | true |
77818f0f1593a68c3a65f621680a4852a0237927 | Ruby | hodak/factory_boy | /spec/factory_boy_spec.rb | UTF-8 | 3,653 | 2.9375 | 3 | [
"MIT"
] | permissive | require "spec_helper"
class TestUser
attr_accessor :name
end
describe FactoryBoy do
before do
FactoryBoy.instance_variable_set(:@defined_factories, [])
end
describe ".define_factory" do
it "can define factory" do
expect(FactoryBoy.define_factory(TestUser)).to eql true
end
it "can recei... | true |
69722a269b4dc2bcceec730b3388cf393b7996b4 | Ruby | tekzsolt/introduction-to-programming | /7_Hashes/3.rb | UTF-8 | 181 | 3.46875 | 3 | [] | no_license | player = {name: "James", life: 75, points: 2000}
player.each_key { |key| puts key }
player.each_value { |value| puts value }
player.each { |key, value| puts "#{key} = #{value}" } | true |
f2d8e9eff64d445d9ed9f59b7aeb53188137cad6 | Ruby | Greg0109/ExpensesTracker | /app/helpers/types_helper.rb | UTF-8 | 260 | 2.8125 | 3 | [] | no_license | # rubocop:disable Style/GuardClause
module TypesHelper
def calculate_budget(budget, total)
if budget.present?
left = budget - total
"Initial Budget #{budget} €. Money Left #{left} €"
end
end
end
# rubocop:enable Style/GuardClause
| true |
c5dff13610610db052bb99f83d3731c730eb979f | Ruby | krislitman/jungle_beat | /spec/insert_and_prepend_spec.rb | UTF-8 | 519 | 2.96875 | 3 | [] | no_license | require './lib/node'
require './lib/linked_list'
RSpec.describe 'Linked List' do
describe 'Insert & Prepend' do
it 'should be able to prepend to beginning of the list/insert' do
list = LinkedList.new
list.append("plop")
expect(list.to_string).to eq("plop")
list.append("suu")
list.pr... | true |
c78cdc87a1c5245201d5d4f5e6a8803d46bbd771 | Ruby | Hiptic/modis | /spec/validations_spec.rb | UTF-8 | 1,087 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe 'validations' do
class TestModel
include Modis::Model
attribute :name, :string
validates :name, presence: true
end
let(:model) { TestModel.new }
it 'responds to valid?' do
model.name = nil
expect(model.valid?).to be false
end
it 'sets errors on the mode... | true |
59d2e75561dc9ea9b784b65a314f4b2933ad3e01 | Ruby | justindelatorre/rb_101 | /lesson_4/module_10/lesson_4_10_1.rb | UTF-8 | 273 | 3.640625 | 4 | [] | no_license | =begin
Turn this array into a hash where the names are the keys and the values are the
positions in the array.
=end
flintstones = ["Fred", "Barney", "Wilma", "Betty", "Pebbles", "BamBam"]
hsh = {}
flintstones.each_with_index { |element, idx| hsh[element] = idx }
p hsh
| true |
7f73ec3bce8b9390d3ee96ff99df2f77f4d05144 | Ruby | Team-Eval/flatiron-kitchen-ruby-003 | /spec/models/recipe_spec.rb | UTF-8 | 1,173 | 2.6875 | 3 | [] | no_license | require 'spec_helper'
describe Recipe do
let(:ingredient1) { Ingredient.create(:name => "Sugar", :count => 1)}
let(:ingredient2) { Ingredient.create(:name => "Spice", :count => 1)}
let(:ingredient3) { Ingredient.create(:name => "Nice", :count => 1)}
let(:recipe) { Recipe.create(:name => "PowerPuffGirls", :... | true |
6e8d44df10aad3eb54c8588656344f6636406921 | Ruby | maxmedia/circuit | /vendor/active_support-3.2/inflector/methods.rb | UTF-8 | 2,849 | 2.65625 | 3 | [
"MIT"
] | permissive | ## Copied from Rails 3.2.6 on 19 June 2012.
## see http://github.com/rails/rails/blob/v3.2.6/activesupport/lib/active_support/inflector/methods.rb
# Copyright (c) 2005-2011 David Heinemeier Hansson
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated docum... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.