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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
6b318b685d7c25165881ed6ecb3f880a4be65240 | Ruby | para-cms/para | /lib/para/search/distinct.rb | UTF-8 | 3,032 | 2.671875 | 3 | [
"MIT"
] | permissive | # This class allows to unify search results and avoid duplicates, avoiding
# SQL DISTINCT errors by adding ORDER BY fields to the DISTINCT selection
# automatically
#
# This fixes a previous issue when trying to order search results with
# Ransack sorting feature, when implying associated models
#
module Para
module ... | true |
10e5effa0c90e17481eaa2f2c968e901871340a1 | Ruby | philmccarthy/futbol | /lib/game_teams.rb | UTF-8 | 752 | 3.078125 | 3 | [] | no_license | class GameTeam
attr_reader :game_id,
:team_id,
:hoa,
:result,
:head_coach,
:goals,
:shots,
:tackles
def initialize(data)
@game_id = data[:game_id].to_i
@team_id = data[:team_id]
@hoa = data[:hoa]
@resu... | true |
5904592880558bd92f8b24fa08523bcf583998ea | Ruby | gshaw/common_validators | /app/validators/slug_format_validator.rb | UTF-8 | 576 | 2.84375 | 3 | [
"MIT"
] | permissive | # Validate fields to be slugs
#
# A slug must only contain lowercase a-z, digits 0-9 or dashes -
#
# A blank slug is considered valid (use presence validator to check for that)
#
# Examples
# validates :slug, slug_format: true # optional
# validates :slug, slug_format: true, presence: true # require... | true |
246f4c4313e70d74e86198594e0f247c749abbb0 | Ruby | sooo-s/AtCoder | /abc026/c/main.rb | UTF-8 | 361 | 3.203125 | 3 | [] | no_license | n = gets.to_i
$soshiki = Array.new(n){ [] }
(n-1).times do |i|
boss = gets.to_i
$soshiki[boss - 1].push i+1
end
def dfs(buka)
chokuzoku = $soshiki[buka]
return 1 if chokuzoku.length == 0
return dfs(chokuzoku[0]) * 2 + 1 if chokuzoku.length == 1
buka_kyuyo = chokuzoku.map{|c| dfs(c)}
return buka_kyuyo.m... | true |
9e71f08e947efcdeb70e677a350cb9380b2075dd | Ruby | TupoBanKai/lessons | /HomeWork2/alphabet.rb | UTF-8 | 202 | 3.359375 | 3 | [] | no_license | alphabet = 'a b c d e f g h i j k l m n o p q r s t u v w x y z'.split(' ')
vowls = 'a e i o u y'.split(' ')
hash = {}
vowls.each do |value|
hash[value] = alphabet.find_index(value) + 1
end
print hash | true |
31fa778f3398ffca4b007d6a86afea0a5f4b493a | Ruby | aeperea/exercism | /ruby/binary/binary.rb | UTF-8 | 329 | 3.171875 | 3 | [] | no_license | class Binary
def initialize(num_bin)
raise ArgumentError if (num_bin =~ /^(1|0)+$/).nil?
@num_bin = num_bin
end
def to_decimal
@num_bin.reverse.chars.map.with_index do |char, i|
if char == "1"
2**i
else
0
end
end.reduce(:+)
end
end
module BookKeeping
VERSION... | true |
01fb43e5223b2b6ed1149474bc9232f29bad7384 | Ruby | mjdele/ttt-6-position-taken-rb-q-000 | /lib/position_taken.rb | UTF-8 | 240 | 3.265625 | 3 | [] | no_license | board = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
def position_taken?(board, position)
if board [position] == " "
false
elsif board [position] == ""
false
elsif board [position] == nil
false
else
true
end
end | true |
ed53ea102b640939754342e97d32abba9c00ecb3 | Ruby | patrickwilliams14/ReachMe | /app/models/contact.rb | UTF-8 | 576 | 2.640625 | 3 | [] | no_license | class Contact < ActiveRecord::Base
# Contact form validations
validates :name, presence: true
validates :email, presence: true
validates :comments, presence: true
end
# Taking data from input form fields and saving it to the database
# Any time you are saving something to a database
# in this case it is contac... | true |
f68981e48d8f5ec3017879771007ccf79f028a26 | Ruby | blnkt/RUBY-choose-your-own-adventure-game | /cyoa.rb | UTF-8 | 2,041 | 3.515625 | 4 | [] | no_license | require './lib/chapter'
require './lib/adventure'
require './lib/adventurer'
def welcome
puts "Welcome to the adventure.\n\nWhat's your name?"
name = gets.chomp
user_adventure = Adventure.new({name: name})
prologue = Chapter.new({id: "0", prompt: "#{name}'s Adventure", :episode => "You awake in a field. You're... | true |
1be33ffa323cf8c41af7ed5ade99ffb295953a14 | Ruby | roschaefer/rasp | /lib/asp/memory.rb | UTF-8 | 431 | 2.734375 | 3 | [
"MIT"
] | permissive | module Asp
class Memory
def initialize
@element_classes = [] # array of classes that include Asp::Element
end
@@instance = Memory.new
def remember(aclass)
@element_classes << aclass
end
def well_known_classes
@element_classes
end
def forget!
@element_classes... | true |
2504979963fc4d4427f7ddd99eef7c0067e50a38 | Ruby | danstutzman/objective-personality-video-clips | /data/split.rb | UTF-8 | 1,431 | 2.84375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'pp'
require 'csv'
label2clips = {}
filename = 'Objective Personality_ YouTube clips - Sheet1.tsv'
File.open(filename).each_line do |line|
next if line.start_with?('Class')
clip = line.strip.split("\t")
labels = (clip[9] || '').split(', ')
labels.each do |label|
label2clips[l... | true |
9d8452acdd7530dd5a18236d89976c1dcfe52370 | Ruby | JamieSK/cinema_homework | /models/screening.rb | UTF-8 | 992 | 2.859375 | 3 | [] | no_license | require_relative '../db/sql'
class Screening
attr_accessor :film_id, :showtime, :capacity
attr_reader :id
def initialize(options)
@id = options['id'].to_i if options['id']
@film_id = options['film_id'].to_i
@showtime = options['showtime']
@capacity = options['capacity'].to_i
end
def save
... | true |
b40de7a69806ae0606faf5aaade4e76deb8c7f10 | Ruby | JakubowskiA/square_array-nyc-web-060319 | /square_array.rb | UTF-8 | 118 | 2.921875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
# your code here
squared = []
array.each do |num|
squared.push(num * num)
end
squared
end
| true |
16aa84caae48dd4253f592c548b0ef81d4ae9719 | Ruby | digitalbias/refactoring-practice | /movie/test/movie_test.rb | UTF-8 | 851 | 3.140625 | 3 | [] | no_license | require_relative '../../test_helper'
require_relative '../lib/movie'
class BottlesTest < Minitest::Test
MOVIE_DATA = [
["Jaws", Movie::REGULAR],
["Frozen", Movie::CHILDRENS],
["Spectre", Movie::NEW_RELEASE],
["Ghost Busters", Movie::REGULAR]
]
def test_output_rental_statement
movies = MO... | true |
970078c043c1ddd13333fbe84b22614fc2672daa | Ruby | vspy/dawg | /spec/builder_spec.rb | UTF-8 | 2,128 | 2.859375 | 3 | [] | no_license | require 'spec_helper'
require 'dawg'
describe Dawg::Builder do
it "should raise an error if words are fed in non-alphabetical order" do
b = Dawg::Builder.new
b.add_word 'dog'
lambda{b.add_word 'cat'}.should raise_error(Dawg::InvalidOrderError)
end
it "should raise an error when adding to closed bui... | true |
2e0bfe74d7c48f403d619ed082989fc8af1d64ac | Ruby | lorenzosinisi/rubydux | /lib/rubydux/store.rb | UTF-8 | 428 | 2.65625 | 3 | [
"MIT"
] | permissive | module Rubydux
class Store
attr_reader :state
INITIALIZE_RUBYDUX = 'INITIALIZE_RUBYDUX'.freeze
def initialize(initial_state = nil, &reducer)
@state = initial_state
@reducer = Rubydux::Reducer.new(reducer)
dispatch({
type: INITIALIZE_RUBYDUX
})
end
def dispat... | true |
d24ba21b6411587f278cb14f46e7fd15afc627c9 | Ruby | X0nic/kata_19 | /spec/lib/word_score_spec.rb | UTF-8 | 1,981 | 2.640625 | 3 | [] | no_license | require 'spec_helper'
describe WordScore do
subject { described_class.new(base_word: base_word, ending_word: ending_word, words: words) }
let(:ending_word) { 'bird' }
let(:words) { Link.new(left_word: base_word, ending_word: ending_word).all_matches }
context 'with cat' do
let(:base_word) { 'cat' }
... | true |
0f5b7609fef76abe20423bfc4e0697e0ef0c3507 | Ruby | snayrouz/reunion | /lib/activity.rb | UTF-8 | 257 | 3.265625 | 3 | [] | no_license | class Activity
attr_reader :name, :participants
def initialize(name)
@name = name
@participants = {}
end
def add_participant(person, amount)
@participants[person] = amount
end
def total_cost
add_participant[:value]
end
end
| true |
2979bb11f00f023bc04a6391b4d4be9247496995 | Ruby | mishin-anton/Lessons_tk | /Lesson_1/ideal_weight.rb | UTF-8 | 858 | 3.53125 | 4 | [] | no_license | # ИДЕАЛЬНЫЙ ВЕС#
# Программа запрашивает у пользователя имя и рост и выводит идеальный вес по
# формуле (<рост> - 110) * 1.15, после чего выводит результат пользователю на
# экран с обращением по имени.
# Если идеальный вес отрицательный, то выводится строка "Ваш вес уже оптимальный"
ideal_weigth = 0
puts "Введите им... | true |
754f24d1bfccebe5f83cda904929b89454d1c204 | Ruby | toothrot/riot | /test/core/reports/basic_reporter_test.rb | UTF-8 | 2,030 | 3.0625 | 3 | [
"MIT"
] | permissive | require 'teststrap'
context "A reporter" do
setup do
Class.new(Riot::Reporter) do
def pass(d, message) "passed(#{d}, #{message.inspect})"; end
def fail(d, message, line, file) "failed(#{d}, #{message} on line #{line} in file #{file})"; end
def error(d, e) "errored(#{d}, #{e})"; end
def re... | true |
74f9aaf1005d4aad8f59b36b054c26b16b40dd9f | Ruby | CallumD/duplicate | /lib/duplicate_image_finder.rb | UTF-8 | 298 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | class DuplicateImageFinder
attr_accessor :file_sorter
def initialize(args)
self.file_sorter = FileSorter.new(file_path: args[:path])
end
def process
file_sorter.copy_to_temp
file_sorter.populate_duplicates
DuplicateImagesParser.parse(file_sorter.dup_file_path)
end
end
| true |
24bf3f9113ad7b49fb73c799674e9ec592db79eb | Ruby | devhut/rubycode | /snoozer.rb | UTF-8 | 1,155 | 4 | 4 | [] | no_license | # snooze class ************************************************************************************
class Snooze
$hours_asleep = 0 # global variable
def tired?
if $hours_asleep >= 7 then
#reset hours_asleep var to 0
$hours_asleep = 0
return false
else
$hours_asleep += 1
return true
end
end
... | true |
e451201efe0cf994056eb3865101f30b366fb24d | Ruby | nastylia/ror_beginner_exercises | /lesson2/5.rb | UTF-8 | 487 | 3.5625 | 4 | [] | no_license | months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
puts "Ввведите день:"
day = gets.chomp.to_i
puts "Введите месяц:"
month = gets.chomp.to_i
puts "Введите год:"
year = gets.chomp.to_i
# check year
if (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0)
months[1] += 1
end
result_days = day
while month ... | true |
44044d0bb108095c9fcaf71f27b2dfcc28401134 | Ruby | songzhou21/ruby | /sbxh/ip.rb | UTF-8 | 199 | 2.71875 | 3 | [] | no_license | ip = Hash.new(0)
ARGF.each do |line|
if /^\d+\.\d+\.\d+\.\d+/ =~ line
ip[$&] += 1
end
end
printf "%15s %s\n", "IP addr", "num"
ip.each do |ip, n|
printf "%15s %s\n", ip, n
end
| true |
f0340311e6f9d5b04ae53aa1abb4c78ffe203e6a | Ruby | krizo/katas | /katas/ruby/spec/kya6/spinning_words_spec.rb | UTF-8 | 535 | 2.53125 | 3 | [] | no_license | require './kyu6/spinning_words'
describe "Spin words" do
let(:test_inputs) do
[
{
input: 'Hey fellow warriors',
expected_output: 'Hey wollef sroirraw'
},
{
input: 'This is a test',
expected_output: 'This is a test'
},
{
input: 'This is another... | true |
5adfab17b55421751821198d0de3bf7afc3db54b | Ruby | rokumatsumoto/rspec-experiments | /matchers-included/spec/higher_order_matchers_spec.rb | UTF-8 | 669 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'uri'
RSpec::Matchers.define_negated_matcher :be_non_empty, :be_empty
RSpec.describe 'Higher Order Matchers' do
def evens_up_to(n = 0)
0.upto(n).select(&:odd?)
end
example 'define negated matcher' do
expect(evens_up_to).to be_non_empty.and all be_even
end
examp... | true |
7be7e54ae2a42fdfab629113715a767bd6e7ee25 | Ruby | isabella232/ruby-guild | /004-sidekiq-best-practices/no_keyword_arguments.rb | UTF-8 | 381 | 2.84375 | 3 | [] | no_license | require 'sidekiq'
class SomeWorker
include Sidekiq::Worker
def perform(id:, timestamp:)
# Do some work
end
end
# SomeWorker.perform_async id: 1, timestamp: Time.now.to_i
# => wrong number of arguments (given 1, expected 0; required keywords: id, timestamp) (ArgumentError)
# We're not calling perform with ... | true |
2930c31952a795c346a10874319e597124347e3c | Ruby | justonemorecommit/puppet | /spec/unit/property_spec.rb | UTF-8 | 19,436 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | require 'spec_helper'
require 'puppet/property'
Puppet::Type.newtype(:property_test) do
newparam(:name, isnamevar: true)
end
Puppet::Type.type(:property_test).provide(:property_test) do
attr_accessor :foo
end
describe Puppet::Property do
let :resource do
Puppet::Type.type(:property_test).new(:name => "foo")... | true |
c448d0e8f4b2494cd75b29d3de68d4ec5ed9f3f7 | Ruby | tatey/conformist | /lib/conformist/hash_struct.rb | UTF-8 | 516 | 2.765625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Conformist
class HashStruct
extend Forwardable
attr_accessor :attributes
def_delegators :attributes, :[], :[]=, :fetch, :key?
def initialize attributes = {}
self.attributes = attributes
end
def == other
other.class == self.class && attributes == other.attributes
end
... | true |
fa01778f6128529f1a6c34a42b2e029dd70a5a46 | Ruby | krazerxz/pairstair | /app/services/card_persister.rb | UTF-8 | 656 | 2.703125 | 3 | [] | no_license | class CardPersister
def self.save collaberations
collaberations.each do |collaberation_hash|
next if card_exists_with_collaberators_and_unmodified? collaberation_hash
CollaberationPersister.new(collaberation_hash).persist
end
end
def self.card_exists_with_collaberators_and_unmodified? collabe... | true |
1b751c5da14bfb777c09b5fdc188c3619a73222f | Ruby | CPL2011/CPL2 | /testscript.rb | UTF-8 | 1,337 | 3.140625 | 3 | [] | no_license | require_relative 'adameus'
$adameus = Adameus.new
puts "\nadameus.version"
puts $adameus.version
puts "\nadameus.airlines"
puts $adameus.airlines
puts "\nadameus.airports"
puts $adameus.airports
puts "\nadameus.destinations(\"BRU\")"
puts $adameus.destinations("BRU")
puts "\nadameus.connections(\"VIE\", \"BRU\", ... | true |
463ced0196e29d3dcd551bda8f765901bffc06fd | Ruby | dharamsk/terraform-landscape | /lib/terraform_landscape/cli.rb | UTF-8 | 1,387 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | require 'commander'
module TerraformLandscape
# Command line application interface.
class CLI
include Commander::Methods
def initialize(output)
@output = output
end
# Parses the given command line arguments and executes appropriate logic
# based on those arguments.
#
# @param ar... | true |
208f0c2d74d9e7e8aaaff5f77f2b923d72774154 | Ruby | LiliFelsen/prime-ruby-web-051517 | /prime.rb | UTF-8 | 205 | 2.96875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Add code here!
def prime?(number)
if number <= 1
return false
end
i = 2
max = number-1
while i < max
if (number % i) == 0
return false
end
i +=1
end
return true
end
| true |
3ace3625809c0adf2ddfaa8ad87cc1f17d118e92 | Ruby | dr-skot/abc | /lib/abc/model/staff.rb | UTF-8 | 1,028 | 2.859375 | 3 | [
"MIT"
] | permissive | module ABC
class Staff
def self.list(list, options={})
list = list.flatten
if options[:type] == :braced
list.first.start_brace += 1
list.last.end_brace += 1
end
if options[:type] == :bracketed
list.first.start_bracket += 1
list.last.end_bracket += 1
e... | true |
101b0bd0a95e6b77fb0d7bf66cebaed93112d643 | Ruby | ManageIQ/manageiq-appliance-build | /scripts/kickstart_generator.rb | UTF-8 | 1,701 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | require 'erb'
require 'json'
require 'fileutils'
require 'pathname'
require_relative 'productization'
module Build
class KickstartGenerator
KS_DIR = "kickstarts"
KS_GEN_DIR = "#{KS_DIR}/generated"
KS_PART_DIR = "#{KS_DIR}/partials"
attr_reader :targets, :product_name, :puddle
def initial... | true |
919c3d1df6345ff76893355e185bb74358d5a6d4 | Ruby | TheBigLou/Learn-Ruby | /dict.rb | UTF-8 | 5,102 | 3.90625 | 4 | [] | no_license | module Dict
def Dict.new(num_buckets=256)
# Initializes a Dict with the given number of buckets, with 256 being the default.
aDict = [] # this creates the aDict variable that is an empty array
# now we fill the array with num_buckets number of empty arrays
(0...num_buckets).each do |i|
aDict.push([... | true |
030aa15fbe20bd81ee63610fbd18429c7e0b9b41 | Ruby | gunbux/ruby-bubble | /bubble.rb | UTF-8 | 677 | 3.921875 | 4 | [] | no_license | def bubble_sort(list)
for i in 0...list.length do
#puts "Currently at iteration #{i}"
list.each_with_index do |left,left_index|
#puts "Pointer currently at #{left}, index is #{left_index}"
right_index = left_index+1
right = list[right_index]
#puts "left is #{left} and right is #{right... | true |
d55b421762306e3bce0a9644177cfaee074093d8 | Ruby | Ada-C11/c11-sockets-library | /app/controllers/books_controller.rb | UTF-8 | 2,202 | 2.65625 | 3 | [] | no_license | class BooksController < ApplicationController
before_action :find_book, only: [:show, :edit, :update, :destroy]
skip_before_action :require_login, only: [:index]
def index
# Load a list of books from somewhere
if params[:author_id]
# @books = Book.where(author_id: params[:author_id])
# - or... | true |
3f81fe4ae783a84ad6c0f15be6899acf26b8dd19 | Ruby | ncbo/ontologies_api | /helpers/pagination_helper.rb | UTF-8 | 1,297 | 2.859375 | 3 | [
"BSD-2-Clause"
] | permissive | require 'sinatra/base'
module Sinatra
module Helpers
module PaginationHelper
MAX_PAGE_SIZE = 5_000
##
# Check the request params to get page and pagesize, both are returned
def page_params(params=nil)
params ||= @params
page = params["page"] || 1
size = params... | true |
d768d35135c9097541d7a312106746f5c06bf4b4 | Ruby | AttacatTim/lecture_2 | /wrestler_name.rb | UTF-8 | 225 | 3.578125 | 4 | [] | no_license | pet_text = "Hi. What was your first pet called"
street_text = "Cool. What was the name of the first street you lived on?"
puts pet_text
pet = gets.chomp
puts street_text
street = gets.chomp
puts pet + street
puts " Da Dah!"
| true |
ed8e6b5eb7f5fc45d23cffff05bf69ee2a497702 | Ruby | akashkapoor9/news | /app.rb | UTF-8 | 999 | 2.828125 | 3 | [] | no_license | require "sinatra"
require "sinatra/reloader"
require "geocoder"
require "forecast_io"
require "httparty"
def view(template); erb template.to_sym; end
before { puts "Parameters: #{params}" }
# enter your Dark Sky API key here
ForecastIO.api_key = "7674a916e740cae79dc3b348f2651d94"
... | true |
c2ceaf5af874d001ff9bdedf088b4057eb6d3927 | Ruby | JaMonty/array-CRUD-lab-online-web-prework | /lib/array_crud.rb | UTF-8 | 713 | 3.265625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def create_an_empty_array
[ ]
end
def create_an_array
colors = ["red","blue","orange", "yellow"]
end
def add_element_to_end_of_array(array, element)
do
array = ["red","blue","orange",'yellow']
element = "green"
do
array.push (green)
end
def add_element_to_start_of_array(array, ele... | true |
d39ddd0b21149953c745c5c8590dda30a839da1c | Ruby | JohnValanidas/Euler-Problems | /Problem 2/Problem 2 - ruby.rb | UTF-8 | 379 | 3.71875 | 4 | [] | no_license | =begin
Euler problem for the sum of even fibonacci numbers to 4 million
=end
def sum_even_fibonacci max
sum = 0
num1 = 1
num2 = 2
while (num1 < max and num2 < max)
if (num1 % 2 == 0)
sum = sum + num1
else if (num2 % 2 == 0)
sum = sum + num2
end
end
num1 = num1 + num2
num2 = nu... | true |
2b3a53e3757fb924ba30c6da206bafa28e236db3 | Ruby | verybamboo/ruby-oo-complex-objects-school-domain-nyc-web-033020 | /lib/school.rb | UTF-8 | 722 | 3.796875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # code here!
class School
attr_accessor :student, :roster
def initialize(student)
@student = student
@roster = {}
end
#or equals operator if grade array in roster array is nil?undefined? then make new empty array? not 100% on how this operator works
def add_student(name, grade)
... | true |
90fda788180f651844b788b585a615b504ff298b | Ruby | djeusette/codility | /StoneWall.rb | UTF-8 | 341 | 3.46875 | 3 | [] | no_license | def solution(h)
stack = []
blocks = 0
h.each do |height|
while stack.length != 0 && height < stack[-1] do
stack.pop
end
if stack.length != 0 && height == stack[-1]
# do nothing
else
stack.push height
blocks += 1
end
... | true |
27622ea3017e39fe452570a0efdc200847ef5a77 | Ruby | tash-tag/plant_shop | /spec/plant_shop_spec.rb | UTF-8 | 786 | 2.71875 | 3 | [] | no_license | require_relative '../plant_specks'
require_relative '../plant_shop'
require_relative '../plant_list'
# test of plant_print
describe 'plant_print' do
it 'should return the price of the item' do
name = "monstera deliciosa"
price = 55.00
plant_print = plant_print.new(name, price)
expect(plant_print.price).to eq(pr... | true |
fdb0c776da773982825dd0406cd16c141724e65c | Ruby | cvut/oauth2 | /lib/oauth2/strategy/base.rb | UTF-8 | 800 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module OAuth2
module Strategy
class Base
def initialize(client)
@client = client
end
# The OAuth client_id and client_secret
#
# @return [Hash]
def client_params
case @client.options[:auth_scheme]
when :request_body
{'client_id' => @client.id,... | true |
fdad50d0f3b8477d7f4008c703b1c5b05db53430 | Ruby | daimyo-college/ruby-super-intro-lesson | /OTA88/chapter3/3-5.rb | UTF-8 | 455 | 3.765625 | 4 | [] | no_license | #ゼロからわかるRuby超入門 -3章練習問題-
#3-5
# season = gets #春を入力=>"あんまんを買ってこう!"が返る。なぜ?
# puts season
# puts season.class
season = "春"
case season
# when season = "春" ※下記へと修正
when "春"
puts "アイスを買っていこう!"
# when season = "夏" ※下記へと修正
when "夏"
puts "かき氷を買ってこう!"
else
puts "あんまんを買ってこう!"
end
| true |
d481c8a9cda4e540cfe4211a494b2a82f773b676 | Ruby | dkubo/legalNLP | /MWE/src/parser/data.rb | UTF-8 | 2,446 | 2.765625 | 3 | [] | no_license | # coding: utf-8
require '../countoken/data'
# require 'json'
require 'csv'
# get sentences including mwes
def getids(toresult)
trainids = []
file = open(toresult, 'r')
file.each_line{|l|
trainids.push(l.split("\t")[0])
}
return trainids
end
def splitSentence(tocorp)
sent_hash, lasthash = Has... | true |
1091d564770b4e0e1b81dd5183258d5575eccde5 | Ruby | ricsrock/Revolution | /config/initializers/named_date_ranges.rb | UTF-8 | 5,642 | 3.296875 | 3 | [] | no_license | module NamedDateRanges
RANGES = ["Next 14 Days", "Today", "Last 24 Hours",
"This Week", "Last 7 Days", "Last Week",
"Last Two Weeks", "Last 14 Days",
"This Month", "Last Month", "Last 30 Days", "Last 4 Weeks", "Last 8 Weeks", "Last 12 Weeks",
"This QTR", "Last 13 Wee... | true |
2f784f07366411a87fd2e140935dc89ffb9e15ee | Ruby | opiskelija-dashboard/dashboard-api | /app/lib/mock_points_store.rb | UTF-8 | 6,382 | 2.625 | 3 | [] | no_license | # A mock PointsStore with fake data but no calls to external APIs
class MockPointsStore
require 'date'
# Format of raw_user_points elements:
# { 'exercise_id' => 33235,
# 'awarded_point' => {
# 'name' => '01-06',
# 'submission_id' => 1062559,
# 'course_id' => 214,
# 'id' => 1273255,
... | true |
4add5b50301bc4478fe8ff82e23cd548dfaa0f3d | Ruby | Samfox2/Quectel_BG96 | /Apple_Homekit/homekit_certification_tools/HomeKit Accessory Tester 5.1/HomeKit Accessory Tester 5.1/HomeKit Accessory Tester.app/Contents/Frameworks/HATKit.framework/Versions/A/Resources/event_generator.rb | UTF-8 | 3,559 | 2.65625 | 3 | [] | no_license | require 'yaml'
require 'erb'
event_yaml_files = Dir.glob(File.join(File.dirname(__FILE__), "..", "Events", "*.yml"))
EventClassHeaderTemplate = ERB.new <<-END
@interface <%= name %>: <%= info['parent'] || "HEEvent" %>
<% info['serialized_properties']&.each_pair do |property_name, attributes| %>
@property <%= attribu... | true |
fcee306b74629a13b0c9d489ce58db3ef0909dfb | Ruby | matthewtodd/en_fuego | /lib/en_fuego/distance.rb | UTF-8 | 270 | 2.9375 | 3 | [] | no_license | module EnFuego
class Distance
def initialize(attributes)
@value = attributes['value']
@units = attributes['units']
end
def to_s
if @value
"#{@value} #{@units}"
else
'an unknown distance'
end
end
end
end
| true |
ab070bbb33a8059ae10c3a7038090666aa527a7f | Ruby | milohuang/image_optim | /lib/image_optim/worker/gifsicle.rb | UTF-8 | 551 | 2.53125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'image_optim/worker'
class ImageOptim
class Worker
class Gifsicle < Worker
# Turn on interlacing (defaults to false)
attr_reader :interlace
def optimize(src, dst)
args = %W[-o #{dst} -O3 --no-comments --no-names --same-delay --same-loopcount --no-warnings -- #{src}]
arg... | true |
27c7e72f91ae88c087dc7620a1a153f02b5c0f84 | Ruby | kylehenson/sales_engine | /test/invoice_item_test.rb | UTF-8 | 2,381 | 2.640625 | 3 | [] | no_license | require 'CSV'
require './lib/invoice_item'
require 'minitest/autorun'
require 'minitest/pride'
class InvoiceItemTest < Minitest::Test
def test_it_exists
assert InvoiceItem
end
def test_find_id
invoice_items = CSV.open('./data/invoice_items.csv', headers: true, header_converters: :symbol)
one_invoi... | true |
edaa48efac7389554fb9cbcda545fdaebb8fadac | Ruby | grosser/organization_audit | /lib/organization_audit/repo.rb | UTF-8 | 4,861 | 2.625 | 3 | [
"MIT"
] | permissive | require "json"
require "base64"
require "net/http"
module OrganizationAudit
class Repo
HOST = "https://api.github.com"
class RequestError < StandardError
attr_reader :url, :code, :body
def initialize(message, url=nil, code=500, body='')
@url = url
@code = Integer(code)
@... | true |
5b09a77d62c61204085a6025148b77d4409531ac | Ruby | leoherrick/domino-mofo | /spec/match_spec.rb | UTF-8 | 2,058 | 2.6875 | 3 | [] | no_license | require "spec_helper"
module DominoMofo
describe Match do
before(:each) { @match = Match.new }
describe "number of houses" do
context "by default" do
it "should have 3 houses" do
@match.number_of_houses.should equal(3)
end
end
context "when passed '4' as op... | true |
5512412f43672ac028619627cef68daa574c4783 | Ruby | eliterry/my-collect-v-000 | /lib/my_collect.rb | UTF-8 | 116 | 3.484375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_collect(arr)
i = 0
new_arr = []
while i < arr.size
new_arr << yield(arr[i])
i +=1
end
new_arr
end
| true |
3c7dadc52a46910c5cfa11c81d15b33c830490f3 | Ruby | Fingertips/Roaund | /lib/roaund/token.rb | UTF-8 | 834 | 2.71875 | 3 | [] | no_license | class Roaund
class Token
attr_accessor :token, :secret, :client
def initialize(token=nil, secret=nil, client=nil)
@token, @secret, @client = token, secret, client
end
def load(input)
params = CGI.parse(input)
@token, @secret = params['oauth_token'].first, params['oauth_toke... | true |
32a03aa754d503637081e15aa009d7a99e1bd0f8 | Ruby | greedybrain/GummyNotes | /app/controllers/application_controller.rb | UTF-8 | 5,085 | 2.53125 | 3 | [] | no_license | class ApplicationController < Sinatra::Base
configure do
set :views, "app/views" # telling sinatra to look inside my app directory for a views folder which houses all of my view templates
set :public_folder, "public" # telling sinatra to look for a public folder which houses all of my styling, ima... | true |
8f801649bf015e557b01aa3dcfb2e2abfa33df99 | Ruby | babyshoes/project-euler-even-fibonacci-web-0715-public | /lib/even_fibonacci.rb | UTF-8 | 297 | 3.078125 | 3 | [] | no_license | # Implement your procedural solution here!
def even_fibonacci_sum(limit)
sequence = [1, 2]
i = 0
next_num = sum = 2
while next_num < limit
next_num = sequence[i] + sequence[i+1]
sequence << next_num
sum += next_num if next_num<limit && next_num%2==0
i += 1
end
sum
end
| true |
d9fbd0a8a4270325df31306fb3c2fc713680f1fd | Ruby | louis-delon/whikend | /app/controllers/users_controller.rb | UTF-8 | 1,396 | 2.546875 | 3 | [] | no_license | class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update]
def show
@average = calcul_average_rating(@user)
@user_trips = trips_user_list(@user)
@default_cover = "http://res.cloudinary.com/dvsmmztrt/image/upload/v1520585118/default_cover.jpg"
end
d... | true |
cce8ec89962e9629beff2c10648e4a5c3db8aedb | Ruby | marcosaureliofarias/aws | /plugins/easysoftware/gems/rys/lib/rys/plugins_management.rb | UTF-8 | 1,065 | 2.546875 | 3 | [] | no_license | module Rys
class PluginsManagement
mattr_accessor :all_plugins
self.all_plugins = []
# Backward compatibility
def self.instance
ActiveSupport::Deprecation.warn('.instance method is deprecated')
self
end
def self.add(engine_klass)
all_plugins << engine_klass
end
# ... | true |
99d331c1ff4c609a3c51b4452e8a90a42e493063 | Ruby | curationexperts/laevigata | /spec/helpers/graduation_helper_spec.rb | UTF-8 | 1,951 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
require 'rails_helper'
RSpec.describe GraduationHelper, type: :helper do
let(:graduation_date) { "2019-08-17" }
context "with valid embargo_length and graduation_date" do
it "inteprets month units" do
release_date = described_class.embargo_length_to_embargo_release_date(gr... | true |
14722342c5206c6292985e004a916ed3e78b7e65 | Ruby | peteroupc/cbor-simple | /lib/cbor/dumper.rb | UTF-8 | 1,853 | 2.78125 | 3 | [
"MIT"
] | permissive | class CBOR::Dumper
include CBOR::Consts
@@registered_classes = {}
def self.register_class(klass, tag, &block)
@@registered_classes[klass] = {
tag: tag,
block: block
}
end
def dump(val)
case val
when nil
dump_simple(Simple::NULL)
when TrueClass
dump_simple(Simple:... | true |
9527a443cf5291c58050a591df43718062051e08 | Ruby | Kohei909Otsuka/tmp_clean | /main.rb | UTF-8 | 887 | 2.875 | 3 | [] | no_license | require_relative "todo_storage_generator"
require_relative "todo_list"
# Todo管理のcliアプリ
MODE = {
list: "list",
append: "append",
update: "update",
remove: "remove",
search: "search"
}
sg = TodoStorageGenerator.new(ENV["STORAGE"])
storage = sg.generate
# STORAGEの指定がcsvでもdbでもjsonでもないときの対応
if storage.nil?
... | true |
d4ad9c89120930bcec6770ae6de891e852ff4f3d | Ruby | StevensLighthouse/Core | /app/controllers/groups.rb | UTF-8 | 2,147 | 2.59375 | 3 | [] | no_license | # GET /groups
# Index of all all groups
get '/groups' do
redirect to('/login') unless current_user
@current_user = current_user
if @current_user.is_site_admin?
@groups = Group.all
respond_to do |format|
format.json { { :groups => @groups }.to_json }
end
elsif @current_user.is_group_admin? and... | true |
1c2237c3efdcb3594cf17319a5f42a597d5362d3 | Ruby | Souravgoswami/ruby-masterclass | /SECTION 2: Introduction to Standard Output and Interactive Ruby (REPL)/sprintf.rb | UTF-8 | 159 | 2.546875 | 3 | [
"Unlicense",
"LicenseRef-scancode-proprietary-license"
] | permissive | sprintf 'Hello World' # => 'Hello World'
sprintf '%s', 'Hello World' # => 'Hello World'
puts(sprintf 'Hello World')
Kernel.puts(sprintf '%s', 'Hello World')
| true |
787c3f5692ff2d5b9b806e4e7353d0ee1835bb30 | Ruby | jkereako/mass-lottery-api | /lib/web_service.rb | UTF-8 | 361 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'net/http'
module MassLotteryAPI
class WebService
attr_reader :uri
def initialize(uri:, params:)
@uri = uri
return if params.empty?
@uri.query = URI.encode_www_form(params)
end
def fetch
response = Net::HTTP.get_response(@uri)
response.body if response.i... | true |
2441e8f5413b2049a768d4f0f8b2e89046fe2031 | Ruby | petrachi/ogame_maximixe_points | /app/compilers/planet_compiler.rb | UTF-8 | 1,863 | 2.71875 | 3 | [] | no_license | class PlanetCompiler
attr_accessor :index, :percentage, :warnings
attr_accessor :planet, :building, :build
def initialize planet
self.planet = planet
self.building = planet.buildings[blueprint_name.to_s]
self.build = Build.find_or_create_by(uid: uid)
unless build.compiled?
build.update com... | true |
b1b11a9c41c902e555c9eaf2a764485a6d6a79e7 | Ruby | ha4gu/atcoder | /ABC/120/122/A.rb | UTF-8 | 117 | 3.171875 | 3 | [] | no_license | b = gets.chomp
case b
when 'A' then puts 'T'
when 'T' then puts 'A'
when 'C' then puts 'G'
when 'G' then puts 'C'
end | true |
dff1cadf649386b0938bf61a55ee22852d708f06 | Ruby | britneywright/june2014 | /person.rb | UTF-8 | 796 | 3.96875 | 4 | [] | no_license | module Debug
def holla
"Holla!"
end
end
class Person
include Debug
def initialize(name)
@name = name
@anxiety_level = anxiety_level
end
def anxiety_level
@level = rand(1..10)
if @level > 8
return too_high
elsif @level == 5
return so_so
else
return low
e... | true |
6ec566b28596cc8f0634203e49cccb331182cd52 | Ruby | bulthuis/redmine_stand_up | /app/models/yesterdays_activity.rb | UTF-8 | 1,371 | 2.640625 | 3 | [
"MIT"
] | permissive | class YesterdaysActivity
attr_accessor :user, :date, :project_activities
def initialize(user, date)
@user = user
@date = date
projects = []
unversioned_issues_projects = []
until projects.count > 0 || unversioned_issues_projects.count > 0 || @date < @user.created_on.to_date
@date = @date - 1
project... | true |
7bc0d1683c439266994bd49ad91d6679e8fed284 | Ruby | babilonczyk/ruby-blackjack | /hand_runner.rb | UTF-8 | 291 | 3 | 3 | [] | no_license | require_relative 'card'
require_relative 'hand'
card_1 = Card.new('Hearts', '2')
card_2 = Card.new('Hearts', 'Jack')
card_3 = Card.new('Hearts', 'Ace')
hand = Hand.new
hand.add_card( card_1 )
hand.add_card( card_2 )
hand.add_card( card_3 )
puts hand.get_cards_value
puts hand.dealt_cards | true |
aadaa1230e28c67bd90475c154b0bd142c747f6c | Ruby | andersblehr/origon-mailer | /middleware/check_jwt.rb | UTF-8 | 557 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'jwt'
class CheckJwt
def initialize(app)
@app = app
end
def call(env)
begin
auth_scheme, jwt_token = env.fetch('HTTP_AUTHORIZATION').split(' ')
return [403, {}, []] if auth_scheme != 'Bearer'
JWT.decode(jwt_token, ENV['JWT_SECRET'], true, {
algorithm: 'HS256... | true |
af566966896cd76b42ee64e86a26bc955dec5077 | Ruby | project42da/Airbnb-copy | /app/models/room.rb | UTF-8 | 1,051 | 2.515625 | 3 | [] | no_license | class Room < ApplicationRecord
searchkick word_start: [:listing_name, :kor_address],
word_middle: [:listing_name, :kor_address]
belongs_to :user
has_many :photos
has_many :reservations
has_many :reviews
geocoded_by :address
after_validation :geocode, if: :address_changed?
# 필터링할 욕의 종류... | true |
c36f32a10950a7ee84ebd653064bd7738522ae23 | Ruby | asux/website_checker | /lib/website_checker.rb | UTF-8 | 1,296 | 3.03125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'csv'
require 'net/ping/tcp'
# Checks host for availablity using `Net::Ping::TCP` from CSV file with `URL` header
class WebsiteChecker
# Exception raised when expected {HEADER} not found in CSV
class UnableToFindHeader < StandardError; end
HEADER = 'URL'
attr_reader :in... | true |
7e9297bc576b6d87dc1347e58c6ae16c03277853 | Ruby | freegit9527/practice-code | /language/ruby/chapter14/ex1.rb | UTF-8 | 340 | 3.78125 | 4 | [] | no_license | #!/usr/bin/ruby
# exercise 1
str = "Ruby is an object oriented programming language"
ar = str.split(' ')
p ar
# exercise 2
ar_sort = ar.sort
p ar_sort
#exercise 3
ar_ig_sort = []
ar_sort.each do |item|
ar_ig_sort << item.downcase
end
ar_ig_sort.sort!
p ar_ig_sort
#exercise 3 THE OTHER ANSWER
p ar.sort_by{|i... | true |
d9a3ae917b96e958da54dbbc7075c1077b6c46d0 | Ruby | carlosmendes/sql_crud | /sql_crud.rb | UTF-8 | 476 | 3.09375 | 3 | [] | no_license | # READ
# reads all the doctors
SELECT * FROM doctors;
# read one doctor
SELECT * FROM doctors WHERE id = 1;
# CREATE
# INSERT INTO table_name (atribute(s)) VALUES (value(s))
INSERT INTO doctors (name, age, specialty)
VALUES ('Dr. Dolladille', 45, 'Dentist')
# UPDATE
# UPDATE table SET attribute(s) = value(s) WHERE ... | true |
9ca1e4dbd0060d710041796ea313078bb5445fce | Ruby | katheroine/languagium | /ruby/classes/inheritance/multilevel_inheritance.rb | UTF-8 | 867 | 3.75 | 4 | [] | no_license | #!/usr/bin/ruby2.7
class Mammal
@isDomesticated
@hasTail
@@isMilkFeeded = true
@@classTaxon = "Mammalia"
end
class Fox < Mammal
attr_accessor :name
@@hasFur = true
@@speciesTaxon = "Vulpes vulpes"
def initialize()
@hasTail = true
@isDomesticated = false
end
def show()
print("Hi, my ... | true |
db2b6f3810e8cee4f0078beef5d1868e7348eb3c | Ruby | vmvictorvm/learn_ruby | /03_simon_says/simon_says.rb | UTF-8 | 635 | 4.0625 | 4 | [] | no_license | def echo(msg)
msg
end
def shout(msg)
msg.upcase
end
def repeat(msg, num=2)
val = []
num.times do
val << msg
end
return val.join(" ")
end
def start_of_word(word, num)
word[0..num-1]
end
def titleize(title)
exclusion = ["and", "or", "the", "over"]
cap_word = title.split(" ").map do |word|
... | true |
ff8bd7b97f01619c02a302c3732a3ea122b39f17 | Ruby | blazevl1/MI-RUB | /Pentomino/lib/main.rb | UTF-8 | 893 | 2.90625 | 3 | [
"WTFPL"
] | permissive | $: << "."
require 'item_factory'
require 'board'
require 'd_l_x_algorithm'
require 'input_parser'
include DLXStructure
include StateSpace
include Pentomino
# Nacteni uzivatelskeho vstupu a vytvoreni desky pentomina
input_parser = InputParser.new
width,height = input_parser.get_board_size()
item_letters = input_parse... | true |
7a5f3b254579ae02ab6b8faee0976ee141ac814a | Ruby | davidtdang/ruby_exercises | /reverse_a_string/reverse_a_string.rb | UTF-8 | 668 | 3.53125 | 4 | [] | no_license | puts "Enter a string:"
input = gets.chomp
characters_array = input.split("")
character_indexes = characters_array.each_index.select{|i| characters_array[i]}
reversed_word = []
character_indexes.each do |x|
reversed_word << characters_array[-1-x]
end
p reversed_word.join
# p first_half_indexes = character_indexes.sl... | true |
11741caaa74197ad248d75bc9d026f59b0a6466b | Ruby | JiaLiangC/competent | /addin/addin.rb | UTF-8 | 799 | 2.84375 | 3 | [] | no_license | require 'ostruct'
ADDINFILE_PATH = File.expand_path('../addins/',__FILE__)
class Addin
def meta(hash=nil)
if hash
@meta = OpenStruct.new(hash)
else
@meta
end
end
def params(hash=nil)
if hash
@params = OpenStruct.new(hash)
else
@params
end
end
def logic(&bloc... | true |
374969e1b2cbedc2fba7d26ea38d84b0ceb1a09a | Ruby | postrank-labs/goliath | /lib/goliath/rack/validation/required_param.rb | UTF-8 | 3,002 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'goliath/rack/validator'
module Goliath
module Rack
module Validation
# A middleware to validate that a given parameter is provided.
#
# @example
# use Goliath::Rack::Validation::RequiredParam, {:key => 'mode', :type => 'Mode'}
# use Goliath::Rack::Validation::RequiredPara... | true |
8899b0f01cd26ab961f1e127efafe80db47c54af | Ruby | AndreasZeissner/puppet-openssh | /lib/puppet/parser/functions/ssh_keygen.rb | UTF-8 | 8,148 | 2.640625 | 3 | [
"MIT"
] | permissive | # Forked from https://github.com/fup/puppet-ssh @ 59684a8ae174
#
# Takes a Hash of config arguments:
# Required parameters:
# :name (the name of the key - e.g 'my_ssh_key')
# :request (what type of return value is requested (public, private, auth, known)
#
# Optional parameters:
# :type (the key ty... | true |
b4b732a74b92c94c81453519a65a0c876fd506be | Ruby | magnars/Adventur-Compiler | /test/commands/test_save_command.rb | UTF-8 | 782 | 2.546875 | 3 | [] | no_license | require 'test/unit'
require 'rubygems'
require 'mocha'
require 'commands/save_command'
require 'room'
require 'commands/plain_text'
class CommandsSaveCommandTestCase < Test::Unit::TestCase
def setup
@enterpreter = mock('enterpreter')
@keeper = mock('hashcode_keeper')
@enterpreter.stubs(:hashcode_keeper)... | true |
d130d632640f92e8c4afd619b97fc26acd97ebf3 | Ruby | under-os/under-os | /gems/under-os-ui/lib/under_os/ui/sidebar.rb | UTF-8 | 908 | 2.546875 | 3 | [
"MIT"
] | permissive | class UnderOs::UI::Sidebar < UnderOs::UI::View
wraps UIView, tag: :sidebar
LOCATIONS = [:top, :left, :right, :bottom]
def initialize(options={})
super
self.location = options.delete(:location) if options.has_key?(:location)
end
def location
@location || :bottom
end
def location=(value)
... | true |
b66f37de13dd2e14147bbba27f60271b2481bf17 | Ruby | kb-dk/valhal_classic | /app/services/transformation_service.rb | UTF-8 | 14,203 | 2.65625 | 3 | [] | no_license | # -*- encoding : utf-8 -*-
# Responsible for transforming from internal descriptive metadata format with authority-metadata into MODS.
class TransformationService
include XmlHelper
# Transforms the descriptive metadata for a Work or an Instance into MODS.
# If the Instance belongs to a Work, then the metadata fo... | true |
cbbd0ab07d4d13016f1d2879f38716a723eb1bc1 | Ruby | boisei0/arcreator | /RMXP/WindowX/WindowX_Selectable.rb | UTF-8 | 3,201 | 2.71875 | 3 | [] | no_license | #==============================================================================
# WindowX_Selectable
#==============================================================================
class WindowX_Selectable < WindowX_Base
attr_reader :index
def initialize(x, y, width, height)
super
@item_max = 1
@... | true |
7ade9df00c4861dbabe891e2d8ed2866418fb91c | Ruby | Jakub41/Ruby-League-Board | /soccer_league_board_test.rb | UTF-8 | 1,282 | 2.9375 | 3 | [] | no_license | require_relative 'soccer_league_board'
require 'test/unit'
require 'byebug'
class TestSoccerLeagueBoard < Test::Unit::TestCase
FILE_NAME = 'sample_input_test.txt'
def setup
@soccer_board = SoccerLeagueBoard.new
end
def test_parse_games_input
games = @soccer_board.parse_games_input(FILE_NAME)
ass... | true |
acec7af2c2e1c6d780c86e6f50304c801b14e61d | Ruby | holmesm8/public_library_1911 | /lib/author.rb | UTF-8 | 467 | 3.21875 | 3 | [] | no_license | require './lib/book'
class Author
attr_reader :name, :books
def initialize(author_info)
@name = author_info[:first_name] + " " + author_info[:last_name]
@books = []
end
def write(title, date)
new_book = Book.new({author_first_name: @name.split.first,
author_last_name: @nam... | true |
dbd7348d841bef7f79c61b1ef2e65120c0adbd8c | Ruby | vendetta546/codewars | /Ruby/6KYU/Parent.rb | UTF-8 | 108 | 2.828125 | 3 | [] | no_license | def find_children(dancing_brigade)
dancing_brigade.chars.sort_by { |char| [char.downcase, char] }.join
end | true |
dc894b9368e85ec692ad8c8ba9e08f5d7a34194e | Ruby | udoschneider/deepsecurity | /lib/deepsecurity/transport_objects/private/vulnerability.rb | UTF-8 | 1,478 | 2.59375 | 3 | [
"MIT"
] | permissive | module DeepSecurity
# This class encapsulates a vulnerability
# @private
class Vulnerability
attr_accessor :dpi_rule_identifier
attr_accessor :cve_identifiers
attr_accessor :secunia_identifiers
attr_accessor :bugtraq_identifiers
attr_accessor :microsoft_identifiers
def parse_vulnerabili... | true |
bc949a38a7960e27e3e8572c3ad3473cd4fe8614 | Ruby | PROJETO-ES-2020-1/mm-express | /features/step_definitions/funcionario_steps.rb | UTF-8 | 3,759 | 2.5625 | 3 | [] | no_license | Given("ha um usuario do tipo funcionario cadastrado com nome {string}, email {string}, password {string}, telefone {string}, cpf {string}, numero_residencia {string}, bloco_residencia {string}") do |nome, email, senha, telefone, cpf, num_residencia, bloco_residencia|
Usuario.create(nome: nome, email: email, password:... | true |
baed8480b84cdc61fda3e99e987a6a555a40d43a | Ruby | aliensjit/Ruby | /Basic/angry_boss.rb | UTF-8 | 74 | 2.609375 | 3 | [] | no_license | reply = gets
puts 'WHADDYA MEAN "' + reply.chomp + '"?!? YOU\'RE FIRED!!' | true |
12f10fac919b00bbb6ceeb640bb47b78e400ddd8 | Ruby | vladimirtemnikov/pagerank | /lib/page_parser.rb | UTF-8 | 1,244 | 2.828125 | 3 | [] | no_license | class PageParser
FILTER_LINK_REGEXP = /^((?!javascript)(?!#)[\w\S])*$/.freeze
def main_page_links
@_main_page_links = links_from_page_with_count(parsed_content(get_html($inputs.main_link)), $inputs.links_count)
end
def general_page_links(link)
links_from_page(parsed_content(get_html(link)))
end
d... | true |
d7beacf4c8c4cad61d95d450832ebcba707366bf | Ruby | plaid/plaid-ruby-legacy | /lib/plaid/income.rb | UTF-8 | 3,830 | 3 | 3 | [
"MIT"
] | permissive | module Plaid
# Public: Representation of Income data.
class Income
# Public: The class encapsulating an income stream.
class Stream
# Public: The Float monthly income associated with the income stream.
# E.g. 5700.
attr_reader :monthly_income
# Public: The Float representation of Pl... | true |
db918f2754f7277d25684fd156db55ec20ad8279 | Ruby | sadmanahmed/scraper_test_1 | /prothoma_v1.rb | UTF-8 | 5,248 | 2.765625 | 3 | [] | no_license | #For All publisher of prothoma final version
require 'nokogiri'
require 'httparty'
require 'byebug'
require 'csv'
#require 'pry'
require 'selenium-webdriver'
#require 'language_converter'
def scraper
#puts "Give the URL"
#url = gets.chomp
url ="https://www.prothoma.com/publisher"
url= url+"?page=1"
unparsed_page = HTT... | true |
b58d3b40aa6ef52327cc228474879805271ec141 | Ruby | kozeyandrey/ShopApp | /app/models/coupon.rb | UTF-8 | 216 | 2.578125 | 3 | [] | no_license | class Coupon < ActiveRecord::Base
# Check code with coupon code from db
def self.check_coupon(code)
self.all.find_each do |coupon|
if code == coupon.code
return true
end
end
end
end
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.