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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
6c32cc974b10bd0e7c2eb76a93eb448cc74d04d9 | Ruby | lewisbrown1993/snakes-and-ladders | /dice.rb | UTF-8 | 150 | 3.15625 | 3 | [] | no_license | class Dice
attr_reader :value
def initialize
@value = nil # not, I suppose, really needed
end
def roll
return rand(1..6)
end
end | true |
40c4f0212d807bdb21262ab34865767b7c82cae1 | Ruby | kfinn/jack-sudoku-experiment | /app/models/puzzle.rb | UTF-8 | 1,377 | 2.96875 | 3 | [] | no_license | class Puzzle
include ActiveModel::Model
attr_accessor :board
BOARD_SIZE = 9
def self.from_file(file)
rows = file.each_line.map do |line|
cells = line.split(' ')
raise "invalid line: #{line}" unless cells.size == BOARD_SIZE
cells.map do |cell|
if cell == '0'
nil
... | true |
55435c64de7d2e6b142e925baadcb47ea9bd8d9d | Ruby | ajduncan/lol | /client.rb | UTF-8 | 908 | 2.546875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# coding: UTF-8
require "rubygems"
require "eventmachine"
HOST = '127.0.0.1'
SSL_PORT = 9001
class LOLKeyboardHandler < EM::Connection
include EM::Protocols::LineText2
attr_reader :queue
def initialize(q)
@queue = q
end
def receive_line(data)
@queue.push(data)
end
end
cl... | true |
1fb6aeee804ee9f9f4bea001ba4189beedd2a70c | Ruby | max888/strandedtravel | /db/seeds.rb | UTF-8 | 1,831 | 2.515625 | 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | true |
b31cb571985d5090698dd4d70cb99c9491449c93 | Ruby | EasyPost/easypost-ruby | /lib/easypost/services/billing.rb | UTF-8 | 2,440 | 2.734375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'easypost/constants'
class EasyPost::Services::Billing < EasyPost::Services::Service
# Get payment method info (type of the payment method and ID of the payment method)
def self.get_payment_method_info(priority)
payment_methods = EasyPost::Services::Billing.retrieve_payme... | true |
02e9155ee251eac6358cb1c853e36a9e03bd2eb8 | Ruby | mixeeff/rubylessons | /lesson_7/carriage.rb | UTF-8 | 1,369 | 3.5625 | 4 | [] | no_license | require_relative('manufacturer')
require_relative('instance_counter')
class Carriage
include Manufacturer
include InstanceCounter
attr_reader :space, :free_space, :number, :owner
NUMBER_FORMAT = /^[A-Z]+\d+$/
OWNER_ERROR = 'Owner must be a Train or Nil'
WRONG_NUMBER_ERROR = 'Number must be String'
EMRTY... | true |
359840b5152199964c73d83b23f848b4bf1d9a10 | Ruby | D4L/projectEuler | /src/problem-179/hral.rb | UTF-8 | 617 | 2.90625 | 3 | [] | no_license | public
def hral
count = 0
numDivisors = Array.new
isPrime = Array.new
remain = Array.new
(0..10000001).each do |i|
remain.push i
isPrime.push true
numDivisors.push 1
end
(2..5000000).each do |i|
if isPrime[i]
n = i * 2
begin
isPrime[n] = false
c = 0
whi... | true |
e4c8cee6d0970951af14c296af59fa9f9db1ad98 | Ruby | erezbosch/Goals | /GoalApp/app/models/cheer.rb | UTF-8 | 543 | 2.53125 | 3 | [] | no_license | class Cheer < ActiveRecord::Base
validates :user_id,
uniqueness: { scope: :goal_id, message: "Can't cheer goal more than once" }
validate :cannot_cheer_own_goal
validate :maximum_cheer_number
validates :user_id, :goal_id, presence: true
belongs_to :user
belongs_to :goal
private
def cannot_cheer_o... | true |
896c84be66a3e515957ff4cfd7563f33efc33113 | Ruby | AKB428/inazuma | /urisure/urisure_dat_extraction.rb | UTF-8 | 303 | 2.78125 | 3 | [] | no_license | open(ARGV[0]) {|file|
while line = file.gets
res_data = line.split("<>")
if res_data.size > 3
stage1 = res_data[3].delete("<br>").delete(">").delete(";&").delete("http://").delete("imu").delete("co")
puts stage1.gsub(/(jp|imgur|https|com|jpeg|png|hp)/, ' ')
end
end
}
| true |
99a8f86bbeac5098043d5ae0bca77da68ce1e49a | Ruby | aidasharif/ML-NLP-Projects | /Home_Credit_Kaggle/HomeCredit_3/transformers.rb | UTF-8 | 8,867 | 2.78125 | 3 | [] | no_license | ##transformers.rb
#### KEEP THIS AT THE TOP OF YOUR FILE ####
class TransformingLearner
include Learner
attr_accessor :name
def initialize transformer, learner
@parameters = learner.parameters
@parameters["learner"] = learner.parameters["name"] || learner.class.name
@transformer = transformer
@le... | true |
dc77fdf059dbe1233adff32cdbc93bd3102d4a1c | Ruby | mmosche2/project-euler | /problem17.rb | UTF-8 | 3,007 | 4.21875 | 4 | [] | no_license | def convert_to_string(num)
if num == 0
num_string = ""
elsif num == 1
num_string = "one"
elsif num == 2
num_string = "two"
elsif num == 3
num_string = "three"
elsif num == 4
num_string = "four"
elsif num == 5
num_string = "five"
elsif num == 6
num_string = "six"
elsif num == 7
num_string = "seve... | true |
c0bcdead0df91b4421ab9e321558695187f80e11 | Ruby | pasosdeJesus/sip | /app/helpers/sip/importa_helper.rb | UTF-8 | 2,520 | 2.96875 | 3 | [
"ISC"
] | permissive |
module Sip
module ImportaHelper
def nombre_en_tabla_basica(tbasica, nombre, menserror,
camponombre = 'nombre')
if !nombre || nombre == ''
return nil
end
d = tbasica.where("upper(unaccent(#{camponombre})) = upper(unaccent(?))",
n... | true |
c2b06ce170b4d8b2e4baff243430b6db08e57c3a | Ruby | Caroguti/Ruby3 | /11_Patron3/patron3.rb | UTF-8 | 157 | 2.96875 | 3 | [] | no_license | n=ARGV[0].to_i
n.times do |i|
if i%6==0 || i%6==1
print '.'
elsif i%6==2 || i%6==3
print '*'
else
print '|'
end
end
puts "\n" | true |
c2b7da274407cf2f641cc1eab137c417c8cdaf5f | Ruby | jennafritz/phase-3-object-relations-practice-code-challenge-students-one-many | /app/models/cohort.rb | UTF-8 | 779 | 3.265625 | 3 | [] | no_license | require 'pry'
class Cohort < ActiveRecord::Base
has_many :students
def add_student(name, age)
self.students << Student.create(name: name, age: age)
end
def average_age
self.students.average(:age).to_f
end
def total_students
self.students.count
end
def self.bi... | true |
44bcb03911e3a32df6a003ecbbee9f745a0dd3da | Ruby | Zekimar/CS1632 | /d2/tests/drive_update_test.rb | UTF-8 | 1,317 | 3.390625 | 3 | [] | no_license | require 'minitest/autorun'
require_relative '../Place'
require_relative '../Driver'
# Unit tests for Driver.update method
# EQUIVALENCE CLASSES:
# @books is updated when location == "Hillman"
# @toys is updated when location == "Museum"
# @classes is updated when location == "Cathedral"
# 1 variable is incrementing at... | true |
fb9e75ceb105f9bd7fd517c51dddd561e70afa81 | Ruby | mdixon47/Codewars-Ruby | /8-kyu/Enumerable Magic #2 - True for Any.rb | UTF-8 | 251 | 3.765625 | 4 | [] | no_license | #Description:
#Create an any? function that accepts an array and a block,
#and returns true if the block returns true for any item in the array.
#If the array is empty, the function should return false.
def any? list, &block
list.any?(&block)
end | true |
de64fe9c345fea368fd1a5c6c85a1a8e631ae0d0 | Ruby | SAMTHP/recipe_scraper | /spec/recipe_marmiton_spec.rb | UTF-8 | 3,058 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe "http://www.marmiton.org recipe crawler" do
before(:each) do
marmiton_url = 'http://www.marmiton.org/recettes/recette_burger-d-avocat_345742.aspx'
@recipe = RecipeScraper::Recipe.new marmiton_url
end
it 'should create the recipe' do
expect(@recipe).not_to be nil
en... | true |
83eef5a3acf53f23d1201628b7ee063e919a4bd2 | Ruby | gsorokolit/mon26_reinforcement | /reinforcement.rb | UTF-8 | 1,192 | 2.65625 | 3 | [] | no_license | project = {
committee: ["Stella", "Salma", "Kai"],
title: "Very Important Project",
due_date: "December 14, 2019",
id: "3284",
steps: [
{description: "conduct interviews", due_date: "August 1, 2018"},
{description: "code of conduct", due_date: "January 1, 2018"},
{description: "compile results", d... | true |
3d005b4e08cd902f694a5535faf7c9d0ee1b0ce5 | Ruby | jkmarx/ActorNameGameApi | /app/models/movie.rb | UTF-8 | 815 | 2.703125 | 3 | [] | no_license | class Movie
include ActiveModel::Model
def self.getPersonsData(arrId)
JSON.parse(MovieDetail::requestPerson(arrId).body)["person_results"][0]
end
def self.parseNameImage(data)
data.map{ |person| {name: person["name"], image: "https://image.tmdb.org/t/p/w185" + person["profile_path"]} }
end
def se... | true |
2a1dfb5a4520e9603c7b5005839eeb310c6b6661 | Ruby | Rabenmund/simple_app | /app/models/player.rb | UTF-8 | 3,106 | 2.625 | 3 | [] | no_license | class Player < ActiveRecord::Base
has_one :profession, as: :professionable
has_one :human, through: :profession
has_many :contracts, through: :human
has_many :organizations, through: :contracts
has_many :teams,
through: :organizations,
source: "organizable",
source_type: "Team"
has_many :offers
... | true |
ea3cad34c73b7c39010cf757c4078c310bc1acf1 | Ruby | BLauris/car-importer | /db/seeds.rb | UTF-8 | 291 | 2.65625 | 3 | [] | no_license | manufacturers = ["Honda", "Ford", "Mazda", "Opel", "Peogeot", "Lada"]
puts "Started Seeding..."
30.times do
Car.create!(
manufacturer: manufacturers.sample,
price: rand(1000..100000),
used: [true, false].sample,
note: Faker::Lorem.sentence
)
end
puts "Seed Finished!"
| true |
c7628dc3255df1ccd4096b38dc456bebb8e3702c | Ruby | Escape-Games-by-Thought-Works/crypto-challenge | /ruby/lib/swap_round.rb | UTF-8 | 93 | 2.765625 | 3 | [] | no_license | class SwapRound
def run(blocks)
[blocks[0], blocks[2], blocks[1], blocks[3]]
end
end
| true |
34730041dd9d7be65985fb46207eee8cf1ed4a72 | Ruby | calorie/cluster-packer | /lib/cluster/lib/cluster/configure.rb | UTF-8 | 2,616 | 2.625 | 3 | [
"MIT"
] | permissive | require 'yaml'
require 'erb'
module Cluster
class Configure
attr_reader :config
CONFIG_FILE = 'config.yml'
KEY_FILE = 'insecure_key'
CHEF_REPO = 'chef-repo'
VAGRANT_FILE = 'Vagrantfile'
PACKER_NFS = 'packer-nfs.json'
PACKER_MPI = 'packer-mpi.json'
def initialize(producti... | true |
9b7845bbf48fa28699cb15121a42aad0ced42a7a | Ruby | Bropell/launch_school_exercises | /RB100_programming_and_back_end_prep/methods_exercises/exercise1.rb | UTF-8 | 258 | 4.15625 | 4 | [] | no_license | #Write a program that prints a greeting
#message. This program should contain
#a method called 'greeting' that takes
#a 'name' as its parameter and returns
#a string
def greeting(name)
"Hello, nice to meet you " + name + "."
end
puts greeting("Brandon")
| true |
ab1e4969ed1cf9b3255f58b54033c4dfc1587555 | Ruby | tzip25/oo-kickstarter-nyc-web-career-021819 | /lib/project.rb | UTF-8 | 334 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Project
require 'pry'
attr_reader :backers
attr_accessor :title
def initialize(title)
@title = title
@backers = []
end
def add_backer(backer)
@backers << backer
#add the projcet the project is self
#we want to push self onto backers backed_projects
backer.backed_projects << se... | true |
5e6e5fa0c40084a275a226cfef67c751ae42213f | Ruby | hanazuki/adventofcode | /src/2a.rb | UTF-8 | 129 | 2.890625 | 3 | [] | no_license | puts $<.each_line.map {|l|
l, w, h = l.chomp.split('x').map(&:to_i)
2*l*w + 2*w*h + 2*h*l + [l*w, w*h, h*l].min
}.inject(:+)
| true |
daa499ec00f1731b6db0a52a32cb0510847dfe00 | Ruby | fiosman/App-Academy | /alpha_curriculum/09_guessing_game_project/lib/play_guessing_game.rb | UTF-8 | 574 | 3.703125 | 4 | [] | no_license | # No need to change or write any code in this file.
#
# After you complete all specs, you can simulate your game by
# running this file with `ruby lib/play_guessing_game.rb` in your terminal!
require_relative "guessing_game"
print "Enter a min number: "
min = gets.chomp.to_i
print "Enter a max number: "
max = gets.c... | true |
657970c903a925872523e26a61f1a9697b515a1d | Ruby | wedesoft/linalg | /lib/linalg/dmatrix/main.rb | UTF-8 | 5,526 | 3.203125 | 3 | [
"MIT"
] | permissive | #
# Copyright (c) 2004-2008 by James M. Lawrence
#
# See LICENSE
#
module Linalg
class DMatrix
include Iterators
include XData # :nodoc:
include Linalg::Exception # :nodoc:
##################################################
#
# singleton methods
#
#############... | true |
2ceafb9eb4988aa18651eb57f7c14d2f9bc6fdab | Ruby | johnfig/DBC-Challenges | /Week_1/Day_2/enumerables.rb | UTF-8 | 1,122 | 4.53125 | 5 | [] | no_license | # Print the 1st, 3rd, 5th, 7th, etc. elements of a list on separate lines.
def print_odd_indexed_integers(array)
array2 = []
array.each_with_index do |item,index|
if (item %2 == 0)
array2.push(item)
end
end
array2
end
print print_odd_indexed_integers([1,2,3,4,5,6,7,8,9])
# Return the odd nu... | true |
6c59c1561216200e66362cf8d65f993701d4a4f8 | Ruby | rubygitflow/thinknetica_ruby | /seventh_lesson/library.rb | UTF-8 | 385 | 2.65625 | 3 | [] | no_license | module Library
Cargo = 1
Passenger = 2
TrainTypeDescription = {
cargo: {
name: 'Грузовой'
},
passenger: {
name: 'Пассажирский'
}
}
def show_train_type_list
puts menu_cargo
puts menu_passenger
end
private
def menu_cargo
"#{Cargo}. Cargo"
end
def menu_passe... | true |
75d1e98723e7dbd9c68058e17df37f262af1e56c | Ruby | sunny-mittal/project-euler | /ruby/pandigital_prime.rb | UTF-8 | 294 | 3.140625 | 3 | [
"MIT"
] | permissive | require 'prime'
def find_largest_pandigital_prime
start = [7, 6, 5, 4, 3, 2, 1] # largest permutation
start.permutation.each do |possibility|
possibility = possibility.join.to_i
if possibility.prime?
p possibility
break
end
end
end
find_largest_pandigital_prime
| true |
c178cac724334c89165367a21b973b39927641f2 | Ruby | Kphillycat/todos | /todo8/deli.rb | UTF-8 | 412 | 3.328125 | 3 | [] | no_license | class Deli
attr_accessor :line
def initialize
@line = []
end
def take_a_number(name)
#@line.length is 3 for some reason
@line << "#{@line.length+1}. #{name}"
# @line.each_with_index do |value, index|
# @line[index] = "#{index+1}. #{name}"
# end
end
def now_serving
num_regex = /\d+. /
name_n_n... | true |
bab807dcb5f29e9c5c508169a1eefca720a3781b | Ruby | jpace/pvn | /lib/pvn/pct/repository_differ.rb | UTF-8 | 2,108 | 2.671875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby -w
# -*- ruby -*-
require 'pvn/io/element'
require 'pvn/pct/differ'
require 'svnx/revision/range'
require 'rainbow'
module PVN::Pct
class RepositoryDiffer < Differ
def get_from_to_revisions rev
if rev.size == 1
if md = Regexp.new('(.+):(.+)').match(rev[0])
[ md[1], md[2] ... | true |
7ec34f55ed9523c6ae88efa0250e9f5559d7b1e6 | Ruby | MichaelConner/week2_day_1_homework_classes_and_objects | /sports_team/sports_team.rb | UTF-8 | 633 | 3.234375 | 3 | [] | no_license | class SportsTeam
attr_reader :team_name, :players
attr_accessor :coach, :points
def initialize(team_name, players, coach)
@team_name = team_name
@players = players
@coach = coach
@points = 0
end
# def get_team_name
# return @team_name
# end
#
# def get_players
# return @players
# end
#
# def get_coach
# retur... | true |
4432d3affa8b037b28416f2535234b27eb602479 | Ruby | ilyutov/balanced-ruby | /lib/balanced/resources/bank_account.rb | UTF-8 | 1,194 | 2.75 | 3 | [
"MIT"
] | permissive | module Balanced
# A BankAccount is both a source, and a destination of, funds. You may
# create Debits and Credits to and from, this funding source.
#
# *NOTE:* The BankAccount resource does not support creating a Hold.
#
class BankAccount
include Balanced::Resource
def initialize attributes = {}
... | true |
ddc7b972d61f26798d1cd29572243d887a65d8f8 | Ruby | pludlum/app_academy_projects | /w1d2/memory_puzzle/humanPlayer.rb | UTF-8 | 1,736 | 3.5625 | 4 | [] | no_license | class HumanPlayer
def prompt(board = nil)
puts "Guess a row! (between 1 and 4)"
row = gets.chomp.to_i # 1 - 4
puts "Guess a column! (between 1 and 4)"
col = gets.chomp.to_i # 1 - 4
# 0 - 15
(row - 1) * 4 + (col - 1)
end
def receive_revealed_card(something, thing)
end
end
class Comput... | true |
91c9d390b4bc1feaa43e6696c342e07b9c9c3794 | Ruby | risatronic/ruby-math-game | /question.rb | UTF-8 | 284 | 3.796875 | 4 | [] | no_license | class Question
attr_reader :answer
def initialize
@number1 = rand(1..20)
@number2 = rand(1..20)
@answer = @number1 + @number2
end
def ask_question
"What does #{@number1} + #{@number2} equal?"
end
def correct_answer?(input)
input == @answer
end
end | true |
546740874d2ed4ad8033a608850a9186700b57de | Ruby | dapawn/collections_practice-cb-000 | /collections_practice.rb | UTF-8 | 631 | 3.8125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(arr)
arr.sort
end
def sort_array_desc(arr)
arr.sort.reverse
end
def sort_array_char_count(arr)
arr.sort do |a, b|
if a.length == b.length
0
elsif a.length < b.length
-1
elsif a.length > b.length
1
end
end
end
def swap_elements(arr)
x = arr[1]
arr[1] = ... | true |
918f873d57ee980ac0625097de7fa2dbfd3c819e | Ruby | kmsheng/kkbox-hackathon-practice | /p3/p3.rb | UTF-8 | 1,457 | 3.84375 | 4 | [] | no_license | class Sudoku
def initialize(width)
@width = width
@sqrt_width = Math.sqrt(width).to_i
@order = (0..@sqrt_width - 1).to_a
@numbers = (1..@width).to_a.shuffle
make_first_template
make_board
end
def shift_order
element = @order.shift
@order.push(element)
end
def make_board
@board = []
for i... | true |
e6ecf1614f4eaa8a091c43b3e0202c2716d04e00 | Ruby | reckenrode/advent_2019 | /lib/advent_2019.rb | UTF-8 | 1,402 | 3.03125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# lib/advent_2019.rb
# Copyright © 2019 Randy Eckenrode
#
# This program is distributed under the terms of the MIT license. You should
# have received a copy of this license with this program. If you did not, you
# can find a copy of this license online at https://opensource.org/license... | true |
81564a7cfb90fcfa43ef9aa5aab78eaac304d35c | Ruby | bhabeshagrawal/myRecipes | /test/models/recipe_test.rb | UTF-8 | 1,533 | 2.59375 | 3 | [] | no_license | require "test_helper"
class RecipeTest < ActiveSupport::TestCase
def setup
@chef = Chef.new(chefname: "Bhabesh", email: "bhabesh@gmail.com")
@recipe = @chef.recipes.build(name:"panner",summary:"this is best recipe i ever ate",description:"hi hi isdhg gsd g gsdg gsd jhdgs gsgd jag dsjj jgsdj jadgjj jajdsg... | true |
fb79ac0817a23e44c97781926edb4bfd83d262bf | Ruby | irmercaldi/Coding-Exercises | /metaprogrammingex4.rb | UTF-8 | 369 | 2.75 | 3 | [] | no_license | class Author
genres = %w(fiction coding history)
genres.each do |genre|
define_method("#{genre}_details") do |arg|
puts "Genre: #{genre}"
puts arg
puts genre.object_id
end
end
end
author = Author.new
author.coding_details("Cal Newport")
author.fiction_details("Brandon Sanderson")
autho... | true |
4b5ddec5c531e9d9f808c689a92bf1f1bd1c6b7f | Ruby | carusocr/bcast | /mech/ytvore.rb | UTF-8 | 7,395 | 2.859375 | 3 | [] | no_license | #!/usr/bin/env ruby
=begin
Name: ytvore.rb
Date Created: 10 December 2013
Author: Chris Caruso
Script to crawl YouTube and search for videos matching keywords stored in a local database.
General process:
1. We generate a list of events and associated search terms and use this information to create a database table of ... | true |
26cdb6df8b076c9f97023cdc200cc39388ebd95c | Ruby | nafnarem/ruby_activity | /confection.rb | UTF-8 | 287 | 3.0625 | 3 | [] | no_license | class Confection
def prepare
puts "Baking at 350 degrees for 25 minutes."
end
end
class BananaCake < Confection
end
class Cupcake < Confection
def prepare
super
puts "Applying Frosting"
end
end
cake1 = BananaCake.new
cake2 = Cupcake.new
cake1.prepare
cake2.prepare | true |
1f8e20bde40764d79b84deac537e69c1ff14569a | Ruby | kagd/R2D2 | /app/services/base_service.rb | UTF-8 | 157 | 2.703125 | 3 | [] | no_license | class BaseService
private #-----------------------------------
def talk(str, color=:light_blue)
puts '/'*60
puts str.colorize(color)
end
end
| true |
902d0e44c508138e4607978addc8d45e9a125e92 | Ruby | blambeau/waw | /lib/waw/tools/mail/template.rb | UTF-8 | 1,185 | 2.546875 | 3 | [
"MIT"
] | permissive | module Waw
module Tools
class MailAgent
# Allows creating WLang templates for mails easily
class Template < Mail
# The wlang dialect
attr_writer :dialect
# Returns the wlang dialect to use
def dialect
return @dialect if @dialect
cas... | true |
00bfc1a240ba302db12057963e501106240c6fe2 | Ruby | hiukkanen/iban-tools | /lib/iban-tools/bic.rb | UTF-8 | 1,072 | 2.859375 | 3 | [
"MIT"
] | permissive | module IBANTools
module BIC
def bic
if country_bics_mapped?(self.country_code) and IBAN.valid?(self.code)
bic_map = bic_maps[self.country_code]
return find_bic bic_map, self.code
else
return nil
end
end
def bic_maps
{"FI" => {
"1" => "NDEAFIHH",
... | true |
42ee4306631d6c6fc30e3fdc69fc0016f9db7851 | Ruby | remind101/email-provider | /lib/email_provider/finder.rb | UTF-8 | 579 | 2.625 | 3 | [
"MIT"
] | permissive | module EmailProvider
class Finder
attr_reader :email
def self.find(*args)
new(*args).find
end
def initialize(email)
@email = email
end
def find
if from_regex?
from_regex
elsif from_mx?
from_mx
end
end
private
def from_regex
@fr... | true |
398cd2f66f2e0638e56ef1ffabdb49af87ad6b59 | Ruby | kax4/bin | /dmenu-app | UTF-8 | 2,898 | 3.296875 | 3 | [] | no_license | #!/usr/bin/ruby
# dmenu accepts a list of items, to which the user filters. The most common
# use of dmenu is to find all binaries in $PATH and select from one of those.
# This is useful if you know what the application's binary is called before hand
# but if the user does not know the binary name, but does know the a... | true |
2692c9bed2024263dfa2207174c126fc6d6dd8d0 | Ruby | DAOkiin/cryptotradingbot | /app/lib/app/parser/operations/construct_klines.rb | UTF-8 | 2,730 | 2.703125 | 3 | [] | no_license | require 'app/operation'
require 'parser/import'
require 'app/parser/entities/kline'
module App
module Parser
module Operations
# Construct App::Parser::Entities::Kline objects from array of hashes
# Need :source, :c1, :c2, interval
class ConstructKlines < App::Operation
def call(data)
... | true |
ee12cd5a10bc98361886df2ca701a3e693ac0ac4 | Ruby | JonathanLoscalzo/Taller-Ruby | /Practica1/ejercicio16.rb | UTF-8 | 952 | 4.5 | 4 | [] | no_license | #
# 16. a. Dado un color expresado como una combinación RGB calcular su representación entera.
# Consideramos que un color rgb se
# expresa como un hash con las claves [:red, :green, :blue],
# y para cada una toma valores en el rango (0..255). Por ejemplo:
#
# { red: 0, green: 0, blue: 255 } =>
#
# { red: 128, green: ... | true |
a1aea55e197da69f8f652e5e992d547b6ce51627 | Ruby | darrenyong/aaClasswork | /W2D4/Big O/anagrams.rb | UTF-8 | 995 | 4.15625 | 4 | [] | no_license | #anagrams
def first_anagram(string, target)
# time complexity O(n!)
combos = string.chars.permutation.to_a
combos.include?(target.chars)
end
def second_anagram(string, target)
# time complexity O(n)
chars = target.chars
string.each_char do |char|
idx = chars.index(char)
next if idx.nil?
cha... | true |
6505cacd84988de864b3bc4de6da3dc0928c711b | Ruby | angel41023/ruby-design-patterns | /Builder/dates.rb | UTF-8 | 164 | 3.09375 | 3 | [] | no_license | class Dates
attr_accessor :from, :to
def initialize(from, to)
@from = from
@to = to
end
def full_date
puts "De: #{from} - A: #{to}"
end
end
| true |
de2d7a66be022c2ff41a6d910ec5cf6bd4705509 | Ruby | xithan/WRCompanyMapping | /tfidf/idf/inverse_document_frequency.rb | UTF-8 | 1,725 | 3.671875 | 4 | [] | no_license | require_relative '../../DocumentUtils/corpus'
require_relative '../../DocumentUtils/text_document'
#InverseDocumentFrequency consists the basic implementation of inverse document frequency. It is the logarithmically
#scaled inverse fraction of the documents that contain the token, obtained by dividing the total numbe... | true |
f145b5d705ec6891bf71d97766197dbba9dadb1a | Ruby | simplebunsen/mindermast-ruby | /players.rb | UTF-8 | 1,708 | 3.65625 | 4 | [] | no_license | require './helper'
# All players, human or computer, inherit common functionality from here
class BasePlayer
def initialize(humanity)
@humanity = humanity
end
# implement rate, guess and make_code in the subclasses!!!
end
# Computer Player that plays algorithmically
class CPUPlayer < BasePlayer
def initia... | true |
baf4497d67af53507f2d9132b41ae537dd29e267 | Ruby | cirediatpl/pokemon-scraper-yale-web-yss-052719 | /lib/pokemon.rb | UTF-8 | 1,297 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Pokemon
attr_accessor :id, :name, :type, :db
def initialize(name:, type:, db:, id:nil)
@id = id
@name = name
@type = type
@db = db
end
# def self.create(name:, type:)
# pokemon = Pokemon.new(name, type, db)
# pokemon.save
# pokemon
# e... | true |
227808e06d977bc51ddc6e56b15b95e53c607fac | Ruby | rcrichton87/project_1_xwing_squad_builder | /models/squad.rb | UTF-8 | 1,384 | 3.3125 | 3 | [] | no_license | require_relative('../db/sql_runner.rb')
require_relative('./piloted_ship.rb')
class Squad
attr_reader :id
attr_accessor :name, :faction
def initialize(options)
@id = options['id'].to_i
@name = options['name']
@faction = options['faction']
end
def save
sql = "INSERT INTO squads (name, facti... | true |
83218fecd7099fea128552d65a2682d5f7ead631 | Ruby | fl00r/monga | /lib/monga/database.rb | UTF-8 | 8,757 | 3.015625 | 3 | [
"MIT"
] | permissive | module Monga
class Database
attr_reader :client, :name
def initialize(client, name)
@client = client
@name = name
end
# Choose collection to work
#
# client = Monga:::Client.new
# db = client.get_db("dbTest")
# collection = db.get_collection("testCollection")
# ... | true |
a899c6f71c04cc4828912a5d7e2db8086965524f | Ruby | rhythm29/Bootcamp-Geometry | /lib/geometry/polygon.rb | UTF-8 | 164 | 3 | 3 | [
"MIT"
] | permissive | class Geometry::Polygon
def initialize(polygon)
@polygon = polygon
end
def perimeter
sum = 0
@polygon.each { |a| sum+=a }
return sum
end
end | true |
4461215d1bdaf97625e68572ff8c4485ae73aa1e | Ruby | h4hany/hackerrank-solution | /Service-Lane.rb | UTF-8 | 193 | 2.65625 | 3 | [] | no_license | # https://www.hackerrank.com/challenges/service-lane
(n, t) = gets.split.map{|i| i.to_i}
a = gets.split.map{|i| i.to_i}
t.times do
(i, j) = gets.split.map{|k| k.to_i}
puts a[i..j].min
end
| true |
5efceea8d91a48fa5d703f7ef253c0ad443de69a | Ruby | anthonyringoet/7-languages | /ruby/guess.rb | UTF-8 | 222 | 3.578125 | 4 | [] | no_license | $num = rand(10)
def ask
input = gets.to_i
eval(input)
end
def eval(input)
if input == $num
puts "Correct!"
return
end
if input < $num
puts "Too low"
else
puts "Too high"
end
ask
end
ask | true |
bca9f4426f54b9f33078e3bc90d172dd0908f097 | Ruby | InfinityG/myvinos-integration-api | /api/utils/rate_util.rb | UTF-8 | 366 | 2.59375 | 3 | [] | no_license | require './api/services/config_service'
module RateUtil
def self.convert_fiat_to_vin(fiat)
config = ConfigurationService.new.get_config
rate = config[:exchange_rate]
return fiat * rate
end
def self.convert_vin_to_fiat(vin)
config = ConfigurationService.new.get_config
rate = config[:exchang... | true |
8fe533f66d3b515927548a7e8e3d3e74ec4cc9a9 | Ruby | snex/spiralizer | /spec/spiralizer/mover_spec.rb | UTF-8 | 1,183 | 2.90625 | 3 | [] | no_license | # frozen_string_literal: true
require 'spec_helper'
require_relative '../../lib/spiralizer/mover'
RSpec.describe Spiralizer::Mover do
subject { described_class.new(input) }
describe '#cursor_element' do
let(:input) { [%w[A B C], %w[D E F]] }
it 'is the element at the cursor' do
expect(subject.curs... | true |
094923583612c12ec133b3d8369c9f057ddfe043 | Ruby | cardmagic/dm-works | /lib/data_mapper/support/typed_set.rb | UTF-8 | 1,302 | 3.1875 | 3 | [
"MIT"
] | permissive | require 'set'
module DataMapper
module Support
class TypedSet
include ::Enumerable
def initialize(*types)
@types = types
@set = Array.new
end
def <<(item)
raise ArgumentError.new("#{item.inspect} must be a kind of: #{@types.inspect}") unless @t... | true |
d7ce41cf2d92531f88ccaf4f882bc09f4e7dd89d | Ruby | noisecape/Learn-Ruby-The-Hard-Way | /revenue.rb | UTF-8 | 164 | 3.375 | 3 | [] | no_license | puts "Please give me some money, I'll give you back 10""%"" of it"
money = gets.chomp.to_f
revenue = (money * 10)/100
puts "Thank you, here's your part: #{revenue}" | true |
c891db1352ca84c1dcce9dcc75f57c7526462480 | Ruby | flori/mize | /lib/mize/cache_methods.rb | UTF-8 | 1,408 | 2.625 | 3 | [
"MIT"
] | permissive | require 'mize/cache_protocol'
require 'mize/default_cache'
module Mize::CacheMethods
# Clear cached values for all methods/functions of this object.
def mize_cache_clear
__mize_cache__.clear
self
end
# Clear all cached results for the method/function +name+.
def mize_cache_clear_name(name)
name ... | true |
08f531e06748fb0ce750aaa3fa0833adf02a1093 | Ruby | pla1207/opal | /spec/opal/core/numeric/downto_spec.rb | UTF-8 | 495 | 3.109375 | 3 | [
"MIT"
] | permissive | describe "Numeric#downto [stop] when self and stop are Fixnums" do
it "does not yield when stop is greater than self" do
result = []
5.downto(6) { |x| result << x }
result.should == []
end
it "yields once when stop equals self" do
result = []
5.downto(5) { |x| result << x }
result.should ... | true |
b07f69331234f292cbe935ac36b91cba8be132b1 | Ruby | MargaretLangley/letting | /lib/tasks/import/import_properties.rake | UTF-8 | 1,023 | 2.640625 | 3 | [] | no_license | require 'csv'
require_relative '../../csv/csv_transform'
require_relative '../../import/file_header'
require_relative '../../import/import_property'
STDOUT.sync = true
#
# import_properties.rake
#
# Imports csv document and generates property objects.
#
# CSV files are converted into an 2D array indexed by row number... | true |
47eafd921e1523bfdf11d840476900bfd16622a5 | Ruby | MasatoraAtarashi/Programming-Competition | /AOJ/ALDS1/tree/BinaryTree.rb | UTF-8 | 1,628 | 3.515625 | 4 | [] | no_license | class Node
attr_accessor :id, :parent, :left, :right, :sibling, :degree, :height
def initialize()
@parent = -1
@sibling = -1
end
def set_info(id, left, right)
@id = id
@left = left
@right = right
@degree = [@left, @right].select {|c| c != -1}.count
end
def set_parent(parent_id)
... | true |
835b7538e09e8e3ff7a46da8b683c4ed7645e334 | Ruby | adparadise/rubylife | /board_spec.rb | UTF-8 | 893 | 3.203125 | 3 | [] | no_license | require 'rspec'
require_relative 'board'
require_relative 'cell'
describe Board do
let(:board) { Board.new }
it "should be able to get the cell at a location" do
cell = Cell.new 1, 1
board.add_cell cell
expect(board.get_cell_at(1, 1)).to eql(cell)
end
it "should be able to add a cell" do
... | true |
9cc4b77f7db4b5bbb617c05479401f02bde3acb1 | Ruby | nvnogomes/peuler | /179.rb | UTF-8 | 1,124 | 3.8125 | 4 | [] | no_license | require "mathn"
# Consecutive positive divisors
class Euler179
@limit
@array
@div_previous
def initialize(max=10000000)
@limit = max
@div_previous = 0
@array = Array.new
end
def solve_interval(ulimit,slimit)
counter = 0
ulimit.upto(slimit) do |x|
counter += consecutive_test(x,x.succ)
p... | true |
e678042f90b7f7a6d817e7f853cbb955307403a7 | Ruby | causes/spacecats | /lib/fixnum_ext.rb | UTF-8 | 171 | 2.859375 | 3 | [] | no_license | class Fixnum
def prime?
return false if self < 2
2.upto(Math.sqrt(self).to_i) do |div|
return false if self % div == 0
end
return true
end
end
| true |
ca0445dc8975bb3c6429afc057e352ce521c1a47 | Ruby | DesterStorm/oo-meowing-cat-online-web-ft-071519 | /lib/meowing_cat.rb | UTF-8 | 205 | 3.75 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Cat
def name=(name)
@name = name
end
def name
@name
end
attr_accessor :meow
def meow
@meow
puts"meow!"
end
end
maru = Cat.new
maru.name = "Maru"
maru.meow | true |
8a76e0189b261b1e33ec56b2ea0eacf188163d1f | Ruby | avalonmediasystem/avalon | /app/models/avalon_annotation.rb | UTF-8 | 2,929 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | # Copyright 2011-2023, The Trustees of Indiana University and Northwestern
# University. Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
#
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# ... | true |
299eb39edd96dfdf82af89a72f997ec8471da03a | Ruby | faliev/stacked | /spec/support/matchers/within.rb | UTF-8 | 473 | 2.75 | 3 | [
"MIT"
] | permissive | module RSpec
module Matchers
class Within #:nodoc:
def initialize(receiver=nil, &block)
@receiver = receiver
# Placeholder
end
def matches?(time)
time = Time.at(time) if time.is_a?(Numeric)
@receiver.ago < time
end
def failure_message
"Expect... | true |
735063834db22213015a97559ee74af2eb82c7cc | Ruby | frograms/coolsms-rb | /test/test_send.rb | UTF-8 | 1,476 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'test_helper'
require 'minitest/autorun'
module Coolsms
class TestSend < Minitest::Test
def test_single
skip('캐시가 차감되서 막아놓음')
msg = Coolsms::Message.new
msg.text = '안녕, 세계 ㅎㅎ'
result = msg.send(COOLSMS_TEST_RECEIVERS.first)
assert_equal 1, result.body['success_count']
... | true |
581f5255b4d95a441a3f36fdb15e762f8cf865ba | Ruby | buildwithaura/aura | /lib/aura/tasks/common.rb | UTF-8 | 379 | 2.53125 | 3 | [
"MIT"
] | permissive | class RakeStatus
def self.heading(what, status)
if what == :run
color = 30
puts "\033[1;#{color}m$ %s \033[0m" % [status]
return
end
puts "* %s" % [status]
end
def self.print(what, status)
color = 32
color = 31 if what == :error
what = "" if what == :info
puts "\03... | true |
561f1fc5d3a2f1b7660d5e765093d1fb66228e85 | Ruby | JosephBianchi/emotions | /exc1.rb | UTF-8 | 643 | 3.921875 | 4 | [] | no_license |
class Person
def initialize(name)
@name = name
@emotions = {
sad: rand(1..3),
happy: rand(1..3),
angry: rand(1..3),
fear: rand(1..3),
joy: rand(1..3),
disgust: rand(1..3)
}
end
# test initialize method
def level(num)
if num == 1
return "low"
elsif n... | true |
5c97a1a7f6e05f1f191d3e5e09814856f57242c0 | Ruby | mhickman84/redex | /lib/redex/document_type.rb | UTF-8 | 922 | 2.96875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Redex
# Type of document to be parsed
class DocumentType
include Helper::ActsAsParent
include Helper::ActsAsType
# Unique name of the type of document containing the content to be extracted (letter, resume, etc).
attr_reader :name
# Path where this type of document is stored
attr_accesso... | true |
435c35dd53d5705d0bf0fe2c8d7b4f660ed07deb | Ruby | mfirmanakbar/hacker-rank | /06.rb | UTF-8 | 548 | 3.328125 | 3 | [] | no_license |
require 'json'
require 'stringio'
def compareTriplets(a, b)
result = []
alice = 0
bob = 0
for i in (0..2) do
if a[i] > b[i]
alice = alice + 1
elsif a[i] < b[i]
bob = bob + 1
end
end
result.push(alice)
result.push(bob)
return result
end
# fptr = File.open(ENV['OUTPUT_PATH'],... | true |
4d4dcd02211b9f9addcf1942eb09c8db23529fd4 | Ruby | DanielleSucher/Greenland | /spec/input_faker.rb | UTF-8 | 359 | 2.953125 | 3 | [] | no_license | # for testing, via http://vcp.lithium3141.com/2011/04/advanced-rspec/
class InputFaker
def initialize(strings)
@strings = strings
end
def gets
next_string = @strings.shift
next_string
end
def self.with_fake_input(strings)
$stdin = new(strings)
yield
en... | true |
58563b2101378063df7e6494687e85e1674c08e4 | Ruby | Lithnotep/war_or_peace | /test/turn_test.rb | UTF-8 | 11,665 | 3.03125 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/player'
require './lib/deck'
require './lib/card'
require './lib/turn'
require 'pry'
class TurnTest < Minitest::Test
def test_it_exists
card1 = Card.new(:heart, 'Jack', 11)
card2 = Card.new(:heart, '10', 10)
card3 = Card.new(:heart, '9',... | true |
cee35bef0abb4d85e1fd51b9e16bd6098a1c50c5 | Ruby | ravichandran1/text | /arrayprocessor.rb | UTF-8 | 618 | 3.34375 | 3 | [] | no_license | class ArrayProcessor
attr_reader :array
def initialize
@array = [20, 4, 2, 40]
end
def add_total
array.inject(:+)
end
def acending_order
array.sort
end
def descending_order
array.sort.reverse
end
def minimum_value
array.min
end
def maximum_value
array.max
en... | true |
00610154124989a06498d980b32cf09cdabc10fc | Ruby | tkameyamax/bonus-drink | /triangle.rb | UTF-8 | 1,071 | 4.46875 | 4 | [] | no_license | # コマンドライン引数
x = ARGV[0].to_i
y = ARGV[1].to_i
z = ARGV[2].to_i
class Triangle
# 三角形である |x - y| < z && z < x + y
# 正三角形判定 x == y && y == z (三辺が同じ値である)
# 二頭編三角形判定 x == y || y == z || z == y (二辺が同じ値である、三辺が同じ値である場合は正三角形であるが先に正三角形の判定をすることで条件からはずす)
# 不等辺三角形 x !=y && y != z && z != x (三辺が同じ値ではない)
# 三角形の判定をまずする f... | true |
2b6036d4febd485324d5a2e3050172ae3fe8233f | Ruby | nyc-rock-doves-2016/linear_vs_binary_search | /binary_search.rb | UTF-8 | 493 | 3.296875 | 3 | [] | no_license | def find(target, dataset)
## Base case: We find the target in the dataset
midpoint = dataset.length / 2
comparitor = dataset[midpoint]
return false if comparitor.nil?
if target == comparitor
true
elsif target > comparitor
## We are too big - take the right side of the array
find(target, dataset... | true |
d4701ab10d92da04c79197d44c089224bb58e94e | Ruby | igaiga/ruby266_refactoring | /be_dry2/bad.rb | UTF-8 | 373 | 2.9375 | 3 | [] | no_license | class Book
attr_accessor :author
end
class Circle
attr_accessor :radius # radius: 半径
end
def set_book_author_and_circle_radius(book, circle)
book.author = "matz"
circle.radius = 3
end
book = Book.new
circle = Circle.new
set_book_author_and_circle_radius(book, circle)
# ...
book = Book.new
circle = Circle.new... | true |
47e5a1a5cf4be25a7ea33c42b1582aa13c1b4c8e | Ruby | calamitas/savon | /lib/savon/core_ext/string.rb | UTF-8 | 1,313 | 2.8125 | 3 | [
"MIT"
] | permissive | require "savon/soap"
module Savon
module CoreExt
module String
# Returns the String in snake_case.
def snakecase
str = dup
str.gsub! /::/, '/'
str.gsub! /([A-Z]+)([A-Z][a-z])/, '\1_\2'
str.gsub! /([a-z\d])([A-Z])/, '\1_\2'
str.tr! ".", "_"
str.tr! "-",... | true |
7fbcc51bd5c6453ee464f0df4f2678a079cb3489 | Ruby | mjording/prime_8 | /lib/prime_8/strategies/atkin_sieve_strategy.rb | UTF-8 | 2,717 | 3.390625 | 3 | [] | no_license | require_relative 'strategy'
module Prime8::Strategies
class AtkinSieveStrategy < Strategy
def initialize
@first_set = %w(1 13 17 29 37 41 49 53).map(&:to_i)
@second_set = %w(7 19 31 43).map(&:to_i)
@third_set = %w(11 23 47 59).map(&:to_i)
super
end
def compute_primes
max_... | true |
2d3da7d766c592a9651ff9065b3b6522ef52ea6f | Ruby | Daatwood/chesscli | /lib/chess/pieces/knight.rb | UTF-8 | 283 | 2.703125 | 3 | [] | no_license | # frozen_string_literal: true
module Chess
# Can move to positions based on an L-shape
class Knight < Piece
def movement_set
{ offset: [
[-1, 2], [1, 2],
[-2, 1], [2, 1],
[-2, -1], [2, -1],
[-1, -2], [1, -2]
] }
end
end
end
| true |
ecc710877bd69999b47d11711b7facbe9b5f47d7 | Ruby | ashitani0803/atcoder | /a_question/round_up_the_mean.rb | UTF-8 | 122 | 3.34375 | 3 | [] | no_license | a, b = gets.strip.split.map(&:to_i)
# x = (a + b) / 2.to_f
# puts x % 1 == 0 ? x.to_i : x.to_i + 1
puts (a + b + 1) / 2 | true |
4bcc27b91bb7f7f074f6208c2728a3f27e69ef3d | Ruby | JCFlores93/devops-eduonix | /scripting/ruby/ruby_essentials.rb | UTF-8 | 1,061 | 3.546875 | 4 | [] | no_license | #!/usr/bin/ruby
puts "Hello world!"
print "Hello world\n"
myname = "Jean"
puts "My name is #{myname}"
printf "My name is %s\n", myname
printf "We are learning %d languages \n", 3
# puts %q{Her pet's name is Kenzy and she loves "Drawing"}
# usernames = ['jdoe', 'peter', 'mary', 'bob']
# Hash
# usernames = {
# "na... | true |
d302bdcbcaf68a62d7d5019af90d9c0dea437b0b | Ruby | jacob-hudson/ProjectEuler | /ruby/33-digit-cancelling.rb | UTF-8 | 591 | 3.25 | 3 | [] | no_license | #!/usr/bin/env ruby
numerator_product, denominator_product = 1, 1
(10..98).each do |n|
(n+1..99).each do |d|
next if n % 10 == 0 && d & 10 == 0
if (n.to_s[0] == d.to_s[1] && n.to_s[1] < d.to_s[0])
fraction_as_float = Float(n.to_s[1]) / Float(d.to_s[0])
elsif (n.to_s[1] == d.to_s[0] && n.to_s[0] < ... | true |
bde787666926a65a4d026509ec25abe4aed607cb | Ruby | Volsunga-Saga1260/bookers3 | /ruby/hello.rb | UTF-8 | 108 | 3.484375 | 3 | [] | no_license | for i in 1..20000
if i % 3 == 0 || i.to_s.include?("3")
puts "Chanmei!"
else
puts i
end
end | true |
b25ca682c7a25123e7dbdde2778a4ef305e0ede1 | Ruby | GCHwee/The_Well_Grounded_Rubyist | /ruby_dynamics/callable_and_runnable_objects/determinations.rb | UTF-8 | 478 | 3.359375 | 3 | [] | no_license | puts
p 'Proc objects are self-contained code sequences that you can create, store, pass around as
method arguments, and, when you wish, execute with the call method. Lambdas are similar to Proc
objects. Truth be told, a lambda is a Proc object, but one with slightly special internal engineering.
The differences will... | true |
8260468e99e87ad9822fba7c0eac1db96b7a5b19 | Ruby | deshpandirolf/funnytube | /funnytube.rb | UTF-8 | 1,464 | 2.625 | 3 | [] | no_license | require "rubygems"
require "bundler/setup"
require 'youtube_g'
require 'mongo'
require 'sinatra'
include Mongo
class FunnyTube
class << self
def coll
@@coll ||= Connection.new.db('funnytube').collection('videos')
end
def youtube
@@youtube ||= YouTubeG::Client.new
end
def update_sc... | true |
34e1f97b64ad5eb48c5b193b98d048045a436789 | Ruby | isabella232/index-content-in-guide-action | /lib/record_list.rb | UTF-8 | 853 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | class RecordList
include Enumerable
def initialize(api:, logger:)
@api = api
@logger = logger
end
def each(&block)
cursor = nil
while true
@logger.debug "Fetching records starting at cursor #{cursor}"
response = @api.list_records(cursor: cursor)
response
.fetch("rec... | true |
1d5c17ded169112190aa7cd37c0a53bf24de751e | Ruby | achiu8/team_violet | /source/model.rb | UTF-8 | 721 | 3.34375 | 3 | [] | no_license | class Card
attr_reader :definition, :answer
attr_accessor :attempts
def initialize(args)
@definition = args[:definition]
@answer = args[:answer]
@attempts = 0
end
end
module Model
def self.save_cards(file_path)
# returns an array of values from file [definition1, answer1, definition, answer2... | true |
d6da1353becfbd4bf0030f7f6e46984d2dd53d9d | Ruby | ElectronVector/greatest-fff | /rakefile.rb | UTF-8 | 5,177 | 2.71875 | 3 | [
"MIT"
] | permissive |
load 'test_runner.rb'
CONFIG = {
:test_dir => "test",
:source_dir => "src",
:build_dir => "build",
# Use .exe for running on windows/Cygwin, use an empty string for Linux.
:test_binary_extension => ".exe",
}
# Set this to true to echo the commands to stdou... | true |
cc6020eef7145af28de61424bf6db0ea220e9e4e | Ruby | EmC14/5calculatorprgm | /sales tax.rb | UTF-8 | 123 | 2.984375 | 3 | [] | no_license | puts "Subtotal?"
a = gets.to_f
puts "tax/intrest rate?"
b = gets.to_f
total = a*b + a
puts "Total amount in $"
puts total
| true |
38cf29356947e30911dd850bd7efafb5674aa285 | Ruby | dgsuarez/similatron | /lib/similatron/pdf_comparison_engine.rb | UTF-8 | 1,040 | 2.5625 | 3 | [
"MIT"
] | permissive | module Similatron
class PdfComparisonEngine < ComparisonEngine
def can_handle_mime?(mime_type)
mime_type =~ %r{application/pdf}
end
def compare(expected:, actual:)
jpg_comparison = jpg_compare(expected: expected, actual: actual)
Comparison.new(
expected: expected,
actu... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.