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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
0d0eec58c116ff61c5703785c94df536d7803713 | Ruby | gucki/assets_booster | /lib/assets_booster/package/base.rb | UTF-8 | 1,860 | 2.546875 | 3 | [
"MIT"
] | permissive | require "assets_booster/packager"
module AssetsBooster
module Package
class Base
attr_accessor :name
attr_accessor :assets
attr_accessor :filename
attr_accessor :merger_class
attr_accessor :compiler_class
def initialize(name, assets)
self.name = name+"_packaged"
... | true |
13ded4fcf60bb4028d916a871f4f4f20bc1d684f | Ruby | coderunner-framework/gs2crmod | /lib/gs2crmod/graphs_rdoc.rb | UTF-8 | 26,286 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | class CodeRunner::Gs2::GraphKits
# Graph of apar^2 vs time integrated over all space. No options
def apar2_vs_time_graphkit
end
# Plot the eigenfunction along the extended domain. Options mag, norm, z can be specified by using a short hand in the name of the graph, eg. efnmagnormz, efnmag, efnnorm etc. If the range is ... | true |
c7d130d8cd8aae2b365f293009b6f9d0e0d02683 | Ruby | jorgemolinan/lab | /regex6_gsub.rb | UTF-8 | 424 | 3.515625 | 4 | [] | no_license | # Definimos varios strings para usar más adelante
liryc = "asereje ja de je de jebe tu dejebe"
keyword = "chocolate"
# Eliminamos los espacios (\s) usando gsub y expresiones regulares (regex)
liryc_no_spaces = liryc.gsub(/\s/, "")
puts liryc_no_spaces
# Reemplazamos cualquier vocal (en minuscula) por una x
keyword_x ... | true |
b7471e5106cfe31f0d939f14fd174059dc4295f7 | Ruby | ArkieCoder/rubyprimer | /lib/sayings.rb | UTF-8 | 2,935 | 3.03125 | 3 | [] | no_license | module Sayings
def Sayings.get_saying(type)
happy = [
"More ramen to you!",
"I'm pleased.",
"I see great potential.",
"Thou shalt pass.",
"Good, good!",
"That was quite something.",
"Most excellent.",
"I'm proud of you.... | true |
84f7a84071c7da442f3dc094f7ad773bc783092d | Ruby | sjh8008/tts-ruby-practice | /practice.rb | UTF-8 | 117 | 3.1875 | 3 | [] | no_license | # def greeting(name)
# puts "Hello #{name}! How are you?"
# end
# greeting("SJ")
# # b = "Henry"
# # greeting(b)
| true |
56ab31c51f5d1cfb4600e2f9afb757ddc20bd454 | Ruby | lyosha85/int2words | /lib/number_in_words.rb | UTF-8 | 1,435 | 3.921875 | 4 | [] | no_license | class Number
ONETEENS = %w[one two three four five six seven eight nine ten eleven twelve
thirteen fourteen fifteen sixteen seventeen eighteen nineteen]
TENS = %w[twenty thirty fourty fifty sixty seventy eighty ninety]
THOUS = %w[thousand million billion trillion quadrillion]
def initial... | true |
7c512e08b8cfdafc0844acded4641420ca75f320 | Ruby | andydvalle/ruby-oo-practice-relationships-silicon-valley-exercise-sea01-seng-ft-042020 | /app/models/run.rb | UTF-8 | 1,407 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
require ('./app/models/startup.rb')
require ('./app/models/venture_capitalist.rb')
require ('./app/models/funding_round.rb')
puts startup1 = Startup.new("n1", "f1", "d1")
puts startup2 = Startup.new("n2", "f2", "d2")
puts startup3 = Startup.new("n3", "f3", "d3")
startup1.pivot("d_changed", "n_changed")... | true |
d42528ca0c6a70fc8ecc408f07c25d1ddd29e8f6 | Ruby | AlexGenK/kottans-kharkiv-2016 | /week1-task2/Chess/app_spec.rb | UTF-8 | 1,874 | 3.25 | 3 | [] | no_license | require './app.rb'
describe Position do
CHESSBOARD = (:a1..:h8)
it "can mapping positions of figures on the chessboard" do
pos=Position.new(a1: :black_queen, e2: :white_queen, h5: :white_bishop)
result_hash={:a1=>:black_queen, :a2=>:empty, :a3=>:empty, :a4=>:empty, :a5=>:empty, :a6=>:empty, :a7=>:emp... | true |
4be9a52ff6cc1a736758837ab5ee286d6adf6fa7 | Ruby | sato-s/sato-s.github.io | /sample_code/iterable/iter.rb | UTF-8 | 503 | 3.484375 | 3 | [] | no_license | class Account
attr_reader :age
def initialize(age)
@age = age
end
def child?
@age < 20
end
end
class Accounts
include Enumerable
def initialize(_accounts)
@_accounts = _accounts
end
def each
@_accounts.each{|account| yield account}
end
# def select(*args, &block)
# self.... | true |
8f12bd27fee82be500ee12a7323a7c6a9e02150a | Ruby | fosterv2/ruby-oo-object-relationships-kickstarter-lab-seattle-web-030920 | /lib/project.rb | UTF-8 | 355 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Project
attr_accessor :title
def initialize(title)
@title = title
end
def add_backer(backer)
ProjectBacker.new(self, backer)
end
def backers
list = ProjectBacker.all.select{|project_backer| project_backer.project == self}
list.map{|project_backer| projec... | true |
57a03e0ff8740f7c848578f237aa855eb467c034 | Ruby | RyanDur/MartianRobots_rb | /spec/lib/mars_spec.rb | UTF-8 | 4,763 | 2.8125 | 3 | [] | no_license | require_relative '../spec_helper'
require 'mars'
require 'position'
require 'robot'
require 'instructions/F'
require 'lang/max'
require 'lang/messages'
include Max
include Messages
describe Mars do
message = 'hello'
context '#setup' do
it "should not be wider than #{MAX_GRID_SIZE}" do
expect { subject.s... | true |
7a25e57da8d2a2429c21e50d8d4d622620895d9b | Ruby | bbdonkor/Ruby_101 | /lesson_4/is_odd.rb | UTF-8 | 207 | 3.5 | 4 | [] | no_license | def is_odd?(number)
# if (number % 2) == 1
# puts "true"
# else
# puts "false"
# end
puts number.remainder(2) == 1
end
is_odd?(3)
is_odd?(-17)
is_odd?(6)
is_odd?(9)
is_odd?(5)
is_odd?(12) | true |
d64751ccbbd6a54b44c9d04eebeb31908716ac39 | Ruby | dbolson/reminder-foo | /app/services/sms_reminder.rb | UTF-8 | 1,545 | 2.734375 | 3 | [] | no_license | module Services
class SMSReminder
def self.run
new.notify_upcoming_reminders
new.notify_upcoming_due_events
end
# Send SMS messages to subscribers of events with upcoming reminders.
def notify_upcoming_reminders
due_reminders.each do |reminder|
reminder.subscribers.each do |... | true |
869a54fd2e797798a4e45c541ad2589296b3246c | Ruby | JonahSinick/Chess | /piece.rb | UTF-8 | 2,023 | 3.390625 | 3 | [] | no_license | require './board.rb'
require './pieces.rb'
class Piece
attr_accessor :board, :position, :color, :value
DIAGONALS = [ [-1, -1], [-1, 1], [1, -1], [1, 1] ]
HORVERTS = [ [0, -1], [0, 1], [-1, 0], [1, 0] ]
def initialize(board, position, color, window)
@board = board
@position = position
@color... | true |
ded1055d8c2bc34e0374937a6e62837eedc4fad3 | Ruby | Cisco-AMP/nexus_sync | /lib/nexus_sync/threads/thread_core.rb | UTF-8 | 4,344 | 2.953125 | 3 | [
"MIT"
] | permissive | require 'nexus_sync/queue'
module NexusSync
class ThreadCore
attr_reader :verbose
attr_reader :download_queue_mutex
attr_reader :upload_queue_mutex
attr_reader :download_queue
attr_reader :upload_queue
attr_reader :failed_queue
attr_reader :corrupted_queue
attr_reader :docker_locked
... | true |
f2c38c75d1ed44fdd2bcaa4c0855250f23bcb16f | Ruby | grjonib/SaaS-Class | /Assignments/hw1/p3.rb | UTF-8 | 233 | 3.359375 | 3 | [] | no_license | def combine_anagrams(words)
wordHash = Hash.new([])
words.each do |word| wordHash[word.downcase.scan(/\w/).sort.join] += [word] end
output = []
wordHash.each_value do |subarray| output += [subarray] end
return output
end | true |
c377dff3a15e18f888d3aee875f9cb35d806bd09 | Ruby | armanim/LeetCodeSolutions | /partition-list.rb | UTF-8 | 842 | 3.71875 | 4 | [] | no_license | # Solution for Partition List
# URL: https://leetcode.com/problems/partition-list/
# Definition for singly-linked list.
# class ListNode
# attr_accessor :val, :next
# def initialize(val)
# @val = val
# @next = nil
# end
# end
# @param {ListNode} head
# @param {Integer} x
# @return {ListNod... | true |
58daec2ff6fd22859980e3e06ce009e1b806fd7d | Ruby | ejdraper/favlang | /lib/language.rb | UTF-8 | 324 | 2.703125 | 3 | [
"MIT"
] | permissive | class Language
def self.favourite_language(repos)
repos
.reject { |repo| repo['primaryLanguage'].nil? }
.inject({}) do |hash, repo|
hash[repo['primaryLanguage']['name']] ||= 0
hash[repo['primaryLanguage']['name']] += 1
hash
end.sort { |a,b| b.last <=> a.last }[0][0]
end... | true |
2390f2aef71702875bf99d3fbc08d4bcd1bd9de2 | Ruby | ArcherCraftStore/ArcherVMPeridot | /RailsInstaller_D/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rvm-1.11.3.9/lib/rvm/shell/result.rb | UTF-8 | 1,163 | 3.171875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | module RVM
module Shell
# Represents the output of a shell command.
# This includes the exit status (and the helpful #successful? method)
# as well accessors for the command and stdout / stderr.
class Result
attr_reader :command, :stdout, :stderr, :raw_status
# Creates a new result objec... | true |
73350d4119e5dd3d52320558cba68fb8ec6c6b2e | Ruby | daveTamayo/mock-nequi | /app/UIManager.rb | UTF-8 | 902 | 3.4375 | 3 | [] | no_license | require 'digest'
class UIManager
def show message
puts message
end
# Menu sin sesion
def initialMenu
puts "Digite un numero correspondiente a lo que quiere hacer"
puts "1. Registrarse"
puts "2. Iniciar sesion"
puts "3. Salir"
number_or_nil (gets.chomp)
end
# Menu de sesion
def... | true |
5a8b5ccbc332c3c7a46e39555ca986f49ab7db1b | Ruby | byjord10/apple_deals | /lib/cli.rb | UTF-8 | 858 | 3.421875 | 3 | [
"MIT"
] | permissive |
class AppleDeals::CLI
def call
deal_list
deal_selection
goodbye
end
def deal_list
puts "Hello, here is a list of Apple products that are on sale this week."
@deals = AppleDeals::Deals.today
@deals.each.with_index(1) do |deals, i|
puts "#{i}.#{deals.name} - #{deals.price} - #{deal... | true |
ba29eb6e2b8345e12e635f71b47b5d3e7c9145b7 | Ruby | Knightster/chess-app | /app/models/king.rb | UTF-8 | 2,399 | 3.078125 | 3 | [] | no_license | class King < Piece
def image
if color == 'white'
'♔'
else
'♚'
end
end
def valid_move?(x, y)
# guard clause style
return false if blocked?(x, y) # checks if piece is blocking at destination coordinate
return false if delta_x(x_position, x) > 1
return false if de... | true |
5e717352d9d89e59aa3575ae0d7e0f1d18f69883 | Ruby | mwwong/w1d5 | /skeleton/lib/knights_travails.rb | UTF-8 | 2,013 | 3.578125 | 4 | [] | no_license | require_relative "00_tree_node.rb"
class KnightPathFinder
attr_reader :consider_positions, :root_node, :pos
DELTAS = [
[2,1],
[1,2],
[-1,2],
[-2,1],
[-1,-2],
[-2,-1],
[2,-1],
[1,-2]
]
def initialize(pos)
@pos = pos
@root_node = PolyTreeNode.new(pos)
@considered_po... | true |
cf6d6c8e3aef28b89bb960b6e65e9278ce69def8 | Ruby | lvjiiiiu/calculation_refactoring | /token_parser.rb | UTF-8 | 602 | 3.578125 | 4 | [] | no_license |
class TokenParser
attr_reader :tokens
def initialize(text)
@tokens = text.chomp.split(" ")
# initializeの中でchomp, splitしていいんだ〜
validate!
end
private
def validate!
mass_exp = /[0-9]+[a-z]+/
formula = @tokens.join(" ")
# 引数の先頭が質量ではなかった場合
unless mass_exp.match?(@tokens.first)
... | true |
6f3a3cf1b4571bce1bf8e42efd96b38262e48a81 | Ruby | adworse/iguvium | /lib/iguvium/labeler.rb | UTF-8 | 3,486 | 3.109375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Iguvium
NEIGHBORS = [[0, -1], [-1, -1], [-1, 0], [-1, 1]].freeze
FLAT_THRESHOLD = 0.2
private_constant :NEIGHBORS, :FLAT_THRESHOLD
# Clusterizes connected pixels using two-pass connected component labelling algorithm (Hoshen-Kopelman),
# 8-connectivity is used. Line-lik... | true |
b696a6fcf309a53a8d225972cdc00bde082d85e1 | Ruby | zachandblue/the_odin_project | /orange.rb | UTF-8 | 672 | 3.59375 | 4 | [] | no_license | class Orange_tree
def initialize name
@name = name
@height = 0
@age = 0
@yield = 0
puts @name + ' is of fruit born'
end
def oneYearPasses
@years = @years.to_i + 1
@feet = @feet.to_i + 1
if @years > 2
@yield = 2
end
if @years > 4
@yield = 4
end... | true |
1c77c4520c7fa30074e74aaca0fbc5597ede0c68 | Ruby | redsquirrel/DoDBcRuby | /07_addition_method_called.rb | UTF-8 | 39 | 2.96875 | 3 | [] | no_license |
def add_one(n)
1 + n
end
add_one(9) | true |
0c003550c17cac5e30929306d5fb2fe973ae8e25 | Ruby | hannahgreen1/bucket_list_app | /models/city.rb | UTF-8 | 1,447 | 3.234375 | 3 | [] | no_license | require_relative('../db/sql_runner.rb')
class City
attr_accessor :id, :name, :country_id
def initialize(options)
@id = options['id'].to_i
@name = options['name']
@country_id = options['country_id'].to_i
end
def save()
sql = "INSERT INTO cities
(name,
country_id)
VALUES
($1, $... | true |
74c33dfe8f0f4018cdc6f9eef251ba3d813d3a20 | Ruby | maxhollmann/ruby-ytdl | /lib/youtube_dl/command.rb | UTF-8 | 955 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'shellwords'
require 'dry/configurable'
module YoutubeDL
class Command
extend Dry::Configurable
def config
self.class.config
end
setting :executable, 'youtube-dl'
setting :default_options, {}
setting :forced_options, {
newline: true,
color: false,
write_info_... | true |
6b6391afa1fd017f0646a6f4f61ad90bc172962b | Ruby | AngeloBot/poli_empresta_v2 | /app/models/student.rb | UTF-8 | 599 | 2.515625 | 3 | [] | no_license | class Student < ApplicationRecord
belongs_to :team
mount_uploader :photo, ImageUploader
has_secure_password
def self.search(search)
if search
where("name like ?", "%#{search}%")
else
all
end
end
def name
given_name+" "+family_name
end
validates_presence_of:given_name
validates_presence_of:fam... | true |
0e536238fbe9972b010e609a31c6b9a2f709a25c | Ruby | Lani1321/hangman | /app/models/game.rb | UTF-8 | 1,478 | 3.375 | 3 | [
"MIT"
] | permissive | class Game
include ActiveModel::AttributeMethods, ActiveModel::Serializers::JSON
class GameOverError < StandardError; end
# Define a limit of failed attempts
MAX_FAILED_ATTEMPTS = 5
attr_accessor :word
attr_accessor :selected_letters
def initialize
@words = %w"learning ruby education rails comput... | true |
e6bf21369c9a02145ec10a7d09d861d7349e026f | Ruby | robfors/ruby-sumac | /spec/sumac/objects/reference/scheduler_spec.rb | UTF-8 | 9,107 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | require 'sumac'
# make sure it exists
describe Sumac::Objects::Reference::Scheduler do
# will will test by setting it to all possible states and sending all possible (valid) directives for each state
# states (chronological order):
# tentative
# active
# forget_initiated
# stale
# directives (... | true |
e3adf260d79aff2d8437e86ca2acdde4391a2933 | Ruby | MadameSardine/chitter | /spec/features/user_management_spec.rb | UTF-8 | 2,460 | 2.671875 | 3 | [] | no_license | require 'spec_helper'
require_relative 'helpers/session'
include SessionHelpers
feature "In order to user chitter I want to sign up" do
scenario "when being logged out" do
expect {sign_up}.to change(User, :count).by(1)
expect(page).to have_content('Welcome, MadameSardine')
expect(User.first.username).to eq(... | true |
d139c1161747dc75e020f346844e31be594d577b | Ruby | rothberry/ruby-objects-belong-to-lab-chicago-web-062419 | /lib/artist.rb | UTF-8 | 246 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
class Artist
attr_accessor :name
# def initialize(name)
# @name ||= name
# # binding.pry
# end
end
# beyonce = Artist.new("bey")
# p beyonce.artist
# beyonce.artist = "Yolo"
# p beyonce.artist | true |
c9daba71e25548c8aa2b9933160414f225251fda | Ruby | xababafr/RubyPFE | /tests/semaine1/PFE/tests/test_1.rb | UTF-8 | 907 | 2.59375 | 3 | [
"MIT"
] | permissive | require "pp"
require_relative "../lib/actors"
class Emitter < Actor
output :f
def initialize name
super(name)
end
def behavior
for i in 0..10
send(i,:f)
end
end
end
class Computation < Actor
input :a,:b
output :f
def behavior
for i in 0..10
a=receive(:a)
b=receive(:... | true |
cf01e5c1845542214c3a513e85edfed4e2a8682b | Ruby | gilbertw1/euler | /Ruby/problem6.rb | UTF-8 | 178 | 3.03125 | 3 | [] | no_license | square_of_sum = 0
sum_of_square = 0
(1..100).each do |x|
square_of_sum += x
sum_of_square += x**2
end
square_of_sum = square_of_sum**2
puts (square_of_sum - sum_of_square) | true |
0e84988ac1fd52599c3d5855de0eea7d8249e162 | Ruby | networkhermit/algorithm | /archive/classic/LockerDoors/Lambda.rb | UTF-8 | 444 | 3.34375 | 3 | [
"MIT"
] | permissive | def bruteForce(n)
arr = Array.new(n, false)
1.upto(n) do |i|
(i - 1).step(n - 1, i) do |j|
arr[j] = !arr[j]
end
end
arr
end
def process(n)
arr = Array.new(n)
temp = 0
1.upto(n) do |i|
temp = Math.sqrt(i.to_f).to_i
arr[i - 1] = temp * temp == i
end
arr
end
if __FILE__ == $PR... | true |
f70f1c8be9ebaafffed99a5b1734ba111118b924 | Ruby | kkoiro/programming_contest | /AtCoder_Beginner_Contest/007/b.rb | UTF-8 | 79 | 3.15625 | 3 | [] | no_license | #!/usr/bin/env ruby
str = gets.chomp
if str=='a'
puts -1
else
puts 'a'
end
| true |
4affad745d31fbbc3854a7f46e4a05b47b0db7af | Ruby | robert-laws/learning-apr-2019-ruby-classes-and-modules | /exceptions/challenge.rb | UTF-8 | 1,644 | 4.34375 | 4 | [] | no_license | # Challenge - Custom Exception
# add custom exception to an existing project
# bday = Date.new(year.to_i, month.to_i, day.to_i)
# # bday = Time.new(1975, 12, 22)
# puts "-----------------------"
# puts "You were born on a #{bday.strftime('%A')}."
# puts "You were born on a #{days[bday.wday]}."
# puts "It was the #{bd... | true |
db31d8faddeb5352f596aa90e8e86ee3ce3e3f06 | Ruby | jeffpeterson/dotfiles | /home/.pryrc | UTF-8 | 1,642 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env ruby
# Load plugins (only those I whitelist)
Pry.config.should_load_plugins = false
# Pry.plugins["doc"].activate!
Pry.config.editor = proc { |file, line| "vim +#{line} #{file}" }
# Launch Pry with access to the entire Rails stack.
# If you have Pry in your Gemfile, you can pass: ./script/console --irb... | true |
0ef6328caff4ee2676bd918fd607ec3deb2752c6 | Ruby | enricob/timesheets | /vendor/plugins/dataset/spec/dataset/test_unit_spec.rb | UTF-8 | 5,297 | 2.515625 | 3 | [
"MIT"
] | permissive | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'test/unit/testresult'
class Test::Unit::TestCase
include Dataset
end
describe Test::Unit::TestCase do
it 'should have a dataset method' do
testcase = Class.new(Test::Unit::TestCase)
testcase.should respond_to(:dataset)
end
... | true |
e3bb035d48494b569afc4c589c9569f527ac341c | Ruby | vhochstein/one_step_active_scaffold | /one_step_activescaffold.rb | UTF-8 | 2,846 | 2.53125 | 3 | [] | no_license | require 'rubygems'
class File #:nodoc:
unless File.respond_to?(:binread)
def self.binread(file)
File.open(file, 'rb') { |f| f.read }
end
end
end
def inject_into_file(inject_into, text, regex)
content = File.binread(inject_into)
content.gsub!(regex, text)
File.open(inject_into, 'wb') { |file|... | true |
9c341e9b836cf3b62af2ffde7379dbf0c38390f3 | Ruby | Eddienewpath/Ruby_programing | /leetcode/playground.rb | UTF-8 | 571 | 2.984375 | 3 | [] | no_license | q,r = 5.divmod 10
ar = [2,3,4,5]
ar.unshift 1
ar.unshift -1,0
# p ar
str ="abcde"
j = str.length - 2
arr = [2,3,4,5]
((arr.length-1).downto 20).each do |x|
x
end
str = "hello"
#p str[0..2]
#p str
str.each_char {|c| c }
#p 'c' == nil;
n = 1234
n.digits.reverse.each do |x|
if true
#p x
next
end
#p... | true |
fcf9c44188e714779a35120ba738ceaeb6ad67d8 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/triangle/bd8b2cbfb70b4074bd5a7e7750df2fb6.rb | UTF-8 | 512 | 3.375 | 3 | [] | no_license | class Triangle
def initialize(side_a,side_b,side_c)
if side_a + side_b <= side_c || side_a + side_c <= side_b || side_b + side_c <= side_a
raise TriangleError
else
@side_a = side_a
@side_b = side_b
@side_c = side_c
end
end
def kind
if @side_a == @side_b && @side_b == @side_c
:equilateral
... | true |
a3f3690115d5e0e29d75583cacff62ecc9103458 | Ruby | TimurM/ruby_prep_work | /correct.rb | UTF-8 | 318 | 3.40625 | 3 | [] | no_license | def hash_correct(hash)
keys = hash.keys
keys.delete(keys[0])
values = hash.values
results = {}
i = 0
while i < keys.count
results[keys[i]] = values[i]
i += 1
end
results
end
wrong_hash = { :a => "banana", :b => "cabbage", :c => "dental_floss", :d => "eel_sushi" }
print hash_correct(wrong_hash) | true |
b7cff22c7e21d3c3325263003fdf1b2ae0be7892 | Ruby | alexbrahastoll/oas-db | /generator/api.rb | UTF-8 | 9,258 | 2.59375 | 3 | [] | no_license | module OASDB
module Generator
class API
attr_accessor :api_issues, :contents
def initialize(api_issues)
@api_issues = api_issues
end
def gen_setup_code
@contents = <<~RUBY
require 'sinatra'
require 'json'
require 'yaml'
require 'act... | true |
d315f7e87613aae7131d92561fff68950dfe0e32 | Ruby | alu0100886306/nutrientes | /lib/alimento.rb | UTF-8 | 3,979 | 2.921875 | 3 | [
"MIT"
] | permissive | require "alimento/version"
require "alimento/lista"
require "alimento/IG_fun"
require "alimento/ordenar"
require "benchmark"
module Alimento
class Alimento
attr_reader :nombre, :prt, :gluc, :lip
include Comparable
def <=>(another)
kcal <=> another.kcal
end
de... | true |
129f69b402e8b2ae3f4e8766e1b185c8f09d02d6 | Ruby | arifkalayci/freelancer-com-ror-job-tasks | /daily_cost_test.rb | UTF-8 | 3,138 | 2.921875 | 3 | [] | no_license | #!/usr/bin/env ruby
require "test/unit"
require_relative './daily_cost'
class DailyCostTest < Test::Unit::TestCase
def test_example
start_date = Date.new(2019, 10, 1)
end_date = Date.new(2019, 10, 3)
time_period_costs = [
{
time_period: ALL_TIME_PERIODS[0], # daily
cost: 10.0
... | true |
bbf72cfe4de7b5560e8b673affef3b7b6d9e958b | Ruby | targess/ironhack-week-4 | /day1/word_central/app/models/text_inspection.rb | UTF-8 | 233 | 2.828125 | 3 | [] | no_license | class TextInspection < ApplicationRecord
def self.count_word_frecuency(my_text)
words = my_text.split(' ')
frecuency = Hash.new
words.each do |word|
frecuency[word] ||= 1
frecuency[word] += 1
end
frecuency
end
end
| true |
1d8d996f381d9727baea510280854b09d84ebdfc | Ruby | deiwin/code-jam-2014 | /spec/repeater_spec.rb | UTF-8 | 3,998 | 3.359375 | 3 | [
"WTFPL"
] | permissive | require './repeater/repeater'
describe Repeater do
let(:solver) {Repeater.new}
describe '#solve' do
it 'should solve sample 1' do
input = ['mmaw', 'maw']
solution = solver.solve(input)
expect(solution).to eq(1)
end
it 'should solve sample 2' do
input = ['gcj', 'cj']
so... | true |
acf05cf598858c0da1e01f9aad47be7464f8fc80 | Ruby | trustinyoon/AAClasswork | /w1/d2/rspec_exercise_1/lib/part_1.rb | UTF-8 | 453 | 4.03125 | 4 | [] | no_license | def average(num1, num2)
return (num1 + num2)/2.0
end
def average_array(arr)
return arr.sum/(arr.length*1.0)
end
def repeat(str, num)
str * num
end
def yell(str)
str.upcase + "!"
end
def alternating_case(sentence)
output = []
sentence.split(" ").each_with_index do |word, i|
if i % 2 ... | true |
ba2b1d59afdaf90ea4fafbf7462e7e54906fc328 | Ruby | jonathanyeong/exercism-solutions | /ruby/protein-translation/protein_translation.rb | UTF-8 | 1,030 | 3.109375 | 3 | [] | no_license | =begin
Write your code for the 'Protein Translation' exercise in this file. Make the tests in
`protein_translation_test.rb` pass.
To get started with TDD, see the `README.md` file in your
`ruby/protein-translation` directory.
=end
class InvalidCodonError < StandardError; end
class Translation
CODON_TO_AMINO = {
... | true |
a8001845317ac909916aaa95ea9ac6cadee36feb | Ruby | andrewzwang/fa17-hw2 | /app/controllers/concerns/foobar.rb | UTF-8 | 159 | 2.875 | 3 | [] | no_license | class Foobar
# ENTER CODE FOR Q2 HERE
def initialize(baz)
@baz = baz
end
def bar(x,y)
a = x.to_s
return a+@baz+y.key(:sat).to_s
end
end
| true |
343a0e9e66a8d202293ed68be20fe9b56b55bc97 | Ruby | schanrai/sgrind-cli-app | /lib/sgrind/events.rb | UTF-8 | 1,647 | 3.0625 | 3 | [
"MIT"
] | permissive | class Event
attr_accessor :name, :event_type, :short_descrip, :location, :location_link, :details_link, :date, :long_descrip, :start_time, :address, :speakers
@@all = []
def initialize(event_hash)
event_hash.each do |k, v|
self.send("#{k}=", v)
end
save
end
def self.make_events(scraped_... | true |
e140cbbea4fd712e4b9534a2fb8cf91b7de1e212 | Ruby | renanbona/advent_of_code | /4_day/part1_day_4.rb | UTF-8 | 843 | 3.203125 | 3 | [] | no_license | require 'pry'
puzzle_input = File.readlines('puzzle_input.txt').map(&:chomp)
valid_passports = 0
required_keys = %w[
ecl:
pid:
eyr:
hcl:
byr:
iyr:
hgt:
]
passport = []
puzzle_input.map do |line|
if line.empty?
validation_flag = true
full_passport = passport.join(' ')
required_keys.each... | true |
55f8e316727d83a6b418d2dc9bd110f8b4d6d116 | Ruby | Paul-Mohabir/Ruby-Excercises | /exercise4.rb | UTF-8 | 162 | 3.1875 | 3 | [] | no_license | 1.upto(100) do |i|
if i % 3 == 0 && i % 5 == 0
puts "Bit Maker"
elsif i % 3 == 0
puts "Maker"
elsif i % 5 == 0
puts "Bit"
else
puts i
end
end
| true |
15b2d140ab6505a09ef0674b84f6a1dda9369b08 | Ruby | geoffkvincent/ruby_golf | /hole_2.rb | UTF-8 | 427 | 3.4375 | 3 | [] | no_license | @r_a = ["rock", "paper", "scissor"].shuffle
def rps
puts "ENTER rock, paper or scissor"
u = gets.strip.downcase
ran = @r_a[0]
if ran == "rock" && u == "rock" || ran == "paper" && u == "paper" || ran == "scissor" && u == "scissor"
puts "TIE"
elsif ran == "rock" && u == "paper" || ran == "paper" && u == "sc... | true |
503a08d5b24b1d81f1efdc1f4ea6e5eb6e2335ea | Ruby | akasocrates/prework | /modroman.rb | UTF-8 | 846 | 3.203125 | 3 | [] | no_license | def roman number
thou = (number / 1000).to_i
fhun = ((number - (thou * 1000)) / 500).to_i
hund = ((number - (thou * 1000) - (fhun * 500)) / 100).to_i
fift = ((number - (thou * 1000) - (fhun * 500) - (hund * 100)) / 50).to_i
tens = ((number - (thou * 1000) - (fhun * 500) - (hund * 100) - (fift * 50)) / 10).to_i
... | true |
10d01e9f5f0a96d93d6d1e334733f36b0ffa39e6 | Ruby | DianaLuciaRinconBl/Ruby-book-exercises | /Hashes/ex_5.rb | UTF-8 | 252 | 4.0625 | 4 | [] | no_license | #What method could you use to find out if a Hash contains a
#specific value in it? Write a program to demonstrate this use.
pets = {freddy: "dog", cecil: "cat", ted: "parrot"}
puts pets.has_value?("cat")#=>true
puts pets.has_value?("rabbit")#=>false
| true |
83ee141d2d38c7fec7f347b5b947b69f9f050362 | Ruby | enowmbi/algorithms | /univalued_binary_tree.rb | UTF-8 | 469 | 3.265625 | 3 | [] | no_license | def is_univalued_tree?(root)
left_univalued = root.left == nil || root.left.val == root.val && is_univalued_tree?(root.left)
right_univalued = root.right == nil || root.right.val == root.val && is_univalued_tree?(root.right)
#return left_univalued == right_univalued ? true : false
return left_univalued && righ... | true |
1c3d7cfc9726331e5dac355c511bb7160603bb6e | Ruby | lelag/active-ext-api | /spec/active_ext_api/api_read_spec.rb | UTF-8 | 4,605 | 2.53125 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + '/../spec_helper'
describe ActiveExtAPI::ClassMethods, "ext_read" do
before(:each) do
end
context "with no argument" do
it "should return a hash with a success, a message, a data and a total property" do
result = Book.ext_read({})
result.should be_a_kind_... | true |
213e6231cdb7dd3aba10c32e0ec10cef010be404 | Ruby | ganeshsurya11/cd-merge | /lib/tasks/update_works_table.rake | UTF-8 | 3,686 | 2.609375 | 3 | [] | no_license | require 'rubygems'
require 'csv'
# Jira ticket - https://carlstahmer.atlassian.net/browse/CEB-13
### Before Running this rake task, Make sure
### migration file 20140809103215_add_work_short_code_to_works.rb is executed
###############################################################################
# Copyright ... | true |
4c90b21023474dcd4dc470ad4f9b52c99252ffb4 | Ruby | derricklannaman/ruby | /quizzes/quiz07.rb | UTF-8 | 136 | 3.21875 | 3 | [] | no_license | class Play
def walk
"I am walking"
end
def Play.run
puts "I am running"
end
end
a = Play.new
puts a.walk
puts Play.run
| true |
695fbde45a92c4b147768d40ab86b0095c9c310d | Ruby | tkettle220/app-academy-classwork | /W2D2/Chess/game.rb | UTF-8 | 748 | 3.671875 | 4 | [] | no_license | require_relative "display.rb"
require_relative "player.rb"
class Game
def initialize(board, display, player1, player2)
@board = board
@display = display
@player1 = player1
@player2 = player2
@current_player = player1
end
def play
until game_over
@current_player.play_turn
sw... | true |
287c6d8a4f8247cb8782cd88bc4398f4a015c885 | Ruby | saiprasaddevare/documentation-APIPIE | /app/controllers/records_controller.rb | UTF-8 | 1,879 | 2.609375 | 3 | [] | no_license | class RecordsController < ApplicationController
# skip_before_action :verify_authenticity_token
# include Apipie::Markup::Markdown
include RecordsDoc
# Title doc
resource_description do
short 'Create, Read, Update and Delete a Student'
formats ['json']
description <<-EOS
Used to handle t... | true |
ee651f8cee0f6360c24350abe9a1865da4c8597c | Ruby | michaelherold/module_builder | /lib/module_builder/builder.rb | UTF-8 | 3,881 | 3.046875 | 3 | [
"MIT"
] | permissive | module ModuleBuilder
# Builds a module based on instance-level state and class-level configuration.
#
# This class is intended to be subclassed, not used as-is. There are several
# methods to override in order to give the builder the behavior you want. You
# can also define setup methods that are specified in... | true |
d9e53b54618f28236738859a634b23b3c00e6d58 | Ruby | toannqnd/Techmaster | /RubyExample/Day01/example.rb | UTF-8 | 490 | 3.734375 | 4 | [] | no_license | input = ['toan', 'AN']
def welcome_msg(arr)
output_str = ''
length = arr.count;
i = 0
arr.each do |element|
i = i + 1
if i != length
output_str = output_str + element.capitalize + ', '
else
output_str = output_str + element.capitalize
end
end
# output_str.chop! # xoa dau cach cuoi cung
... | true |
6c709936a2b09751622343ff2fc7e0f632b9f590 | Ruby | dronwork/base_ruby | /Task_1/right_triangle.rb | UTF-8 | 502 | 4.03125 | 4 | [] | no_license | sides_triangle = [] # Array
puts 'Enter side A:'
sides_triangle << gets.chomp.to_f
puts 'Enter side B:'
sides_triangle << gets.chomp.to_f
puts 'Enter side C:'
sides_triangle << gets.chomp.to_f
a, b, c = sides_triangle.sort!
if a**2 + b**2 == c**2
puts 'Your triangle is rectangular !'
else
puts 'Your triangle is no... | true |
8b90674df93e52007f31c4199d2731335b5978fd | Ruby | shanna/swift | /lib/swift/migrations.rb | UTF-8 | 1,446 | 2.59375 | 3 | [
"MIT"
] | permissive | module Swift
module Migrations
module ClassMethods
# @example
# class User < Swift::Record
# migrations do |db|
# db.execute %q{create table users(id serial, name text, age int)}
# end
# end
#
# @param [Proc] migrations
#
# @see Swift::... | true |
ff0594c54c91b44da79c2187d9a9f82d73dd2314 | Ruby | wstrinz/procjam-geoloc | /geo.rb | UTF-8 | 1,767 | 2.9375 | 3 | [] | no_license | require 'open-uri'
require 'json'
class Geo
MAPZEN_BASE_V1 = "http://search.mapzen.com/v1"
STRING_FNS = {
make_cgi: ->(opts) { opts.map{|k,v| "#{k}=#{v}"}.join("&") }
}
#FNS = {
#mapzen_call: ->(key, endpoint, opts) {
#opts_fn = STRING_FNS[:make_cgi]
#reverse_search = "api_key=#{key}"
... | true |
7ff5239eb1f3e1d95fa899bb01d01ca30bfe0949 | Ruby | jtorreggiani/tree-mapper-app | /app/controllers/trees_controller.rb | UTF-8 | 2,682 | 2.5625 | 3 | [] | no_license | # Controller for rendering trees related pages
class TreesController < ApplicationController
before_action :set_tree, only: %i[show edit update destroy]
# lists all trees
# @api public
# @example GET /trees?query=dope
# @return renders index
def index
@trees = Tree.all
end
# renders an individual ... | true |
b14bc94378a464b36a21b61d1788e82694eec41b | Ruby | spenta/wizard_rails2 | /spec/controllers/user_request_spec.rb | UTF-8 | 10,790 | 2.53125 | 3 | [] | no_license | require 'spec_helper'
describe UserRequestsController do
before(:each) do
super_usage_id = 1
usage_id = 1
%w{Bureautique Internet Jeux Mobilite}.each do |super_usage_name|
super_usage = Factory(:super_usage, :name => super_usage_name, :id => super_usage_id)
[1, 2].each do |usage_number|
... | true |
0490e8867e87ee2e51a18a1da5a4bf4228125b7a | Ruby | archived-ioroioroi-applications/rails-portal-app-sample | /app/models/article.rb | UTF-8 | 1,312 | 2.5625 | 3 | [] | no_license | class Article < ApplicationRecord
# validates :article_link, presence: true, uniqueness: true # 記事リンクは存在しないとエラーかつ一意でないとエラー
# validates :article_title, presence: true # 記事タイトルは存在しないとエラー
# これはモデルに対するユニーク制約. これだけだと不完全なのでmigrationファイルにも制約をかける必要あり.
## モデルでバリデーションかけると、制約にひっかかったときにエラーが帰ってこないので一旦DBのバリデーションのみで.
# ... | true |
4b92db0a60f1bd3cac5e3fc1efd6491a39d713f9 | Ruby | crawfordmikyle/prime-ruby-v-000 | /prime.rb | UTF-8 | 197 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def prime?(num)
range = Array(1..num)
trueval = []
range.each do |x|
if num % x == 0
trueval << x
end
end
if trueval.size > 2 || num == 1 || num < 1
false
else
true
end
end
| true |
b5a0b932571b1a4f2fa12f70b383d738ad02ecce | Ruby | Gotteschalk/Battle-day3 | /spec/features/attack_spec.rb | UTF-8 | 316 | 2.75 | 3 | [] | no_license | # As Player 1,
# So I can win a game of Battle,
# I want to attack Player 2, and I want to get a confirmation
feature 'attack' do
scenario 'player 1 attacks player 2' do
sign_in_and_play
click_button ("Attack")
expect(page).to have_content("Congratulations Boris, you have attacked James!")
end
end
| true |
2e17df855e2a3f0e5f9d43568a25c8cfe42861f4 | Ruby | antonhalim/badges-and-schedules-bk-002-public | /conference_badges.rb | UTF-8 | 437 | 4.09375 | 4 | [] | no_license | # Write your code here.
def badge_maker(name)
"Hello, my name is #{name}."
end
def batch_badge_creator(people)
people.map{|person| badge_maker(person)}
end
def assign_rooms(people)
people.map.with_index(1) do |person, room|
"Hello, #{person}! You'll be assigned to room #{room}!"
end
end
def printer(people)
ba... | true |
26c85fdfc33ae73ccf0081c33cedac4a035a11a2 | Ruby | trevorbennett/kata-master-repo | /ruby/unique_emails.rb | UTF-8 | 411 | 2.921875 | 3 | [] | no_license | # @param {String[]} emails
# @return {Integer}
def num_unique_emails(emails)
@unique_emails = []
emails.each do |email|
user_address = email.split('@')[0]
unique_user_address = user_address.split('+')[0]
unique_user_address.tr!('.','')
user_domain = email.split('@')[1]
@unique_emai... | true |
0d4e25a8ade34097ed2cf952b3174520f13238f3 | Ruby | igorsimdyanov/ruby | /variables/klass.rb | UTF-8 | 225 | 3.65625 | 4 | [] | no_license | class HelloWorld
@@counter = 0
def counter
@@counter
end
def set_counter(counter)
@@counter = counter
end
end
first = HelloWorld.new
first.set_counter 10
second = HelloWorld.new
puts second.counter # 10
| true |
e37489ea3b4f73d2b2faa300ee76bdeb80306ba1 | Ruby | lindseyolson/ruby-basics | /times_iteration.rb | UTF-8 | 55 | 3.15625 | 3 | [] | no_license | 5.times do |item|
puts "At item number #{item}."
end
| true |
e74c636cc5c90a8f27b8e144c11fe000eb80c2e1 | Ruby | jstone18/roadtrip-adventures-gem | /lib/roadtrip_adventures/adventure.rb | UTF-8 | 808 | 2.984375 | 3 | [
"MIT"
] | permissive | class RoadtripAdventures::Adventure
attr_accessor :name, :url, :price
def self.list_adventure_names(destination_name)
self.scrape_adventures(destination_name)
end
def self.scrape_adventures(destination_name)
new_adventures_list = []
url = RoadtripAdventures::Destination.url_for_destination_name(... | true |
71d83c13ed10e63d5ebec34e3a5b8b416db7d905 | Ruby | a0x77ry/odin | /ruby-exercises/caesar_cipher/spec/caesar_cipher_spec.rb | UTF-8 | 812 | 3.234375 | 3 | [] | no_license | # frozen_string_literal: true
require './caesar_cipher'
describe '#caesar_cipher' do
it 'shifts a single lower case letter to the right by a specified number' do
expect(caesar_cipher('a', 6)).to eql('g')
end
it 'shifts a single upper case letter to the right by a specified number' do
expect(caesar_ciph... | true |
e947376023121854055cd3b37749ca01c11e352e | Ruby | mcordell/noaa | /lib/noaa/current_conditions.rb | UTF-8 | 5,472 | 3.171875 | 3 | [
"MIT"
] | permissive | module NOAA
#
# Representation of the current conditions for a given observation point.
#
class CurrentConditions
class <<self
private :new
def from_xml(doc) #:nodoc:
new(doc)
end
end
def initialize(doc) #:notnew:
@doc = doc
end
#
# Time object contain... | true |
74ff2bb6c617fca6086066b468db7d4d841a3437 | Ruby | mavstronaut/JBoard | /jruby/lib/sendmail.rb | UTF-8 | 1,274 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'net/smtp'
require 'lib/encrypt.rb'
module Board
class SendMail
include Encrypt
def initialize( host, port )
@host = host
@port = port
end
def send_email(props, to, to_alias, subject)
from = props['emailfrom']
if !props['emailus... | true |
ecff19ae026c54e5a1947fc260716b615b1fb35d | Ruby | mac718/Launch_School | /small_problems/easy_3/odd_lists.rb | UTF-8 | 533 | 3.96875 | 4 | [] | no_license | def oddities(arr)
odd_arr = []
arr.each_with_index do |elem, index|
odd_arr << elem if index.even?
end
odd_arr
end
def evenies(arr)
even_arr = []
arr.each_with_index do |elem, index|
even_arr << elem if index.odd?
end
even_arr
end
def evenies(arr)
even_arr = []
index = 0
while index <... | true |
be9636fa8bd11a7ca87ee807342b4d326e2df8db | Ruby | cwkarwisch/RB101 | /small_problems/easy_2/exer_01.rb | UTF-8 | 849 | 4.59375 | 5 | [] | no_license | =begin
Build a program that randomly generates and prints Teddy's age. To get the age,
you should generate a random number between 20 and 200.
Example Output
Teddy is 69 years old!
Understand the Problem
------------
Input: none
Output: printing a string
Examples/Test Cases
------------
Want a return value or OK w... | true |
44c1cfaad65c5e2167cd79585e74b400126b2e67 | Ruby | dfhcc/pubmed_original | /lib/pubmed/parse_fetch_results.rb | UTF-8 | 4,197 | 3.046875 | 3 | [
"MIT"
] | permissive | module Pubmed
module ParseFetchResults
# Accepts an xml_string of pubmed fetch results representing several articles. Returns an array of hashes
# that describe publications.
def parse_fetch_results(xml)
hash_of_pubmed_articles = Hash.from_xml(xml)
array_of_articles = hash_of_pubmed_article... | true |
e5aba7f5edc9f03b836554e04e3a9e376f1aedce | Ruby | hoshinotsuyoshi/euler | /lib/euler032.rb | UTF-8 | 1,024 | 3.34375 | 3 | [] | no_license | # coding: utf-8
class Euler032
def self.pandigital(e1, e2, e3, e4, e5, e6, e7, e8, e9)
sum = (e6 + e7 + e8 + e9).to_i
# 1-4-4
return sum if e1.to_i * (e2 + e3 + e4 + e5).to_i == sum
# 2-3-4
return sum if (e1 + e2).to_i * (e3 + e4 + e5).to_i == sum
0
end
def self.solve
array = []
a ... | true |
fb30181a813599b988b1a3b30c0252139f338f84 | Ruby | lhsteele/aA_classwork | /w2/w2d3/w2d3_classwork/W6D3/chess/modules/slideable.rb | UTF-8 | 1,599 | 3.4375 | 3 | [] | no_license | module Slideable
HORIZONTAL_DIRS = [[0, 1], [1, 0], [0, -1], [-1, 0]]
DIAGONAL_DIRS = [[1, 1], [1, -1], [-1, -1], [-1, 1]]
def horizontal_dirs
HORIZONTAL_DIRS
end
def diagonal_dirs
DIAGONAL_DIRS
end
#moves is an array that is going to return the answer from grow_unblocked_moves array method
... | true |
1abd7040ea16f6fdc9a2dfe86e9ede3706aa3fde | Ruby | AsheAvenue/Juvenile | /functions.rb | UTF-8 | 2,758 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'aws/s3'
require 'yaml'
class Functions
def self.load_config
YAML::load(File.open(File.join(File.dirname(__FILE__), "config.yml")))
end
def self.upload(app, settings)
#Set variables based on the config
db_type = settings['db']['type']
db_host = settings['db']['hos... | true |
e4b3516b794cc083c00a899b8cd633efd8518fd3 | Ruby | haines/tar | /test/header_test.rb | UTF-8 | 1,917 | 2.796875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative "test_helper"
require "tar/header"
class HeaderTest < Minitest::Test
def test_parse
header = Tar::Header.parse(header_data("020523"))
assert_equal "path/to/file", header.name
assert_equal 0o644, header.mode
assert_equal 83, header.uid
assert_equal ... | true |
e64b231a6b8c002cd3ba26f874387c3e73e73a24 | Ruby | lucas7qa/aut-kenoby-ui | /features/support/helpers.rb | UTF-8 | 2,785 | 2.515625 | 3 | [] | no_license | module Helpers
def change_last_page
page.switch_to_window(page.windows.last)
end
def wait_and_click(element, ind = nil)
@count = 0
300.times do
Capybara.default_max_wait_time = 0.1
p "Element #{element} is waiting for Click - #{@count}"
@count += 1
begin
send("wait_fo... | true |
00c604c550346bb075d2428c984e4c155d5494fd | Ruby | davefreiman/sinch-ruby | /lib/sinch/gateway.rb | UTF-8 | 908 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'httparty'
module Sinch
# Sinch Api Gateway
class Gateway
class << self
def request(endpoint, params)
request =
"Sinch::Request::#{endpoint.to_s.camelize}".constantize.new params
response = "Sinch::Response::#{endpoint.to_s.camelize}".constantize.new
new(request,... | true |
b4ef23b34b249c2fd23cb8c16ac24a98aa672fc7 | Ruby | merongivian/turboruby | /lib/turbo_ruby/parser.rb | UTF-8 | 7,324 | 3.078125 | 3 | [
"MIT"
] | permissive | require "strscan"
module TurboRuby
module Syntax
Tokens = {
K_CLASS: /class/,
K_DEF: /def/,
K_END: /end/,
T_CONSTANT: /[A-Z][\w\u0080-\u{10ffff}]*/u,
T_IDENTIFIER: /[\w\u0080-\u{10ffff}]+/u,
T_METHOD_NAME: Regexp.union(
... | true |
9801a567b42cb7503e65658fa2025db972252b80 | Ruby | iwhiteday/ChipsManager | /app/models/chip.rb | UTF-8 | 2,355 | 3.046875 | 3 | [] | no_license | class Chip < ApplicationRecord
validates :value, presence: true, uniqueness: true
after_initialize :set_defaults
private
def set_defaults
self.count ||= 0
end
class << self
def convert_from_money(currency)
ActiveRecord::Base.transaction do
raise ArgumentError, 'Amount < 0' if curre... | true |
1be3259c74b5ac2c99debf3e62f51364051875b3 | Ruby | mjvsha/oop1 | /ex4.rb | UTF-8 | 1,838 | 3.8125 | 4 | [] | no_license | class Paperboy
def initialize(name)
@name = name
@experience = 0
@earnings= 0
end
#we initially begin with the min quota of 50
#as paperboy makes deliveries, the minimum of 50 is added to the @experience
#@experience is the number of papers delivered in history of paperboy's life
def quota
#should calculate ... | true |
4c9ac29dfc1e924a30defad0db7579cb879295af | Ruby | leticiadesouza/improve | /modulo_02/ex_facom/ex_1_cond_facom.rb | UTF-8 | 347 | 3.953125 | 4 | [] | no_license | # um programa que imprima um numero com uma quantidade específica de seus múltiplos
# mostre o numero de multiplos se forem maiores do que 50
puts "Digite um numero: "
numero = gets.to_i
puts "Digite quantos multiplos você quer: "
quant_mult = gets.to_i
i = 1
while i <= quant_mult
if numero * i > 50
puts numer... | true |
e57629d4db6250f082550c7dfeae78f7428e3b32 | Ruby | ianmorgan/railsbank | /app/models/country.rb | UTF-8 | 135 | 2.640625 | 3 | [] | no_license | class Country
def self.find_all
["Australia", "New Zealand", "Indonesia", "Spain", "Afghanistan", "South Africa"]
end
end
| true |
5f5337d03ca368234c5f7e04bd6f5d1554fbf6d6 | Ruby | ianmorgan/wikikeep | /app/commands/base_poro.rb | UTF-8 | 1,034 | 2.515625 | 3 | [] | no_license | # Build an active record model manually
# without a database table
#
# TODO - need to work out how to get mass assigment (attributes and attributes=) methodd added
class BasePoro
extend ActiveModel::Naming
include ActiveModel::Conversion
include ActiveModel::Validations
# def initialize
# @er... | true |
4b5a77eb66d0afd9296c8a05106fbbd9bdb2d213 | Ruby | arunthampi/activecouch | /lib/active_couch/support/exporter.rb | UTF-8 | 3,653 | 2.609375 | 3 | [
"MIT"
] | permissive | # TODO
# - might consider moving create_database and delete_database to an adapter type class to encapsulate CouchDB semantics
# and responses.
module ActiveCouch
class Exporter
class << self # Class methods
def all_databases(site)
conn = Connection.new(site)
JSON.parse(conn.get("/_all_db... | true |
a7ec5c7dabf485ec13956d91c3892e4d7e583f97 | Ruby | studio3104/houcho | /lib/houcho/outerrole/yabitz.rb | UTF-8 | 1,533 | 2.578125 | 3 | [
"MIT"
] | permissive | require "houcho/config"
require "houcho/outerrole/save"
require "net/http"
require "cgi"
require "json"
include Houcho::OuterRole::Save
module Houcho
class OuterRole
class Yabitz; end
class << Yabitz
def load
begin
yabitz = YAML.load_file(Houcho::Config::FILE)["yabitz"]
rescue
end
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.