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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
edb92fa17bcd4c1a6c08aad6c3ed695cd882ed2a | Ruby | kcmills/mutiny | /spec/unit/tests/test_set/filterable_spec.rb | UTF-8 | 2,004 | 2.640625 | 3 | [
"MIT"
] | permissive | module Mutiny
module Tests
class TestSet
describe Filterable do
context "for" do
let(:subjects) { subject_set_for("Max", "Min") }
let(:test_set) { test_set_for("Min", "Min#run", subjects: subjects) }
it "should return only those tests that are relevant to the subject" ... | true |
1ab098b117999d04d7ff8e732fe41cad190d8de8 | Ruby | ClaudiaPfeil/schwab-auber | /cloth_app/vendor/plugins/cp_utils/lib/model_methods.rb | UTF-8 | 674 | 2.765625 | 3 | [
"MIT"
] | permissive | # To change this template, choose Tools | Templates
# and open the template in the editor.
module ModelMethods
def self.build_attribute_accessor(attributes)
method_symbols = ""
method_symbols << ":" << attributes.map { |value| '%s%s' % value}.join(',:') unless attributes.nil?
#method_symbols
end
de... | true |
1c97d0f90e80143c1b186e906dbf2791316399ac | Ruby | Witchrist/nivelamento-aluno | /06-exercicio.rb | UTF-8 | 3,231 | 3.78125 | 4 | [] | no_license | def valida_parametros(vacinacao, transmissao, leitos)
if vacinacao<0.0 || vacinacao>1.0
validacao = "Dado inválido: vacinação "+vacinacao.to_s
elsif transmissao<0.0
validacao = "Dado inválido: transmissão "+transmissao.to_s
elsif leitos<0.0 || leitos>1.0
validacao = "Dado inválido: ... | true |
dd1a146811a31a6de8620983e788eaa4a92da3ff | Ruby | barsoom/attr_extras | /spec/attr_extras/method_object_spec.rb | UTF-8 | 901 | 3 | 3 | [
"MIT"
] | permissive | require "spec_helper"
describe Object, ".method_object" do
it "creates a .call class method that instantiates and runs the #call instance method" do
klass = Class.new do
method_object :foo
def call
foo
end
end
assert klass.call(true)
refute klass.call(false)
end
it "d... | true |
903ee3ad365bcf5c5fce90ea659a0accbbdbd941 | Ruby | jonathanpberger/pairtrix | /app/models/pair.rb | UTF-8 | 1,043 | 2.71875 | 3 | [
"MIT"
] | permissive | class Pair < ActiveRecord::Base
belongs_to :pairing_day
has_many :pair_memberships, inverse_of: :pair
has_many :team_memberships, through: :pair_memberships
has_many :employees, through: :team_memberships
validates_presence_of :pairing_day
validate :validate_team_membership_count
def validate_team_m... | true |
9316b8245d053720abd1fb14de2ff9f4c5186cf6 | Ruby | clm1403/Intro-to-programming | /loops_and_iterators/exercise_2.rb | UTF-8 | 232 | 3.171875 | 3 | [] | no_license | looping = "Let's go looping ... "
puts looping
user_answer = gets.chomp
still_looping = ''
while still_looping != "STOP" do
puts looping
puts "Still looping here ..."
still_looping = gets.chomp
end
puts "Thanks for playing." | true |
49a5e1b8d208c113296b1cfadae4588563ffd13e | Ruby | SteveBirtles/RubyMetaprogramming | /Example3.rb | UTF-8 | 307 | 2.90625 | 3 | [] | no_license | class CarModel
attr_accessor :engine_info, :engine_price,
:wheel_info, :wheel_price,
:airbag_info, :airbag_price,
:alarm_info, :alarm_price,
:stereo_info, :stereo_price
end
car = CarModel.new()
car.stereo_price = 4
puts car.stereo_price
| true |
66270cbde7d972e657b9f817d2db33dc561125d3 | Ruby | AugustoPresto/LP-Database | /app/views/lps_view.rb | UTF-8 | 278 | 2.953125 | 3 | [] | no_license | class LpsView
def index(lps)
puts ""
puts "Listing all your LPs..."
lps.each do |lp|
puts "#{lp.id}. #{lp.artist} - #{lp.title} - #{lp.year} - R$ #{lp.price}"
end
end
def ask_for(string)
puts "#{string}?"
print "> "
gets.chomp
end
end
| true |
a48734fcd11b89e504f75d8fcaec979ecbfd9b19 | Ruby | chubberlisk/tic-tac-toe | /lib/user_interface/presenter.rb | UTF-8 | 796 | 2.734375 | 3 | [] | no_license | # frozen_string_literal: true
class UserInterface::Presenter
def initialize(start_new_game:, evaluate_game:, take_turn:, user_interface:)
@start_new_game = start_new_game
@evaluate_game = evaluate_game
@take_turn = take_turn
@ui = user_interface
end
def execute(*)
first_player = @ui.ask_user... | true |
877635a33bdc517c19dfe79335e449e7bd035b30 | Ruby | bunmiaj/CodeAcademy | /Web-Development/Ruby/5- Loops & Iterators/3.rb | UTF-8 | 692 | 4.71875 | 5 | [] | no_license | # The 'Until' Loop
# The complement to the while loop is the until loop. It's sort of like a backwards while:
# i = 0
# until i == 6
# i += 1
# end
# puts i
# In the example above, we first create a variable i and set it to zero.
# Then we execute a block of code until i is equal to 6. That block of code increments ... | true |
74501f7e9e8ef8c07aa8ed852bff8fa1ad9d5db4 | Ruby | DFE-Digital/get-help-to-retrain | /spec/models/job_vacancy_spec.rb | UTF-8 | 4,652 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'rails_helper'
RSpec.describe JobVacancy do
describe '#title' do
it 'returns the title from a parsed body' do
body = { 'title' => 'Some title' }
expect(described_class.new(body).title).to eq('Some title')
end
it 'returns nil if title missing' do
body = {}
expect(described... | true |
a48fa928ca3e3cd50827126a6559dad3c537e0de | Ruby | AlanGabbianelli/oystercard-2 | /lib/oystercard.rb | UTF-8 | 665 | 3.203125 | 3 | [] | no_license | require_relative 'journey'
class Oystercard
attr_reader :balance, :journey
MAX_BALANCE = 50
MIN_LIMIT = 0
def initialize(journey_klass = Journey)
@balance = 0
@journey = journey_klass
end
def top_up(amount)
fail "Max balance #{MAX_BALANCE} reached" if @balance + amount > MAX_BALANCE
@bala... | true |
e28099d6bd374a63550257f716a60646d4feb0ca | Ruby | dajia/RubyTraining | /namexample.rb | UTF-8 | 1,017 | 3.375 | 3 | [] | no_license | puts 'what is you firts name?'
name = gets.chomp
puts 'what is your middle name?'
name2=gets.chomp
puts 'what is you last name?'
name3=gets.chomp
puts "Greetings " + name + ' '+ name2+ ' ' + name3 + '!' + ' Who is you favorite number?'
number=gets.chomp
number2 = number.to_i + 1.to_i... | true |
61dba878447915a18c25f9b05d1efe64378bf4b4 | Ruby | karlwitek/launch_school_rb130 | /ruby_challenges/easy/word_count.rb | UTF-8 | 1,219 | 4.28125 | 4 | [] | no_license | # Write a program that given a phrase can count the occurences of each word in that phrase.
class Phrase
attr_reader :phrase
def initialize(phrase)
@phrase = phrase
end
def clean_up_phrase
# remove punctuation (except apostrophes, numbers)
# normalize case here? tests: hash includes al... | true |
8d249fe21c2699c8075c209cdfdc0f018d010cf9 | Ruby | samk826/todo-ruby-basics-online-web-prework | /lib/ruby_basics.rb | UTF-8 | 362 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def division(num1, num2)
12/2
end
def assign_variable(value)
value
end
def argue(phrase)
phrase
end
def greeting(greeting,name)
puts "#{greeting} ejcbecb #{name}"
end
def return_a_value
(return_a_value="Nice")
end
def last_evaluated_value
last_evaluated_value="expert"
end
def pizza_party(choice="cheese"... | true |
487876e58cebb801887bf34c86bd3eb9d0a1bb5b | Ruby | MargaretLzy/programming-univbasics-2-statement-repetition-with-while-yale-web-yss-051721 | /lib/count_down.rb | UTF-8 | 103 | 3.21875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Write your code here
count = 10
while (count>0) do
puts count
count-=1
end
puts "Happy New Year!" | true |
018267e602349fdc13cf61aadfd3d107fe7825d9 | Ruby | brandnewlink/noteblock | /app/services/aes.rb | UTF-8 | 795 | 2.875 | 3 | [] | no_license | require 'openssl'
module AES
extend self
def encrypt(string, key)
Base64.urlsafe_encode64(aes(key, string))
end
def decrypt(string, key)
aes_decrypt(key, Base64.urlsafe_decode64(string))
end
def aes(key,string)
cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
cipher.encrypt
cipher... | true |
66615a9da454f5ec8268a0ad7f1bd8e536171c7f | Ruby | johndillon773/101_109_small_problems | /medium_2/9.rb | UTF-8 | 475 | 4 | 4 | [] | no_license | # bubble sort
def bubble_sort!(arr)
n = arr.length
loop do
newn = 0
1.upto(n-1) do |i|
if arr[i-1] > arr[i]
arr[i-1], arr[i] = arr[i], arr[i-1]
newn = i
end
end
n = newn
break if n == 0
end
end
array = [5, 3]
bubble_sort!(array)
p array == [3, 5]
array = [6, 2, 7... | true |
788109843009c184439fd2e61ae39fc03fb64c6c | Ruby | WozniakMac/penalty_game | /tests/game_list_test.rb | UTF-8 | 484 | 2.515625 | 3 | [] | no_license | require_relative '../lib/game_list'
require 'test/unit'
# tests/game_list_test.rb
class TestGameList < Test::Unit::TestCase
def test_creating_game
game = GameList.instance.create
assert_instance_of(Game, game)
game2 = GameList.instance.find(game.id)
assert_instance_of(Game, game2)
end
def test_g... | true |
6ca204a77bd4e73b6cdac025cd49b68a296a738d | Ruby | wudip/need-not-to-speed | /lib/view/painters/background.rb | UTF-8 | 463 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'view/painters/painter'
module NeedNotToSpeed
module View
# Background of a game (image of surface on which car moves)
class Background < Painter
PATH_TEMPLATE = 'lib/images/map/map_%<level>s.png'.freeze
def initialize(world, level)
super(world)
path = format(PATH_TEMPLATE... | true |
7b8154e30713c239905f5732c77bae0614a4eb69 | Ruby | yhk1038/facebook_page_manager | /app/helpers/application_helper.rb | UTF-8 | 1,565 | 2.515625 | 3 | [] | no_license | require 'rails_autolink'
module ApplicationHelper
# Facebook Scope request parameters and lists
def scope_parameters
'?scope='+scope_list.join(',')
end
def scope_list
%w(pages_show_list manage_pages publish_pages read_page_mailboxes pages_messaging read_insights)
end
# Flash ... | true |
ce46a257a6761281dbddfb72967b1c22a0f97cde | Ruby | scroniser/learn_ruby | /02_calculator/calculator.rb | UTF-8 | 407 | 3.796875 | 4 | [] | no_license | def add(v1, v2)
v1 + v2
end
def subtract(v1, v2)
v1 - v2
end
def sum(array)
array.inject(0){|running_total, item| running_total + item }
end
def multiply(array)
array.inject(1){|running_total, item| running_total * item }
end
def power(v1, v2)
v1**v2
end
def factorial(num)
if num > 0
total = 1
... | true |
c193dbd4882403a5b096d213c22136aab44b6534 | Ruby | doniexun/furnace | /lib/furnace/ssa/constant.rb | UTF-8 | 834 | 3.125 | 3 | [
"MIT"
] | permissive | module Furnace
class SSA::Constant < SSA::Value
attr_reader :type
attr_reader :value
def initialize(type, value)
@value = value
@type = type.to_type
super()
end
def type=(type)
@type = type.to_type
SSA.instrument(self)
end
def value=(value)
@value... | true |
83cd1664cea4d987ade0c531727ae7be20037605 | Ruby | celinero/ruby-order-picker | /group.rb | UTF-8 | 1,033 | 3.328125 | 3 | [] | no_license | require_relative "methods"
class Group
attr_reader :name, :names_array
def initialize(group_name, file_path)
@name = group_name
@path = file_path
@names_array = self.path_to_array
end
def randomise_order
@names_array.shuffle
end
def output_random_array
randomise_order.each_with_index... | true |
2122c6de042e942c8fb3c2beba6860b3b8ffe3cd | Ruby | acareaga/headcount | /lib/enrollment.rb | UTF-8 | 3,663 | 3.109375 | 3 | [] | no_license | require_relative 'district'
require_relative 'formatting'
class Enrollment
attr_reader :district_data, :name, :dropout_rate_by_year
def initialize(name, enrollment_data)
@dropout_rate_by_year = enrollment_data.fetch(:dropout_rates)
@graduation_rates = enrollment_data.fetch(:graduation_rates)
@partici... | true |
8d7960e036116d00638556668ae3509eb55ac56f | Ruby | amangautamberyl/training_and_learning | /ruby/ruby_multiarray.rb | UTF-8 | 634 | 3.328125 | 3 | [] | no_license | class ArrayExample
def multidim_array
@str_details = Array['id','firstname', 'lastname', 'Company' ],[1,'Aman', 'Gautam','Beryl'],['2', 'Anand', 'Kumar', 'Beryl']
#@empty_array = Array.new #blank array
puts "#{@str_details[0][0]} \t #{@str_details[0][1]} \t #{@str_details[0][2]} \t #{@str_details[0][3... | true |
2967bc3add49102e1da3691170b8483da25f2578 | Ruby | kulraj-singh/ruby | /4palindrome.rb | UTF-8 | 350 | 3.796875 | 4 | [] | no_license | class String
def palindrome?
# compare string with its reverse in ignore case mode. casecmp returns zero if they match
casecmp(reverse) == 0
end
end
puts "enter the string to check. enter q to quit"
while
string = gets.chomp
break if string.match(/^q$/i)
puts (string.palindrome?) ? "it is palindrome"... | true |
267e90c15fc726057bbaf41018d2653bc4884be5 | Ruby | doches/corncob | /scripts/get_words_rmc.rb | UTF-8 | 471 | 2.828125 | 3 | [] | no_license | prefix = ARGV[0]
words_f = IO.readlines("#{prefix}.wordmap").map { |x| x.strip.split(" ") }
words = {}
words_f.each { |pair| words[pair[0].to_i] = pair[1] }
counts = IO.readlines("#{prefix}.counts").map { |x| x.strip.split(" ").map { |x| x.to_i } }
counts.each_with_index { |x,x_i| x.each_with_index { |w_c, w_i| count... | true |
262897b70972a633a1b41cddbe923a5b702677e3 | Ruby | DouglasAllen/code-The_Book_of_Ruby | /code/ch06/if_else_alt.rb | UTF-8 | 371 | 4.53125 | 5 | [] | no_license | # ch06 The Book of Ruby - http://www.sapphiresteel.com
def dayIs(aDay)
(aDay == 'Saturday' || aDay == 'Sunday') ?
daytype = 'weekend' :
daytype = 'weekday'
daytype
end
x = 11
x == 10 ? puts("it's 10") : puts("it's some other number")
day1 = 'Monday'
day2 = 'Saturday'
print(day1 + ' is a ' + dayIs(day1) +... | true |
94def714521e31c58a2ed366bf1f9816d1989af7 | Ruby | seattlerb/sexp_processor | /lib/sexp_matcher.rb | UTF-8 | 23,830 | 3.0625 | 3 | [
"MIT"
] | permissive | class Sexp #:nodoc:
##
# Verifies that +pattern+ is a Matcher and then dispatches to its
# #=~ method.
#
# See Matcher.=~
def =~ pattern
raise ArgumentError, "Not a pattern: %p" % [pattern] unless Matcher === pattern
pattern =~ self
end
##
# Verifies that +pattern+ is a Matcher and then disp... | true |
fd1ce43611ff164bc3e145b709ee341ff97d4b3c | Ruby | SadTreeFriends/DanmakuHunter | /danmaku_hunter.rb | UTF-8 | 1,295 | 2.90625 | 3 | [] | no_license | class DanmakuHunter
require 'nokogiri'
f = File.open('danmaku.xml')
@doc = Nokogiri::XML(f).slop! do |option|
option.strict.nonet
end
f.close
@danmaku_storage = Array.new
class Danmaku
attr_accessor :font,:time,:color,:type, :content
def initialize(font,time,color,type,content)
@font... | true |
4b2fd531ba119fd7dd78768f4c565856234ad671 | Ruby | thread314/teaching_app_v1 | /scratch.rb | UTF-8 | 867 | 2.9375 | 3 | [] | no_license | @user = User.last
#Determine how many new cards need to be added
#This isn't working, if there are any existing new cards in the users cardstates, it enters every single card to their cardstates for some reason. Non-essential feature, can fix later
newcardsneeded = 6
@user.cardstates.each do |card|
if card.due.nil?... | true |
84536a64f79cef5cf508c24ab1b8db761ad0b54f | Ruby | crystalwilliams/tts-ruby | /092517/question_4.rb | UTF-8 | 314 | 4.25 | 4 | [] | no_license | # ask user for a sentence
puts "Write a sentence."
sentence = gets.chomp.to_s
# ask favorite word in sentence
puts "What is your favorite word in the sentence?"
fav_word = gets.chomp.to_s
# tell user what index favorite word starts at
index = sentence.index(fav_word)
puts "Your favorite word starts at #{index}." | true |
b7fae332258e28334f00a2d038dd6e9018161c16 | Ruby | sllee/activerecord_jr | /test.rb | UTF-8 | 696 | 2.6875 | 3 | [] | no_license | require_relative 'app'
cohort = Cohort.find(1)
p cohort
cohort[:name] = 'What Cohort'
cohort.save
puts "--------------"
p cohort
p Student.all.size
p Cohort.all.size
p Student.create(:cohort_id => 4, :first_name => 'ping', :last_name => 'pong', :email => 'dingdong@gmail.com', :gender => 'f', :birthdate => '1982-12... | true |
328e34659dbc9ce0769d79c097dbc82f021770d8 | Ruby | memetibryan/Shoe-Distribution-Ruby | /lib/brand.rb | UTF-8 | 411 | 2.65625 | 3 | [] | no_license | class Brand < ActiveRecord::Base
has_many :stores_shoes
has_many :stores, through: :stores_shoes #creating many to many relationship
#Active Record Validations making sure the form is not submitted blank
validates(:name, :presence => true)
#changes the input to Title_Case
before_save(:titlecase_name)
privat... | true |
735302171078c3951b34adc7b7109f914150d65f | Ruby | marvelousNinja/porse | /spec/lib/porse/url_generator_spec.rb | UTF-8 | 1,957 | 2.9375 | 3 | [] | no_license | module Porse
describe 'UrlGenerator' do
let(:starting_url) { 'google.com' }
let(:param_name) { 'p' }
let(:url_generator) { UrlGenerator.new(starting_url, param_name) }
describe '#initialize' do
it 'sets up starting url and name of the parameter' do
expect(url_generator.starting_url).to ... | true |
63d3cb65b9ca7862787c9f9ca3a7c4f67db24f89 | Ruby | sreemudunuri/module-one-final-project-guidelines-nyc-web-060418 | /lib/user_interactions.rb | UTF-8 | 6,506 | 3.1875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'colorize'
def login_process
puts "enter a username, or enter \".exit\" to return to main menu".colorize(:red)
user_command = gets.chomp
if user_command == '.exit' then exit_to_main end
login_name = user_command
if User.find_user(login_name) == nil
puts "User doesn't exist!".colorize(:red)
lo... | true |
20c727bb81c1ef2f7a4aba9f79fe1af68c6008b4 | Ruby | alexandre-h/drivy | /level5/main.rb | UTF-8 | 2,903 | 3.328125 | 3 | [] | no_license | require 'json'
require 'date'
FILE = File.open('data.json').read
class Pricing
def initialize(data)
@data = JSON.parse(data)
@cars = @data['cars']
@rentals_cars = {}
@data['rentals'].map do |rental|
@rentals_cars[rental['id']] = rental.merge!(@cars.find { |e| e['id'] == rental['car_id'] })
... | true |
45ef91319eb2de1476efba22db504faa3e1052ce | Ruby | surekrishna/RubyOnRailsPractise | /main.rb | UTF-8 | 71 | 2.671875 | 3 | [] | no_license | numbers = [1,2,3,4,5,6,7,8,9]
p numbers
p numbers[4]
p numbers.reverse! | true |
65fe39eae9ff9ed64f454110ae0b79da9dbb12c6 | Ruby | zengjk/tsvm | /select.rb | UTF-8 | 463 | 2.859375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
input = ARGV.first
num = ARGV[2] || 1000
name = "#{input}.#{num}"
train_file = name
test_file = "#{name}.t"
#
# select N random instances as train data
# a bit of a memory hog, sorry
#
File.open(input) do |f|
lines = f.readlines
train_lines = lines.sample(num)
test_lines = lines - train_l... | true |
cfc8096f09e90354c7bdf811ddbcda8ca19f2484 | Ruby | terhechte/appventure.me-codebase | /_plugins/global_filters.rb | UTF-8 | 2,317 | 2.796875 | 3 | [] | no_license | module Jekyll
module Filters
def list_of_month_years(posts = nil)
array = {}
checkarray = []
if posts
# break down into January, 2011 | etc, return
posts.each { |element|
date_string = element.date.strftime('%B %Y')
if not checkarray.include?(date_string)
checkarray.push(date_... | true |
a3cea09540106144c3cdeca4b0aabfa78806ea6a | Ruby | thyagobr/pylon | /lib/pylon.rb | UTF-8 | 3,821 | 2.734375 | 3 | [] | no_license | require 'ostruct'
require 'rss'
require 'open-uri'
require 'action_view'
require 'pylon/tracer'
module Pylon
class General
# Displays all the associations on a Rails app.
#
# It works by retrieving all files on the app/models folder,
# trying to turn the file names into classes (which will probably ... | true |
196676a8fa326e6c242e19469476959605b16679 | Ruby | msloekito/flow_control | /exercise3.rb | UTF-8 | 272 | 4.15625 | 4 | [] | no_license | puts "what is the number?"
number = gets.to_i
if (number > 100)
puts "it's above 100"
elsif (number > 50 && number <= 100)
puts "it's between 51 and 100"
elsif (number <= 50 && number >= 0)
puts "it's between 0 and 50"
else
puts "it's outside tested range"
end | true |
71cf0f49ea6e1551a53c50fd3b9f0a91acf9fcdb | Ruby | shawnmne/week-03-library-project | /lib/book.rb | UTF-8 | 598 | 2.796875 | 3 | [] | no_license | #this is class that create a book object
#
#+title - string: title of the book
#+author - string: author of the book
#+isbn - integer: isbn of the book
#+library_id - integer: primary key of the libary
# where the book is available
# will be nil if checked out
#+parton_id - integer: primary key of the patron
# ... | true |
a0888e8615d8d35b48731501a9355bc4501a5794 | Ruby | monkeygq/ruby_demo | /method_argument_and_parameter.rb | UTF-8 | 817 | 4.09375 | 4 | [] | no_license | class Myclass
def method_missing(method, *args)
puts "you called undefined method : #{method}(#{args.join(',')})"
end
end
Myclass.new.mymethod(2,3,4) #=> you called undefined method : mymethod(2,3,4)
#==============================================================================>
# parameter and argument : *
... | true |
4c0aa20c86463a47be81d8b9b767c7934d4ef663 | Ruby | proxygear/exo_cms | /app/services/ckeditor_railser.rb | UTF-8 | 2,148 | 2.609375 | 3 | [
"MIT"
] | permissive | class CkeditorRailser
RAILS_STRUCTURE = {
rails_assets: {
javascripts: /\.js\z/,
stylesheets: /\.css\z/,
images: /\.(png|jpg|jpeg)\z/,
otheres: nil
}
}
attr_accessor :base_path, :actions
def process path=nil
self.base_path = path || '.'
raise "base path #{base_path} doe... | true |
29a6a8acf53d6e8fa62424928ba8b6e620196ca1 | Ruby | sena-ji/app-academy-open | /software_engineering_foundations_curriculum/blocks_project/lib/part_2.rb | UTF-8 | 486 | 3.25 | 3 | [] | no_license | def all_words_capitalized?(array)
array.all? { |word| word == word.capitalize}
end
def no_valid_url?(array)
valid_urls = [".com", ".net", ".io", ".org"]
array.none? do |url|
index = url.index(".")
url_ending = url[index..-1]
valid_urls.include?(url_ending)
end
end
def any_pas... | true |
387d88302ba4c97ba6a2c6a9dbb501c101894910 | Ruby | Slouch07/Intro_to_Ruby | /Basics/ex_5.rb | UTF-8 | 166 | 3.015625 | 3 | [] | no_license | five = 5 * 4 * 3 * 2 * 1
six = 6 * 5 * 4 * 3 * 2 * 1
seven = 7 * 6 * 5 * 4 * 3 * 2 * 1
eight = 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1
puts five
puts six
puts seven
puts eight | true |
e8331405ff55ea7ffa90a38a51e23c8ed5c69340 | Ruby | mrkamel/significance | /lib/significance.rb | UTF-8 | 1,046 | 3.109375 | 3 | [] | no_license |
require "significance/version"
require "complex"
module Significance
LANCZOS_COEF = [
0.99999999999980993,
676.5203681218851,
-1259.1392167224028,
771.32342877765313,
-176.61502916214059,
12.507343278686905,
-0.13857109526572012,
9.9843695780195716e-6,
1.5056327351493116e-7
]
... | true |
7f0b6c4bfe56585325513b39cc03352b52b68146 | Ruby | rshiva/MyDocuments | /01-notes-programming /04-ruby+rails/ruby1.9/samples/tutcontainers_42.rb | UTF-8 | 556 | 3.3125 | 3 | [] | no_license | #---
# Excerpted from "Programming Ruby",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit http://www... | true |
7f4e2701c3b8581ed1f050058949fea48b74edec | Ruby | JuliaPrussia/BlackJack | /card.rb | UTF-8 | 275 | 3.625 | 4 | [] | no_license | class Card
attr_reader :suit,
:value
def initialize (suit, value)
@suit = suit
@value = value
end
def score
if @value.to_i > 0
@value.to_i
elsif @value == 'A'
@value
else
10
end
end
end
| true |
848da8bf392e99aee869764bd930a2a9c06f135c | Ruby | aks/easy_time | /lib/easy_time.rb | UTF-8 | 15,682 | 3.09375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'time'
require 'date'
require 'active_support'
require 'active_support/duration'
require 'active_support/time_with_zone'
require 'active_support/core_ext/numeric/time'
require 'easy_time/version'
require 'easy_time/convert'
# Are you tired of having to deal with many kinds of da... | true |
dd65acf0cb420d8a28d4f39b43a0d3c44bf3450b | Ruby | vlezya/my_study_projects | /hero_dragon_game/c_3/engine.rb | UTF-8 | 2,147 | 3.671875 | 4 | [] | no_license | require_relative "game_config"
require_relative "char"
require_relative "hero"
require_relative "dragon"
class Engine
attr_reader :game_config
def initialize(file = "game_options.yaml")
@game_config = GameConfig.new(file). # => instance of GameConfig
load_config # => Hash from YAML file
@dragon... | true |
de20a0aef1812eb5a9805cdc1d25248f0a52fbcc | Ruby | camnpr/studentinsights | /app/charts/student_profile_chart.rb | UTF-8 | 2,366 | 2.5625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] | permissive | class StudentProfileChart < Struct.new :student
def percentile_ranks_to_highcharts(star_results)
return nil unless star_results
star_results.select(:id, :date_taken, :percentile_rank, :grade_equivalent, :total_time)
end
def interventions_to_highcharts
return if student.interventions.blank?
stud... | true |
073140d66ba1d45508b2ef12dd01ec6057582569 | Ruby | amfazlani/phase-1 | /week-7/gps6/my_solution.rb | UTF-8 | 8,722 | 3.25 | 3 | [
"MIT"
] | permissive | # Virus Predictor
# I worked on this challenge [by myself, with: ].
# We spent [#] hours on this challenge.
# EXPLANATION OF require_relative
#
#
# require_relative 'state_data'
# require is a file call necessary for this program to run. The relative part means that look in the relative directory to the program. R... | true |
19dec6ec0cf8317669faabcfe8ca92dac43151e0 | Ruby | hyperloop-rails/static-analyzer | /applications/jobsworth/helpers/cache_helper.rb | UTF-8 | 1,177 | 2.90625 | 3 | [] | no_license | # Using expire_fragment with a regular expression is PITA as it makes Rails iterate over all the cache keys which is too slow.
# Additionally, some cache strategies don't support iterating over keys, making it non-trivial to drop multiple cache entries.
#
# This helper makes it possible to group together multiple cache... | true |
fe7ea91c242e30d551c1d9b22bcce9c5db6e3477 | Ruby | kasumi8pon/nlp100 | /04.rb | UTF-8 | 339 | 3.203125 | 3 | [] | no_license | sentence = "Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Might Also Sign Peace Security Clause. Arthur King Can."
words = sentence.split(/\W+/)
one_char = [1, 5, 6, 7, 8, 9, 15, 16, 19]
hash = {}
words.each.with_index(1) do |word, i|
key = one_char.include?(i) ? word[0] : word[0..1]
hash[key] ... | true |
b9a27c53a5d587eef72d28de3e398d455a99e7e3 | Ruby | Alonsorozco/desafiosopcionales | /opcional1.rb | UTF-8 | 176 | 3.71875 | 4 | [] | no_license | a = [1, 9 ,2, 10, 3, 7, 4, 6]
puts a.map(&:to_f)
puts a.select {|num| num<=5 }
puts a.inject(:+)
# ejemplo [3, 6, 10, 13]
# (((3 + 6) + 10) + 13) => 32
puts a.count {|x| x<5} | true |
c19c3838e22de77d2a3f2d71f39f7bd5e677126d | Ruby | pkordel/oss_analyzer | /app/helpers/application_helper.rb | UTF-8 | 869 | 2.625 | 3 | [] | no_license | # Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
# Return a link for use in layout navigation.
def nav_link(text, controller, action='index')
link_to_unless_current text, :id => nil,
:controller => controller,
... | true |
9d1355ad7e8c238ae14623f5e6103f362d8557a8 | Ruby | ghiculescu/sorbet | /test/testdata/lsp/rename/method_attr.rb | UTF-8 | 406 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | # typed: true
# frozen_string_literal: true
class Foo
attr_reader :foo
# ^ apply-rename: [A] invalid: true
attr_writer :bar
# ^ apply-rename: [C] invalid: true
attr_accessor :baz
# ^ apply-rename: [D] invalid: true
end
f = Foo.new
f.foo
# ^ apply-rename: [B] newName: ba... | true |
62b99433c0f72c1fd42f290212647624f0784319 | Ruby | otegami/cherry | /spec/effects_spec.rb | UTF-8 | 951 | 3.28125 | 3 | [] | no_license | require 'spec_helper'
RSpec.describe "Effects" do
describe "Reverse" do
it "makes words to reverse" do
effect = Effects.reverse
expect(effect.call('Ruby is fun!')).to eq('ybuR si !nuf')
end
end
describe "Echo" do
context "makes words to echo" do
it "is twice" do
effect = Eff... | true |
2bbc96c6f1044f6bfa38dbacada56720bff70a5e | Ruby | CCCQ2/Euler | /problem62-solved.rb | UTF-8 | 949 | 3.375 | 3 | [] | no_license | #The cube, 41063625 (345^3), can be permuted to produce two other cubes: 56623104 (384^3) and 66430125 (405^3). In fact, 41063625 is the smallest cube which has exactly three permutations of its digits which are also cube. Find the smallest cube for which exactly five permutations of its digits are cube.
solution = []... | true |
0e372cc8e1793aae8e718a9212d7423cd7000082 | Ruby | agarun/homeworks | /classwork/W3D2/bonus_refactor_WIP/reply.rb | UTF-8 | 1,879 | 2.796875 | 3 | [] | no_license | require_relative 'dbconnection'
require_relative 'user'
require_relative 'question'
class Reply < ModelBase
attr_accessor :body, :user_id, :question_id, :reply_id
attr_reader :id
def initialize(options)
@id = options['id']
@body = options['body']
@reply_id = options['reply_id']
@question_id = op... | true |
645ac5c8843048310571dc497686de8559636b8f | Ruby | travis-ci/travis-scheduler | /lib/travis/support/registry.rb | UTF-8 | 1,835 | 2.75 | 3 | [
"MIT"
] | permissive | module Travis
module Registry
class Registry
def []=(key, object)
objects[key.to_sym] = object
end
def [](key)
key && objects[key.to_sym] || fail("can not use unregistered object #{key.inspect}. known objects are: #{objects.keys.inspect}")
end
def objects
@o... | true |
1922f32bb25b397bed17e3e4b868316150f3b28b | Ruby | tgrosch91/debugging-with-pry-v-000 | /lib/pry_debugging.rb | UTF-8 | 38 | 3.171875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def plus_two(num)
sum=num+2
sum
end
| true |
438a51d81a735537d2416db65d9d10f41c26c782 | Ruby | beltrachi/automatic_dictionary | /test/integration/lib/interactor/snapshooter.rb | UTF-8 | 1,381 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'interactor/shared'
require 'tempfile'
require 'fileutils'
module Interactor
module Snapshooter
class << self
include Shared
def create_screenshot
file = tmp_file.path
# NOTE: we are using jpg because imagemagick png can last as much as 12s
# when converting images. J... | true |
2a8209409512cdae4b4886615a551683f244338d | Ruby | billbell73/Week-4-test | /inject_method/lib/array.rb | UTF-8 | 513 | 3.3125 | 3 | [] | no_license | class Array
def new_inject
first, *rest = self
accumulator = first
rest.each do |value|
accumulator = yield accumulator, value
end
accumulator
end
def new_inject_with_arg(initial)
accumulator = initial
self.each do |value|
accumulator = yield accumulator, value
end
accumulator
end
... | true |
7dfd6e2f08dc860232c66dba9cae4b550c608b0c | Ruby | enspirit/bmg | /lib/bmg/sql/ext/predicate/expr.rb | UTF-8 | 362 | 2.546875 | 3 | [
"MIT"
] | permissive | class Predicate
module Expr
def to_sql_literal(buffer, value)
case value
when TrueClass
buffer << Sql::Expr::TRUE
when FalseClass
buffer << Sql::Expr::FALSE
when Integer, Float
buffer << value.to_s
else
buffer << Sql::Expr::QUOTE << value.to_s << Sql:... | true |
7db50d6cf7036cf8bbc41bc2abb1891e0a9fb4cc | Ruby | dvandersluis/number_muncher | /spec/number_muncher/parser_spec.rb | UTF-8 | 3,897 | 3.140625 | 3 | [] | no_license | RSpec.describe NumberMuncher::Parser do
subject { described_class }
describe '.call' do
let(:options) { { thousands_separator: '.', decimal_separator: ',' } }
context 'when given invalid input' do
it 'raises an exception' do
expect { described_class.new('a').call }.to raise_error(NumberMunch... | true |
9a0eaf0efff164c9e766bc6eb715579428ae7d93 | Ruby | MaggieHibberd/card_game | /spec/deck_spec.rb | UTF-8 | 611 | 3.25 | 3 | [] | no_license | require 'deck'
describe Deck do
context 'Class starts with a full deck of cards of which you can apply methods to' do
it 'initializes with a deck of cards' do
deck = Deck.new
sample = deck.check_deck.sample
expect(deck.check_deck).to include sample
end
it 'allows you to shuffle a deck' do
de... | true |
1f160202494e49c72dd2e1308edef054fffb3bfa | Ruby | aantix/email_finder | /lib/email_finder/email_pattern_resolver.rb | UTF-8 | 2,439 | 3.359375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'erb'
require 'email_finder/utils'
module EmailFinder
class EmailPatternResolver
include Utils
attr_reader :username
FIRST_NAMES = "data/first_names.txt"
LAST_NAMES = "data/last_names.txt"
def initialize(username)
@username = username.downcase
end
def pattern
email... | true |
d53812f0d76a2805fa09a3f7f12073508547ea59 | Ruby | jaredianmills/nyc-web-062518 | /19-rails-forms-rest-validations-bagel-shop/app/controllers/bagels_controller.rb | UTF-8 | 1,263 | 2.6875 | 3 | [] | no_license | class BagelsController < ApplicationController
# rails will infer i want to render index when at /bagels
# show ALL bagels
def index
@bagels = Bagel.all
render :index
end
# show form to create a new bagel
def new
@bagel = Bagel.new
render :new
end
# POST request from our new bagel form
... | true |
b78a8b88613d58556db91a11d7b0353eaf44d70f | Ruby | kushwahdeepak/deepak_cardinal | /lib/tasks/update_intake_batch_person.rake | UTF-8 | 939 | 2.5625 | 3 | [] | no_license | require 'csv'
namespace :scheduled do
task :update_person, [:name] => [:environment] do |task, args|
puts "starting intake batches"
load_csv = iterate_input_rows args[:name]
end
def load_csv_file file
file_read = File.read(file)
CSV.parse file_read, {
headers: true,
skip_blanks: true,... | true |
7653b056701fe7eea647ac795688c40fc074bc66 | Ruby | kevthunder/pawa | /lib/pawa/operations/replace_operation.rb | UTF-8 | 2,267 | 2.515625 | 3 | [
"MIT"
] | permissive | module Pawa
module Operations
class ReplaceOperation < Operation
def findable?
true
end
def parser()
super.tap do |parser|
parser.flags.push 'word'
end
end
def start_reg
if listedParams.first.is_a?(String)
Regexp.n... | true |
1a31b88ad5334f92792271f5b771e575ae67e648 | Ruby | celluloid/celluloid | /lib/celluloid/internals/handlers.rb | UTF-8 | 859 | 2.921875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require "set"
module Celluloid
module Internals
class Handlers
def initialize
@handlers = Set.new
end
def handle(*patterns, &block)
patterns.each do |pattern|
handler = Handler.new pattern, block
@handlers << handler
end
end
# Handle inc... | true |
ca716b334510a725573d83c396ee2e1f8bbf640e | Ruby | b-studios/doc.js | /lib/dom/node.rb | UTF-8 | 11,664 | 3.453125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require_relative 'dom'
require_relative 'exceptions'
module Dom
# Node can be seen as an **aspect** or feature of another Object. Therefore it can be mixed in to
# add node-functionality to a class.
# Such functionality is used by {CodeObject::Base code-objects} and {Document::Document documents}.
#
# Inst... | true |
0d8580344403e9f51ce1e6258a66baa0bc481de2 | Ruby | sadeeshkumarv/simple_record | /test/my_child_model.rb | UTF-8 | 538 | 2.59375 | 3 | [] | no_license | require File.expand_path(File.dirname(__FILE__) + "/../lib/simple_record")
require 'my_model'
class MyChildModel < SimpleRecord::Base
belongs_to :my_model
has_attributes :name
end
#
#
#puts 'word'
#
#mm = MyModel.new
#puts 'word2'
#
#mcm = MyChildModel.new
#
#puts 'mcm instance methods=' + MyChildModel.instan... | true |
0c782102302376a5238ae929b835dc2f4634ab94 | Ruby | weavery/clarc | /Rakefile | UTF-8 | 2,077 | 2.640625 | 3 | [
"Unlicense"
] | permissive | # This is free and unencumbered software released into the public domain.
require 'yaml'
require 'active_support/core_ext/hash' # `gem install activesupport`
def parse_examples(filepath, type)
examples = {}
File.open(filepath) do |file|
name = nil
file.readline; file.readline # skip URL
file.read.sp... | true |
ffbcc2bafe0dcfa3fdcdc7b75f9acf8741720864 | Ruby | Augustus-Gabe/ruby_stuff | /condicionais.rb | UTF-8 | 263 | 3.5 | 4 | [] | no_license | puts"insira um numero"
numero = gets.to_i
puts "insira outro numero"
oto_numero = gets.to_i
if numero == oto_numero then
puts "Os numeros #{numero} e #{oto_numero} foram testados"
puts "os numeros sao iguais"
else
puts"os numeros são diferentes"
end
| true |
769dceebac3f3dbb00f0b8fe0bc69c20dbdd328d | Ruby | ryuchan00/Miscellaneous | /paiza/D.rb | UTF-8 | 1,012 | 3.546875 | 4 | [] | no_license | # input_lines = gets
# p gets.to_i
# p gets.to_i
# p input_lines
# words = []
# while s = gets
# words << s.chomp.to_i
# end
# p words.sort
# p gets.to_i
# p gets.to_i
# p input_lines
gets
words = []
while s = gets
words << s.chomp.to_i
end
# p words.sort
words.sort.each { |v| puts v.to_s + "\n" }
# a,b = gets.chom... | true |
539d71261bc390786ed5ec7322f52e36127b93ff | Ruby | abicky/typed_data | /lib/typed_data/schema/enum_type.rb | UTF-8 | 315 | 2.5625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module TypedData
class Schema
class EnumType < Type
def initialize(name, symbols)
@name = name
@symbols = symbols
end
def primitive?
false
end
def match?(value)
@symbols.include?(value)
end
end
end
end
| true |
600261e48a9023e90b81993e633088a0c5ba71c4 | Ruby | meganemura/private_please | /lib/private_please/methods_calls_tracker.rb | UTF-8 | 772 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'private_please/tracking/trace_point_processor'
module PrivatePlease
class MethodsCallsTracker
def self.instance
@instance ||= new(Config.new)
end
def self.reset
@instance = nil
end
# -----
attr_reader :config
def initialize(config)
@config = c... | true |
e2864184accae9377f8bfa87044d093f9152fd79 | Ruby | olsi2984/Ruby_projects | /Tic_Tac_Toe/tic_tac_toe.rb | UTF-8 | 3,329 | 4.0625 | 4 | [] | no_license | class Game
@@message = "It's a tie" # updated from check_winner
def initalize(board)
@board = board
end
def show_board(board)
puts row1 = "#{board[0]}"" | ""#{board[1]}"" | ""#{board[2]}"
puts separator = "---------"
puts row2 = "#{board[3]}"" | ""#{board[4]}"" | ""#{board[5]}"
puts s... | true |
13e7964b7df57a2bc43a4161f31888bd6e810ff8 | Ruby | ivanvanderbyl/cloudist | /examples/sandwich_worker_with_class.rb | UTF-8 | 1,355 | 2.734375 | 3 | [
"MIT"
] | permissive | # Cloudst Example: Sandwich Worker
#
# This example demonstrates receiving a job and sending back events to the client to let it know we've started and finsihed
# making a sandwich. From here you could dispatch an eat.sandwich event.
#
# Be sure to update the Cloudist connection settings if they differ from defaults:... | true |
4629e1e286821ce4c6af800526a492404e4c7b9a | Ruby | mattgfisch/phase-0-tracks | /ruby/santa.rb | UTF-8 | 2,045 | 4 | 4 | [] | no_license | # ----- SANTA CLASS DEFINITION
class Santa
attr_reader :ethnicity
attr_accessor :gender, :age
def initialize(gender, ethnicity)
puts "Initializing Santa instance..."
@gender = gender
@ethnicity = ethnicity
@reindeer_ranking = ["Rudolph", "Dasher", "Dancer", "Prancer", "Vixen", "Comet", "Cup... | true |
972dc83c1af574f985c04355997b294abe5185ea | Ruby | banyanbbt/Multi-Trust-Connector | /cloud/app/models/util/token.rb | UTF-8 | 708 | 2.9375 | 3 | [
"MIT"
] | permissive | module Util
class Token
class << self
def friendly_token(length=16)
SecureRandom.base64(length).tr('+/=lIO0', 'xmhesch')
end
def generate_password(password, salt)
pwd_str = password + "mtc" + salt
Digest::MD5.hexdigest(pwd_str)
end
def numeric_code(length=... | true |
05cc5f676c07a3951747223b797821d374eafc19 | Ruby | taiak/ruby_denemelerim | /Problemler/kok_bulma/kok_bul.rb | UTF-8 | 1,542 | 3.265625 | 3 | [] | no_license | def islem (x)
func = x**10 - 1
return func
end
def tablo_bas (alt, ust, adim, xR, hata_payi)
print "#{adim}\t#{alt.round(4)}\t#{ust.round(4)}\t"
print "#{xR.round(4)}\t#{islem(alt).round(4)}\t"
print "#{islem(ust).round(4)}\t#{islem(xR).round(4)}\t"
puts "#{hata_payi.round(6)}"
end
def kok_bas (xR)
puts "Kök: ... | true |
8c0fb3d51a42c25c7df5da977f53d1d671a86e53 | Ruby | Adedee/ruby | /Exercise12/bin/main.rb | UTF-8 | 204 | 3.578125 | 4 | [] | no_license | require_relative('../lib/CharacterClass.rb')
puts "Please enter text"
text = gets.chomp
if text.nil?
puts "Please enter a number"
else
characters = CharacterClass.new(text)
puts characters.to_s
end | true |
233aa40c4de13aab861c1a7cfc85fbcaec8dc399 | Ruby | akatz/check_internet | /check_internet.rb | UTF-8 | 525 | 2.75 | 3 | [] | no_license | #!/usr/bin/ruby
require 'rubygems'
require 'curb'
unless ARGV.size == 2
puts "Usage: \n #{$0} url delay"
exit
end
url = ARGV[0]
delay = ARGV[1]
puts "Checking " + url + " every " + delay + " seconds"
while 1
time = Time.now
# url = URI.parse('http://www.google.com')
begin
p = Curl::Easy.perform(url).r... | true |
72c2d76aebb594118e1abd5d4d965c05abfb78ff | Ruby | ozfortress/serveme | /app/services/ftp_zip_file_creator.rb | UTF-8 | 787 | 2.640625 | 3 | [] | no_license | # frozen_string_literal: true
class FtpZipFileCreator < ZipFileCreator
def create_zip
tmp_dir = Dir.mktmpdir
begin
reservation.status_update("Downloading logs and demos from FTP")
server.copy_from_server(files_to_zip, tmp_dir)
zip(tmp_dir)
chmod
ensure
FileUtils.remove_entry... | true |
8edf90ca170eb15bb12c8f91d6ff78583832ab18 | Ruby | Automatic365/module_3_diagnostic | /app/models/station.rb | UTF-8 | 292 | 2.671875 | 3 | [] | no_license | class Station < OpenStruct
def self.service
StationService.new
end
def self.search_locations_by_zipcode(params)
raw_stations = service.search_locations_by_zipcode(params)
raw_stations["fuel_stations"].map do |raw_station|
Station.new(raw_station)
end
end
end
| true |
c99e621c1a8ad82b8da2c6592a1e141d6ebd635d | Ruby | khotta/simple_rotate | /lib/simple_rotate/internal/process_sync.rb | UTF-8 | 3,492 | 2.53125 | 3 | [
"MIT"
] | permissive | require_relative "./process_sync_mixin"
class SimpleRotate
class ProcessSync
include ProcessSyncMixin
ProcessSyncMixin.instance_methods.each do |method_name|
method = instance_method(method_name)
define_method(method_name) do |*args|
# common execution
... | true |
e50cc699cbd052455f374f978cc49286ec49650e | Ruby | Brandan-Hummell/blocipedia | /db/seeds.rb | UTF-8 | 464 | 2.5625 | 3 | [] | no_license | require 'faker'
5.times do
User.create!(
email: Faker::Internet.unique.email,
password: Faker::Internet.password(6, 10),
role: :standard
)
end
users = User.all
20.times do
Wiki.create!(
title: Faker::Witcher.character,
body: Faker::Witcher.quote,
user: users... | true |
3bf1fd6132499fc1077558cb1d13faf006bd60d3 | Ruby | ossert/ossert | /lib/ossert/classifiers.rb | UTF-8 | 3,216 | 3.046875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'ossert/classifiers/base'
require 'ossert/classifiers/decision_tree'
require 'ossert/classifiers/growing'
require 'ossert/classifiers/cluster'
require 'ossert/classifiers/check'
module Ossert
module Classifiers
module_function
# The list of available data sections.
... | true |
243d48ab596ff1ccf040011e581d71ac8728fdb4 | Ruby | menor/dbc_flashcards_and_todos | /part4_ruby-todos-2-additional-features-challenge/solutions/sample_19.rb | UTF-8 | 4,053 | 3.421875 | 3 | [] | no_license | require 'csv'
require 'date'
class CSVParser
def self.load
test = []
CSV.foreach('todo3.csv', { headers: true, header_converters: :symbol }) do |row|
test << Task.new(row.to_hash)
end
test
end
end
class Task
attr_reader :todo, :index, :completion_date, :creation_date, :tags
attr_acces... | true |
355ced9d1b46d49c6582b867bc688141ec06e9a0 | Ruby | ecmerchant/Somali | /app/models/product.rb | UTF-8 | 10,432 | 2.578125 | 3 | [] | no_license | class Product < ApplicationRecord
require 'uri'
require 'open-uri'
require 'nokogiri'
require 'date'
def collect(user, data)
logger.debug("====== Collect ========")
asin = data[0]
logger.debug(asin)
check1 = data[9].to_s
check2 = data[14].to_s
check3 = data[18].to_s
logger.debug(... | true |
5bc9c843a76ed724c34c78a9c8958f63f0d0e56e | Ruby | k-kibi/codeiq_solutions | /1621/1621.rb | UTF-8 | 717 | 3.640625 | 4 | [] | no_license | require 'pp'
def count_prime(num)
# 0〜numのindexを持つ配列を作る
list = Array.new(num+1)
2.upto(num/2) do |i|
list[i*2] = 1
end
prime = 3
while prime * prime < num
#puts "prime: #{prime}"
prime.step(num/prime, 2) do |i|
list[i*prime] = 1
end
#list.each_with_index do |n, i|
# print "#{... | true |
9878e3c98c84837745545848996d3cc7498ed102 | Ruby | AnnaGulstine/ruby_exercises | /calc_3.rb | UTF-8 | 1,440 | 4.5 | 4 | [] | no_license | # In this example, we have THREE calculators, the two included in the previous
# exercises as well as Whiz Bang Calculator that can even calculate the
# hypotenuse of a triangle if given the length of the other two sides. Figure
# out how to DRY up all the code below - there shouldn't be a single method
# duplicated be... | true |
6fa7bea059cf34ce278f81bb1aafeb976f1fdbfa | Ruby | oveja87/D3_crossfilter_movie_connection_demo | /app/workers/filmography_scanner_worker.rb | UTF-8 | 1,947 | 2.625 | 3 | [] | no_license | # encoding: UTF-8
class FilmographyScannerWorker
include Sidekiq::Worker
sidekiq_options :queue => :filmography
def perform(imdb_id)
imdb_id = imdb_id.pop
doc = PersonCrawler.person_data(imdb_id)
f = doc.at('#filmography')
if f && (f.at('div[data-category="actor"]') || f.at('div[data... | true |
9caeb94791350682c0bd6c842e14f50b520e39ee | Ruby | ja-laporte/launch-school | /LS_Prep/More_Stuff/more_stuff_exercises/ex3.rb | UTF-8 | 698 | 3.625 | 4 | [] | no_license | # what_is_exception_handling.rb
# My answer:
<<-HERE
Exception handling is the process by which a programmer can "catch" error instances and trace them back to their origin in hopes of trying to determine the cause of the error. It solves having to dig around in your code with no idea where an issue may have occurred... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.