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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
0699797a2bdefb9a8aeb293dd91f864e74ea1aee | Ruby | shivahemanth/hemanth_test | /Test/test_scholarship.rb | UTF-8 | 922 | 2.703125 | 3 | [] | no_license | require '../PageObjects/scholarships'
require "json"
require "selenium-webdriver"
require "test/unit"
class Scholarship < Test::Unit::TestCase
def setup
@scholarship= Scholarships.new(@driver)
end
def teardown
@scholarship.teardown(@__name__, @passed)
end
def test_scholarship
scholarship_page=... | true |
b04b65e375863e9562f32e5171decc4a73a859a5 | Ruby | sumitsethtest/ruby-string-showdown | /lib/test_variant.rb | UTF-8 | 551 | 2.546875 | 3 | [] | no_license | class TestVariant
include Enumerable
attr_reader :name, :results
def initialize(name, operation)
@name = name
@operation = operation
@results = []
end
def results_vector
@results_vector ||= results.to_scale(name: name)
end
def run
redirecting_stdout do
Benchmark.measure { ope... | true |
43baa5df172fbdd03f0d077dc4f0e97bc1d526b3 | Ruby | SCCP2016/01-ruby-tutorial-s1240060 | /temp/bbb.rb | UTF-8 | 157 | 2.609375 | 3 | [] | no_license | r = STDIN.gets
nr= r.to_f
pi= 3.141592653589
# puts (nr*nr*pi).to_s+ " " + ((nr+nr)*pi).to_s
puts sprintf("%.6f %.6f",(nr*nr*pi),(nr+nr)*pi)
# puts nr.class
| true |
9517eeae3688b5e6284283322cdcf136d59d62dc | Ruby | takkii/Sample | /jruby.rb | UTF-8 | 237 | 3.03125 | 3 | [
"MIT"
] | permissive | require 'java'
import 'java.lang.System'
class Hello
def Hello.world
puts ("JRubyのRubyバージョンは : " + RUBY_VERSION + " です。")
System.out.println("こんにちは、Javaの世界よ!")
end
end
Hello.world
| true |
a132411884fe39ea77527e4335040113b5ae25fd | Ruby | dsgh/midi_switch | /lib/midi_switch/song.rb | UTF-8 | 232 | 2.96875 | 3 | [] | no_license | module MidiSwitch
class Song
attr_accessor :name
attr_accessor :programs
def initialize(name, programs)
self.name = name
self.programs = programs
end
def to_s
name
end
end
end
| true |
ce312e8ba22e8661483babd54cb93a461e2bccdc | Ruby | alberto911/termometro | /app/models/usuario.rb | UTF-8 | 420 | 2.703125 | 3 | [] | no_license | class Usuario < ActiveRecord::Base
def self.authenticate(username, password)
usuario = self.where(:username => username).first
if usuario
given_passwd = Usuario.encrypt_password(password)
if usuario.password != given_passwd
usuario = nil
end
end
return usuario
end
private
def self.encrypt_... | true |
a6e8b3ab8a1a48aef84831435fbe6582db01a3fa | Ruby | sandipransing/math_series | /test/number_series_test.rb | UTF-8 | 230 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class NumberSeriesTest < Minitest::Test
def subject
@subject ||= Number.new
end
def test_print
assert_equal [1,2,3,4,5], subject.print(5)
assert_equal [1,2,3], subject.print(3)
end
end | true |
f7aa5d4a715d7152434570a7788b1290ea8fb8fb | Ruby | malcolmsgroves/chess | /pieces/pieces.rb | UTF-8 | 1,868 | 3.578125 | 4 | [] | no_license | require_relative 'moves'
class Piece
include PieceMethods
attr_accessor :color, :pos
def initialize(color, pos)
@color = color
@pos = pos
end
end
class Rook < Piece
attr_accessor :type
def initialize(color, pos)
super(color, pos)
@type = :rook
end
def get_moves(board)
slide(boar... | true |
2f326d23d6543360d73846dd3242c2e8faa3ae91 | Ruby | petewilkins/gildedrose-refactoring-kata | /lib/gilded_rose.rb | UTF-8 | 619 | 3 | 3 | [] | no_license | class GildedRose
def initialize(items)
@items = items
end
def update_quality
items.each do |item|
index = items.index(item)
item = klass_for(item.name).new(item.quality, item.sell_in)
item.update_quality
items[index] = item
end
end
private
attr_reader :... | true |
fd116a8a0f9335a6ac197f7fdbb697e8f33de428 | Ruby | codesrobertson/slack-cli | /lib/slack.rb | UTF-8 | 1,787 | 3.203125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'table_print'
require 'dotenv'
require 'httparty'
Dotenv.load
require_relative 'workspace.rb'
require_relative 'receiver.rb'
require_relative 'channel.rb'
require_relative 'user.rb'
module SlackCLI
def self.main
puts "Welcome to the Ada Slack CLI!\n\n"
workspace = SlackCLI::Wo... | true |
d7fb5ce21b2f207350595926d0ba195b3e0806b6 | Ruby | petedmarsh/esoblocks | /lib/esoblocks/beatnik/interpreter.rb | UTF-8 | 3,132 | 3.4375 | 3 | [
"MIT"
] | permissive | require 'io/console'
module Esoblocks
module Beatnik
DEFAULT_CHARACTER_SCORES = {
'a' => 1,
'b' => 3,
'c' => 3,
'd' => 2,
'e' => 1,
'f' => 4,
'g' => 2,
'h' => 4,
'i' => 1,
'j' => 8,
'k' => 5,
'l' => 1,
'm' => 3,
'n' => 1,
... | true |
0e98b07ade377c8012f21ec721787287a1485343 | Ruby | medert/ninety-nine-bottles | /ninety-nine-bottles.rb | UTF-8 | 766 | 3.96875 | 4 | [] | no_license | # YOUR CODE HERE
require 'pry'
class Song
def initialize()
@num = 99
@sign = '.'
end
def print_lyrics
begin
puts "#{@num} bottles of beer on the wall, #{@num} bottles of beer#{@sign}"
puts "Take one down and pass it around, #{@num - 1} bottles of beer on the wall."
puts
@num ... | true |
afdc8ea9d67fc49ca7178530c81b55e479086418 | Ruby | Mwriley1/ls_course_120 | /lesson4/exercises/easy1.rb | UTF-8 | 585 | 3.828125 | 4 | [] | no_license | # 1. They are all objects. You can call the class method on each of the objects.
# 2. Include the module Speed in the Car and Truck Class. Call the go_fast method on a Car and Truck object.
# 3. By calling the class method on the class itself using self.class.
# 4. bob = AngryCat.new
# 5. The Pizza class, because... | true |
f997416f733dbbcbbd0bf65edb25c31f6ae8c048 | Ruby | alikhajeh1/Electune | /app/models/playlist.rb | UTF-8 | 1,164 | 2.515625 | 3 | [] | no_license | class Playlist < ActiveRecord::Base
has_many :playlist_items
after_initialize :default_values
validates :name, uniqueness: { case_sensitive: false }
def fetch(playlist_item)
PlaylistItem.find playlist_item
end
delegate :count, to: :playlist_items
def push(playlist_item)
playlist_item.playlist =... | true |
bbfc65bff5ac95d5b384e267c20840eb555ed9ab | Ruby | willfthompson/rails-mister-cocktail | /db/seeds.rb | UTF-8 | 1,995 | 2.65625 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
6420bda0acc921a6615ff014311664ec0e9bba14 | Ruby | redbeard/laughtrack | /lib/importers/comedy_festival.rb | UTF-8 | 2,143 | 2.796875 | 3 | [] | no_license | require 'open-uri'
module Importers
class ComedyFestival
URI_2008 = 'http://www.comedyfestival.com.au/season/2008/shows/a-z/'
URI_2009 = 'http://www.comedyfestival.com.au/season/2009/shows/a-z/letter/'
URI_2010 = 'http://www.comedyfestival.com.au/2010/season/shows/a-z/letter/'
def self.import
... | true |
f273f29f4403befc8ba95af596d38e1ee50ad4c2 | Ruby | macsux/cf-dotnet-sdk-builder | /cf-sdk-builder/lib/parameter.rb | UTF-8 | 1,101 | 2.875 | 3 | [] | no_license | module SDKBuilder
class Parameter
attr_reader :name, :description, :type, :is_array, :is_index_hash, :method
def initialize(name, method, description, raw_data = nil)
@name = name
@raw = raw_data
@description = description
@is_array = is_array?
@is_index_hash = is_index_hash?
... | true |
8adf4d42dc7a4e930e3dd226ea35eaf6b2c377c6 | Ruby | michelemendel/misc | /projects/film24/film24.rb | UTF-8 | 1,414 | 3.109375 | 3 | [] | no_license | require "open-uri"
class Film24
def initialize(baseUrl, stopMarker, startPage)
@baseUrl = baseUrl
@stopMarker = stopMarker
@counter = startPage
end
def each(pageList)
loop {
@counter += 1
@url = @baseUrl + pageList + @counter.to_s
content = URI.parse(@url).read
break if(!content... | true |
fa7e50468bde835bd353bebb2173cf8401ebe462 | Ruby | ajtran303/codeacademy-ruby | /5/method-syntax.rb | UTF-8 | 240 | 3.578125 | 4 | [] | no_license | # Methods have 3 parts
# Header includes def keyword, name of method and arguments
# Body contains the code block
# end keyword
def puts_1_to_10
(1..10).each { |i| puts i }
end
puts_1_to_10 # Ignore this for now. We'll explain it soon!
| true |
ea013b2ed953776b4deb869771a1946aa3198abc | Ruby | microsoftgraph/msgraph-sdk-ruby | /lib/models/security_ediscovery_add_to_review_set_operation.rb | UTF-8 | 3,635 | 2.75 | 3 | [
"MIT"
] | permissive | require 'microsoft_kiota_abstractions'
require_relative '../microsoft_graph'
require_relative './models'
module MicrosoftGraph
module Models
class SecurityEdiscoveryAddToReviewSetOperation < MicrosoftGraph::Models::SecurityCaseOperation
include MicrosoftKiotaAbstractions::Parsable
#... | true |
1b374afbe21d5431c0ddbb3d6e79f64fe6f696da | Ruby | anthonygharvey/ruby-music-library-cli-v-000 | /lib/song.rb | UTF-8 | 1,574 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song
attr_accessor :name, :artist, :genre
@@all = []
def initialize(name, artist = nil, genre = nil)
@name = name
if artist != nil
self.artist=(artist)
end
if genre != nil
self.genre=(genre)
end
end
def artist=(artist)
@artist = artist
artist.add_song(self)
en... | true |
1cc00718db6bb4277875d6eeabdbe323de2576c2 | Ruby | AlphaHydrae/tableling-rails | /lib/tableling-rails/type_serializer.rb | UTF-8 | 240 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive |
module Tableling
class TypeSerializer
def initialize type, block
@type, @block = type, block
end
def match? value
value.kind_of? @type
end
def serialize value
@block.call value
end
end
end
| true |
a31cdbcf53bb0c70f6d0001599d26b7bd9584551 | Ruby | pmo55/ruby-object-attributes-lab-v-000 | /lib/dog.rb | UTF-8 | 131 | 2.546875 | 3 | [] | no_license | class Dog
def name=(names)
@name=names
end
def name
@name
end
def breed=(breed)
@breed=breed
end
def breed
@breed
end
end | true |
e685302951829c212dae038013acdb97c87209cb | Ruby | mateocj/CursoRubyNov17 | /solucion2de2.rb | UTF-8 | 339 | 2.9375 | 3 | [] | no_license | puts "--------------------"
#Que resuelvan esto también los alumnos que van más rápido
contact_list.each do |contact|
puts "Nombre: #{contact["name"]}"
if contact["phone_numbers"].size > 0
contact["phone_numbers"].each do |phone_number|
puts "Teléfono: #{phone_number}"
end
end
puts "-------------... | true |
2d16ba7288b7f46789838e7b3b6cbdac48b0b21d | Ruby | pallan/mca_draws | /app/models/club.rb | UTF-8 | 912 | 2.71875 | 3 | [] | no_license | class Club < ActiveRecord::Base
attr_accessible :bottom_sheet, :name, :top_sheet
def self.find_for_sheet(sheet)
club_data = [[(1..9), "Granite"],
[(41..48), "Heather"],
[(51..56), "Fort Rouge"],
[(71..75), "Elmwood"],
[(91..96), "Deer Lodge"],
[(101..106), "Pembina"],
[(111..116), "Fo... | true |
c9122cc25d6b190c5c7f7aca72d08cfc8b813e6f | Ruby | JaceTheFirst/Ruby | /deal.rb | UTF-8 | 312 | 2.796875 | 3 | [] | no_license | class Deal
attr_accessor :user :vehicle :cost :startDate :endDate
def initialize (user, vehicle, startDate, endDate)
self.user = user
self.vehicle = vehicle
self.startDate = startDate
self.endDate = endDate
@cost = vehicle.cost * (endDate = startDate)
end
end | true |
244cd1a316381d80c449fef12a194fcfa3c548da | Ruby | fredriksa/SurvivalBox-2D | /src/Player.rb | UTF-8 | 3,590 | 2.84375 | 3 | [] | no_license | class Player
WIDTH = 32
HEIGHT = 32
attr_accessor :KbW, :KbSpace, :KbSpace_updated, :x, :y, :weapon, :health, :width, :height, :health, :type, :angle, :pickup_counter
attr_reader :alive
def initialize(window, x, y, map, angle = 90)
@width, @height = 32, 32
@window = window
@x, @y, @angle = x, y, ... | true |
005923e812c37c509d132e0bb5d53a53b2ce3dc3 | Ruby | SviatDrivy/trello_control | /config.ru | UTF-8 | 820 | 2.71875 | 3 | [] | no_license | require "json"
require "faraday"
require_relative "trello_client"
API_KEY = ENV['API_KEY']
API_TOKEN = ENV['API_TOKEN']
class MyApp
def call(env)
trello_client = TrelloClient.new
body = "<h1>My todo list</h1>"
if env["PATH_INFO"] == "/create"
req = Rack::Request.new(env)
puts req.params... | true |
6f9f0ff943373a848542cc20b0dec72dcc1011fa | Ruby | Dwaynew85/ruby-music-library-cli-online-web-sp-000 | /lib/artist.rb | UTF-8 | 339 | 2.9375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Artist < Song
extend Concerns::Findable
def initialize(name)
@name = name
@songs = []
end
def songs
@songs
end
def add_song(song)
song.artist = self if song.artist == nil
@songs << song if @songs.include?(song) == false
end
def genres
self.songs.collect {|song| song.gen... | true |
52794aa0419dde599daa7de03d6b24ddb8ee665c | Ruby | pse4/system | /DoctorToFSParser/parser.rb | UTF-8 | 752 | 2.921875 | 3 | [] | no_license | class Parser
require_relative 'adapter'
attr_accessor :file
def initialize (filename)
self.file = File.open(File.dirname(__FILE__) + "/#{filename}")
end
#@return an array of parsed MDC - FS documents
def parse_documents
documents = Array.new
file.each_line() do |row|
columns = row.split(... | true |
2aba9bf8f1464e59b4c5f72e48e888ad166b0bfa | Ruby | ejmenendez/entrega1 | /spec/manejador_usuarios_spec.rb | UTF-8 | 6,286 | 2.984375 | 3 | [] | no_license | require_relative '../manejador_usuarios'
require 'spec_helper'
describe ManejadorUsuarios do
let (:manejador) {ManejadorUsuarios.new}
describe "initialize" do
it "No tiene usuarios creados al inicio" do
expect(manejador.hay_usuario_logueado?).to be false
expect {
manejador.usuario_logueado
... | true |
598c566c4d091af6e1ed2ef92519694820b3f44f | Ruby | ramiror/personal-dev-learning | /ruby/deep_test/simple_test/tests/bonjour_test.rb | UTF-8 | 166 | 2.734375 | 3 | [] | no_license | require "tests/hello"
class FrenchHello < Hello
def hello
"Bonjour"
end
def goodbye
"Au revoir"
end
def lang
"fr"
end
end
FrenchHello.new
| true |
5d77c60b162a1b5c5f7bea0c6e663e8bc0ae3f31 | Ruby | gzavaglia/ruby-objects-has-many-lab-online-web-pt-041519 | /lib/author.rb | UTF-8 | 432 | 3.28125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require_relative "../lib/post.rb"
require 'pry'
class Author
attr_accessor :name, :title
@@posts = []
def initialize(name)
@name = name
@title
end
def add_post(post1)
@@posts << post1
post1.author = self
end
def posts
@@posts
end
def add_post_by_title(title)
new_post ... | true |
d64d557046c8b3191f182b741a026c4ea28de2ce | Ruby | JHussle/Chef-Training | /iterators/iterators.rb | UTF-8 | 254 | 3.703125 | 4 | [] | no_license | #iterator
5.times {puts "I am coding Ruby!"}
#iterator w/ an array
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
days.each { |day| puts day }
# iterator blocks
1.times do
puts "This is a code block!"
end | true |
3087fc76428cc3619cbe347098008aec24b584ce | Ruby | blairezy/advent-of-code-2018 | /day_5/main_pt2.rb | UTF-8 | 1,385 | 3.796875 | 4 | [] | no_license | def read_input()
content = ''
File.open("day_5/input.txt", "r") do |f|
f.each_line do |line|
content += line
end
end
content.strip()
end
def opposing_polarity?(a, b)
(a.upcase == a && a.downcase == b) || (a.downcase == a && a.upcase == b)
end
def react(input)
initial = input.split('')
accu... | true |
ff5d707ac3cfca93e05c61bdeb36c615f5d5e399 | Ruby | frmendez21/aA_Classwork | /W4D4/tdd_project/spec/tdd_spec.rb | UTF-8 | 807 | 3.46875 | 3 | [] | no_license | require 'tdd'
describe "my_uniq" do
let(:arr) { [1, 1, 2, 2, 5, 4, 3] }
it "returns an array that removes duplicates" do
expect(arr.my_uniq).to eq([1, 2, 5, 4, 3])
end
end
describe "two_sum" do
let(:arr) { [1, -1, 3, 4, -3, 6] }
it "return an array of indices that add to zero" do
... | true |
7db67ca0adb796c761f0e338f8a9c4f683cf4dd4 | Ruby | PenneyGadget/chisel | /emphasis_test.rb | UTF-8 | 1,257 | 2.859375 | 3 | [] | no_license | require "minitest/autorun"
require "minitest/pride"
require_relative "emphasis"
class EmphasisTest < Minitest::Test
def test_is_there_emphasis?
markdown = "You are *so* nice!"
words = Emphasis.new(markdown)
assert words.contains_emphasis
end
def test_it_recognizes_there_are_two_asterisks
markdo... | true |
c28029435525418cd837d886991dca4f80921ea9 | Ruby | eaglerockdude/tealeaf_precoursework | /methods/x1greet.rb | UTF-8 | 483 | 3.71875 | 4 | [] | no_license | # ken mcfadden : Tealeaf Academy pre-course exercises
# Methods Exercise 1 :
# Summary :
# Write a program that contains a method called greeting that takes a name as its parameter.
# It then prints a greeting message with the name included in it.
def greeting(name)
puts " Hi there #{name}, how are you doing t... | true |
bdcb86704396b8b089b3ad7c5e243a3a84d914b0 | Ruby | dvdalilue/OhTeX | /core/Package.rb | UTF-8 | 499 | 3 | 3 | [] | no_license | class Package
attr_reader :name, # Name of the package
:options # Options of the paackage
def initialize name, *options
@name = name
@options = options
end
def options
tex = ""
@options.each { |o| tex << "#{o.to_tex}, "} unless @options.empty?
... | true |
9faaa0b93e1525ab76ed14fa84fd6e32c0a55493 | Ruby | Thinknetica-SoftProject/SP-test-assignment-4-Artesann | /4.rb | UTF-8 | 1,614 | 3.390625 | 3 | [] | no_license | ## Задача №4:
#
# В соседнем районе рождественские эльфы готовят подарки для жителей города.
# Для каждого подарка (файл data/4.txt) нужно найти сколько оберточной бумаги потребуется.
# Формула рассчета: 2*ш*д + 2*д*в + 2*в*ш + площадь наименьшей стороны
# Например, на подарок размером 2х3х4 требуется 2*6 + 2*12 +... | true |
66a3f439eb72306846bd778e36503fea34a61f40 | Ruby | renuo/buschtelefon | /features/step_definitions/stepdefs.rb | UTF-8 | 1,537 | 2.6875 | 3 | [
"MIT"
] | permissive | Given("there is a tattler {string}") do |tattler_name|
tattlers[tattler_name] = Tattler.new
end
Given("{string} is connected to {string}") do |tattler_a, tattler_b|
tattlers[tattler_a].connect(tattlers[tattler_b])
end
Given("{string} knew about {string}") do |tattler, gossip|
connections_backup = tattlers[tattl... | true |
9f40782d6b2a512420e190b5bea0a9a4a824da0c | Ruby | Sambo9/Ruby3 | /ex_06/ex_6.rb | UTF-8 | 480 | 3.046875 | 3 | [] | no_license | #!/usr/bin ruby
# ================================
# ========= Class Mother =========
# ================================
class Mother
def initialize
if instance_of? Mother
else
puts "My daughter!!!"
end
end
end
# class Daughter < Mot... | true |
88cb0bb595dbf25b72427cf30a06949b2d6cacdb | Ruby | pho1n1x/codewars | /ruby/7kyu/genetic_algorithm/generate/solution.rb | UTF-8 | 65 | 2.96875 | 3 | [
"MIT"
] | permissive | def generate(length)
(1..length).map { [0, 1].sample }.join
end | true |
07a5dac61766f0a4a21479ce6f64f07a8a23d16c | Ruby | dkubo/legalNLP | /MWE/src/countoken/dict_match.rb | UTF-8 | 4,718 | 2.75 | 3 | [] | no_license | #coding:utf-8
require './data'
# require 'natto'
require 'json'
require 'csv'
# for ITC
# MYDIC = "../../result/tsutsuji_dic_20161215.json" # 先頭の「う」と「ん」を削除, ハイフン処理, エントリ追加をした辞書
CONST1="../const/const1_unidic.tsv"
CONST2="../const/const2.tsv"
# カンマ区切りされているデータがある⇒分割
def splitCont(mwe, start_idx, sentence)
precont,... | true |
b6e8a5f009bbf47ba27b4dbe220eb3886ee9ede4 | Ruby | nagata03/Ruby_Cherry | /lib/proc_object.rb | UTF-8 | 828 | 3.921875 | 4 | [] | no_license | hello_proc = Proc.new { 'Hello' }
p hello_proc.call
add_proc = Proc.new { |a = 0, b = 0| a + b }
p add_proc.call(10, 20)
p add_proc.call
sub_proc = proc { |a, b| a - b } # Kernelモジュールのprocメソッドを使ってもよい
p sub_proc.call(20, 5)
puts '*' * 30
def greeting(&block)
puts 'おはよう'
text = block.call('こんにちは')
puts text
... | true |
35a5e76eae56fedbb872de357ab8546b81f824c6 | Ruby | birbalds/ride-share-two | /lib/rider.rb | UTF-8 | 1,223 | 2.953125 | 3 | [] | no_license | require 'csv'
module RideShare
class Rider
RIDER_INFO = CSV.read('support/riders.csv')
attr_reader :rider_id, :name, :phone_number
def initialize(id)
raise ArgumentError, "#{id} is not a valid ID number" unless id.is_a?(Integer) && id >= 1
raise ArgumentError, "#{i... | true |
1d391a4641ece3b1ceb49d3a9db4721f7a355958 | Ruby | jemc/wires | /lib/wires/base/channel.rb | UTF-8 | 15,425 | 3.25 | 3 | [] | no_license |
module Wires.current_network::Namespace
#
#
# = Hooks Summary
# As a courtesy for custom services seeking to integrate with {Wires}, some
# hooks are provided for the {Channel} class. These hooks can be accessed
# by the methods inherited from {Util::Hooks}. Note that they are on a class
# level, ... | true |
4aa1cffb0f30bd542edf190c0fc37637036f279a | Ruby | sdmalek44/algorithm_practice | /lib/mock_interview_1119.rb | UTF-8 | 1,404 | 3.578125 | 4 | [] | no_license | # const kv = KV()
# kv.set('foo', 'bar')
# console.log(kv.get('foo')) // 'bar'
#
# const kv = KV()
# const timestamp = kv.set('foo', 'bar')
# setTimeout(() => {
# kv.set('foo', 'bar2')
# console.log(kv.get('foo', timestamp)) // 'bar'
# console.log(kv.get('foo')) // 'bar2'
# }, 1000)
#
# const kv = KV()
# const ti... | true |
9f513b63640c35ee4a78bbe8ddb32872a0f34206 | Ruby | erikaannesmith/black_thursday | /lib/invoice_item_repo.rb | UTF-8 | 679 | 2.875 | 3 | [] | no_license | require 'csv'
require_relative 'invoice_item'
class InvoiceItemRepo
attr_reader :invoice_items, :parent
def initialize(file, se=nil)
@invoice_items = {}
open_file(file)
@parent = se
end
def open_file(file)
CSV.foreach file, headers: true, header_converters: :symbol do |row|
invoice_item... | true |
68f9037386b4dbd309e0441992bcd4768403f7a9 | Ruby | mwakipesile/launch-school-101 | /oo-lesson2/rps-history/moves.rb | UTF-8 | 587 | 3.21875 | 3 | [] | no_license | # frozen_string_literal: true
# Moves class
class Moves
attr_accessor :data
def initialize
results = { freq: 0, won: 0, lost: 0, tie: 0 }
@data = {
'rock' => results.dup,
'paper' => results.dup,
'scissors' => results.dup
}
end
def track(choice, result = :tie)
data[choice][:f... | true |
da3433ccfa4491acd2c453a9ced336c6e6709a65 | Ruby | devinMcArthur/St.FX-Book-xChange | /app/models/book.rb | UTF-8 | 518 | 2.5625 | 3 | [] | no_license | class Book < ApplicationRecord
belongs_to :user, :foreign_key => :user_id
has_many :conversations, dependent: :destroy
default_scope -> { order(created_at: :desc) }
# For searching
# scope :title, -> (title) { where "title LIKE ?","%#{title.downcase}%"}
validates :user_id, presence: true
validates :title,... | true |
f800675d8429024027675d9f404f8be67e53d09f | Ruby | xfbs/passgen | /scripts/symbols-check.rb | UTF-8 | 2,041 | 2.859375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env ruby
require 'optparse'
options = {}
options[:prefix] = []
options[:regex] = []
options[:exact] = []
parser = OptionParser.new do |opts|
opts.banner = "Usage: check_symbols.rb [options]"
opts.on("-nPATH", "--nm=PATH", "Path to nm executable") do |nm|
options[:nm] = nm
end
opts.on("-pPREFI... | true |
4ccb7c8847d84fdb264768bbd24edc72ea7f95f6 | Ruby | johnfig/ruby-core | /alias.rb | UTF-8 | 195 | 3.65625 | 4 | [] | no_license | class Person
attr_accessor :name
def initialize(name)
@name = name
end
alias :title :name
end
john = Person.new("The Dawg")
puts john.name #=> The Dawg
puts john.title #=> The Dawg
| true |
8af4981c157e1d0adcfe8293bce8a725a82e2d5b | Ruby | edas/bitwapi | /lib/bitwapi/crypto.rb | UTF-8 | 3,911 | 2.640625 | 3 | [
"ISC"
] | permissive | # Most of the code here originated from the the file /lib/bitwarden.rb
# in the 'bitwarden-ruby' project, and was modified since then.
#
# The original code is Copyright (c) 2017 joshua stein <jcs@jcs.org>
# and licensed under the ISC license
#
# https://github.com/jcs/bitwarden-ruby/blob/master/LICENSE
# https://gith... | true |
b3a5252d7bb16fde67cc4159c5ebbeecf9931e1d | Ruby | paridhi16065/MyopicVicar | /lib/tasks/image.rake | UTF-8 | 3,202 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | namespace :image do
require 'freereg_aids'
desc "load the image file names from a listing created by rsync from the image server."
# rake image:load_pages[limit,county,file_name] --trace
# limit is the number of pages to be retrieved
# county is the chapman_code for the county to be processed. ALL is all co... | true |
eaeb29bb6f4d4dfa6db9cdb9d6e1ab74133add37 | Ruby | ministryofjustice/prison-visits-2 | /spec/services/nomis/api_slot_spec.rb | UTF-8 | 787 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | require 'rails_helper'
RSpec.describe Nomis::ApiSlot do
subject do
described_class.new(time: unparsed_slot,
capacity: 4,
max_groups: 3,
groups_booked: 1,
adults_booked: 1)
end
let(:unparsed_slot) { '2015-10-23T14... | true |
109d19382698ca0e6574c8e80ad98680245dd0ca | Ruby | Growingplant3/fountain_of_wisdom | /db/seeds.rb | UTF-8 | 1,634 | 2.640625 | 3 | [] | no_license | # 1508件のシードデータが少なすぎる場合にはこちらを使ってください。
# alphabet_array1 = ("A".."z").to_a
# alphabet_array2 = alphabet_array1
# alphabet_array3 = alphabet_array1
# task_name_array = []
# alphabet_array1.each do |first_letter|
# alphabet_array2.each do |second_letter|
# alphabet_array3.each do |third_letter|
# task_name_arra... | true |
26bf022b5bac94fcae958f999d8ce37793b4602d | Ruby | BrennanAyers/to_sweater_or_not_to_sweater | /app/generators/road_trip_generator.rb | UTF-8 | 2,008 | 2.6875 | 3 | [] | no_license | # frozen_string_literal: true
# An object to take in forecast and directions information and create POROs to
# be serialized for the RoadTrip endpoint
class RoadTripGenerator
attr_reader :id, :timezone, :location, :estimated_travel_time
def initialize(origin, destination)
time_traveled = duration(origin, dest... | true |
a789b39b9264af5fce4c0d560ee38179571cd235 | Ruby | nickzaf95/ruby-project-alt-guidelines-london-web-021720 | /lib/app.rb | UTF-8 | 12,090 | 3.65625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class App
def greet
puts "Welcome to Nick's music app! Here you can check out songs and add them to your own playlists"
end
def ask_for_name
puts "Hi there! What is your first name?"
end
def welcome_back(name)
puts "Welcome back #{name}! Enjoy your time using this app."
... | true |
27de8ed719d3a79d087fb02aa01bc10a44d9b3b6 | Ruby | simeonge/ruby-ninja | /tests/test_linked_list.rb | UTF-8 | 3,032 | 3.078125 | 3 | [] | no_license | require 'minitest/autorun'
require_relative '../linked_list.rb'
class TestLinkedList < MiniTest::Unit::TestCase
def setup
@list = LinkedList.new
end
def test_empty
assert_equal("", @list.to_s)
end
def test_insert_1
@list.insert(23, 0)
assert_equal("23 -> ", @list.to_s)
end
def test_in... | true |
598f212ec15d762ac2b5e2b39f3898fe56fe6a18 | Ruby | mbj/rz | /lib/rz/client.rb | UTF-8 | 5,281 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'json'
require 'rz/context'
require 'rz/errors'
module RZ
module Client
include Context
class TimeoutError < RZ::Error
end
# Send a request to service
#
# @param [String|Symbol] name the name of service
# @param [Hash] job the job definition
#
# @return self
def requ... | true |
7f290ab9aefce4284c71717241821bd028969e8d | Ruby | joe-walsh/bing_translator-gem | /lib/bing_translator.rb | UTF-8 | 5,833 | 2.5625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# (c) 2011-present. Ricky Elrod <ricky@elrod.me>
# Released under the MIT license.
require 'rubygems'
require 'cgi'
require 'uri'
require 'net/http'
require 'net/https'
require 'nokogiri'
require 'json'
require 'savon'
class BingTranslator
WSDL_URI = 'http://api.microsofttranslator.com/V2/soap.s... | true |
82b2275b97004fe53c16b3369fdce8bfd8845e2e | Ruby | fvargasserani/desafio_hashes | /iter3.rb | UTF-8 | 425 | 3.015625 | 3 | [] | no_license | ventas = {
Enero: 15000,
Febrero: 22000,
Marzo: 12000,
Abril: 17000,
Mayo: 81000,
Junio: 13000,
Julio: 21000,
Agosto: 41200,
Septiembre: 25000,
Octubre: 21500,
Noviembre: 91000,
Diciembre: 21000
}
def filter(parameter,hash)
new_hash = {}
hash.each do |k,v|
if v > parameter.to_i
new_hash[k] ... | true |
e39512eaaf14489ddd89224dd70ff2b22df51d85 | Ruby | fursich/hack_jack_compiler | /test/transformer/visitor/node_extractor_test.rb | UTF-8 | 16,837 | 2.640625 | 3 | [] | no_license | require 'test_helper'
module JackCompiler
module Transformer
class TestVisitorNodeExtractor < Minitest::Test
def test_class
node = VisitorTestHelper.prepare_tree(<<~SOURCE, root_node: :class)
class Foo {
field int x, y;
field Array map;
}
SOURCE
... | true |
b4ae2340dbdf65fefe44f935e6ffb1910a489904 | Ruby | alexchi1114/event_manager | /event_manager.rb | UTF-8 | 1,214 | 3.09375 | 3 | [] | no_license | require "csv"
require "sunlight/congress"
require 'erb'
Sunlight::Congress.api_key = "e179a6973728c4dd3fb1204283aaccb5"
def clean_zipcode(zipcode)
zipcode.to_s.rjust(5,"0")[0..4]
end
def legislators_by_zipcode(zipcode)
Sunlight::Congress::Legislator.by_zipcode(zipcode)
end
def save_thank_you_letters(id,form_lett... | true |
ff1cb0af500cacfe580f529cea493634117b4cac | Ruby | jfleck1/nbgallery | /lib/extension_points/remote_storage.rb | UTF-8 | 538 | 2.625 | 3 | [
"MIT"
] | permissive | # Stub interface for remote storage service
class RemoteStorage
class << self
# Store a new file. Return a commit id of some sort.
def create_file(filename, content, options={})
end
# Update an existing file. Return a commit id of some sort.
def edit_file(filename, content, options={})
end
... | true |
6247dd660e754c6be363a98507169dd71eebb004 | Ruby | Schofield88/myRuby | /hash_assign_exercise.rb | UTF-8 | 370 | 3.015625 | 3 | [] | no_license | players = [
{ :name => "Sam", :sport => "tennis" },
{ :name => "Mary", :sport => "squash" },
{ :name => "Ed", :sport => "tennis" },
{ :name => "Mark", :sport => "football" }
]
sports_hash = {}
players.each { |hash|
if sports_hash[hash[:sport]].nil?
sports_hash[hash[:sport]] = []
end
sports_hash[ha... | true |
42f2a3f3390f33940a51fed527443ffb0c9a992c | Ruby | GururajDesai/Engineering | /RubyWarrior/player.rb | UTF-8 | 923 | 3.109375 | 3 | [] | no_license | class Player
def play_turn(warrior)
@health = warrior.health unless warrior.health
@behind = 2 if @behind.nil?
@temp = 2 if @temp.nil?
@behind = @behind - 1
if @behind < -3 and @behind > -7
warrior.shoot!
else
if warrior.feel.empty?
if warrior.health > 15 or under_attack?(... | true |
0638c9b9dfdb4cae0e9144de55594be3f6fcceed | Ruby | Bulatkin/meta_koans | /knowledge.rb | UTF-8 | 732 | 2.890625 | 3 | [] | no_license | class Object
def attribute(attribute, &block)
attribute.is_a?(Hash) ? (attr, value = attribute.first) :
(
attr = attribute
value = (block ? block : nil)
)
class_eval do
define_method "#{attr}=" do |attr_value|
instance_variable_set("@#{attr}", attr_value)
end
... | true |
3b9c91ac13035622b9c5fe8dae800a4362d87637 | Ruby | ebellani/my-rc-files | /Projects/robot-language/code-new/robot_movement.rb | UTF-8 | 1,845 | 3.78125 | 4 | [] | no_license | # -*- coding: utf-8 -*-
=begin
Suppose you have to implement a robot that follows the following
commands:
L - Turn left 90 degrees
R - Turn right 90 degrees
M - Move forward
T - Teleport to X,Y
The robot moves in a Cartesian coordinate system. Here is a sample of
the robot's input.
10 10 # define the ... | true |
4d88afa82dd17147b45f874474e38d9e80394039 | Ruby | radu-constantin/small-problems | /easy3/square.rb | UTF-8 | 246 | 3.5 | 4 | [] | no_license | def multiply (first_number, second_number)
first_number * second_number
end
def square(number, n)
counter = 1
power = 1
loop do
power << multiply(power, number)
counter += 1
break if counter == n
end
power
end
puts square(5, 2)
| true |
d7d0ece34525d8bc0e3c686631f7499852246899 | Ruby | alki-project/piah | /lib/piah/config_processor.rb | UTF-8 | 4,230 | 3.046875 | 3 | [
"MIT"
] | permissive | module Piah
class ConfigMergeError < StandardError
def initialize(a,b)
super "Failed to merge config values #{a.pretty_print_inspect}\n and\n#{b.pretty_print_inspect}"
end
end
class ConfigProcessorResultError < StandardError
def initialize(v)
super "Config processors must return a Hash o... | true |
fb36b672095b79aa0e73a06c33c854cd42bdff42 | Ruby | jessburnsm/discorama | /lib/player.rb | UTF-8 | 2,378 | 3.40625 | 3 | [] | no_license | require_relative './utilities/battle_entity'
class Player
include BattleEntity
attr_accessor :x_coord, :y_coord, :in_battle,
:dance_skill, :taunt_skill, :rally_skill, :taunt_bonus, :dance_bonus, :cp
MAX_HP = 100
MAX_CP = 50
def initialize
@game_text = GameText.new
# Starting position
@x_c... | true |
7c0bafe7dc936294c48232b5d02785dc5bbbb3d2 | Ruby | hide5stm/IJN48 | /lib/naka/models/battle/midnight_battle.rb | UTF-8 | 1,191 | 2.5625 | 3 | [] | no_license | module Naka
module Models
module Battle
class MidnightBattle
attr_accessor :enemy_ids, :enemy_hps, :fleet_hps
def completed? ; true ; end
def self.from_api(response)
battle = new
data = response[:api_data]
max_hps = data[:api_maxhps]
now_hps ... | true |
352ce237d85b089aadbd79d6a847d5d01bdfd78c | Ruby | YavuzOrbey/learn_ruby | /04_pig_latin/pig_latin.rb | UTF-8 | 561 | 3.4375 | 3 | [] | no_license | #write your code here
def translate sentence
words = sentence.split
sentence = ""
words.map! do |word|
if word.start_with?("a", "e", "i", "o", "u")
word += "ay"
else
#sentence = sentence.slice(1,sentence.length) + sentence.slice(0) + "ay"
if word.include?("qu")
word = word.slice... | true |
ff985a593195b9fd3e7b7f7d75a026718e46e424 | Ruby | keshav-c/enumerable-methods | /enumerable.rb | UTF-8 | 1,970 | 3.0625 | 3 | [] | no_license | # frozen_string_literal: true
module Enumerable
def my_each
for idx in (0...self.size)
yield(self[idx])
end
end
def my_each_with_index
for idx in (0...self.size)
yield(self[idx], idx)
end
end
def my_select
filtered = []
self.... | true |
5c2f7e25989555dcc1e41c22f1bdab018f1883f0 | Ruby | learn-co-students/seattle-web-060120 | /12-active-record/models/artist.rb | UTF-8 | 2,071 | 3.234375 | 3 | [] | no_license | class Artist < ActiveRecord::Base
# attr_accessor :name, :id
# def initialize(artist)
# @name = artist["name"]
# @id = artist["id"]
# end
# def self.all
# # Returns [#<Artist>, #<A>, #<A>]
# artists = DB.execute("SELECT * FROM artists")
# artists.map { |artist| Artist.new(artist) }
# end... | true |
f25dfb425cff6f25a137c1359f948af8430f93c6 | Ruby | lizlam/bookclub | /seven-languages-in-seven-weeks/ruby/tree2.rb | UTF-8 | 572 | 3.671875 | 4 | [] | no_license | class Tree
attr_accessor :children, :node_name
def initialize(name, children={})
@children = children
@node_name = name
end
def visit_all(&block)
visit &block
children.each_value {|c| puts c}
end
def visit(&block)
block.call self
end
end
ruby_tree = Tree.new( "Ruby",
{'grandpa'... | true |
67885e5bf2b1ec7195d126f1d1fae39adc80eea6 | Ruby | ninthwalker/NowShowing | /root/var/lib/nowshowing/omdb.rb | UTF-8 | 1,228 | 2.609375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
require 'rubygems'
require 'json'
require 'httparty'
# Class that interacts with omdbapi.com.
#
# Author: Brian Stascavage
# Email: brian@stascavage.com
#
class OMDB
include HTTParty
# temporarily add api key since OMBI closed their API and started charging.
# Old: base_uri 'http://www.omdb... | true |
ab11f028cb5d20925cf6a14693e535417d3c6d4f | Ruby | hoyzington/programming-univbasics-nds-nds-to-insight-with-methods-online-web-prework | /lib/nds_extract.rb | UTF-8 | 574 | 3.140625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'directors_database'
def directors_totals(nds)
result = {}
which_dir = 0
while which_dir < nds.length do
result[nds[which_dir][:name]] = gross_for_director(nds[which_dir])
which_dir += 1
end
result
end
# Find a way to accumulate the :worldwide_grosses and return that Integer
# using direc... | true |
96412519fd5cb6fa5f9ce8e6457d5d3be9beb481 | Ruby | quintel/etengine | /app/models/command_attributes.rb | UTF-8 | 1,016 | 2.65625 | 3 | [
"MIT",
"LicenseRef-scancode-free-unknown"
] | permissive | # Mixed into models which contain attributes which are GQL strings. Provides a
# useful helper for converting the string to a GQL::Command, including the extra
# information for getting a decent backtrace.
module CommandAttributes
# Internal: Given an +attribute+ name, returns the GQL::Command which
# represents th... | true |
10af9ec78cea1a64520a31297e3e63d5e98fba75 | Ruby | Kandiie/pushbots | /spec/requests.rb | UTF-8 | 2,487 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'webmock/rspec'
module Requests
def single_device_requests
token = 'token'
message = 'Hello World!!!'
sound = 'sound'
# Valid data
pushbots_single_request(:post, token, message, sound, 200)
# Empty or nil token returns status 400
pushbots_single_request(:post, '', message, sound, 4... | true |
6953c43a977ccf52d280187369393401d0958f2a | Ruby | cenzo-development/cenzo-city | /app/roles/passcode_verifier.rb | UTF-8 | 365 | 2.640625 | 3 | [] | no_license | class PasscodeVerifier < SimpleDelegator
def verify_psaacode(code)
case code
when nil then return false
when code.length < 6 then return false
when !is_numeric_code?(code) then return false
end
Digest::SHA512.hexdigest(code) == self.pass_code
end
private
def is_numeric_code?(code)
... | true |
59940621d5d57051062bccfd9bbffd288ef946d6 | Ruby | SamWegs/Intro_to_programming_Ruby | /exercises/exercises9.rb | UTF-8 | 151 | 3.625 | 4 | [] | no_license | # exercises9.rb
hash_array = {a: [1, 2, 3], b: [4, 5, 6], c: [7, 8, 9]}
p hash_array[:a]
array_hash = [{a: 1, b:2 }, {c: 3, d: 4}]
p array_hash[1]
| true |
a64785d56d7bab801713c65661dced40917473bc | Ruby | Holden4/learn-to-program | /chap07-Flow_Control/grandma.rb | UTF-8 | 494 | 3.359375 | 3 | [] | no_license | bye_count = 0
while true
puts "Say something to Grandma...."
chat = gets.chomp
if chat == chat.upcase
if chat == "BYE" && bye_count < 2
bye_count += 1
elsif chat == "BYE" && bye_count == 2
puts "OH, GOING SO SOON? OKAY THEN, BYE BYE!"
puts "*" * 50
break
else
puts "No, NO... | true |
8e8fb122645d18c68e2f5e236b5e72f94495218f | Ruby | dploeg/kanban_dashboard | /lib/readers/file_config_reader.rb | UTF-8 | 301 | 2.71875 | 3 | [
"MIT"
] | permissive | require 'yaml'
class FileConfigReader
def initialize(filename)
@filename = filename
end
def read_config
begin
config = YAML.load_file(@filename)
rescue => error
raise RuntimeError.new(error)
end
unless config
return Hash.new
end
config
end
end | true |
97bd649ea11cabb119c1c118409e991b2014afe6 | Ruby | tensins/uw_sfinder | /test/models/room_test.rb | UTF-8 | 4,283 | 2.578125 | 3 | [] | no_license | require 'test_helper'
# tests for the model room
class RoomTest < ActiveSupport::TestCase
def setup
@offset = Time.now.utc_offset
@room = Room.new(room_name:"MC 2065",classes:[{"subject"=>"AFM", "catalog_number"=>"417", "section"=>"LEC 001",
"weekdays"=>"F", "start_time"=>"17:00", "end_time"=>"21:50"... | true |
971f8e8085ccaae61f33f073e90060ef84cc2384 | Ruby | centaurustech/researchable | /db/migrate/20110311091509_create_states.rb | UTF-8 | 3,551 | 2.53125 | 3 | [
"MIT"
] | permissive | # coding: utf-8
require 'sexy_pg_constraints'
class CreateStates < ActiveRecord::Migration
def self.up
create_table :states do |t|
t.string :name, :null => false
t.string :acronym, :null => false
t.timestamps
end
constrain :states do |t|
t.name :not_blank => true, :unique => true
... | true |
2c23706c3c62d0580b58c3f8feae439ed9b5e0fe | Ruby | greytape/backend | /101-109 /easy6_3.rb | UTF-8 | 884 | 4.75 | 5 | [] | no_license | # # I/O
# input: integer
# output: integer
# # Logic
# - put two numbers of the series (1 and 1) in an array
# - then add a new number based on summing the last two (separate method)
# - at each iteration calculate the length of the latest number in the array
# - break the loop when the length is equal to or greate... | true |
ed141a72e962abb9c29699d625c8e11806b66a02 | Ruby | milesfr0mh0me/Ruby-Class1 | /flow.rb | UTF-8 | 320 | 4.03125 | 4 | [] | no_license | #program control flow
name = gets.chomp
=begin
==
!=
|| or
&& and
>
<
<=
>==
=end
if condition
else
end
if (5 != 2) and (2 != 5)
puts "These numbers are different"
end
if 5 != 2
puts "5 is not equal to 2"
end
if 5 > 2
puts "5 is greater than 2"
end
if name == "Aarai"
puts "found #{name}"
end
puts name | true |
1a9fca485320efcfa42f3e80df972603684f17c4 | Ruby | lazaronixon/pushmeup | /lib/pushmeup/mpns/notification.rb | UTF-8 | 291 | 2.53125 | 3 | [
"MIT"
] | permissive | module MPNS
class Notification
attr_accessor :device_url, :data, :type, :delay
def initialize(device_url, data, options = {})
self.device_url = device_url
self.data = data
self.type = options[:type] || :raw
self.delay = options[:delay]
end
end
end
| true |
41ff9eb73b861179fb8a2ce311e10afecd6eb85f | Ruby | fela/hacketyhack | /app/ui/editor/program_runner.rb | UTF-8 | 1,869 | 2.921875 | 3 | [
"Ruby",
"MIT"
] | permissive | # code used to run a program from the editor
#
# a message is shown displaying "Running...", and is replaced with the say
# method
#
# if an error occurs it will be displayed, but only if it happens at the top
# level: exceptions in a Shoes app or thread will just be shown in the Shoes
# console
module HH::ProgramRunn... | true |
fdd9178212248bedee8c01912590cb3609cbf27c | Ruby | IsuruV/Market_Quoter-cli-gem | /lib/company.rb | UTF-8 | 788 | 2.875 | 3 | [
"MIT"
] | permissive | require 'pry'
require 'open-uri'
require 'nokogiri'
class Company
attr_accessor :website, :managers, :description, :ticker
attr_accessor :name, :events, :stats, :posts, :price
@@all = []
def initialize(summary_hash)
if summary_hash
summary_hash.each do |key,value|
self.send("#{key}=", value)
... | true |
1ac06999d297d3986a4d7be6382ee51a45eede6e | Ruby | urieljuliatti/csv_record | /lib/csv_record/writer.rb | UTF-8 | 2,489 | 2.75 | 3 | [
"MIT"
] | permissive | module CsvRecord
module Writer
module ClassMethods
def __create__(attributes={})
instance = self.build attributes
result = instance.save
instance
end
[:attr_accessor, :attr_writer].each do |custom_accessor|
define_method custom_accessor do |*args|
@rele... | true |
51811c0b1a2b1138a7b6b4ac38669f556d6a9eb6 | Ruby | yodel-cms/yodel | /lib/yodel/models/core/fields/date_field.rb | UTF-8 | 907 | 2.609375 | 3 | [] | no_license | class DateField < Field
def default_input_type
:date
end
def before_create(record)
return unless name == 'created_at' || name == 'updated_at'
record.set(name, Time.now.utc.to_date)
end
def before_update(record)
return unless name == 'updated_at'
record.set(name, Time.now.utc.to_date)
... | true |
0fd222e24ade21c5133ac32aa176666a2a67c668 | Ruby | jkrall/wesabe-rubygem | /lib/wesabe/util.rb | UTF-8 | 169 | 2.578125 | 3 | [
"MIT"
] | permissive | module Wesabe::Util
extend self
def all_or_one(what, &block)
result = Array(what).each(&block)
return what.is_a?(Array) ? result : result.first
end
end
| true |
7b15b72e9d1028014ae37e01aeee9359a2e53b26 | Ruby | timchunght/libgfapi-ruby | /lib/glusterfs/file.rb | UTF-8 | 1,918 | 2.90625 | 3 | [
"MIT"
] | permissive | require "tempfile"
class GlusterFS::File
attr_reader :volume, :path
def initialize(volume, path)
@volume = volume
@path = path
end
def read_file(buf_size = 4092)
check_exists
fd = GlusterFS.open(@volume.fs, @path, 0)
if path.include?('.')
ext = '.' << path.split('.').pop
temp = ... | true |
04e9e245fbc20bd67fb386a2d5a1f006f2360245 | Ruby | kishaningithub/rbnd-survivr-part2 | /lib/survivr.rb | UTF-8 | 2,432 | 3.734375 | 4 | [] | no_license | require 'colorizr'
require_relative "game"
require_relative "tribe"
require_relative "contestant"
require_relative "jury"
#After your tests pass, uncomment this code below
#=========================================================
# # Create an array of twenty hopefuls to compete on the island of Borneo
@contestants ... | true |
9c3aa3f4e9d47bd543487ea1d5a4375844138cff | Ruby | warna720/TDP007 | /seminar2/tc-uppg2.rb | UTF-8 | 552 | 2.578125 | 3 | [] | no_license | #!/usr/bin/env ruby
# -*- coding:utf-8 -*-
require_relative "./uppg2"
require "test/unit"
class TestUppg2 < Test::Unit::TestCase
require 'rexml/document'
def test_all
src = File.open("calendar.html")
doc = REXML::Document.new(src)
events = []
doc.elements.each("//div[@class=... | true |
a60b61e3be123c60fb1854ae62ab188f2726baae | Ruby | Jin-12/exos_ruby_basics | /lib/00_hello.rb | UTF-8 | 248 | 3.296875 | 3 | [] | no_license | def ask_first_name
puts "Comment tu t'appelle ?"
first_name = gets.chomp
return first_name
end
def say_hello(first_name)
puts "Bonjour, #{first_name} !"
end
def perform
first_name = ask_first_name
say_hello(first_name)
end
perform
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.