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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ccc299dcdef5a0baa532060edd5d02e4334d9c61 | Ruby | Redande/ratebeer | /app/models/concerns/rating_average.rb | UTF-8 | 213 | 2.546875 | 3 | [] | no_license | module RatingAverage
extend ActiveSupport::Concern
def average_rating
average_rating = ratings.inject(0.0){ |sum, r| sum+r.score } / ratings.count
average_rating.nan? ? nil : average_rating
end
end
| true |
4595305cb6143a2a661b08160b1fff29621decdc | Ruby | ysato5654/twstock-finance | /script/script_show_twstock_code_info.rb | UTF-8 | 2,696 | 2.5625 | 3 | [
"MIT"
] | permissive | #! /opt/local/bin/ruby
# coding: utf-8
require File.dirname(File.realpath(__FILE__)) + '/command_line_option'
require File.dirname(File.realpath(__FILE__)) + '/../lib/twstock/finance'
require File.dirname(File.realpath(__FILE__)) + '/../lib/twstock/stock_code'
Year = '2020'
Month = 'Jun'
Day = '07'
Build ... | true |
f44608878ed4f464e1ca04f547527ce610fb1469 | Ruby | freerange/sauron | /lib/message_repository.rb | UTF-8 | 1,587 | 2.59375 | 3 | [] | no_license | # encoding: utf-8
require 'mail'
class MessageRepository
EXCLUDED_ADDRESSES = [
'notifications@pivotaltracker.com',
'tracker-noreply@pivotallabs.com',
'mention-*@postmaster.twitter.com',
'n-*@postmaster.twitter.com',
'twitter-follow*@postmaster.twitter.com',
'twitter-dm*@postmaster.twitter.co... | true |
05f1715cc47952fd160e8d94424b16ce86bd2aa0 | Ruby | orlando/velvet_rope | /lib/velvet_rope.rb | UTF-8 | 1,400 | 2.75 | 3 | [
"MIT"
] | permissive | require "redcarpet"
require "pygments.rb"
require "gemoji"
module Redcarpet
module Render
class VelvetRope < HTML
def initialize(extensions={})
@extensions ||= {}
@extensions[:highlight_syntax] = extensions.delete(:highlight_syntax) || false
@extensions[:emoji] = extensions.delete(... | true |
2b702685b7de49b7a97450b6450edc75c94f3d2b | Ruby | pinkninjajess/Projects | /JV_Solutions/check_palindrome.rb | UTF-8 | 497 | 4.5625 | 5 | [
"MIT"
] | permissive | class CheckPalindrome
=begin
Author: Jessica Valenti
Date: September 2, 2015
Script that determines if a string is a palindrome or not.
=end
def checkPalindrome(word)
reversedWord = word.reverse
if (word == reversedWord)
puts "#{word} is a palindrome!"
else
puts "#{word} is not a palind... | true |
d8bc77ab53769c81fa76c7685951c72504a0b230 | Ruby | therocketforever/runrun---bak | /runrun.rb | UTF-8 | 2,268 | 2.609375 | 3 | [] | no_license | require 'sinatra'
require 'datamapper'
SITE_TITLE = "RUNRUN Bicycle Couriers"
SITE_DESCRIPTION = "Fast, Affordable, Reliable. Anywhere in Ann Arbor"
DataMapper::setup(:default, "sqlite3://#{Dir.pwd}/runrun.db")
# Define waybills Table.
class Waybill
include DataMapper::Resource
property :id, Serial
property :n... | true |
b939f451f5df9ebec4c99e0d07b03b594deade22 | Ruby | bahelms/todolist_app | /bin/todolist | UTF-8 | 800 | 3.03125 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative '../lib/todolist'
require_relative '../lib/todolist/helpers'
include Helpers
if ARGV.empty?
list = TodoList.new
print NL, "Enter title of list: "
list.title = gets.chomp
display list
else
list = TodoList.new ARGV[0]
ARGV.clear
display list
end
loop do
puts NL, COMM... | true |
d3f7c58650a8dd93afb084a4e5174495f9f0f0c5 | Ruby | rlecaro2/tig1 | /app/models/bodega.rb | UTF-8 | 3,214 | 2.703125 | 3 | [] | no_license | class Bodega
def self.informacion
begin
res = HTTParty.get("http://iic3103.ing.puc.cl/webservice/integra1/?function=getInfoBodegas&key=45XtPg")
objArray = JSON.parse(res)
#objArray[0]["almacenId"]
return objArray
rescue Exception => e
return nil
end
end
def self.informacion_sku
begin
res ... | true |
e2b6389b57d59e3e851cb791f05ef8e771198c3a | Ruby | cafedomancer/word2vec | /lib/word2vec/word_clusters.rb | UTF-8 | 763 | 3.015625 | 3 | [
"MIT"
] | permissive | require "csv"
module Word2Vec
class WordClusters
attr_accessor :vocab, :clusters
def initialize(vocab:, clusters:)
self.vocab = vocab
self.clusters = clusters
end
def ix(word)
raise NotImplementedError
end
def [](word)
raise NotImplementedError
end
def get_... | true |
3ccfc4432b3cf49c26298c7c2f1ac66ca0dd4811 | Ruby | jv-cortez/ar-exercises | /exercises/exercise_1.rb | UTF-8 | 587 | 2.65625 | 3 | [] | no_license | require_relative '../setup'
Store.create(name: 'Burnaby', annual_revenue: 300000, mens_apparel: true, womens_apparel: true)
Store.create(name: 'Richmond', annual_revenue: 1260000, mens_apparel: false, womens_apparel: true)
Store.create(name: 'Gastown', annual_revenue: 190000, mens_apparel: true, womens_apparel: false)... | true |
190aed440add4a58c81dc8080882c89638d40615 | Ruby | iovino/ruby-forum | /app/helpers/forums_helper.rb | UTF-8 | 6,113 | 2.671875 | 3 | [] | no_license | module ForumsHelper
# Builds an array of forum data based on the ids and collection info passed
#
# @param Array The array of forum ids to build
# @param Array An Array of all the forums present in the database (avoids querying the db)
def build_child_info(ids, collection)
forums = []
for forum in... | true |
d13d4eeec9640b298f6ff94dce7caf6623949583 | Ruby | toshimaru/Study | /thread/gil.rb | UTF-8 | 386 | 3.0625 | 3 | [] | no_license | # 並行
threads1 = Array.new(5) do
Thread.new do
r = rand(10) # Concurrent(since GIL)
puts "sleep #{r} seconds"
sleep r
puts "sleep #{r} seconds ended"
end
end
puts threads1.each(&:value)
# 並列
require 'open-uri'
threads2 = Array.new(5) do
Thread.new do
puts URI.open('https://toshimaru.net/') # ... | true |
0aa6ed876e07fa23aec8844fa885c04f9964c87d | Ruby | Hughesja/programming_foundations | /lesson_3/hard_exercises/hard_1.rb | UTF-8 | 3,911 | 4.03125 | 4 | [] | no_license | # Question 1: What do you expect to happen when the greeting variable
# is referenced in the last line of the code below?
if false
greeting = “hello world”
end
greeting # it is defined with the "if" and will result in nil.
# Question 2: What is the result of the last line in the code below?
greetings = { a: 'hi'... | true |
f348159b1c65a0775f687673f6104ec9022f07b6 | Ruby | khongcodes/ruby-music-library-cli-online-web-ft-081219 | /lib/music_library_controller.rb | UTF-8 | 2,469 | 3.6875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MusicLibraryController
attr_accessor :path,:library
def initialize(path="./db/mp3s")
@path=path
@library=MusicImporter.new(@path).import
end
def call
puts "Welcome to your music library!"
puts "To list all of your songs, enter 'list songs'."
puts "To list all of the art... | true |
48754f9f0d84583d4fb2ea8cdbf09a92397b4ba2 | Ruby | gps-touring/cmd-line-tools | /gps_touring/lib/gps_touring/geom/point.rb | UTF-8 | 541 | 3.328125 | 3 | [] | no_license |
module GpsTouring
module Geom
class Point
attr_accessor :x, :y
def initialize(x, y)
@x, @y = x.to_f, y.to_f
end
def cross(w)
x * w.y - y * w.x
end
def -(w)
Point::new(x - w.x, y - w.y)
end
def +(w)
Point::new(x + w.x, y + w.y)
end
def *(n) # scalar ... | true |
3929a3acf436e25cf63929f7ec8f4e4effb6df39 | Ruby | AAMani5/tic_tac_toe | /spec/helpers/boardstates.rb | UTF-8 | 1,013 | 2.75 | 3 | [] | no_license | module BoardStates
def board_fully_occupied
board_partially_occupied
board.claim_field(:six, :o)
board.claim_field(:five, :x)
board.claim_field(:eight, :o)
board.claim_field(:seven, :x)
end
def board_partially_occupied
board.claim_field(:zero, :x)
board.claim_field(:one, :o)
boar... | true |
a2d1d46464f3d03cd66c67d551e3e0a8d6f30c31 | Ruby | mneumann/guugelhupf | /src.old/ruby/gh.rb | UTF-8 | 11,220 | 2.859375 | 3 | [] | no_license | #
# Copyright (c) 2002 Michael Neumann <mneumann@ntecs.de>
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, t... | true |
3fe3e7bcee24d36e9300c68dfad442047e7b0726 | Ruby | jordantroberts/chitter-challenge | /lib/peep.rb | UTF-8 | 970 | 3.0625 | 3 | [] | no_license | require 'pg'
require 'time'
class Peep
attr_reader :id, :text, :time
def initialize(id:, text:, time:)
@id = id
@text = text
@time = time
end
def self.all
if ENV['ENVIRONMENT'] == 'test'
connection = PG.connect(dbname: 'chitter_test')
else
connection = PG.connect(dbname: 'ch... | true |
5f4c3e82e4d1618444cb68837d794117e8b6db9f | Ruby | rmcastil/Create-Sequential-Integer-Directories | /create_mult_dir.rb | UTF-8 | 560 | 3.53125 | 4 | [] | no_license | #!/usr/bin/ruby
class DirectoryName
def to_s
Dir.getwd
end
def create_int_dir(dir_number)
if dir_number > 0
if dir_number < 10
Dir.mkdir("0" + dir_number.to_s())
else
Dir.mkdir(dir_number.to_s())
end
else
puts "Cannot create direct... | true |
3d0953c026fd36f657bd1cf0029e03263e4b4f04 | Ruby | tbanish/ruby-music-library-cli-online-web-sp-000 | /lib/genre.rb | UTF-8 | 504 | 2.921875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Genre
attr_accessor :name, :songs, :artist
extend Concerns::Findable
@@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... | true |
ac4a5e2906c48e8585ed42438ef9f2b909cf2ef6 | Ruby | ldenken/helper-modules | /fileio-test.rb | UTF-8 | 905 | 2.859375 | 3 | [] | no_license | require_relative 'lib/var'
require_relative 'lib/fileio'
tmpArrays = []
3.times do
tmpArray = []
tmpArray << rand(1..9)
tmpArray << rand(20..40)
tmpArray << rand(1..5)
tmpArrays << tmpArray
end
Var.Info("tmpArrays", tmpArrays)
delimiter = ","
filename = "testfile.ary"
flag = "w"
FileIO.arrayToFile(tmpArra... | true |
991b337cf52bedc2591351bfdf1b42135ad75a7f | Ruby | sumajirou/ProjectEuler | /p077.rb | UTF-8 | 1,434 | 3.796875 | 4 | [] | no_license | #今度は素数:
#2
2
#3
3
#4
2+2
#5
5
3+2
#6
3+3
2+2+2
#7
7
5+2
3+2+2
#8
5+3
3+3+2
2+2+2+2
#9
7+2
5+2+2
3+3+3
3+2+2+2
#10
7+3
5+5
5+3+2
3+3+2+2
2+2+2+2+2
[1,1,1,2,2,3,3,4,5]
#nのときn以下の素数を考える
#10 -> 7,5,3,2
# part(7) = part(7-7,7) + part(7-5,5) + part(7-3,3) + part(7-2,2)
# part(10) = part(10-... | true |
b2a1bc280fc41ef63ca27998f56d7835aeaab052 | Ruby | dupjpr/ruby | /read_file.rb | UTF-8 | 300 | 3.0625 | 3 | [] | no_license |
def read(a)
if File.exist?(a)
File.read(a)
else
nil
end
end
a = "test.txt"
read(a)
# def write(a, b)
# File.write(a, b)
# end
# a = "test.txt"
# b = "This is the second time tha i use this function"
# write(a, b) | true |
9f4d80835f8564d3414d874d3da642d042cd1f22 | Ruby | stennity8/tic-tac-toe-rb-online-web-sp-000 | /lib/tic_tac_toe.rb | UTF-8 | 3,282 | 4.125 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry'
# WIN_COMBINATIONS constant
WIN_COMBINATIONS = [
[0, 1, 2], #Top row
[3, 4, 5], #Middle row
[6, 7, 8], #Bottom row
[0, 3, 6], #First Column
[1, 4, 7], #Second Column
[2, 5, 8], #Third Column
[0, 4, 8], #Diagonal left to right
[2, 4, 6], #Diagonal right to left
]
# Display board method
de... | true |
f6a7678443ab7338e73cb27adbdb65a926034579 | Ruby | Nearsoft/google-code-jam | /solutions/standing-ovation/ruby/approach3.rb | UTF-8 | 3,238 | 3.375 | 3 | [
"MIT"
] | permissive | class Shyness
input = File.open('A-small-practice.in')
out = File.new('A-small-practice.out', 'w')
#Array for the members of the audience
arrayAudience = []
#Variables
#testCase - It holds the number of test cases
#maxShyness - It holds the max level of Shyness for each testcase
#numStanding - ... | true |
8041644234b0d887292b1ada9df7f6876685a48d | Ruby | bencornelis/twitter-haiku | /app/models/haiku_search.rb | UTF-8 | 562 | 2.625 | 3 | [] | no_license | class HaikuSearch
include TwitterClient
attr_reader :mood, :topic
def initialize(attr)
@mood = attr[:mood]
@topic = attr[:topic]
end
def find_haikus
results = CLIENT.search("#haiku #{topic} #{mood} -rt", result_type: "mixed").take(20)
if results.empty?
results = CLIENT.search("#haiku ... | true |
f833dfef5831a14b41cc477b58c30e9170988fc0 | Ruby | mattlistor/apis-and-iteration-nyc-web-071519 | /lib/api_communicator.rb | UTF-8 | 1,074 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'rest-client'
require 'json'
require 'pry'
def get_character_movies_from_api(character_name)
#make the web request
response_string = RestClient.get('http://www.swapi.co/api/people/')
response_hash = JSON.parse(response_string)
response_hash["results"].find {|character| character["name"].downcase == ch... | true |
aea8923a28a2daaf7be57f8b36c7f7a68f068d2d | Ruby | alex-barstow/giggle-gem | /lib/giggle.rb | UTF-8 | 1,487 | 3.890625 | 4 | [] | no_license |
class Giggle
JOKES = [
"There are 2 hard problems in computer science: caching, naming, and off-by-1 errors",
"A programmer is going to the grocery store and his wife tells him, 'Buy a gallon of milk, and if there are eggs, buy a dozen.' So the programmer goes, buys everything, and drives back to his house. ... | true |
936d1eb325b82b40f6cfdd1b4800aca2416239d3 | Ruby | iwabuchiken/JQM-1 | /test.rb | UTF-8 | 3,359 | 3.359375 | 3 | [] | no_license | #coding:utf-8
module V_1_8_1_1
def do_1
a = "Russia supports Asad"
puts a
puts a.match(/A\w+/)
b = "Russia supports アサド"
puts b
puts a.match(/A../)
p b.match(/ア.../)
puts "****"
... | true |
21e6364b7cdbe538492ca685ac4f2c03552a88cc | Ruby | barifche/Prog_ruby_THP | /exo_15.rb | UTF-8 | 161 | 3.046875 | 3 | [] | no_license | puts" Bonjour! Veuillez entrer votre date de naissaissance svp!"
a = gets.to_i
k = 2020
c =0
while a < k
puts " #{a+=1} vous aviez #{c+=1} ans "
end | true |
f269c06c3e70930871712f1ba8cd387b0b939e40 | Ruby | johnwake/advent-of-code-2020 | /day3/part1.rb | UTF-8 | 261 | 3.15625 | 3 | [] | no_license | f = File.open("./input.txt")
list = f.read
map = list.split("\n").map { |line| line.split('') }
x, y, trees = 0, 0, 0
right = 3
down = 1
while y < map.length - 1
x += right
x %= map[0].length
y += down
trees += 1 if map[y][x] == '#'
end
puts trees
| true |
44ff36960403af2277207c0a80b92c9266622fdc | Ruby | vidarh/writing-a-compiler-in-ruby | /features/inputs/nil.rb | UTF-8 | 455 | 3.46875 | 3 | [] | no_license |
foo = nil
puts "1: foo"
if foo
puts "ERROR: nil"
else
puts "OK: nil"
end
puts "2: !foo"
if !foo
puts "OK: nil2"
else
puts "ERROR: nil2"
end
puts "3: foo.nil?"
if foo.nil?
puts "OK: nil?"
else
puts "ERROR: nil?"
end
puts "4: !foo.nil?"
#FIXME:
if !(foo.nil?)
puts "ERROR: !nil?"
else
puts "OK: !nil?"... | true |
0e1c95d3117fe3b3a6403be7295d7cd2bb851212 | Ruby | drutyper/assignments | /triangle_test.rb | UTF-8 | 1,940 | 3.6875 | 4 | [] | no_license | # 1. Copy this file from the course notes repo into a new repository
# 2. Run `ruby triangle_test.rb`. You should see 6 error messages.
# 3. Implement the Triangle class until all 6 tests are passing.
require 'minitest/autorun'
#require 'pry'
class Triangle
def initialize(a,b,c)
@side1 = a
@side2 = b
@s... | true |
c939f92100b1a0beb896c7c133b1d1b91f48e4d7 | Ruby | itggot-jonas-nordin/standard-biblioteket | /lib/split_string.rb | UTF-8 | 471 | 3.59375 | 4 | [] | no_license | def split_string(string, splitter)
output = Array.new
i = 0
j = 0
same_char = 0
word_to_push = String.new
while i < string.length
while j < splitter.length
if string[i + j] == splitter[j]
same_char += 1
end
j += 1
if same_char == splitter.length
output << word_to_push
word_to_push = ""
... | true |
fb00d50fbf59d1e0655394a297d0fd3691c92046 | Ruby | SebastianCarroll/ruby-practice | /algorithms/sherlock_and_squares/sherlock.rb | UTF-8 | 863 | 3.125 | 3 | [] | no_license | require "benchmark"
require 'gruff'
class Numeric
def sqrt; Math.sqrt(self); end
end
def bigo_logn(l,h)
n = l.sqrt.ceil
count = 0
while n**2 <= h
n += 1
count += 1
end
return count
end
def bigo_1(l,h)
h.sqrt.floor - l.sqrt.ceil + 1
end
l = 3
loop_times = []
eqn_times = []
labels = {}
count = 0... | true |
ee65e64ecf2f8c906753573f6f100cd6197c0fc9 | Ruby | Meneti/Ironhack | /Week1/Chess/lib/Bishop_Class.rb | UTF-8 | 217 | 3.34375 | 3 | [] | no_license | class Bishop
include Diagonal
def initialize (x,y,color)
@x=x
@y=y
@color=color
end
def can_move?(x,y)
if diagonal_move(x,y) == "yes"
output = "yes"
else
output = "no"
end
output
end
end | true |
a6c275b1dc3e9c8966f2aa5fb147bc65f7066199 | Ruby | stevensonmt/exercism_ruby | /run-length-encoding/run_length_encoding.rb | UTF-8 | 390 | 2.953125 | 3 | [] | no_license | module BookKeeping
VERSION = 2
end
class RunLengthEncoding
def self.encode input
counted = input.chars.chunk{|i| i}.map{|i, a| [a.size, i]}
counted.flatten!.delete(1)
counted.join
end
def self.decode(input)
input.scan(/(\d*)(.)/).reduce('') do |output, (num, char)|
multiplier = num.empty... | true |
08bd856195c9704db1527d5489b3d93fb5446646 | Ruby | nicolemal/ics_bc_w18 | /week2/ch07/99_bob.rb | UTF-8 | 983 | 4.28125 | 4 | [] | no_license | # Print out the 99 Bottles of Beer lyrics as shown here:
# http://www.99-bottles-of-beer.net/lyrics.html
### Your Code Here ###
number = 99
while number >= 0
if number > 1
puts number.to_s + " bottles of beer on the wall, " + number.to_s + " bottles of beer."
elsif number == 1
puts number.to_s + " bottle ... | true |
68ddba91f07bfa8b8748e6fa85f0be7af1d0c65f | Ruby | etdev/algorithms | /0_code_wars/is_valid_identifier.rb | UTF-8 | 420 | 3.171875 | 3 | [
"MIT"
] | permissive | # http://www.codewars.com/kata/563a8656d52a79f06c00001f/train/
# --- iteration 1 ---
def is_valid(idn)
return false if idn.size < 1
return false unless /[a-z_$]/i === idn[0]
return false unless idn[1..-1].chars.all? { |n| /[a-z0-9_$]/i === n }
true
end
# --- iteration 2 ---
def is_valid(idn)
/\A[a-z_$][a-z0... | true |
fcfaf710ca9e9e4a564a9d6de05e6d79077f28d8 | Ruby | shadowroot/sirius | /lib/sirius/event_planner.rb | UTF-8 | 2,446 | 2.640625 | 3 | [] | no_license | require 'models/schedule_exception'
require 'roles/applied_schedule_exception'
require 'roles/planned_timetable_slot'
require 'models/parallel'
require 'sirius/time_converter'
require 'sirius/semester_calendar'
module Sirius
class EventPlanner
def initialize
@sync = Sync[Event, matching_attributes: [:time... | true |
d67e2a12862cb0e75f561e11feb9c0528e65c680 | Ruby | tdooner/scioly-reg | /app/models/score.rb | UTF-8 | 806 | 2.65625 | 3 | [] | no_license | class ScoreValidator < ActiveModel::Validator
def validate(record)
return record.errors.add(:base, "Schedule cannot be empty") if record.schedule.nil?
return record.errors.add(:base, "Placement cannot be empty") if record.placement.nil?
max = record.schedule.tournament.teams.count+2
record.errors.add(... | true |
ca7a31c233fe3eeac08c4ede7f4f489be4e8ac87 | Ruby | josephb65/prime-ruby-noukod-000 | /prime.rb | UTF-8 | 111 | 3.109375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Add code here!
def prime?(number)
number > 1 ? (2..number - 1).none? { |i| number % i == 0 } : false
end | true |
1fad9dfad80836299a25a284b3bd1592442cd880 | Ruby | paulzay/dsalgos | /leetcode/200_number_of_islands.rb | UTF-8 | 1,718 | 3.578125 | 4 | [] | no_license | # frozen_string_literal: true
# Given an m x n 2d grid map of '1's (land) and '0's (water), return the number of islands.
# An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically.
# You may assume all four edges of the grid are all surrounded by water.
def num_island... | true |
3ce4714eaf1e0bfd6426a0da172e9fb54bd05814 | Ruby | emilyfreeman/tealeaf_prep_course | /case_statement.rb | UTF-8 | 1,688 | 4.1875 | 4 | [] | no_license | def num_compare(num)
case num
when 0..50
puts "#{number} is between 0 and 50"
when 51..100
puts "#{number} is between 51 and 100"
else
if num < 0
puts "You can't enter a negative number!"
else
puts "#{number} is above 100"
end
end
end
puts "Please enter a number between 0 and ... | true |
99de4797dc2ffc2675823d4af85265d5f173609c | Ruby | rsoemardja/Codecademy | /Ruby/Learn Ruby/Object-Oriented Programming, Part II/Object-Oriented Programming, Part II in Ruby/Module Magic.rb | UTF-8 | 202 | 2.625 | 3 | [] | no_license | # We will cover more Modules to discover how Magical they really are
# Create your module below!
module Languages
# Here we made a constant called FAVE and set it equal to a string
FAVE = "CSharp"
end | true |
075aa750a08144afcc26675dbc547fe577786ab0 | Ruby | IvikGH/imager | /lib/imager.rb | UTF-8 | 1,316 | 3.03125 | 3 | [] | no_license | require 'rubygems'
require 'httparty'
require 'nokogiri'
require 'uri'
# Main class
class Imager
def self.get_images
puts 'Enter the page link:'
PageParser.get_images_link(gets.chomp)
end
end
# Get copy of page
class PageLoader
include HTTParty
ERROR_MESSAGE = 'Bad URL or internet connevtion'.freeze
... | true |
a7cdbf39d6517971fd05937eef553d740ab4bf1d | Ruby | venkydmadgundi/movie_booking | /app/models/booking.rb | UTF-8 | 1,023 | 2.8125 | 3 | [] | no_license | class Booking < ApplicationRecord
belongs_to :user
belongs_to :show
before_save :validate_booking
default_scope { order("updated_at DESC") }
def self.create_booking(booking)
Booking.transaction do
booking.save!
booking.show.available_seats -= booking.seats
booking.show.save!
end
... | true |
2cc01bbadb83904601080e3427d4f2c5e732bd33 | Ruby | ncschameleon/inforouter | /lib/inforouter/responses/base.rb | UTF-8 | 1,932 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Inforouter #:nodoc:
module Responses #:nodoc:
# A base infoRouter SOAP response.
class Base
# Raw response.
attr_accessor :raw
# @param savon_response [Savon::Response]
def initialize(savon_response)
@raw = savon_response.to_hash
parse!
end
class <<... | true |
f673383d71cad6c9c32633d874616eb03ca64f4f | Ruby | adrianomitre/cartesian | /lib/cartesian_iterator.rb | UTF-8 | 1,460 | 3.390625 | 3 | [
"MIT"
] | permissive | require 'iterable'
class Array
include Iterable
end
class CartesianIterator
def initialize(foo, bar)
@lists = []
@tot_iter = 1
product!(foo)
product!(bar)
end
def dup
Marshal.load(Marshal.dump(self))
end
def equal(other)
self.instance_variables.each do |var_name|
retur... | true |
e1ffffc50c19bf7efab661724c0b3528c27c3eb6 | Ruby | davidwilliam/p-adic-crypto-ruby | /data/samples_1.rb | UTF-8 | 581 | 2.578125 | 3 | [] | no_license | require Dir.pwd + "/p-adic-crypto"
puts "Running Key Generation"
k = Gen.new(128)
puts "done!"
puts "Generating random plaintexts"
plaintexts = Array.new(16){ Tools.random_number(16)}
puts "done!"
puts "Generating ciphertexts"
ciphertexts = plaintexts.map{|plaintext| PAdicCrypto.encrypt(k,plaintext)}
puts "done!"
p... | true |
a6f4d87f4c4ec9838de5b7e3461357a3b6279600 | Ruby | abhinav-koppula/canvas_ruby | /spec/unit/application/button_spec.rb | UTF-8 | 1,653 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Button do
it 'should create a button' do
button = Button.new(10, 20, 250, 350, "click me", Color.red)
graphics = double("graphics")
expect(graphics).to receive(:setColor).with(Color.red).exactly(4).times
expect(graphics).to receive(:drawLine).with(10,20,260,20)
ex... | true |
1a3b6db6be55fd33fb240f22aaf56657d7e29925 | Ruby | huangtonyj/DataStruct_Algo | /heaps/heaps_solution/lib/heap.rb | UTF-8 | 2,298 | 3.828125 | 4 | [] | no_license | class BinaryMinHeap
attr_reader :store
def initialize(&prc)
@prc ||= Proc.new {|a,b| a <=> b}
@store = []
end
def count
@store.length
end
def peek
@store[0]
end
def extract
@store[0], @store[-1] = @store[-1], @store[0]
val = @store.pop
BinaryMinHeap.heapify_down(@store, 0... | true |
bb29e978ca06ee94c218779d74bedb3d5ddea3ee | Ruby | laynor/sexpistol | /test/unit/parenthesis_test.rb | UTF-8 | 574 | 2.609375 | 3 | [
"MIT"
] | permissive | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper.rb'))
class ParenthesesTest < Test::Unit::TestCase
def setup
@parser = Sexpistol.new
end
test "should parse sexp containing diffent types of parentheses" do
ast = @parser.parse_string("([1 2 3] {4 5 6})")
assert_equal [[... | true |
26ceef4f3a512f8e5081964c4c96d0f13e2eab58 | Ruby | seankibler/wedding_invitations | /test/unit/wedding_test.rb | UTF-8 | 434 | 2.515625 | 3 | [] | no_license | require 'test_helper'
class WeddingTest < ActiveSupport::TestCase
test "should have bride and groom name in name" do
bride = Bride.new(first_name: 'Brenda', last_name: 'Carver')
groom = Groom.new(first_name: 'Brandon', last_name: 'Claver')
wedding = Wedding.new(bride: bride, groom: groom, wedding_date: D... | true |
4a7b9d80d032bb6a0115d0304781eb41199a010d | Ruby | skp11194/ADAGE | /app/models/data_group.rb | UTF-8 | 2,740 | 2.796875 | 3 | [
"BSD-3-Clause"
] | permissive | class DataGroup
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_accessor :series
def initialize(attributes = {})
self.series = Array.new
attributes.each do |name, value|
send("#{name}=", value)
end
end
def add_to_group data_hash, user... | true |
4ff58fb47441bdc7e65faca7e4d8a14e541da70f | Ruby | jin914/30-Days-of-Code | /Day1.rb | UTF-8 | 506 | 3.78125 | 4 | [] | no_license | i = 4
d = 4.0
s = 'HackerRank '
# Declare second integer, double, and String variables.
input_int = gets
input_double = gets
input_string = gets
# Read and save an integer, double, and String to your variables.
# Print the sum of both integer variables on a new line.
puts i + input_int.to_i
# Print the sum of the dou... | true |
5426b904408eb6acd160a81c0b5dc4699dd6c604 | Ruby | RobertDober/lab42_nested_hash | /spec/unit/hierarchies/tree_form_spec.rb | UTF-8 | 2,015 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe NHash do
describe :hierarchies do
context 'tree form' do
let(:ints){
described_class.new( twelve: 'i12' )
.with_indifferent_access
}
let(:odds){
described_class.new(
one: 'o1', three: 'o3')
.with_indifferent_access
... | true |
7f3ac61d6688ff2e6845ad699268a0e137314c74 | Ruby | nullsix/tinder | /spec/models/version_spec.rb | UTF-8 | 5,877 | 2.671875 | 3 | [] | no_license | # == Schema Information
#
# Table name: versions
#
# id :integer not null, primary key
# title :string(255)
# content :text
# created_at :datetime not null
# updated_at :datetime not null
# piece_id :integer
# number :integer
#
require 'spec_helper'
shared_example... | true |
0dd2274484e0931867fcc09626aff689052f6bf6 | Ruby | eabrash/stacks-queues | /Queue.rb | UTF-8 | 730 | 3.859375 | 4 | [] | no_license | class Queue
def initialize
@store = Array.new
end
def enqueue(element)
@store << element
end
def dequeue
return @store.delete_at(0) # Or use .shift method. There is also a .unshift method that appends to the beginning
end
def front
return @store.first
end
def size
return @sto... | true |
cbb85b049a4820d487ea7eb0721390e2628f07c6 | Ruby | trustvox/sales_up | /app/controllers/concerns/contract_data_points.rb | UTF-8 | 1,868 | 2.859375 | 3 | [
"MIT"
] | permissive | module ContractDataPoints
def start_contract
@data = { contract_sum: 0, partial_sum: 0, vendor_names: '',
store_names: '', value: 1, wait: false }
end
def fetch_contract_data(searched_contract)
search_contract_data(searched_contract)
end
def fetch_contract_points
@contract_data.col... | true |
e2bd0cd709dc167957d477bae52b663f53992d2f | Ruby | chippolot/advent-of-code | /2018/06/6_1.rb | UTF-8 | 3,017 | 3.890625 | 4 | [] | no_license | =begin
The device on your wrist beeps several times, and once again you feel like you're falling.
"Situation critical," the device announces. "Destination indeterminate. Chronal interference detected. Please specify new target coordinates."
The device then produces a list of coordinates (your puzzle input). Are they ... | true |
41d72efe942e485c2fd942971d6c9f03b94b2d2c | Ruby | FrankYan93/nanotwitter | /api/test/reset.rb | UTF-8 | 3,409 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'csv'
require 'time'
# delete all data and create a testuser
get '/api/v1/test/reset/all' do
deleteAll
resetTestuser
user_size = User.count
"user size = #{user_size}"
end
# create data based on seeds
# /api/v1/test/reset/standard?n=8000
get '/api/v1/test/reset/standard' do
Thread.new do
... | true |
527f92bf2a5402ae8e5253e17973fead32e650e1 | Ruby | bestriser/rails_school | /jyanken_191104.rb | UTF-8 | 1,560 | 3.984375 | 4 | [] | no_license | puts "これは、じゃんけんゲームです。"
puts "自分手を「グー(1) チョキ(2) パー(3)」から選択して下さい。"
mine_hand = gets.chomp!
partner_hand = rand(1..3)
loop{
if mine_hand == "1"
puts "あなたが出したのは、グーです。"
elsif mine_hand == "2"
puts "あなたが出したのは、チョキです。"
elsif mine_hand == "3"
puts "あなたが出したのは、パーです。"
else
puts "1~... | true |
043c6a8ad94011b88735d7fcefb7dfd7b628fca5 | Ruby | ton00987/test_git_heroku | /features/step_definitions/movie_steps.rb | UTF-8 | 1,304 | 2.9375 | 3 | [] | no_license | Given ("the following movies exist:") do |table|
# table is a Cucumber::MultilineArgument::DataTable
table.hashes.each do |movie|
Movie.create(movie)
end
end
Then /^I should see (none|all) of the movies$/ do |should|
rows = page.all("table#movies tbody tr td[1]").map {|t| t.text}
if should == "... | true |
95181a17b49f523efe3fe27a78da6114e4c67589 | Ruby | glnlewedim/phase-0-tracks | /ruby/shout.rb | UTF-8 | 547 | 3.546875 | 4 | [] | no_license |
=beginmodule Shout
def self.yell_angrily(words)
puts words + "!!!" + " :("
end
def self.yelling_happily(words)
puts words + "!!!" + ":)"
end
end
Shout.yell_angrily ("AHHHHHH")
Shout.yelling_happily ("yayyyyyy!!")
=end
module Shout
def screaching(words)
puts words + "**!!!***" + ":%... | true |
cc3cc2e25da7503fac4f4de6cdd50100aeb231a0 | Ruby | jpjane89/problem_solving_algorithms_data | /parenthesisStack.rb | UTF-8 | 867 | 3.515625 | 4 | [] | no_license | def par_checker(string)
s = Stack.new
balanced = true
index = 0
while index < string.length and balanced
symbol = string[index]
if symbol == "("
s.push(symbol)
else
if s.is_empty
balanced = false
else
s.pop
end
end
index += 1
end
if balanced and s.is_empty
return true
else
ret... | true |
5f81a4375cce54b741b2766fd3037cedbaba2a36 | Ruby | ha4gu/atcoder | /ABC/030/038/B.rb | UTF-8 | 123 | 3.1875 | 3 | [] | no_license | h1, w1 = gets.split.map(&:to_i)
h2, w2 = gets.split.map(&:to_i)
puts (h1==h2 || h1==w2 || w1==h2 || w1==w2) ? 'YES' : 'NO'
| true |
1b7b997d9eadc9159b1ec406d74240624ff42bf0 | Ruby | laurasimmons30/rescue-mission | /rescue-mission-app/spec/features/user_asks_question_spec.rb | UTF-8 | 1,884 | 2.703125 | 3 | [] | no_license | require 'rails_helper'
feature ' user visits ask question page and fills out form to ask question', %(
As a user
I want to post a question
So that I can receive help from others
) do
#Acceptance Criteria
# - I must provide a title that is at least 40 characters long
# - I must provide a description tha... | true |
dd41ea093d7dfa4831f0ad45c40b69343de8c5db | Ruby | phiggins/braincandy | /rainbow-parens/prettifier.rb | UTF-8 | 2,521 | 3.296875 | 3 | [] | no_license | require 'strscan'
COLORS = {
:blank => "\e[0m",
:red => "\e[31m",
:green => "\e[32m",
:yellow => "\e[33m",
:blue => "\e[34m",
:magenta => "\e[35m",
:cyan => "\e[36m",
}
class Prettifier
OPEN_PARENS = ['(', '[', '{']
CLOSE_PARENS = [')', ']', '}']
STRING_DELIM = %w[' "]
... | true |
229c021c15ee183571f1fa0bff011aefb6bfcbcc | Ruby | chegewara/ogn_client-ruby | /lib/ogn_client/aprs.rb | UTF-8 | 1,759 | 2.75 | 3 | [
"MIT"
] | permissive | module OGNClient
# Minimalistic APRS implementation for OGN
#
# Use a unique all-uppercase callsign to create the instance and then
# connect with or without filters.
#
# OGNClient::APRS.start(callsign: 'OGNC', filter: 'r/33/-97/200') do |aprs|
# puts aprs.gets until aprs.eof?
# end
#
# See... | true |
98e2f9acd839818d87ccc7f1d49112d574bc72d8 | Ruby | robbkidd/advent-of-code | /2018/day02.rb | UTF-8 | 1,949 | 3.40625 | 3 | [] | no_license | class Day2
def self.part1
box_ids = File.read('day02-input.txt').split("\n")
BoxScanner.new.checksum(box_ids)
end
def self.part2
box_ids = File.read('day02-input.txt').split("\n")
bs = BoxScanner.new
correct_box_ids = bs.off_by_one(box_ids)
bs.common_characters(*correct_box_ids)
end
end... | true |
40eda7f79fe51475ba1a86ec02a13149ac03b25f | Ruby | PandaBean18/Ghost | /game.rb | UTF-8 | 734 | 3.453125 | 3 | [] | no_license | #this is the main file. run this to play the game
require_relative "player.rb"
require "byebug"
$Game = Players.new()
def ask_user
puts "please type the number of players"
num_players = gets.chomp.to_i
i = 0
while i < num_players
puts " "
puts "please type the name of player " + (i + 1).... | true |
e32adc7587955ecf0b304a1a71a010e4f9733941 | Ruby | nathanandre/yield-and-return-values-onl01-seng-ft-072720 | /lib/practicing_returns.rb | UTF-8 | 191 | 3.6875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def hello(array)
counter = 0
while counter < array.length
yield(array[counter])
counter += 1
end
end
hello(["Tim", "Tom", "Jim"]) { |name| puts "Hi, #{name}" }
| true |
de21a7067315ef0e3522c04e1ad660f2ff372f23 | Ruby | paulcc/spree-demo | /vendor/gems/chriseppstein-compass-0.5.4/lib/compass/installers/manifest.rb | UTF-8 | 1,219 | 2.65625 | 3 | [] | no_license | module Compass
module Installers
class Manifest
# A Manifest entry
class Entry < Struct.new(:type, :from, :options)
def to
options[:to] || from
end
end
def initialize(manifest_file = nil)
@entries = []
parse(manifest_file) if manifest_file
... | true |
45a1919eae59a353366518e4edf91f558538415f | Ruby | josh-works/turing_school_ruby_exercises | /comparisons/string_comparison_test.rb | UTF-8 | 1,534 | 2.96875 | 3 | [
"MIT"
] | permissive | gem 'minitest', '~> 5.2'
require 'minitest/autorun'
require 'minitest/pride'
require 'minitest/homework'
class StringComparisonsTest < Minitest::Homework
be_gentle!
def test_equality
s1 = "abc"
s2 = "abc"
maybe s1.object_id == s2.object_id
maybe s1 == s2
end
def test_greater_or_less_than
... | true |
eeaf9ce1f6fe8fdecd39ceb206a934b39ef1e675 | Ruby | fusillicode/mission-to-mars | /spec/plateau_spec.rb | UTF-8 | 2,233 | 2.578125 | 3 | [] | no_license | require 'rspec'
require 'spec_helper'
require 'plateau'
describe Plateau do
describe '#initialize' do
it_behaves_like 'load mission file'
it do
allow(File).to receive(:open).with('dummy_file_path').and_return(['1 2 3'])
expect { described_class.new('dummy_file_path') }
.to raise_error(Tw... | true |
4de5c97844592da950f52f085bf9f3875fa0ea9d | Ruby | Mikoto882/furima-34334 | /spec/models/item_spec.rb | UTF-8 | 4,912 | 2.5625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Item, type: :model do
before do
@item = FactoryBot.build(:item)
end
describe "商品出品機能" do
context '商品出品ができるとき' do
it "商品画像が1枚あれば出品できる" do
expect(@item).to be_valid
end
it "商品名があれば出品できる" do
@item.title = 'test'
@item... | true |
abc58c4d719df0910a9432f2e419ebe2c14ac87b | Ruby | MEdwards0/chitter-challenge-apprenticeships | /spec/message_spec.rb | UTF-8 | 535 | 2.796875 | 3 | [] | no_license | require 'message'
describe Message do
describe '.all' do
it 'can add a peep to database' do
Message.peep(message: 'This is a peep')
#----
# p Message.all
#----
expect(Message.all.length).to eq 1
expect(Message.all.first.message).to eq 'This is a peep'
end
end
descr... | true |
1a609ca9419280e6f145ec15740b3cad5e4e3d96 | Ruby | opencivicdata/ocd-division-ids | /scripts/country-ca/ca_census_subdivisions.rb | UTF-8 | 3,659 | 2.828125 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | #!/usr/bin/env ruby
# coding: utf-8
require File.expand_path(File.join("..", "utils.rb"), __FILE__)
# Scrapes census subdivision codes and names from Statistics Canada
class CensusSubdivisions < Runner
def names
organization_names = {
"4819006" => "County of Grande Prairie No. 1", # Municipality of Grand... | true |
2466714fe5662b31de014b65267950ec1b21320b | Ruby | k-ankobia/chitter-challenge | /lib/peeps.rb | UTF-8 | 751 | 2.890625 | 3 | [] | no_license | require 'pg'
require 'dotenv/load'
class Peeps
attr_reader :id, :message, :time
def initialize(id:, message:, time:)
@id = id
@message = message
@time = time
# Time.now.strftime "%d/%m/%Y %H:%M"
end
def self.all
connection = PG.connect(dbname: ENV['DATABASE'])
query = 'SELECT * FROM ... | true |
dca7317759bd92203e9650c4961e1a956fd9d614 | Ruby | makevoid/presentations | /ruby/keyword_arguments_merge.rb | UTF-8 | 160 | 3.59375 | 4 | [] | no_license | def foo(args = {})
defaults = { a: 1, b: 2 }
values = defaults.merge args
puts "a is #{values[:a]}, b is #{values[:b]}"
end
foo(b: 4) # => a is 1, b is 4 | true |
10745bff619a32ffd71c661994b5bd93286ef963 | Ruby | SecondBureau/midas | /app/models/entry.rb | UTF-8 | 5,657 | 2.65625 | 3 | [] | no_license | class Entry < ActiveRecord::Base
attr_accessible :label, :category_id, :account_id, :src_amount_in_cents, :cheque_num, :invoice_num, :operation_date, :status
belongs_to :account, :inverse_of => :entries
belongs_to :category, :inverse_of => :entries
before_validation :set_currency, :set_amount
def amount
... | true |
550dc2b1415de4279d14eef3445064b6cb6d442c | Ruby | mcarpenter/csvobj | /test/test_parse.rb | UTF-8 | 2,704 | 2.984375 | 3 | [
"BSD-2-Clause"
] | permissive |
require 'test/unit'
require 'stringio'
require 'csvobj'
class TestParse < Test::Unit::TestCase
def setup
@parser = Class.new(CSVobj)
end
def teardown
@parser = nil
end
def test_duplicate_header
s = "foo,bar,bar,baz\n1,2,3,4\n"
assert_raise CSVobjDuplicateHeader do
@parser.parse(s)
... | true |
e87e586bb82163d98f1b09db1fd19b6ba12bd792 | Ruby | kig/rdma-pipe | /rdpipe | UTF-8 | 3,313 | 2.53125 | 3 | [] | no_license | #!/usr/bin/ruby
require 'optparse'
VERSION = "1"
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: rdpipe [options] HOST:CMD ..."
opts.on("-v", "--verbose", "Run verbosely") do |v|
options[:verbose] = v
end
opts.on("-n", "--dryrun", "Print out pipeline commands but don't execute them") do |v... | true |
7184479432787d946c9a70aa99cadd0107f7e63d | Ruby | ChaimSh/oo-student-scraper-online-web-sp-000 | /lib/scraper.rb | UTF-8 | 1,325 | 2.875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'open-uri'
require 'nokogiri'
require 'pry'
class Scraper
attr_accessor :students
def self.scrape_index_page(index_url)
index_html = open(index_url)
index_doc = Nokogiri::HTML(index_html)
student_cards = index_doc.css(".student-card")
students_array = []
student_cards.collect do |info|
stude... | true |
10073709a13f5f211c2e2b857f35928903d0e58b | Ruby | inasacu/thepista | /httparty/ruby/1.9.1/gems/moped-1.5.2/lib/moped/protocol/update.rb | UTF-8 | 3,558 | 2.71875 | 3 | [
"MIT"
] | permissive | module Moped
module Protocol
# The Protocol class for updating documents in a collection.
#
# @example Rename a user
# Update.new "moped", "users", { _id: "123" }, { name: "Bob" }
#
# @example Rename all users named John
# Update.new "moped", "users", { name: "John" }, { name: "Bob" }... | true |
402149dcfc88c8f67a712d9bb14a733b61089da4 | Ruby | bomatson/FutureMe | /Future.rb | UTF-8 | 3,127 | 3.640625 | 4 | [] | no_license | require './Past.rb'
class Future
def initialize(name, engine)
@name = name
@past = Past.new(@name, engine)
@engine = engine
end
def description
puts "You've found yourself in Los Angeles, 2030. Way to go #{@name}!"
puts "Hilariously enough, there's no traffic"
puts "Do you:"
put... | true |
f1610c157584c3d0d4a8bdafa16632adc2ff6adc | Ruby | Sam-Killgallon/hangman | /console_hangman.rb | UTF-8 | 1,357 | 4.15625 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'io/console'
class TooManyLetters < StandardError ; end
class HangmanGame
attr_accessor :displayed_word, :lives
attr_reader :word
def initialize(word)
@word = word
@displayed_word = '*' * word.size
@lives = 3
end
def guess_letter(letter)
raise TooManyLetters if... | true |
70eb125c26610477a8a63e2a569e08159f4b6749 | Ruby | adambeynon/opal | /spec/opal/core/numeric/lte_spec.rb | UTF-8 | 281 | 3.125 | 3 | [
"MIT"
] | permissive | describe "Numeric#<=" do
it "returns true if self is less than or equal to other" do
(2 <= 13).should == true
(-600 <= -500).should == true
(5 <= 1).should == false
(5 <= 5).should == true
(-2 <= -2).should == true
(5 <= 4.999).should == false
end
end | true |
ed3f0e44c6de67ad7081cce2869b73457a9063dd | Ruby | jsertel/ruby_practice | /imperial_to_imperial.rb | UTF-8 | 650 | 4.21875 | 4 | [] | no_license | # puts 72 * 2.54
puts "What is your name?"
user_name = gets.chomp
#users weight in lbs
puts "How much do you weigh in pounds?"
weight_lbs = gets.chomp.to_f
puts "How much do your height in inches?"
#users height in inches.
height_in = gets.chomp.to_f
#lbs to kg conversion factor
lbs_to_kg = 0.45
#inches to cm conversi... | true |
b997bfd39b4564b3baa17c3191c1333646d1b210 | Ruby | Yoni-Satat/week2_day2_homework | /specs/fish_specs.rb | UTF-8 | 232 | 2.609375 | 3 | [] | no_license | require_relative('../fish.rb')
require('minitest/autorun')
require('minitest/rg')
class TestFish < MiniTest::Test
def setup
@fish = Fish.new("Yoni")
end
def test_fish_name
assert_equal("Yoni", @fish.name)
end
end
| true |
03d9ed60baff9bba176a259e62c976e0db79887f | Ruby | CodeCoreYVR/june-2016-fundamentals | /ruby_day_1/car.rb | UTF-8 | 303 | 3.421875 | 3 | [] | no_license | puts "Which year is car?"
year = gets.to_i
if year == 2016
puts "New"
elsif year > 2016
puts "Future!"
elsif year < 2000
puts "Very old"
else
puts puts "Old"
end
if year == 2016
puts "New"
elsif year > 2016
puts "Future!"
elsif year > 2000
puts puts "Old"
else
puts "Very old"
end
| true |
54c140b5ba262f2e4a34b2f6f6468b5c126ab3e9 | Ruby | nberveiler/gitlab-development-kit | /tooling/danger/roulette.rb | UTF-8 | 6,034 | 2.671875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative 'teammate'
require_relative 'request_helper'
require_relative 'weightage/reviewers'
require_relative 'weightage/maintainers'
module Tooling
module Danger
module Roulette
ROULETTE_DATA_URL = 'https://gitlab-org.gitlab.io/gitlab-roulette/roulette.json'
HO... | true |
f6b29865d51d8457267263f98bd9f9d2a3c8b5ff | Ruby | carquet/practice_exercises_folder | /Caesar/spec/caesar_spec.rb | UTF-8 | 1,205 | 3.5625 | 4 | [] | no_license | #spec/caesar_spec.rb
require './lib/caesar'
RSpec.describe Caesar do
describe "#solve_cipher" do
it "returns a string of shifted characters by 1 number" do
caesar = Caesar.new("Hello Dolly!", 1)
expect(caesar.solve_cipher).to eql("Ifmmp Epmmz!")
end
it "returns a string of shifted characters by 2 number" ... | true |
00283119e6aec125910a98a48da401665c8fdd89 | Ruby | stussy446/phase-0-tracks | /ruby/shout.rb | UTF-8 | 608 | 3.96875 | 4 | [] | no_license | #module Shout
#def self.yell_angrily(words)
#words + "!!!" + " :("
#end
#def self.yelling_happily(words)
#words + "!!!" + " :) :) :)"
#end
#end
# TEST CODE
#puts Shout.yell_angrily("NOOO")
#puts Shout.yelling_happily("YESSSS")
module Shout
def yell_angrily(words)
words + "!!!" + "... | true |
4681cf77f58d9c4118eb03f2dffa3e0bd872036d | Ruby | rui725/rui-portf | /practices/ruby/tut10.rb | UTF-8 | 1,593 | 3.734375 | 4 | [] | no_license | #!/usr/bin/env ruby
#input/output
#automtic new line
puts "hello"
#prints a character no new line
putc 'e'
#no newline
print "hello"
puts ""
#simple input
i = gets
puts "\ninputted #{i}"
#highline
require 'rubygems'
require 'highline/import'
loop do
cmd = ask("Enter command: ", %w{save loa... | true |
5cf598dc9a9394b8ebfc5db773ba30d0dd57edb9 | Ruby | kkrmno/imgrb | /lib/imgrb/text.rb | UTF-8 | 1,365 | 3.203125 | 3 | [
"MIT",
"CC0-1.0"
] | permissive | module Imgrb
##
#This class represents textual data along with any keywords read from chunks
#that deal with text (i.e. tEXt, zTXt, and iTXt)
class Text
attr_reader :language, :translated_keyword
def initialize(keyword, text, compressed = false, international = false,
language = "", t... | true |
8b92e658561908fd2a5e99e1b94e1f86bcdb9af0 | Ruby | dayjp44/lmtgroups | /app/models/user.rb | UTF-8 | 5,410 | 2.6875 | 3 | [] | no_license | require 'digest/sha1'
class User < ActiveRecord::Base
acts_as_mappable
belongs_to :role
has_many :members
has_many :gradings
has_many :reports, :order => "date_of_meeting DESC"
has_many :notes, :order => "created_at DESC"
has_many :facilitator_assignments_as_parent, :class_name => "FacilitatorAss... | true |
148dc2e90cf5acb58c231edcc2b76acc75b3a4f6 | Ruby | cihad/hs | /app/models/concerns/taggable.rb | UTF-8 | 363 | 2.625 | 3 | [] | no_license | using TurkishSupport
module Taggable
extend ActiveSupport::Concern
included do
has_many :taggings, as: :taggable, dependent: :destroy
has_many :tags, through: :taggings
end
def tag_list
tags.map(&:name).join(', ')
end
def tag_list=(tag_list)
self.tags = tag_list.map { |tag_name| Tag.find... | true |
5804b2a24b29fe03400844fd12fa3400af356170 | Ruby | AtActionPark/odin_chess | /spec/board_spec.rb | UTF-8 | 13,451 | 3.296875 | 3 | [] | no_license | require 'spec_helper'
describe "Board" do
let(:board) {Board.new}
before(:each) do
board.clear_board
end
describe "#initialize" do
it "creates a properly sized empty 2d array" do
expect(board.grid[0][0]).to eql nil
expect(board.grid[7][7]).to eql nil
end
end
describe "#get_cell" ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.