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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
6f8d6abfb72f8dff6454e3ff31cf935b7c80d0d5 | Ruby | larsjoakimgrahn/advent-of-code | /2022/09/part_1.rb | UTF-8 | 1,311 | 3.28125 | 3 | [] | no_license | Move = Struct.new('Move', :direction, :distance)
Point = Struct.new('Point', :x, :y)
$input = File.readlines('input.txt').map{|line| line.gsub("\n", '')}
.map{|line| Move.new(line.split(' ')[0], line.split(' ')[1].to_i) }
$visited_points = {[0,0]=>1}
$head_position = Point.new(0,0)
$tail_position = Point.new(0,0)
... | true |
72786853a28eee84bdad80d961026431ec14c3f5 | Ruby | Ralst0n/The-Odin-Project | /Ruby/Building_Blocks_Projects/word_frequency.rb | UTF-8 | 276 | 3.25 | 3 | [] | no_license | #histogram of word frequency in a string. redundant, I know.
def word_count(str)
str_arr = str.split(' ')
word_total = {}
str_arr.each do |word|
if word_total.include?word
word_total[word] +=1
else
word_total[word] = 1
end
end
word_total
end
| true |
06838bbe99144c7f84a88aa05e31e019e0ca70f7 | Ruby | 15Dkatz/agile-ruby | /chapter5/Trip.rb | UTF-8 | 582 | 3.296875 | 3 | [] | no_license | class Trip
attr_reader :bicycles, :customers, :vhicle
def prepare(preparers)
preparers.each {|preparer|
# prepare_trip is the method implemented through the duck type
preparers.prepare_trip(self)}
end
end
# Preparers are an interface and duck type
class Mechanic
def prepare_trip(trip)
tri... | true |
e1cbcaea7373931816034478d06c2f52357e3447 | Ruby | Kighway/rspec-fizzbuzz-web-1116 | /fizzbuzz.rb | UTF-8 | 158 | 3.46875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def fizzbuzz(number)
output = ""
output += number%3 == 0 ? "Fizz" : ""
output += number%5 == 0 ? "Buzz" : ""
output = output == "" ? nil : output
end
| true |
df4e4df0d0d0b8bbca59477ca3ec000e8174d8c1 | Ruby | ericgj/rubekah | /test/dummy_server.rb | UTF-8 | 1,462 | 2.6875 | 3 | [] | no_license | require 'rubygems'
require 'eventmachine'
module EchoIRC
attr_accessor :nick
def post_init
@@connections ||= []
@regstate = 0
send_registration
end
def receive_data data
(@buffer ||= BufferedTokenizer.new).extract(data).each do |line|
receive_line(line)
end
end
def rec... | true |
96ac1741425b34dcb29a25f768a236f03c4e4982 | Ruby | voxmedia/rich-text-ruby | /lib/rich-text/iterator.rb | UTF-8 | 912 | 3.03125 | 3 | [
"MIT"
] | permissive | module RichText
# @api private
class Iterator
def initialize(ops)
@ops = ops
reset
end
def each(size = 1)
return enum_for(:each, size) unless block_given?
yield self.next(size) while next?
end
def peek
if op = @ops[@index]
op.slice(@offset)
else
... | true |
6f201ed55645ea9242e26a32a903c06e3df5889c | Ruby | Hareramrai/parking_lot | /spec/supports.rb | UTF-8 | 379 | 2.9375 | 3 | [] | no_license | def run_command(pty, command)
stdout, stdin, _pid = pty
stdin.puts command
sleep(0.3)
stdout.readline
end
def fetch_stdout(pty)
stdout, _stdin, _pid = pty
res = []
while true
begin
Timeout.timeout 0.5 do
res << stdout.readline
end
rescue EOFError, Errno::EIO, Timeout::Error
... | true |
00e2ed10a49beb888164583d218971f608af13d5 | Ruby | kennethcalamay/shinkyokushin | /db/seeds.rb | UTF-8 | 2,318 | 2.59375 | 3 | [] | no_license | puts 'Cleaning up...'
%w{ Instructor Member Dojo AdminUser }.each do |model|
model.constantize.delete_all
end
puts 'Creating instructor...'
james = Instructor.new(
is_active: true,
first_name: 'James',
last_name: 'Dela Cruz',
email: 'james@shinkyokushin.co... | true |
f5146d3f646238f1889cde4d3b089c915ef77224 | Ruby | ErikDeBruijn/rdw | /lib/rdw/configuration.rb | UTF-8 | 768 | 2.859375 | 3 | [
"MIT"
] | permissive | module RDW
class Configuration
# Configure a cache to be used. Leave nil if no cache should be used.
attr_accessor :cache
# If you are using the cache you can set a custom prefix for cache keys.
# Default value: rdw_
attr_accessor :cache_prefix
# If set to true, Dutch values will be transl... | true |
792b06073517c338ee3fb043d8bcc8ea715d273f | Ruby | ray-curran/phase-0 | /week-5/pad-array/my_solution.rb | UTF-8 | 4,213 | 4.59375 | 5 | [
"MIT"
] | permissive | # Pad an Array
# I worked on this challenge with Karen Ball
# I spent 2 hours on this challenge.
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented in the file.
# 0. Pseudocode
# What is the input? an array, a ... | true |
2162e48e7005e04f4ebbe419f308616410f95ab3 | Ruby | Coredump-FHP/chess | /spec/models/bishop_spec.rb | UTF-8 | 1,592 | 2.71875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Bishop, type: :model do
def create_bishop(x, y)
FactoryGirl.create(:bishop, x_coordinate: x, y_coordinate: y)
end
describe '#valid_move?' do
it 'should move diagonally lt-bottom to rt-top any number of steps on the board' do
bishop = create_bishop(0, 0)
... | true |
6ba66542939f5c85926f54f530854ee85ed2e7e3 | Ruby | onebusjenny/countdown-to-midnight-online-web-prework | /countdown.rb | UTF-8 | 96 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #write your code here
def countdown
x = 10
while x > 0
puts "#{x} SECONDS!"
x -= 1
end
| true |
7b492ae541ec849ed7c2ec7baf5a2e7a4c4efd35 | Ruby | LewisYoul/ruby-kickstart | /session3/challenge/17_hashes.rb | UTF-8 | 587 | 4.3125 | 4 | [
"MIT"
] | permissive | # Print to stdout, each element in a hash based linked list, in reverse.
# If you don't know what that is, go check out the previous problem.
#
# EXAMPLES:
# head = {:data => 1, :next => nil}
# head = {:data => 2, :next => head}
#
# print_list_in_reverse head # >> "1\n2\n"
=begin
head = {:data => 1, :next => nil}
he... | true |
589e0b7bb1aba596725c2b04136448467e2224ba | Ruby | demonsheepgit/demonasimov | /plugins/lib/dj/requests.rb | UTF-8 | 4,064 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | require 'date'
require 'open-uri'
require 'pp'
require 'redis'
require 'json'
require_relative '../logging'
require_relative 'song'
require_relative 'amazonSong'
require_relative 'spotifySong'
require_relative 'spotifyPlaylist'
class Requests
include Logging
SATURDAY = 6
DEADLINE_HOUR = 9
attr_reader :show_d... | true |
7989239bcb4f476cc10fc5927f91143e62f30bbf | Ruby | maowaw/mini_jeu_POO | /lib/player.rb | UTF-8 | 2,880 | 3.875 | 4 | [] | no_license |
class Player
attr_accessor :name, :life_points #read&write attributes
def initialize (name) #allows to create a player. we only have to type the name in
@name = name
@life_points = 10 #every player has 10 points at the beginning. without coma so it knows it's an integer
end
def show_state #allows to ... | true |
93e9d996154374af8b68a7512a8eceb60441b22a | Ruby | marissa-a/kwk-l1-instance-methods-lab-ruby-kwk-students-l1-la-070918 | /lib/dog.rb | UTF-8 | 112 | 3.46875 | 3 | [] | no_license |
class Dog
def bark
puts "Woof!"
end
def sit
puts "The Dog is sitting"
end
end
puts Dog
| true |
2be874be4552da2c8bc4c6bebe19cc32c1a82768 | Ruby | aronsonben/School-Projects | /CMSC330/p4_SmallCInterpreter/p4a_SmallCParser/testing/framework/TestConfig.rb | UTF-8 | 525 | 2.546875 | 3 | [] | no_license | require "yaml"
class TestConfig
@@NAME = "name"
@@TYPE = "type"
@@RESOURCES = "resources"
@@LOCAL_RESOURCES = "local_resources"
@@MODULES = "modules"
def initialize(filename)
@config = YAML::load_file(filename)
end
def name
@config[@@NAME]
end
def type
... | true |
8543cf01822d97cb134cc0a05d9890e6a9ea6761 | Ruby | nfisher/FBomb | /test/request_test.rb | UTF-8 | 1,200 | 2.546875 | 3 | [
"BSD-3-Clause"
] | permissive | # To change this template, choose Tools | Templates
# and open the template in the editor.
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
require 'test/unit'
require 'request'
require 'digest/md5'
module Facebook
class RequestTest < Test::Unit::TestCase
def setup
@instance = Facebook::Request.new
... | true |
895d63c2d258023f0b79e51ac0855f8806f8a5f3 | Ruby | nick-stebbings/ruby-rb101-109 | /OOP/ruby_OOP_small_problems/Easy_1/09_complete_the_program_-_cats!.rb | UTF-8 | 1,414 | 4.09375 | 4 | [] | no_license | class Pet
attr_accessor :name, :age
def initialize(name, age)
@name = name
@age = age
end
end
class Cat < Pet
attr_reader :color
def initialize(name, age, col)
super(name, age)
@color = col
end
def to_s
"My cat #{name} is #{age} years old and has #{color} fur."
end
... | true |
f7b910d513114f87845164fc2ede0a54c5e3816e | Ruby | shanghuifu/medi-chart | /app/models/reservation.rb | UTF-8 | 697 | 2.671875 | 3 | [] | no_license | class Reservation < ApplicationRecord
with_options presence: true do
validates :date
end
belongs_to :patient
belongs_to :schedule
def rsv_date_check(days)
none = ""
if self.date == Date.today + days
return self.patient.name
else
return none
end
end
def rsv_time_check(sch... | true |
36e6dc60dc11850180673a9ebecc58f55328519c | Ruby | meeke198/W2D3 | /battleship_project/lib/board.rb | UTF-8 | 3,380 | 3.609375 | 4 | [] | no_license | # require "byebug"
# class Board
# attr_reader :size
# def initialize(n)
# # debugger
# @grid = Array.new(n){Array.new(n, :N)}
# @size = n * n
# end
# def [](pos)
# # debugger
# row, col = pos
# @grid[row][col]
# end
# def []=(pos, value)
# ... | true |
bfb26123da21f9928a64b8c15aceeeb0cc1b78da | Ruby | shimoal/ruby-tests | /03_simon_says/simon_says.rb | UTF-8 | 966 | 3.90625 | 4 | [] | no_license | def echo (string)
string
end
def shout (string)
string.upcase
end
def repeat (words, a=2)
repeats = ' '
repeats = words.to_s + ' ' + words.to_s
while a > 2
repeats = repeats + ' ' + words.to_s
a -= 1
end
repeats
end
def start_of_word (word, a)
x = 0
start = ''
while x < a
start = start + word[x].to... | true |
26400aad326ac72f9dd862c2879510e1986f320a | Ruby | hoshito/AtCoder | /diverta 2019 Programming Contest/main_b.rb | UTF-8 | 221 | 3.15625 | 3 | [] | no_license | r,g,b,n=gets.chomp.split(" ").map(&:to_i)
count = 0
(0..3000).each do |r_i|
(0..3000).each do |g_i|
tmp = n - r * r_i - g * g_i
if tmp >= 0 && tmp % b == 0 then
count += 1
end
end
end
puts count
| true |
223e61555ef8666e27d6c09970ea618d66b4d8e8 | Ruby | kopylovvlad/vc_reader | /lib/vc_reader/config.rb | UTF-8 | 1,766 | 2.546875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module VcReader
# here is only logic how to manipulate with data
class Config
attr_reader :vc_client, :link_repository
def initialize
@vc_client = VcClient.new
@link_repository = LinkRepository.new
end
def current_links
link_repository.current_links... | true |
ed4310e98075a83d183517941f62e957a628eb92 | Ruby | simeonwillbanks/mygists | /app/helpers/profile/tags_helper.rb | UTF-8 | 610 | 2.53125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Profile::TagsHelper
# Public: By default, all requests are not considered a profile. However,
# the Profile::TagsHelper is mixed into profile requests, so we
# override the ApplicationHelper.profile? definition.
#
# Returns a TrueClass.
def profile?
true
end
# Public: Builds... | true |
7ec6126141535d2c76e4e4020f6e312108b603cd | Ruby | vcavallo/dopa_core | /spec/models/dopa_core/leaderboard_spec.rb | UTF-8 | 2,545 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
module DopaCore
describe Leaderboard do
context "World Leaderboard" do
let!(:player_one) { FactoryGirl.create(:player_for_leaderboard, name: "Player One") }
let!(:player_two) { FactoryGirl.create(:player_for_leaderboard, name: "Player Two") }
let!(:player_three) { FactoryG... | true |
ec9859a9c1c6e651f80c9a0980444262eb0cc8fe | Ruby | joshuaneedham/ruby-learn | /test-area/lib/testing.rb | UTF-8 | 184 | 3.3125 | 3 | [] | no_license | def testing
empty_array = []
test_array = [1,2,3,4,5]
test_array.select do |number|
empty_array << number.even?
end
puts test_array
puts empty_array
end | true |
3ac2a9059b344e485fc3571466479979923f2de7 | Ruby | AlecR/coursegen | /lib/coursegen/cli.rb | UTF-8 | 1,435 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'thor'
require 'coursegen/templates'
require 'nanoc'
require './cg_config.rb' if File.exist? 'cg_config.rb'
module CourseGen
class CLI < Thor
include Thor::Actions
desc "new COURSE", "Create a new course by calling nanoc. Argument is name of the COURSE"
def new(course)
run("nanoc create-si... | true |
b79ccccacaa9bddcfb15ac9be6232a43f8f3c7d4 | Ruby | fanjieqi/LeetCodeRuby | /601-700/687. Longest Univalue Path.rb | UTF-8 | 537 | 3.359375 | 3 | [
"MIT"
] | permissive | # Definition for a binary tree node.
# class TreeNode
# attr_accessor :val, :left, :right
# def initialize(val)
# @val = val
# @left, @right = nil, nil
# end
# end
def depth(root, val)
root&.val != val ? 0 : [depth(root.left, val), depth(root.right, val)].max+1
end
# @param {TreeNode} ro... | true |
363ec8c68b6e4f29e624f384c2e55fe35eaeab9a | Ruby | trivett/BEWD-NYC | /nikhita_kamath/class6/animals/main.rb | UTF-8 | 802 | 3.578125 | 4 | [] | no_license | require_relative 'lib/Dog'
require_relative 'lib/Cat'
require_relative 'lib/module'
dog1 = Dog.new(3,"a lot","bark at the mailman","spayed","super friendly","super cute","fierce")
dog2 = Dog.new(2,"a little","bark rarely","not spayed","not so friendly","uglyyy","not so fierce")
dog3 = Dog.new(1,"not at all","bark ince... | true |
ec5e2eecd0f001573e07fde121f67f2e4f448241 | Ruby | Msegun/hello-rspec-Msegun | /CodeQuizzes/spec/questionThirteen_spec.rb | UTF-8 | 337 | 3.28125 | 3 | [] | no_license | require_relative '../lib/questionThirteen'
class String
def alliteration?
letter = self[0]
self.split.all? do |w|
w[0] == letter
end
end
end
describe "#to_money" do
it "converts float to money format" do
expect(12.991.to_money).to eq '$12.99'
end
it "correctly rounds zeros" do
expect(9.0.to_money).to eq... | true |
50cb28d0a4f0ed4bd32927057718cfc3c723c11e | Ruby | tanyeun/scripts | /translate.rb | UTF-8 | 3,166 | 3 | 3 | [] | no_license | require 'optparse'
require 'ostruct'
require 'fileutils'
require 'pp'
options = OpenStruct.new
options.filename = ""
options.foldername = ""
options.str = ""
options.dst = ""
options.lang = ""
options.case = 0
OptionParser.new do |opts|
opts.banner = "Usage: translate.rb [options]"
opts.on("-f", "--file FILENAME... | true |
6db77195cb6ebc0de77ca1707d5dc444afae5c1f | Ruby | pofystyy/codewars | /7 kyu/maximum_length_difference.rb | UTF-8 | 853 | 3.78125 | 4 | [] | no_license | # https://www.codewars.com/kata/5663f5305102699bad000056
# Details:
# You are given two arrays a1 and a2 of strings. Each string is composed with letters from a to z. Let x be any string in the first array and y be any string in the second array.
# Find max(abs(length(x) − length(y)))
# If a1 and/or a2 are empty re... | true |
f744eedde7561e7f0b36d325897755ef09a548fb | Ruby | EthanGould/wdi_2_ruby_lab_rspec_geometry | /spec/triangle_spec.rb | UTF-8 | 723 | 3.328125 | 3 | [] | no_license | require 'spec_helper'
require_relative '../lib/triangle.rb'
describe Triangle do
before do
@triangle = Triangle.new(a: 10, b: 10, c: 10)
@second_triangle = Triangle.new(a: 7, b: 5, c: 10)
@third_triangle = Triangle.new(a: 8, b: 7, c: 20)
end
it 'calculates the perimeter of the triangle' do
expect... | true |
5b06753a96fc87ed12c2c0cac25498856210c04d | Ruby | ajth-work/ODIN | /practice-docs/ruby/BasicDataTypes/preparation.rb | UTF-8 | 125 | 2.53125 | 3 | [] | no_license | # preparation.rb
require "pry"
a = [1,2,3]
a << 4
binding.pry # execution should pause here for inspection purposes
puts a | true |
fe4fa21797eb9e4ea30c2fe5d1d6acb017f4f82e | Ruby | dowlmic/AStar | /board.rb | UTF-8 | 5,598 | 3.40625 | 3 | [] | no_license | require_relative "cell"
class Board
attr_reader :board, :board_size, :start, :end
def initialize(length: 0, width: 0, with_random_barriers: true, percent_barriers: 25)
l, w = validate_parameters(length, width, percent_barriers)
@board_size = { length: l+2, width: w+2, num_cells: (l+2) * (w+2) }
initialize_bo... | true |
0e020c495457662fbd72295b28d52dc06e65f2a1 | Ruby | var114/Episode6 | /models/vehicle.rb | UTF-8 | 599 | 3.453125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Vehicle
@@vehicle = [] #can be used anywhere.
attr_reader :color, :make, :model, :year, :model
def initialize(hash={})
@@vehicle << self
@color = hash.fetch(:color)
@make = hash.fetch(:make)
@model = hash.fetch(:model)
@year = hash.fetch(:year)
end
def self.wheels
... | true |
bf4a9345b91df98347fb26f05c7592828fc3d1b5 | Ruby | terryq/ruby-import-export-tools | /RubyExportImportTool/export_cards.rb | UTF-8 | 2,619 | 2.796875 | 3 | [] | no_license | require 'rally_rest_api'
require 'stuff'
class ExportCards
STORY_FIELDS = %w{Type Name Parent Owner Status Blocked Release Iteration PlanEstimate TaskEstimate TaskToDo TaskActuals Rank
Description Notes}
protected
# Should share with ExportStories class
def ExportCards.... | true |
56c121fe53d36a32b221b91005aa8ea16c471b1a | Ruby | natalya-patrikeeva/ruby | /love.rb | UTF-8 | 126 | 3.234375 | 3 | [] | no_license | # Awww Love Note!
inf = (+1.0/0)
time = Time.new.hour
love = "\33[31mlove\33[0m"
while time < inf
puts "I #{love} you"
end
| true |
81c542a1ccb0faeeb28d81afb694afbe7d6e2736 | Ruby | Brendaneus/the_odin_project | /ruby_on_rails/flight-booker/app/models/flight.rb | UTF-8 | 1,125 | 2.90625 | 3 | [] | no_license | class Flight < ApplicationRecord
belongs_to :origin, class_name: 'Airport',
inverse_of: :departing_flights
belongs_to :destination, class_name: 'Airport',
inverse_of: :arriving_flights
has_many :bookings
validates_presence_of :origin, :destination, :departure, :duration
validates :duratio... | true |
ce6b9560f3b3f50036e07e9cfd1e94902e620c47 | Ruby | IceDragon200/edst-writing | /lib/edst/catalogue/relation_leaf.rb | UTF-8 | 2,111 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | require 'set'
module EDST
module Catalogue
class RelationLeaf
# the current character
attr_reader :character
GROUPS = [
:grand_parents,
:grand_children,
:biological_parents,
:adopted_parents,
:parents,
# parent siblings (aunts, uncles)
:... | true |
75b2e2ee4c2c7a4345078861ea04f2aedacf4b2e | Ruby | felipekari/r06_ciclos | /lorem_generator.rb | UTF-8 | 581 | 2.796875 | 3 | [] | no_license | n = ARGV[0].to_i
i = 0
lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non molestie urna. Mauris dictum justo tempor erat mattis porttitor. Ut dignissim sodales lorem, vel tempor lectus gravida non. In libero erat, tempor congue aliquam quis, imperdiet quis dolor. Duis suscipit nisl accumsan risus... | true |
76bdeff54a011a91e9bef7a24c294f8a2331d00f | Ruby | goneflyin/stockinfo | /lib/stock.rb | UTF-8 | 809 | 3.296875 | 3 | [] | no_license | require 'json'
class Stock
attr_reader :symbol, :name, :market_cap, :ipo_year, :sector, :industry
class << self
def add(data)
@stocks ||= []
@by_symbol ||= {}
stock = Stock.new(data)
@by_symbol[data[:symbol]] = stock
@stocks << stock
end
def find(symbol)
@by_symbo... | true |
c976104fcb39450c75cbf70357f2c5f7383eeb71 | Ruby | jenmccarthy/artist_search | /spec/artist_spec.rb | UTF-8 | 1,623 | 3.078125 | 3 | [] | no_license | require 'rspec'
require 'artist.rb'
require 'work.rb'
describe Artist do
before do
Artist.clear
end
describe Artist.all do
it 'provides a place to hold all artist objects' do
expect(Artist.all).to eq []
end
end
it 'is initialized with a name and style' do
test_artist = Artis... | true |
2160e2093fb670f3f68592badd53bb7596c8c6fd | Ruby | HassanTC/Simple_web_projects | /Twitter-Spambot/micro_blogger.rb | UTF-8 | 2,129 | 2.828125 | 3 | [] | no_license | require 'jumpstart_auth'
require 'bitly'
Bitly.use_api_version_3
class MicroBlogger
attr_reader :client
# to initialize your Tweeter account
def initialize
puts "MicroBlogger is get Start in"
@client = JumpstartAuth.twitter
end
def shorten(original_url)
bitly = Bitly.new('hungryacademy', '... | true |
8fa55b8b5aea5b180066af1fb99419bf7d26eddd | Ruby | joseph-jalbert/learn-to-program | /ask.rb | UTF-8 | 494 | 3.078125 | 3 | [] | no_license | def ask question
while true
puts question
reply = gets.chomp.downcase
if (reply == 'yes' || reply == 'no')
if reply == 'yes'
return true
else
return false
end
else
puts 'please answer "yes" or "no".'
end
end
end
puts "hell and blah blah"
puts
a... | true |
993e722aeb4dbd291e47d3b74ddbfa4358130eb0 | Ruby | pwnall/igor | /app/models/role.rb | UTF-8 | 1,663 | 2.625 | 3 | [
"MIT"
] | permissive | # == Schema Information
#
# Table name: roles
#
# id :integer not null, primary key
# user_id :integer not null
# name :string(8) not null
# course_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# A privilege granted to an ... | true |
12a93e9cc0536069f23c6b73d56c5295257bbdcf | Ruby | Patrick-Duvall/backend_prework | /day_4/ex3.rb | UTF-8 | 974 | 4.15625 | 4 | [] | no_license | #Binds input_file to first argument given when ex3.rb is run
input_file = ARGV.first
#Defines a method for printing a file (better than f.each {|x| puts x})??
def print_all(f)
puts f.read
end
#Defines a method to go to position 0 in a given file
def rewind(f)
f.seek(0)
end
#Defines a method to print a given line fr... | true |
4ea4263b1acff1bc317f373e014caa1693ffd4fe | Ruby | kennyfrc/puzzlenode-solutions-1 | /12_secret_messages/lib/secrets/caesar_cracker.rb | UTF-8 | 510 | 3.265625 | 3 | [] | no_license | require 'secrets/ciphers/caesar'
# XXX: Use something like Ruby-Wordnet to look for an English word
module Secrets
class CaesarCracker
def initialize(enc)
@enc = enc
end
def crack
puts "Which of these look right?"
cipher = Ciphers::Caesar.new
cipher.valid_shifts.each do |shift|
... | true |
41e87adbbb4e772220ffe12c86e0d1ca603be279 | Ruby | karenhunter01/MyFavsHTML | /ruby/chapter1Game.rb | UTF-8 | 449 | 3.9375 | 4 | [] | no_license | #!/usr/bin/ruby
n = rand(10);
puts "\nPlease enter your name: "
username = gets
username = username.chomp
max=10
min=0
puts username + ", guess a number from 1 - 10\n";
while min <= 10
guess = gets;
if guess.to_i == n
print "\nGood Job, You got it!!";
print "\nRandom number is " + n.to_s;
min = 11;
elsif ... | true |
b56c34806c6de3617bf5dd4af0c182e6be154d18 | Ruby | GitHubAdmin/MDS3Builder | /app/models/fields/n2001.rb | UTF-8 | 751 | 2.703125 | 3 | [] | no_license | class N2001
attr_reader :options, :name, :field_type, :node
def initialize
@name = "Drug Regimen Review: Did a complete drug regimen review identify potential clinically significant medication issues? (N2001)"
@field_type = RADIO
@node = "N2001"
@options = []
@options << FieldOption.new("0", ... | true |
86490392867d11eb064a13201e6c63fc825b5da0 | Ruby | a6ftcruton/literipsum | /test/ipsum_test.rb | UTF-8 | 1,063 | 3.09375 | 3 | [] | no_license | require 'test_helper'
require 'ipsum'
class IpsumTest < ActiveSupport::TestCase
# book = "Tom Sawyer"
# my_ipsum = Ipsum.new(book)
#
# my_ipsum.header_words(3)
# my_ipsum.sentences(3)
# my_ipsum.paragraphs(3)
# First step -> a gem that creates a yaml file (in the root dir) of the book being used
# ... | true |
7d7e09295d95d751b395e309413f4e91cfae0594 | Ruby | mawaldne/exercism_solutions | /ruby/hexadecimal/hexadecimal.rb | UTF-8 | 388 | 3.546875 | 4 | [] | no_license | class Hexadecimal
HEX_CHARS = { 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15 }
def initialize(hex)
@hex = hex
end
def to_decimal
return 0 if @hex =~ /[g-z]/
@hex.reverse.chars.each_with_index.map do |ch, i|
if ch =~ /[0-9]/
ch.to_i * 16**i
elsif ch =~ /[a-f]/
... | true |
55d57ee8dad0b0970f7e311bf2b3c2c0b6bceaec | Ruby | Kunal8208/ruby_assignments | /day_3/day_3.rb | UTF-8 | 923 | 3.625 | 4 | [] | no_license | #Accept student detials with marks and display the same detais with percentage
class Student
attr_accessor :roll, :name, :percentage, :marks
def initialize
@marks=Array.new
end
def getDetails
print "Enter Roll No: "
@roll=gets.chomp.to_i
print "Enter Name: "
@name=gets.chomp
(0...5).each do |index... | true |
7e63eba345c2174052847e76532f90a630bde707 | Ruby | aqingsao/subway | /line.rb | UTF-8 | 733 | 3.546875 | 4 | [] | no_license |
require File.join(File.dirname(__FILE__), 'station.rb')
class Line
attr_reader :name, :stations
def initialize(name, stations = [])
@name = name
@stations = []
stations.each{|station|add_station(station)}
end
def add_station(station)
@stations.push station
station.lines << self unless station.lines.incl... | true |
418b13772d540516b3183f1799d104972776d04f | Ruby | arizuk/programming-contest-solutions | /gcj/2019/b/main.rb | UTF-8 | 1,069 | 3.15625 | 3 | [] | no_license | require 'logger'
logger = Logger.new('logfile.log')
def output(msg)
puts msg
STDOUT.flush
end
def init_rem
rem = {}
for c in 'A'..'E'
rem[c] = 24
end
rem
end
def resolve(rems)
ans = Array.new(4)
5.times do
rems.each_with_index do |rs, i|
rs = rs.reject { |c| ans.include?(c) }
if r... | true |
5d0fc8cc1f38a3ea13438548fe84534e6641cd85 | Ruby | chrismay/warwick-sso-ruby | /lib/sso/client.rb | UTF-8 | 4,719 | 2.5625 | 3 | [] | no_license | require 'uri'
require 'net/http'
require 'net/https'
require 'yaml'
require 'sso/user'
require 'sso/memory_cache'
# Performs old-mode SSO against Websignon (i.e.
# checks the WarwickSSO cookie and sends a requestType=1
# to the Websignon sentry to get back user attributes.
#
# Include this module in your ApplicationCo... | true |
bb9a4555eb34ec8b562269ccb0b1e9329e834091 | Ruby | bryanteng/algorithms | /ruby/graph_edges.rb | UTF-8 | 554 | 3.8125 | 4 | [] | no_license | # Count the number of different edges in a given undirected graph with no loops and multiple edges.
# For
#
# matrix = [[false, true, true],
# [true, false, false],
# [true, false, false]]
# the output should be graphEdges(matrix) = 2.
#
# [execution time limit] 4 seconds (rb)
def graphEdges(matrix... | true |
64732ddd2e86d6add4f3716352f8708fea73d145 | Ruby | tommottom/ruby | /hello_class3.rb | UTF-8 | 434 | 4.15625 | 4 | [] | no_license |
class HelloWorld
attr_accessor :name
def initialize(myname = "Ruby")
@name = myname
end
def hello
puts "Hello, world. I am #{@name}"
end
end
ruby = HelloWorld.new
bob = HelloWorld.new("Bob")
alice = HelloWorld.new("Alice")
#1番目のnameメソッドを実行しています。
p ruby.name
#2番目のname(value)メソッドを実行しています。(アクセスメソッドで... | true |
c61cf4172fa7396dbd03380e867b4bc20cda6784 | Ruby | unepwcmc/pp-live-report | /app/serializers/chapter_dates_serializer.rb | UTF-8 | 498 | 2.890625 | 3 | [] | no_license | class ChapterDatesSerializer
def initialize(dates)
@dates = dates
end
def serialize
@dates.keys.each do |chapter|
['last_updated', 'next_updated'].each do |date_type|
chapter_dates = @dates[chapter]
date = Date.strptime(chapter_dates[date_type], '%b-%y')
chapter_dates[date... | true |
d39a2681fcdccef49582ed6fdd9174515c52b9d9 | Ruby | Chux/viper-wiki | /RubyOnRails/Viper/app/helpers/application_helper.rb | UTF-8 | 1,546 | 2.546875 | 3 | [] | no_license | module ApplicationHelper
def wikiToHtml ( inputString )
rules = [
{:regex => /(\n[ ]*[^#* ][^\n]*)\n(([ ]*[#]([^\n]*)\n)+)/x, :replace => '\1<ol>' + "\n" + '\2' + '</ol>' + "\n"},
{:regex => /(\n[ ]*[^#* ][^\n]*)\n(([ ]*[*]([^\n]*)\n)+)/x, :replace => '\1<ul>' + "\n" + '\2' + '</ul>' + "\n"},
... | true |
61092f169125cca068a32bbfbb052bd7d1535e50 | Ruby | ypylypenko/algorithmable | /lib/algorithmable/cups/stacks_and_queues/stack_sorter.rb | UTF-8 | 551 | 2.5625 | 3 | [
"MIT"
] | permissive | module Algorithmable
module Cups
module StacksAndQueues
class StackSorter
include Algorithmable::DataStructs
def self.sort(stack)
new.sort(stack)
end
def sort(stack)
local_stack = new_lifo_queue
until stack.empty?
temp = stack.pop
... | true |
a7adbc4c4278e82a1ce7b1361a43fcdf5878ca60 | Ruby | camihayes/ruby_class_projects | /homework_project_one.rb | UTF-8 | 852 | 3.765625 | 4 | [] | no_license | #create dictionary hash with 10 city names
dial_book = {
"newyork" => "212",
"newbrunswick" => "732",
"tampa" => "727",
"denver" => "303",
"shreveport" => "318",
"knoxville" => "865",
"arizona" => "928",
"juneau" => "907",
"modesto" => "213",
"honolulu" => "808"
}
def get_city_names(somehash)
s... | true |
e7118e37e05cd072262c2ddb3ed273fc48405c5a | Ruby | LewisYoul/ruby-kickstart | /session3/challenge/3_hashes.rb | UTF-8 | 581 | 4.375 | 4 | [
"MIT"
] | permissive | # Write a method that takes a string and returns a hash
# whose keys are all the downcased words in the string,
# and values are the number of times these words were seen.
#
# No punctuation will appear in the strings.
#
# Example:
# word_count "The dog and the cat" # => {"the" => 2, "dog" => 1, "and" => 1, "cat" => 1}... | true |
f8e1ea6eb57d89603fbfccf6a621371a8127f707 | Ruby | birbalds/ride-share-two | /lib/driver.rb | UTF-8 | 1,430 | 3.1875 | 3 | [] | no_license | require 'csv'
module RideShare
class Driver
DRIVER_INFO = CSV.read('support/drivers.csv')
attr_accessor :driver_id, :name, :vin
def initialize(id)
raise ArgumentError, "#{id} is not a valid ID number, only positive whole numbers are accepted" unless id.is_a?(Integer) && id >= ... | true |
e11d964f30e8abef023bc777176a129838397aaf | Ruby | jakolehm/ruby-packer | /ruby/benchmark/bm_vm1_blockparam_yield.rb | UTF-8 | 95 | 2.703125 | 3 | [
"BSD-2-Clause",
"GPL-2.0-only",
"CC0-1.0",
"GPL-2.0-or-later",
"GPL-1.0-or-later",
"Autoconf-exception-generic",
"Artistic-1.0",
"Zlib",
"LicenseRef-scancode-unicode-mappings",
"dtoa",
"MIT",
"ISC",
"BSD-3-Clause",
"LicenseRef-scancode-unicode",
"FSFUL",
"BSD-4-Clause-UC",
"OFL-1.1",... | permissive | def bp_yield &b
yield
end
i = 0
while i<30_000_000 # while loop 1
i += 1
bp_yield{}
end
| true |
a9bac081956d76503426097906480a7582ac18f8 | Ruby | trikey/game_blackjack | /models/deck.rb | UTF-8 | 382 | 3.515625 | 4 | [] | no_license | class Deck
SUITS = ["\u2665", "\u2666", "\u2663", "\u2660"]
FACES = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'A', 'K', 'Q', 'J']
def initialize
@deck = Array.new(self.class.deck)
@deck.shuffle!
end
def take_card
@deck.pop
end
def self.deck
@deck ||= SUITS.map do |suit|
FACES.ma... | true |
b64e431081d53d73edfc84acd271b33203dd0299 | Ruby | njpa/launchschool-ruby-basics | /06_user_input/06_passwords.rb | UTF-8 | 1,038 | 4.75 | 5 | [] | no_license | # EX 6
# ====
# Write a program that displays a welcome message, but only after the user
# enters the correct password, where the password is a string that is defined
# as a constant in your program. Keep asking for the password until the user
# enters the correct password.
# ANSWER
# ======
# 1) instantiate a vari... | true |
821edf64bc519c4ab50eb84fcc12bd5bbc39d220 | Ruby | nabetani/yokohama.rb | /ruby_by_ruby/5.1.1.rb | UTF-8 | 1,408 | 3.296875 | 3 | [
"Apache-2.0"
] | permissive | require "minruby"
require "pp"
require "stringio"
def ppp(x)
PP.pp( x, $stdout, 20 )
end
def evaluate(tree)
case tree[0]
when "lit"
tree[1]
when "+"
left = evaluate(tree[1])
right = evaluate(tree[2])
left + right
when "-"
left = evaluate(tree[1])
right = evaluate(tree[2])
left - ... | true |
7101bb268b36f428efeef750d41a4a9618b9dafa | Ruby | coryodaniel/MerbMax | /lib/merb_max/meta.rb | UTF-8 | 1,794 | 2.875 | 3 | [] | no_license | module Merb
class Controller
class << self
alias :orig_inherited :inherited
# Default any subclasses meta tags to that of the parent
def inherited(klass)
orig_inherited(klass)
klass.meta(self.meta)
end
# Setter/Getter for meta Tags
#
# @param tags [... | true |
56d6dd176f01379b6dbf4ab0056748e197936139 | Ruby | copilotroadtrip/CoPilotBackend | /app/services/poi_service.rb | UTF-8 | 4,155 | 3.03125 | 3 | [] | no_license | class PoiService
# Eventually this should have the encoded coordinate string passed in
attr_reader :steps, :poi_info, :coord_info, :nested_poi, :places, :legs
def initialize(steps)
@steps = steps
@poi_info, @coord_info, @nested_poi = traverse_steps
@places = filter_poi
@legs = build_legs
end... | true |
6bf28e022e246bf9d22ea25ee5ba38d2bb087110 | Ruby | xavier/exercism-assignments | /ruby/queen-attack/queens.rb | UTF-8 | 1,320 | 3.90625 | 4 | [] | no_license |
class ChessBoard
SIZE = 8
COLUMN_SEPARATOR = " "
ROW_SEPARATOR = "\n"
def render
(0...SIZE).map do |row|
(0...SIZE).map do |col|
yield row, col
end.join(COLUMN_SEPARATOR)
end.join(ROW_SEPARATOR)
end
end
class Queens
DEFAULT_POSITIONS = {
white: [0, 3],
... | true |
3ee9fe6319e6e5eca408c66c6e4e298a153c0e17 | Ruby | avineshwar/LicenseFinder | /lib/license_finder/license.rb | UTF-8 | 1,629 | 2.671875 | 3 | [
"LicenseRef-scancode-unknown",
"MIT",
"GPL-1.0-only",
"LicenseRef-scancode-unknown-license-reference",
"GPL-1.0-or-later"
] | permissive | # frozen_string_literal: true
require 'license_finder/license/text'
require 'license_finder/license/template'
require 'license_finder/license/matcher'
require 'license_finder/license/header_matcher'
require 'license_finder/license/any_matcher'
require 'license_finder/license/none_matcher'
require 'license_finder/lic... | true |
fad06c093fe17051fa69c53a4ba8cb457daa013f | Ruby | bandzoogle/mail_dump | /app/models/logged_mail.rb | UTF-8 | 1,303 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'mail/fields/common/address_container'
class LoggedMail < ActiveRecord::Base
# attr_accessible :body, :from, :html, :raw, :subject, :to, :reply_to
serialize :from
serialize :reply_to
serialize :to
serialize :body
serialize :html
def has_text?
self.body.present?
end
def has_html?
se... | true |
5ad1ca11c629c27db8e544967a7846cdb07415ff | Ruby | eglital/prep_ruby_challenges | /factorial.rb | UTF-8 | 116 | 3.765625 | 4 | [] | no_license | def factorial(number)
result = 1
(1..number).each { |num| result *= num }
return result
end
puts factorial(5) | true |
c6a2190bc7b4cf36a53d6210e807d6c51bb25178 | Ruby | renewablefunding/spectifly-sequel | /lib/spectifly/sequel/model.rb | UTF-8 | 2,020 | 2.515625 | 3 | [] | no_license | module Spectifly
module Sequel
class Model
attr_accessor :table_name, :display_name, :model_name,
:single_value_fields, :multiple_value_fields,
:has_and_belong_to_many, :name_as_foreign_key,
:foreign_keys
def initialize(entity, fields)
@display_name = entity.root
... | true |
02e22ac741ad378657f66431bf00f75683c90824 | Ruby | nimalwyd/cpp | /src-rb/led_sign_server.rb | UTF-8 | 1,692 | 2.6875 | 3 | [] | no_license | # Base class
require 'webrick'
require 'webrick/https'
require 'json'
class LedSignServer < WEBrick::HTTPServlet::AbstractServlet
# Not meant to be used
def do_GET( request, response )
puts "#{__method__}"
HTTPAuth.basic_auth( request, response, "VPCRealm" ) {|user,pass|
user == 'locom... | true |
66bddda94d3c4f02f8fd6011a1738c0e71d8becb | Ruby | vvj5/rails_todo | /app/controllers/todos_controller.rb | UTF-8 | 853 | 2.765625 | 3 | [] | no_license | class TodosController < ApplicationController
def index
render json: Todo.all
end
def new
render json: Todo.new
end
def create
render json: Todo.create(entry: params[:entry])
end
def show
begin
render json: Todo.find(params[:id])
rescue ActiveRecord::RecordNotFound => error
... | true |
ce70e18e31124d635ebae4f472f47ede968de33b | Ruby | BovvyBoy/OO-Get-Swole-london-web-051319 | /tools/console.rb | UTF-8 | 613 | 3.03125 | 3 | [] | no_license | # You don't need to require any of the files in lib or pry.
# We've done it for you here.
require_relative '../config/environment.rb'
# test code goes here
dan = Lifter.new("Danny B", 180)
chris = Lifter.new("Chrissy A", 150)
ben = Lifter.new("Benny Boy", 120)
andy = Lifter.new("Andy Son", 100)
david_lloyds = Gym.new... | true |
3b0ac450fa5149f4ea4b935341b67a5a38b00030 | Ruby | smoline/codewars | /ruby/7kyu_regexp_basics_is_it_8bit_unsigned_number.rb | UTF-8 | 1,607 | 3.46875 | 3 | [] | no_license | # https://www.codewars.com/kata/regexp-basics-is-it-a-eight-bit-unsigned-number/train/ruby
require 'awesome_print'
class String
def eight_bit_number?
match(/^([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$/) ? true : false
end
end
answer = "".eight_bit_number?
ap answer
# false
answer = "0".eight_bit_nu... | true |
d775d46b29f500be6813f75e040d9dba437eea9c | Ruby | AlistairTait12/makers_learning_notes | /week_4/calculator_exercise.rb | UTF-8 | 653 | 4.75 | 5 | [] | no_license | # Refactor the methods in the Calculator example into two classes as you see fit.
#
# class Calculator
# def add(number_1, number_2)
# number_1 + number_2
# end
# def subtract(number_1, number_2)
# number_1 - number_2
# end
# def print_answer(answer)
# "The Answer is: #{ answer }"
# end
# end... | true |
6c9b4829bdd2a97513e47d87632f59d3437e5425 | Ruby | katiekeel/classroom-exercises | /week4/modules/student_2.rb | UTF-8 | 144 | 2.890625 | 3 | [] | no_license | module Student
class Hufflepuff
def cast_spell
puts "Expelliarmus!"
end
def speak
puts "I'm a Hufflepuff! Potato."
end
end
end
| true |
6fa099793fbf2f7537eb7ae0dc191d15a7a26fe2 | Ruby | fiteclub/2020_advent | /day_01/report_repair_00.rb | UTF-8 | 664 | 3.84375 | 4 | [] | no_license | #!/usr/bin/ruby
require 'pry'
target_sum = 2020
file = "input.txt"
input_data = File.read("input.txt")
integer_array = input_data.split.map { |string| string.to_i }
def find_sum_pair(input_array, target)
sum_pair = [nil, nil]
input_array.each do |entry|
difference = (target.to_i - entry.to_i)
puts "Trying... | true |
c0dd00b176a39984eb151c7eaa1c4a66d1c2e5a9 | Ruby | IonatanMocan/ruby-word-generator | /modules/words_importer_module.rb | UTF-8 | 233 | 2.71875 | 3 | [] | no_license | module WordsImporterModule
def words_importer_module(file_name)
result = []
file = File.read(@from_file)
file.each_line do |line|
result << line.downcase.chomp if line.chomp.length > 0
end
result
end
end | true |
682f3a10d25e3fbd461c1a271b1ed697c68beba7 | Ruby | ealwafai/war_or_peace | /spec/deck_spec.rb | UTF-8 | 1,993 | 3.078125 | 3 | [] | no_license | require 'rspec'
require '../lib/card'
require '../lib/deck'
describe Deck do
it 'deck setup' do
card1 = Card.new(:diamond, 'Queen', 12)
card2 = Card.new(:space, '3', 3)
card3 = Card.new(:heart, 'Ace', 14)
cards = [card1, card2, card3]
deck = Deck.new(cards)
expect(deck).to be_an_instance_of(... | true |
960829d45fee61cab3f63c7c87e8c2cc6bef9aca | Ruby | repohoarder/UrlShortener | /app/models/url_datum.rb | UTF-8 | 734 | 2.609375 | 3 | [] | no_license | require 'uri'
class UrlDatum
include Mongoid::Document
include Mongoid::Timestamps
field :long_url, type: String
field :short_url, type: String
field :hits, type: Integer, default: 0
index({long_url: 1, short_url: 1})
index({short_url: 1})
before_save :create_short_url
def create_short_url
ch... | true |
3f9e82e61cf20364866d66f8373991d5e384f426 | Ruby | deniznida/flatiron-bnb-methods-ruby-007-public | /app/models/city.rb | UTF-8 | 911 | 2.734375 | 3 | [] | no_license | class City < ActiveRecord::Base
has_many :neighborhoods
has_many :listings, :through => :neighborhoods
has_many :reservations, :through => :listings
def city_openings(checkin, checkout)
self.neighborhoods.collect do |neighborhood|
neighborhood.neighborhood_openings(checkin, checkout)
end.flatten
e... | true |
c031d735ec643a2815af2c7d72849f52068a1965 | Ruby | Podenniy/falconmotors | /app/models/cart.rb | UTF-8 | 578 | 2.59375 | 3 | [] | no_license | class Cart < ActiveRecord::Base
has_many :line_items, dependent: :destroy
def total_price
line_items.to_a.sum { |item| item.total_price}
end
def add_price_part(price_part_id)
current_item = line_items.find_by_spare_part_id(price_part_id)
if current_item
current_item.quantity +=1
els... | true |
7b6875c8d620c9fe6f84e1dab238d634192bbf30 | Ruby | neontapir/lendr | /ruby/lib/domain/person.rb | UTF-8 | 236 | 2.5625 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'entity.rb'
require_relative '../events/author_created_event.rb'
class Person < Entity
attr_reader :name
private
def initialize(name = nil)
super()
@name = name
end
end
| true |
46f4b0009f9879f0e0b0c04965d899ebd220af77 | Ruby | helmedeiros/ruby_bits | /level_4/3_dates/game.rb | UTF-8 | 206 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive | require 'active_support/all'
def anniversary(game, years)
game[:release].advance(years: years)
end
game = {
name: 'Contra',
release: DateTime.new(1987, 2, 20, 0, 0, 0)
}
puts anniversary(game, 20)
| true |
ebff11c8a2d02f8250baac58992094cb9eafc3e9 | Ruby | nathansobo/piston | /lib/piston/svn/revision.rb | UTF-8 | 1,904 | 2.53125 | 3 | [
"MIT"
] | permissive | require "piston/revision"
require "fileutils"
module Piston
module Svn
class Revision < Piston::Revision
def client
@client ||= Piston::Svn::Client.instance
end
def svn(*args)
client.svn(*args)
end
def name
"r#{revision}"
end
def checkout_to(pa... | true |
350a0dae511f4a79c508a47d650a634a89229bcc | Ruby | michniewicz/TorrentClient | /lib/torrent_service.rb | UTF-8 | 5,375 | 2.609375 | 3 | [] | no_license | ##
# Represents TorrentService class and its methods
#
class TorrentService
include NetworkHelper
# Connection handshake timeout in sec
HANDSHAKE_TIMEOUT = 5
def initialize(torrent_file)
@torrent_file = torrent_file
@files_to_load = []
@message_queue = Queue.new
@incoming_queue = Queue.new
... | true |
9830b2000679c618dd4ba8c97f149c161580d5d5 | Ruby | jeremyf/tor-probability | /lib/tor/probability/check.rb | UTF-8 | 2,951 | 3.1875 | 3 | [] | no_license | module Tor
module Probability
# A container for the different kinds of checks
module Check
# Originally extracted as a parameter object (because the
# `success_probability_for_given_check_or_later` method had too
# many parameters), this object helps encapsulate the data used
# to calc... | true |
eb574f1e536634b8efc1c09c68efff1eaa62c5a1 | Ruby | torvick/panel_rh | /app/services/get_records.rb | UTF-8 | 658 | 2.6875 | 3 | [] | no_license | class GetRecords
def initialize(args)
@id_employee = args[:employee_id]
@id = args[:record_id]
@token = args[:current_user]
@options = {
headers: build_headers,
query:{}
}
end
# Public Interface
def self.send(*args)
new(*args).send!
end
def se... | true |
6121612b099fa3c7ca85375e78dff09c3c54676b | Ruby | s1230057/Keisuke | /ITP1_2-B.rb | UTF-8 | 165 | 3.125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
a, b, c = STDIN.gets.split.map(&:to_i)
a=b.to_i
b=b.to_i
c=b.to_i
puts(if a < b && b < c then
'Yes'
else
'No'
end)
| true |
5675b7a486f987438ef11871e3fc63db3251d7e9 | Ruby | lime1024/rubybook | /chapter_04/4-3-7.rb | UTF-8 | 99 | 3.375 | 3 | [] | no_license | # [1, 2] と [3, 4] をつなげた配列を作って表示する
a = [1, 2]
b = [3, 4]
puts a + b
| true |
0c8c5ab427068ec75cdb39b927a3ae5ad6051c80 | Ruby | ggustilo/phase-0 | /week-5/group-research-methods/my_solution.rb | UTF-8 | 1,899 | 4 | 4 | [
"MIT"
] | permissive | # # Research Methods
# # I spent [] hours on this challenge.
# i_want_pets = ["I", "want", 3, "pets", "but", "only", "have", 2]
# my_family_pets_ages = {"Evi" => 6, "Ditto" => 3, "Hoobie" => 3, "George" => 12, "Bogart" => 4, "Poly" => 4, "Annabelle" => 0}
# # #
# Person 2
# pseudocode:
# iterate through the ar... | true |
b95b72b35150407c02778f608abd70a6d796d385 | Ruby | reduviidae/module-one-holiday-project-dumbo-web-121018 | /lib/user_total_score.rb | UTF-8 | 1,829 | 3.453125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # determines user mood
def user_total_score
# grabs the currently logged in user
user = User.all.find_by(logged_in: true)
# calculates cumulative average score and magnitude based on all liked quotes
score_sum = user.quotes.sum(:score)
magnitude_sum = user.quotes.sum(:score)
quote_count = user.quotes.length
... | true |
96b5346e89fce231777323088d1a35d46863b334 | Ruby | ngoalvin/jungle-rails | /spec/models/user_spec.rb | UTF-8 | 2,092 | 2.640625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
describe 'Validations' do
it "is valid with valid attributes" do
@user = User.new(name: "Alvin", email: "ngoalvin97@gmail.com", password: "123456789")
@user.save!
expect(@user).to be_valid
end
it "is valid with valid attribute... | true |
f0af6f4bde95637159c0142feb664f4b5cddbe60 | Ruby | le3ah/LaughTracks | /spec/features/statistic_calculations_spec.rb | UTF-8 | 1,995 | 2.625 | 3 | [] | no_license | RSpec.describe "As a visitor" do
it "can see the average age of all comedians" do
Comedian.create(name: "Jim Carrey", age: 56, city: "Newmarket")
Comedian.create(name: "Demetri Martin", age: 45, city: "New York City")
Special.create(special_name: "All in Good Taste", run_time: 85)
Special.create(speci... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.