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
bba1b4cb00b3495497435314f760db03820c86f2
Ruby
sergiiss/markdown_parser
/lib/markdown-parser/header_first_or_second_level.rb
UTF-8
1,113
3.109375
3
[]
no_license
module MarkdownParser class HeaderFistOrSecondLevel attr_reader :converted_characters def initialize(converted_characters) @converted_characters = converted_characters end def convert_headers_first_or_second_level_in_html headers_to_find_and_transform converted_characters end ...
true
1c84e9ff8e8a30de9ac53f063160846e4a9e0719
Ruby
HusnaAhad/ppl_uk
/features/support/pages/app.rb
UTF-8
497
2.625
3
[]
no_license
class App attr_accessor :browser @@browser ||= Watir::Browser.new ('chrome').to_sym @@browser.window.maximize @@browser.cookies.clear def self.method_missing(method_name, *arguments, &block) # Initializes App.page_object if it doesn't already exist @@pages ||= {} class_name = method_name.to_...
true
b806d6517fb4fa04547ff38bd39e6186af0b4fe3
Ruby
aaduru/course-work
/w2d3/TDD/spec/practice_spec.rb
UTF-8
1,605
3.328125
3
[]
no_license
require "practice" describe "monkey patching" do # my_uniq array test cases describe "#my_uniq" do subject(:array) {[1,2,2,3,3,4,4,5]} it "receives an array and returns an array" do expect(array.my_uniq).to be_an(Array) end it "returns unique array" do expect(array.my_uniq).to eq([1,2,3,...
true
e600d4999a37164c3fa9e8dbdb1350acae379e52
Ruby
lishiyo/App-Academy-Projects
/wordchains/word_chains.rb
UTF-8
1,938
3.8125
4
[]
no_license
require 'set' class WordChainer def initialize(dictionary_filename = 'dictionary.txt') @dictionary = File.readlines(dictionary_filename).map(&:chomp).to_set end def run(source, target) @dictionary = @dictionary.select{|word| word.length == source.length } @current_words = [source] @all_seen_words = { so...
true
5f753688f6fc93afa5659e9be6743031c4920abe
Ruby
maneta/rails_services
/weather/geographic_location.rb
UTF-8
382
2.796875
3
[]
no_license
class GeographicLocation attr_reader :place, :options MAPPINGS_FILE = "#{Rails.root}/config/specifications/marine_locations.yml" def initialize place, options = {} @place = extract_location place.to_s.downcase @options = options end def to_s place.to_s end private def extract_location...
true
bdcded78f3709ce406254fbe714c00ffa63b7a6a
Ruby
lleibow/ruby_fundamentals1
/exercise3.rb
UTF-8
136
3.828125
4
[]
no_license
puts "What is your name?" name=gets puts "Hi #{name}!" puts "How old are you?" age=gets.to_i puts "You are born in #{2017-age}"
true
40f7c6323357c4ad65018f0d05cf81e46bc4719f
Ruby
SimonDein/launch
/course_120_oop/oop_with_ruby_book_ls_book/chpt1_the_object_model/exercises/exercise_1.rb
UTF-8
242
3.90625
4
[]
no_license
# Question: # How do we create an object in Ruby? Give an example of the creation of an object. # We create a new object by defining a class and instatiating it by using the Class#new on it. class Dog end plet = Dog.new plet.class # => Dog
true
e6dd97a676cb31e3d83e6b7d390ce880c7e25a87
Ruby
mmcdevitt/guess_who
/array.rb
UTF-8
1,476
3.296875
3
[]
no_license
class Person attr_reader :name, :gender, :skin_color, :hair_color, :eye_color def initialize(name, gender, skin_color, hair_color, eye_color) @name = name @gender = gender @skin_color = skin_color @hair_color = hair_color @eye_color = eye_color end mike = Person.new("mike", "male", ...
true
1cd0ce26ed665353b858aee40872295172c53e3b
Ruby
rsmease/homework-app-academy
/W2D2/notes.rb
UTF-8
3,008
3.140625
3
[]
no_license
#Non-Technical Aspects of Ruby #Dynamic programming language is one that can excute a lot of common programming behaviors at runtime (which static languages have to manage during compilation) #Dynamic programming languages can be more easily abstracted, metaprogrammed and simplified, but they are slower to run than sta...
true
927bb3bf07304cdfd7460ee4e4279eb8fc113568
Ruby
AndrewYW/aA-W1D5
/skeleton/lib/KnightPathFinder.rb
UTF-8
2,068
3.796875
4
[]
no_license
require_relative "00_tree_node" class KnightPathFinder attr_reader :root_node def self.valid_moves(pos) x, y = pos result_array = [] [-2,2].each do |i| [-1, 1].each do |j| result_array << [x+i,y+j] if KnightPathFinder.inbounds(x+i, y+j) result_array << [...
true
88edade51a86390e3beec0bd89e75556764a4d08
Ruby
jeffmjwong/solar-power-generation-and-consumption
/spec/main_spec.rb
UTF-8
1,986
2.734375
3
[]
no_license
require './src/main' RSpec.describe Main do describe '#run' do let(:current_directory) { File.dirname(__FILE__) } let(:solar_generation_file_path) { '../data/01-solar_generation.csv' } let(:energy_consumption_file_path) { '../data/02-consumption.csv' } let(:household_information_file_path) { '../dat...
true
05d03d41c9e8246570f9c6479c7909a5243e11b6
Ruby
landerton/simpalytics
/FlurryApi.rb
UTF-8
3,859
3.125
3
[]
no_license
require 'yaml' require 'curb' require 'json' class FlurryApi # Initialize the following: # * Yaml configuration parameters def initialize @config = YAML::load(File.open('parameters.yml'))['flurry'] end # Get all defined metrics for all apps defined in the config yaml file # for a giv...
true
e4edab9535861eda7165d0fd7cf22c5387263fbc
Ruby
cminnerath/night_writer
/test/night_writer_test.rb
UTF-8
689
2.8125
3
[]
no_license
require './lib/night_writer' require 'minitest/autorun' require 'minitest/pride' class NightWriterTest < Minitest::Test def test_it_can_take_in_a_braille_input_file_and_seperate_lines testwriter = NightWriter.new("./data/input_fixture.txt") assert_equal ["0.0.0.0.0....00.0.0.00", "00.00.0..0..00.0000..0", "....
true
b06c229f6c567d82034e10ecb9abac53d55435b4
Ruby
DGaffney/news
/lib/model/setting.rb
UTF-8
488
2.703125
3
[]
no_license
class Setting include MongoMapper::Document key :name, String, :required => true key :value def self.method_missing(method, *args) return set_value(method.to_s.chop, args.first) if method.to_s.strip.last == "=" if setting = Setting.first(:name => method.to_s) return setting.value else ...
true
6de28603f1bbc621955141691df9d66db0160e38
Ruby
Kulabuhov-Alexey/askme
/app/models/user.rb
UTF-8
3,146
2.859375
3
[]
no_license
require 'openssl' class User < ApplicationRecord ITERATIONS = 20_000 DIGEST = OpenSSL::Digest::SHA256.new USER_NAME_FORMAT = /\A\w+\z/ attr_accessor :password has_many :questions validates :email, presence: true, uniqueness: true, format: {with: URI::MailTo::EMAIL_REGEXP} valid...
true
de2874b86e41761e5e9c48ec6890c12e5da976d7
Ruby
mxhold/opted
/lib/opted/result/match.rb
UTF-8
1,552
2.671875
3
[ "MIT" ]
permissive
module Opted module Result module Match def self.match_value(value, &block) Matcher.new(OkMatch.new(value)).match(&block) end def self.match_error(error, &block) Matcher.new(ErrMatch.new(error)).match(&block) end class Matcher def initialize(match) ...
true
0d6c433eb6bda1c7b0e355fc56727336d28be183
Ruby
liam619/cloud_project
/app/helpers/application_helper.rb
UTF-8
667
2.578125
3
[]
no_license
module ApplicationHelper def full_title(page_title = '') base_title = "YourBook" if page_title.empty? base_title else page_title + " | " + base_title end end # For nav tab, active the correct tab def is_active?(link_path) link_path.include?(request.path) ? "active" : "" end ...
true
91c2b51da97f33c4abfba039092b301339a42eea
Ruby
matzryo/youtube-slack-cooperation
/youtube.rb
UTF-8
1,799
2.5625
3
[]
no_license
require "google/apis" require "google/apis/youtube_v3" require "googleauth" require "googleauth/stores/file_token_store" require "fileutils" require "json" class YouTube def initialize( redirect_uri: "urn:ietf:wg:oauth:2.0:oob", application_name: "YouTube Data API Ruby Tests", client_secrets_path: "clien...
true
40dd622ffd4aaac6fc5906c92a7fad1d2c6aab4b
Ruby
igorsimdyanov/ruby
/blocks/block_return.rb
UTF-8
263
3.921875
4
[]
no_license
def greeting name = block_given? ? yield : 'world' "Hello, #{name}!" end puts greeting # Hello, world! puts greeting { 'Ruby' } # Hello, Ruby! hello = greeting do print 'Пожалуйста, введите имя ' gets.chomp end puts hello
true
ae0d95e8810f19f96621ab3d9af217ee2cdfcba6
Ruby
srirambtechit/ruby-programming
/modules/mymoral.rb
UTF-8
90
2.828125
3
[]
no_license
module Moral VERY_BAD = 0 BAD = 1 def Moral.sin(badness) puts badness end end
true
16e29c28e43ba2a9f45cf1f3488eecb3112cf673
Ruby
gumroad/epub-parser
/lib/epub/ocf/physical_container/zipruby.rb
UTF-8
1,107
2.671875
3
[ "MIT" ]
permissive
require 'zipruby' if $VERBOSE warn <<EOW [WARNING]Default OCF physical container adapter will become ArchiveZip, which uses archive-zip gem to extract contents from EPUB package, instead of current default Zipruby, which uses zipruby gem, in the near future. You can try ArchiveZip adapter by: 1. gem install archive...
true
4545240ff05cf79badc2e081349099af51c51d5d
Ruby
mkrahu/launchschool
/exercises/small_problems/vers2/easy_9/grade_book.rb
UTF-8
385
3.90625
4
[]
no_license
# grade_book.rb # Launch School 101-109 Small Problems Exercises (2nd time through) def get_grade(grade1, grade2, grade3) average_grade = (grade1 + grade2 + grade3) / 3 case average_grade when 90..100 then 'A' when 80...90 then 'B' when 70...80 then 'C' when 60...70 then 'D' when 0...60 then 'F' end e...
true
535b9c00cb51f15ae848ca3092176877100eee72
Ruby
shaqsinc22/wknd_4
/algo/missing_letter.rb
UTF-8
1,276
4.3125
4
[]
no_license
# Return the missing letter from a given range of letters passed into the method # as a string. If there is no missing letter, the method should return nil. # bonus: returns a string of all missing letters as a string. ex: find_missing_letter("ace") would return "bd", write your own test. #97 - 122 def find_missing_let...
true
6cf7c78062cccdfef2f8696526bf23ad935cf086
Ruby
alphagov-mirror/signon
/db/migrate/20171108144303_model_dit_org_structure.rb
UTF-8
1,260
2.6875
3
[ "LicenseRef-scancode-proprietary-license", "MIT" ]
permissive
class ModelDitOrgStructure < ActiveRecord::Migration def up dit = Organisation.find_by(name: "Department for International Trade") missing_orgs = [] ["Export Control Organisation", "Department for International Trade Defence & Security Organisation"].each do |child_name| org = Organisation.find_by...
true
41588de8b0f6df49f14b43f3dd931b994c440ee0
Ruby
afast/map_print
/bin/map_print
UTF-8
1,728
2.8125
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require 'thor' require 'bundler/setup' require 'map_print' class MapPrintCommand < Thor desc "print", "Print a map using the given parameters" method_option :south_west, type: :string, required: true method_option :north_east, type: :string, required: true method_option :width, type: :nu...
true
f0336f476138b124a76bf8febe8ec9b5bf299150
Ruby
Chris29tate2/operators-online-web-pt-120919
/lib/operations.rb
UTF-8
277
2.84375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def unsafe?(speed) return true if speed is > speed = 60 return false if speed is between = 40 & 50 answer = 35 end def not_safe?(speed) return true if speed is > than 60 return false if speed is between 40 & 60 return if the speed is < than 40 answer = 79 end
true
c43231d69b614eb9af58633bf916a80935e5c64f
Ruby
NickRaleigh/hashbase
/hash/class/write.rb
UTF-8
1,077
2.734375
3
[]
no_license
module Write def write i=@select.count hashLocation = @select["hashLocation"] hashID = @select["hashID"] rmFile(hashLocation) touchFile(hashLocation) while i > 0 open(hashLocation, 'a') { |f| f.puts "$#{hashID} = {\n"} @select.each do |k, v| if i > 1 i...
true
6427d07966fdd817ed8aa805213b3410a959ff7c
Ruby
FabioLibonati/Exemplos
/Exemplos da aula/lacos.rb
UTF-8
495
4.25
4
[ "MIT" ]
permissive
=begin valor = 0 while valor < 10 puts "O valor é #{valor}" break if valor == 5 valor += 1 end =end =begin range = 0..5 for meu_valor in range # range é gual a [0, 1, 2, 3, 4, 5] puts "O meu valor é #{meu_valor}" end =end =begin lista = [0, 1, 2, 3, 4, 5] lista.each do |meu_valor| puts "Me...
true
bcfd1c95b580aa01e09bce169203d88e43cbe21b
Ruby
sul-metadata/stanford-library-metadata
/spec/apps/authority_lookup/authority_lookup_spec.rb
UTF-8
2,941
2.671875
3
[]
no_license
require '../apps/authority_lookup/authority_lookup' require '../apps/authority_lookup/file_parser' require './spec_helper' RSpec.describe AuthorityLookup do before(:all) do @authority_lookup_test = AuthorityLookup.new(['Dorothy Dunnett'], 'LOCNAMES_RWO_LD4L_CACHE', 'https://lookup.ld4l.org/authorities/search/li...
true
1376439e33116d941c49f0a975df63240f7eec73
Ruby
GKhalsa/the_scout
/app/models/calculator.rb
UTF-8
395
2.96875
3
[]
no_license
class Calculator def self.calculate_profit(item) begin profit = ((item.lowest_amazon_price.to_i / 100.0) - item.salePrice).round(2) rescue Item.find(item.id).destroy end end def self.calculate_margin(item) # begin profit = calculate_profit(item) margin = (profit/(item.low...
true
56eb03db5652a7435818f72238ab388752e5f46a
Ruby
omidbachari/game_gosu
/player.rb
UTF-8
2,524
3.078125
3
[]
no_license
require 'gosu' require_relative 'bullet' class Player attr_accessor :bullet, :x, :y, :go_right, :go_left, :running_right, :running_left, :direction, :height, :shoot_ready, :bullets, :x3 def initialize(window) @window = window @player = Gosu::Image.new(@window, "images/player_right/player1.png") @player...
true
5884aa458a9749cd1d968b44665b4cbe1fc07761
Ruby
topazproject/topaz
/spec/testffi/spec/ffi/enum_spec.rb
UTF-8
8,153
2.765625
3
[ "BSD-3-Clause" ]
permissive
# # This file is part of ruby-ffi. # For licensing, see LICENSE.SPECS # require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper")) module TestEnum0 extend FFI::Library end module TestEnum1 extend FFI::Library ffi_lib TestLibrary::PATH enum [:c1, :c2, :c3, :c4] enum [:c5, 42, :c6, :c7, :c8]...
true
c94ebff54970b2a584b3d36e4aa7256a1d04ee82
Ruby
microsoftgraph/msgraph-sdk-ruby
/lib/models/attribute_definition.rb
UTF-8
15,468
2.625
3
[ "MIT" ]
permissive
require 'microsoft_kiota_abstractions' require_relative '../microsoft_graph' require_relative './models' module MicrosoftGraph module Models class AttributeDefinition include MicrosoftKiotaAbstractions::AdditionalDataHolder, MicrosoftKiotaAbstractions::Parsable ## # Sto...
true
84a6c832c55fff2b065147b264c984308391424b
Ruby
Nejuf/checkers
/Board.rb
UTF-8
7,304
3.203125
3
[]
no_license
require_relative 'errors' require_relative "Piece" require 'colorize' class Board protected attr_accessor :piece_positions public attr_reader :piece_positions def initialize @show_help_board = true setup end def setup @piece_positions = Hash.new (1..12).each do |num| @piece_position...
true
95635411441384573d5b2f8c9c21823b9c56bc86
Ruby
SebastianStorz/rubystuff
/loops.rb
UTF-8
386
3.796875
4
[]
no_license
# for index in 0..5 # puts index # end # 5.times do |index| # puts index # end arr = ["affe", "hund", "katze"] # for var in arr # puts var # end arr.each do |var| puts var end while false puts "this is never gonna happen :D" end #this loop is terminated with break, so its basically the most fl...
true
f5412af9b387dadce337325361cd36bfc6ffc4bf
Ruby
judofyr/kramer
/lib/kramer/dsl.rb
UTF-8
4,136
2.578125
3
[]
no_license
require 'kramer' module Kramer module DSL def self.load(filename) parse(File.read(filename)) end def self.parse(str) res = nil res = Grammar.new(str) raise res.failure_message unless res.success? g = Class.new(Kramer::Grammar) class << g attr_accessor :current...
true
f23ee7f8c5f3e42ae73ffa7857ef6f95f0feddf3
Ruby
Adubz97/m2m-template
/tools/console.rb
UTF-8
824
2.78125
3
[]
no_license
require_relative '../config/environment.rb' # create test data/variables here avengers= Movie.new("Avengers", "action") snowpiercer=Movie.new("Snowpiercer", "action") #movie.name #puts Movie.find_all_movies_by_name("Avengers") rdj= Actor.new("RDJ") chris_evans=Actor.new("Chris Evans") MovieActor.new(avengers, rdj) tr...
true
fbc83e81bfd43b6a58e5420f2e29a79bd033c2d7
Ruby
imeyer/fugu
/lib/fugu.rb
UTF-8
1,594
3.234375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require 'array' class Fugu attr_accessor :text, :delimiter def self.puff(string) f = self.new f.text = string f.puff end def puff hosts = @text.split('|').collect do |range| if range.match(/\{/) before, expand_string, after = range.scan(/(.*)\{(.*)\}(.*)/)[0] expanded_s...
true
edfb44758065ec0e47521f8be305ea0f0d61f334
Ruby
Diley/studio_game
/fundraising_program/lib/fundraising_program/die.rb
UTF-8
140
2.84375
3
[ "MIT-0", "MIT" ]
permissive
module FundraisingProgram class Die attr_reader :number def initialize roll end def roll rand(1..5) end end end
true
1bdedafcf415cea03c90ccdd7a79955aed06fa6c
Ruby
nikitavasilev/intro_to_ruby
/exo_17.rb
UTF-8
569
3.78125
4
[]
no_license
puts "Cher utilisateur, quelle est votre année de naissance ?" print "> " year_of_birth = gets.chomp.to_i counter = 2018 - year_of_birth i = 0 counter.times do if i == 0 puts "Il y a #{counter} ans vous aviez moins d'un an." elsif i == 1 puts "Il y a #{counter} ans vous aviez 1 an." elsif counter == 1 puts "...
true
b90a313cc22d6265ad643a979bfcdf8452d0918f
Ruby
Ultragreen/rrobots
/lib/bullets.rb
UTF-8
1,453
3.03125
3
[ "Ruby" ]
permissive
class Bullet attr_accessor :x attr_accessor :y attr_accessor :heading attr_accessor :speed attr_accessor :energy attr_accessor :dead attr_accessor :origin def initialize bf, x, y, heading, speed, energy, origin @x, @y, @heading, @origin = x, y, heading, origin @speed, @energy = speed, energy ...
true
5a84a2363e0b0885248107314134d2ed1bfe48a0
Ruby
johnae/role_playing
/lib/role_playing/context.rb
UTF-8
724
2.5625
3
[ "MIT" ]
permissive
module RolePlaying module Context def self.included(base) base.extend(ClassMethods) end module ClassMethods ## this seemed too dangerous to use ## it enabled us to use Constants when ## defining roles but would also not ## warn about missing constants - which is pretty bad ...
true
78cdcb20dc103da9a456bfa67e4de4d4a2ff1b4b
Ruby
cEhlen/101rails
/app/adapters/books_adapters/test_adapter.rb
UTF-8
185
2.6875
3
[]
no_license
module BooksAdapters class TestAdapter attr_accessor :books def initialize(books=[]) @books = books end def get_books(title) @books end end end
true
6e71de2380bc8ae63673b92c25345ad97e0f8c3b
Ruby
oleksiivykhor/movie_finder
/lib/finders/base_finder.rb
UTF-8
725
2.515625
3
[]
no_license
class BaseFinder include Capybara::DSL MANDATORY_METHODS = [:search_process, :data_collection] FIELDS = [:title, :genres, :rating, :year] def initialize(search_request) Capybara.current_driver = driver @search_request = search_request end def visit_site visit self.class::SITE_URL end def...
true
5999ad22e90b6049528761df044d54da0ba220b1
Ruby
amycen/guessing-cli-prework
/guessing_cli.rb
UTF-8
533
3.890625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Code your solution here! require "pry" def run_guessing_game your_guess = nil play = true while play puts "Guess a number between 1 and 6." your_guess = gets.chomp if your_guess == "exit" puts "Goodbye!" break elsif (1 .. 6).include? (your_guess.to_i) comp_guess = rand(1 .. 6) ...
true
07bc6364bec3995fcc3e5bba5e861b70eeaf840b
Ruby
hgally1/guided-module-one-final-project-houston-web-100818
/lib/CLI/cli.rb
UTF-8
3,250
3.53125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require_relative '../config/environment' $prompt = TTY::Prompt.new $start_menu_choices = { "Search haunts by name" => 0, "Search haunts by location" => 1, "Search haunts by type of haunting" => 2, "Exit" => 3 } $type_of_haunting_menu_choices = { "Poltergeist" => 0, "Demonic" => 1, "Apparations" => 2, ...
true
7eb640c736481c14318af132d7dd21873f79cb6e
Ruby
johnisom/ruby-object-oriented-problems
/classes-and-objects-1/3.rb
UTF-8
428
3.953125
4
[]
no_license
# Exercise 3 class MyCar attr_accessor :color attr_reader :year def initialize(year, color, model) @year = year @color = color @model = model @speed = 0 end def speed_up(amount) @speed += amount end def brake(amount) @speed -= amount end def shutoff @speed = 0 end ...
true
21848ac3c82c3c2595529832a1ccaddec3a16c64
Ruby
d0nn13/VolcanoFTP
/lib/volcano_ftp/command/list.rb
UTF-8
1,725
2.671875
3
[]
no_license
# ==== LIST ==== # Transfers the contents of the current working directory class FTPCommandList < FTPCommand def initialize(path) super() @code = 'LIST' @args << path unless path.nil? @ls_cmd = 'ls -l' end def do(client) begin session = client.session raise FTP530 unless session.l...
true
ff08b137159f9a0fc64a4968fb92c6e13abe5ecf
Ruby
sonianand11/feeback_app
/app/models/client_info.rb
UTF-8
2,827
2.59375
3
[]
no_license
class ClientInfo < ActiveRecord::Base has_many :child_infos has_one :investment_type has_one :house has_one :vehicle # gives set of objects of clients which have birthday at present day def self.birthday_reminder return self.select{|client| client.date_of_birth.month == Date.today.month and client.date...
true
406962f7e9a95a00e4f8a315a22fa477a336f895
Ruby
mort/prpgtn
/lib/link_fetcher.rb
UTF-8
1,153
2.609375
3
[]
no_license
require 'opengraph' require 'pismo' require 'open_uri_unsafe_redirections' class LinkFetcher def self.fetch(m) data = begin OGFetcher.fetch(m) rescue OGFail PismoFetcher.fetch(m) rescue PismoFail {:og_url => m, :og_title => nil, :og_description => nil, :fetch_method => nil} ...
true
75cb4307855a2875efccb99bf095ed48f78bbf0c
Ruby
jimlengel/composition-module-inheritance
/vegan_food.rb
UTF-8
490
3.078125
3
[]
no_license
require_relative 'expire' require_relative 'fridge' class VeganFood # all vegan food expires - require module include Expire attr_accessor :age CONTAINS_NO_MEAT = true def initialize(args = {}) @age = args.fetch(:age, 0) end def check_if_expired expire?(@age, self.class::VEGAN_FOOD_EXPIRATION...
true
bcc80565261fe2e61503dcc74673ee61a2daa714
Ruby
carlhashmi/translations-manager
/lib/translations_manager/yaml_tree_reader.rb
UTF-8
1,159
2.53125
3
[ "MIT" ]
permissive
# frozen_string_literal: true require_relative 'locale_file_walker' module TranslationsManager class YamlTreeReader < LocaleFileWalker attr_reader :tree, :anchors def initialize(filename) @filename = filename @tree = { children: {} } @anchors = {} end def read @stream = par...
true
191be76575c52df9d130d0e622c2684b0512f0e5
Ruby
lucasdonuts/chess
/spec/knight_spec.rb
UTF-8
1,072
3.59375
4
[]
no_license
require './lib/pieces/knight.rb' describe Knight do board = Board.new white_knight = board.board[1][0] black_knight = board.board[1][7] describe "#initialize" do it "should create a knight piece with the color white" do expect(white_knight.color).to eq(:white) end it "should create a knight...
true
49a4aaa036b42ad53fc90ad81b4df2e3d050504b
Ruby
gitter-badger/sea-c21-ruby-1
/lib/class3/exercise1.rb
UTF-8
799
3.734375
4
[ "MIT" ]
permissive
# Section 7.5 on page 49 # 5 points # # Write a program that prints out the lyrics to that beloved classic, # "99 Bottles of Beer on the Wall." Here's what the output should look like: # # 99 bottles of beer on the wall, 99 bottles of beer! # Take one down, pass it around, 98 bottles of beer on the wall! # 98 bottles o...
true
c973d1581ce00b1fdfe04d98e697a78b0b9bf138
Ruby
bonochof/sudoku-solver
/exhaustive/print_grid.rb
UTF-8
123
3
3
[]
no_license
def print_grid (grid, pad=" ") print (0..8).collect{|i| grid[9*i, 9].collect{|v| v || '.'}.join('')}.join(pad), "\n" end
true
322bd7f0dd5ca9fc2338c26fb0f353e1f15a7aea
Ruby
norman/friendly_id
/lib/friendly_id/base.rb
UTF-8
11,234
3.1875
3
[ "MIT" ]
permissive
module FriendlyId # @guide begin # # ## Setting Up FriendlyId in Your Model # # To use FriendlyId in your ActiveRecord models, you must first either extend or # include the FriendlyId module (it makes no difference), then invoke the # {FriendlyId::Base#friendly_id friendly_id} method to configure your des...
true
5bee70f5695e8e507269b95edf30a01c1e9c6597
Ruby
janebranden/launch-school-intro-to-programming
/04_flow/flow2.rb
UTF-8
755
4.53125
5
[]
no_license
# flow2.rb # Write a method that takes a string as argument. # The method should return the all-caps version of the string, only if the string is longer than 10 characters. # Example: change "hello world" to "HELLO WORLD". (Hint: Ruby's String class has a few methods that would be helpful. Check the Ru$ puts "Enter...
true
4fc6244ccdbd5a422881ade25741f8508c29d77e
Ruby
floatbox/steam_revenue
/app/models/borrower.rb
UTF-8
3,211
2.640625
3
[]
no_license
# frozen_string_literal: true # == Schema Information # # Table name: borrowers # # id :integer not null, primary key # title :string not null # amount :decimal(12, 2) not null # date_of_loan :date not null # term_in_months :i...
true
3e55a965d857b5512609bf08ea77b21d2cad19ea
Ruby
troystribling/studium_ruby
/scripts/sort.rb
UTF-8
494
3.4375
3
[]
no_license
def merge(a1, a2) n1, n2 = a1.length, a2.length n = n1 + n2 i, j = 0, 0 b = [] n.times do |k| if i >= n1 b[k] = a2[j] j += 1 elsif j >= n2 b[k] = a1[i] i += 1 elsif a1[i] < a2[j] b[k] = a1[i] i += 1 else b[k] = a2[j] j += 1 end end b end def has_substring(str, substr) m = subs...
true
32a53a5f6ca65a58970cac877b09041136907d49
Ruby
ashhamp/coffee-findah
/models/geocode_address.rb
UTF-8
871
3.015625
3
[]
no_license
require "net/http" require "json" require 'dotenv' Dotenv.load class GeoCodeAddress attr_reader :street, :town, :state, :data def initialize(street, town, state) @street = street @town = town @state = state @data = create_geocode_data end def lat @data['results'].first['geometry']['locati...
true
b23e7f94dd3234704546176c0cf0de2d8160041a
Ruby
ddcornwell/Ruby-track
/ruby/gps2-2.rb
UTF-8
2,835
4.40625
4
[]
no_license
# Create a new list # Add an item with a quantity to the list # Remove an item from the list # Update quantities for items in your list # Print the list (Consider how to make it look nice!) # Method to create a list # input: string of items separated by spaces (example: "carrots apples cereal pizza") #define ...
true
46d6e90372e4cd0d2a248f98c13786bbf5848029
Ruby
RSMP/abc_parser
/lib/abc/file.rb
UTF-8
974
2.859375
3
[ "MIT" ]
permissive
module ABC class File attr_reader :parsed, :version, :tunes, :header def initialize(filepath) @filepath = filepath @file = ::File.open(@filepath, "r") {|f| f.read} @parsed = false parse end def parsed? parsed end private def parse @sections = @file.spli...
true
1e6f77855f79cc116742eb75a6f6715df6b0bd71
Ruby
per-pro/aaclasswork
/W4D5/execution_time_diff.rb
UTF-8
1,275
3.796875
4
[]
no_license
require "byebug" def my_min(list) min = list.first list.each { |el| min = el if min > el } min end # list = [ 0, 3, 5, 4, -5, 10, 1, 90 ] # p my_min(list) # => -5 # def largest_contiguous_subsum(list) # arr = [] # x = 0 # while x < list.length # # debugger # y = x # ...
true
728dc3d1c6ad06cff66fb9d03748611b0242c507
Ruby
erikbenton/AppAcademyFullStackOnline
/Ruby/LRU/LRU_Cache_homework/lru_cache.rb
UTF-8
959
3.5625
4
[]
no_license
class LRUCache def initialize(size) @size = size @store = [] end def count @store.count { |el| !el.nil? } end def add(el) eject(el) @store.push(el) # Add to store chop end def show p @store end private def eject(el) @store.delete(el) if @store.include?(el) end ...
true
e64c65a824caf6dbe31bcccbac638ac3cf730c69
Ruby
fafafariba/Chess
/rook.rb
UTF-8
239
2.9375
3
[]
no_license
require_relative 'piece' require 'sliding_piece_mod' class Rook < Piece include SlidingPiece def initialize(color, position) @value = "\u265C" @position = position @directions = [:horiz, :vert] super(color) end end
true
46502ac153a735d80851f533c487d1c4859fe69d
Ruby
tmdgusya/DailyAlgorithMultipleLang
/filter_non_unique/filter_non_unique.rb
UTF-8
182
3.296875
3
[]
no_license
def filter_non_unique(list) list.select {|val| is_duplicate(list.count(val))} end def is_duplicate(val) val < 2 end print filter_non_unique([1, 2, 2, 2, 3, 3, 4, 5, 9, 9])
true
b030f37ff9c89f9a87b41d852ea8ec7bbab96ce3
Ruby
eternal44/myrubyprograms
/1_week/1c_year_months.rb
UTF-8
1,348
4
4
[]
no_license
# doctest: convert age to a whole year # >> ages = 979000000 # >> seconds_to_years_and_months(ages) # => "I'm 31 years old." # doctest: convert age to a year and some months # >> seconds_to_years_and_months(300_000_000) # => "I'm 9 years and 6 months old." # This method takes your age in seconds and converts it to ye...
true
930f706820ee6d10dee1a22d678a694e5ab93c4a
Ruby
Pablitob/prueba-1
/app/models/instructor.rb
UTF-8
890
2.546875
3
[]
no_license
class Instructor < ActiveRecord::Base #Atributos accesibles attr_accessible :cedula, :direccion, :email, :fch_ncto, :materia_id, :nombres, :telefono #Metodo de Busqueda def self.search(search) where("nombres like '%#{search}%' or email like '%#{search}%' or telefono like '%#{search}%' or direccion like ...
true
314a5b83538fe1c5869003146378378c88dc147d
Ruby
ashucoding/learn-co-sandbox
/trending_foods/lib/trending_foods/scraper.rb
UTF-8
548
2.890625
3
[ "MIT" ]
permissive
class TrendingFoods::Scraper URL= "https://www.wholefoodsmarket.com/tips-and-ideas/top-food-trends" def self.scrape_trending_foods foods = [] doc= Nokogiri::HTML(open(URL)) food_nodes = doc.css(".w-cms-richtext") food_nodes.shift food_nodes.each do |food_node| food_title = food_nod...
true
8a083ae499a86809bc38fb0facc17eb2944eef1d
Ruby
lordmortis/CuzzaScores
/app/models/game.rb
UTF-8
498
2.6875
3
[]
no_license
class Game < ActiveRecord::Base has_many :scores, :dependent => :destroy def score_table if cumulative values = scores.joins(:nickname).group(:name).sum(:value) else values = scores.joins(:nickname).group(:name).maximum(:value) end output = Array.new values.keys.each do |name| output << {:name ...
true
2bdf0fe8102b15140106b5f6a7bae0ed643de1c4
Ruby
apeiros/baretest
/lib/baretest/invalidselectors.rb
UTF-8
499
2.515625
3
[ "Ruby", "LicenseRef-scancode-public-domain" ]
permissive
#-- # Copyright 2009-2010 by Stefan Rusterholz. # All rights reserved. # See LICENSE.txt for permissions. #++ module BareTest # Raised by BareTest.process_selectors if one or more invalid selectors are # passed in. class InvalidSelectors < StandardError # The selectors that are invalid attr_reader :s...
true
09fe286349eac7ac70568f02de6648f3c0c0be10
Ruby
Sharpie/vagrant-config_builder
/lib/config_builder/loader/yaml.rb
UTF-8
963
2.625
3
[ "Apache-2.0" ]
permissive
require 'yaml' require 'deep_merge/core' class ConfigBuilder::Loader::YAML # Load configuration from YAML files in one or more directories # # @overload yamldir(path) # @param path [String] A directory path containing YAML files # @overload yamldir(paths) # @param paths [Array<String>] A list of direc...
true
307e45f2efa0964051ca61a6db6d98b48925af55
Ruby
sinsnk/speedtest
/lib/a1516so_speedtest.rb
UTF-8
562
3.265625
3
[ "MIT" ]
permissive
require 'time' require 'date' class A1516soSpeedTest @@s = nil # It will start the time measurement at any time.. def self.start @@s = Time.now end # after calling the start method, by calling the end method, # it is possible to measure the processing performed in the meantime. def self.end ...
true
a8b84aeb8c92efcd15b32f6ea5a37de3d8dfa056
Ruby
gcfunk/rails-fullcalendar-icecube
/test/unit/event_test.rb
UTF-8
3,750
2.859375
3
[]
no_license
require 'test_helper' describe Event do before do @event = create :event end it "should be valid" do assert @event.valid? assert @event.schedule.all_occurrences.length == 1 end describe "can repeat events" do it "repeats the event daily" do event_daily_repeat = create :event_daily_r...
true
b4893e2b8fa6cf153b5adc59aaac3d72642a82e1
Ruby
smarchante1/CtCI-6th-Edition-Ruby
/spec/ch04/4.02_spec.rb
UTF-8
413
3.296875
3
[]
no_license
require "ch04/4.02.rb" describe "4.2 Minimal Tree" do let(:array) { (1..10).to_a } describe "#array_to_bst" do it "[1,2,3] should be bst" do a = [1,2,3] root = array_to_bst(a, 0, a.length - 1) expect(stringify(root)).to eq "213" end it "array is bst" do root = array_to_bst(arr...
true
253db440ec388f165445e3bd038153ccf6b59749
Ruby
papakosh/flashlight-mystery
/node.rb
UTF-8
25,171
3.109375
3
[]
no_license
require 'ostruct' # Node class updated class Node < OpenStruct DEFAULTS = { :root => { :open => true, :can_take => false, :can_open => false, :can_see => "none", :locked => false }, # initialize hash obj to hold defaults of different node types :room => { :open => true, :can_take => false, :can_open => fa...
true
7617a6b8c782740a5455992d24be3e465dc0a0d1
Ruby
t-nagasaka/ruby-test-week-1
/02_07.rb
UTF-8
101
2.984375
3
[]
no_license
array = ["1", "2", "3", "4", "5"] # p array.map! { |sentence| sentence.to_i }\ p array.map p!(&:to_i)
true
2f844c8b862b7bd41d3692ec5d1669824e9cb4da
Ruby
sheelah/Dessert-Recipes
/app/models/recipe.rb
UTF-8
701
2.515625
3
[]
no_license
class Recipe < ActiveRecord::Base attr_accessible :name, :image_type, :data, :user_id, :ingredients, :instructions, :uploaded_picture has_many :ratings # one to many relationship with ratings belongs_to :user validates :name, :ingredients, :instructions, :user_id, :presence => true validates :name, :uni...
true
a90c13d67d018e30b523934c1a77232a7cc4f7b7
Ruby
zackmdavis/App_Academy_Exercises
/Week_1/rpn_calc.rb
UTF-8
1,576
3.5625
4
[]
no_license
class RpnCalc def initialize @stack = [] @operations = { "+" => :add, "-" => :subtract, "*" => :multiply, "/" => :divide } end def input(chars) if @operations.include? chars self.send(@operations[chars]) else @stack.push(chars.to_i) end end def push_number(n) @stack.push...
true
8b3a35294a5056ebaa2f344eb231913deb9a7199
Ruby
hexlet-basics/exercises-ruby
/modules/20-collections/40-hash-methods/test.rb
UTF-8
978
2.703125
3
[]
no_license
# frozen_string_literal: true require 'test_helper' require_relative './index' describe 'function' do it 'should works' do data = { 'Queen' => [ 'Bohemian Rhapsody', "Don't Stop Me Now" ], 'Metallica' => [ 'Nothing Else Matters' ], "Guns N' Roses" => [ ...
true
d8b7164f91015bc1340f33ee23b7f3eaf877cf88
Ruby
milevy1/backend_prework
/day_1/ex3.rb
UTF-8
779
4.34375
4
[]
no_license
# Prints text puts "I will now count my chickens:" # Prints some math, addition subtraction, multiplication and modulus puts "Hens #{25.0 + 30.0 / 6.0}" puts "Roosters #{100 - 25 * 3 % 4}" # Prints text puts "Now I will count the eggs:" # Prints some math puts 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 # Prints text puts "Is it...
true
e659903791aa94be18daff606d9190cbf18254a8
Ruby
rye/duff
/lib/duff/logger.rb
UTF-8
412
2.546875
3
[]
no_license
require 'logger' module Duff module Logging class DuffFormatter < Logger::Formatter def call(severity, time, program_name, message) "#{time.strftime '%H:%M:%S (%z)'} (#{program_name ? program_name + " " : ''}#{severity}) >>> #{msg2str(message)}\n" end end end LOGGER = Logger.new...
true
01178415edb5ca232322ded1fbf44e010d6ea8b2
Ruby
mcittar/eargo
/app/models/publication.rb
UTF-8
1,797
2.59375
3
[]
no_license
# == Schema Information # # Table name: publications # # id :integer not null, primary key # logo :string not null # name :string not null # site_type :string # editor :string not null # owner :string # url :string not null # ...
true
2ee5e80123355ca9daec125dcefc49d7e52a29f6
Ruby
ksss/rgot
/test/example_pass_test.rb
UTF-8
403
2.6875
3
[ "MIT" ]
permissive
# Output: # bad output module ExamplePassTest # Output: # bad output def example_singleline puts "ok go" # Output: ok go end def example_multiline # multiline example testing start puts "Hello" puts "I'm example" puts "Example is so cool" # Output: # Hello # I'm example ...
true
fc781823e5882fdc93c0401d0b0a12b9efdcdc17
Ruby
Dwin357/tic_tac_toe
/lib/operations/configuration/players/main.rb
UTF-8
1,002
2.78125
3
[]
no_license
require_relative '../../../models/players/players' require_relative 'symbol_solicitor' require_relative 'type_solicitor' class Players class Configuration class Main def initialize @players = Players.new @cell = Players::Cell.new end attr_reader :players, :cell def confi...
true
7969b9af61f0349f2ecd0f121ff8a36e55c0ff81
Ruby
larvailor/Chatter
/server.rb
UTF-8
1,058
3.375
3
[]
no_license
require 'socket' # Receiving messages from client and sending to # other clients def client_handler(client, all_clients) client.puts 'Welcome to server, stranger!' loop do msg = client.gets if msg.nil? puts 'Client disconnected' break end all_clients.each { |dest| send_msg(msg, dest) if...
true
53b0a9e5bfb0048c370731ed5e6ba11ab8fe5276
Ruby
julsfelic/linked_list
/test/list_test.rb
UTF-8
2,926
3.46875
3
[]
no_license
require 'minitest' require 'list' require 'pry' require 'node' class ListTest < Minitest::Test # refactor tests! def setup @list = List.new @node = Node.new # context for minitest @node_1 = Node.new("Hi!") @node_2 = Node.new("Hello!") @node_3 = Node.new("Wassup!") @node_4 = Node.new("Y...
true
fa5c0bdd2362afea3b46661bafdf83ca83a44cb6
Ruby
Yelp/marionette-collective
/lib/mcollective/discovery.rb
UTF-8
4,307
2.546875
3
[ "Apache-2.0" ]
permissive
module MCollective class Discovery def initialize(client) @known_methods = find_known_methods @default_method = Config.instance.default_discovery_method @client = client end def find_known_methods PluginManager.find("discovery") end def has_method?(method) @known_me...
true
0652a287bd0d7b2347ab06488abae4984f8a2a82
Ruby
SonofNun15/MoreDrillsWithRSpec
/lib/fizzbuzz.rb
UTF-8
716
4.15625
4
[]
no_license
class SuperFizzBuzz def run(input) save_fizz = self.fizz? input save_buzz = self.buzz? input if !save_fizz && !save_buzz then return input end output = "" if save_fizz then output += "Fizz" end if save_buzz then output += "Buzz" end return output end ...
true
7e2c90f11e9e3450beac6a89ae7a5a5c45d7305a
Ruby
SilentNN/aA-Homework
/W3D5/map.rb
UTF-8
239
3.28125
3
[]
no_license
class Map def initialize @world = {} end def set(key, value) @world[key] = value end def get(key) @world[key] end def delete(key) @world.delete(key) end end
true
2af6ecfe7c4b143ab23379704516bcb0a5531f9d
Ruby
kevinelliott/social_butterfly
/lib/social_butterfly/services/twitter_service.rb
UTF-8
739
2.53125
3
[ "MIT" ]
permissive
require 'social_butterfly/abstract_service' module SocialButterfly::Services class TwitterService < SocialButterfly::AbstractService def self.share_button_url(content, service_options={}) "http://twitter.com/share?" + "url=" + content[:url] + "&text=" + content[:text] + "&via=" + se...
true
a8d62d62537220f90300a7f7f9c4674fc41f7a6f
Ruby
cooljasonmelton/get-a-command-line-boost
/lib/fuckin_rules_method.rb
UTF-8
600
2.984375
3
[]
no_license
require_relative './fuckin_rules_library.rb' def play_fuckin_rules # flashes FUCKIN four times i = 0 while i < 3 do puts "\e[H\e[2J" puts letter_fuckin sleep(0.3) puts "\e[H\e[2J" puts letter_blank_fuckin sleep(0.3) i += 1 end # flashes RULES...
true
3ce211ec67a5d890ceaa1b81795a63aec0e90c96
Ruby
gabrielecorso/edx
/app/helpers/movies_helper.rb
UTF-8
1,498
2.59375
3
[]
no_license
module MoviesHelper # Checks if a number is odd: def oddness(count) count.odd? ? "odd" : "even" end def yellow?(sortBy,name,id) if params[:id] == sortBy then haml_tag :th, id: sortBy, class: 'hilite' do haml_concat link_to name, "/movies?id=" + sortBy, :id => id, :class => @hilite ...
true
5360c7a782174569412c18c6f1ccfe4067dbf19d
Ruby
peperon/evans
/app/helpers/challenges_helper.rb
UTF-8
598
2.5625
3
[]
no_license
# encoding: utf-8 module ChallengesHelper def challenge_solution_status(solution) return :unchecked if not admin? and not solution.challenge.checked? return :unchecked if admin? and solution.log.blank? solution.correct? ? :correct : :incorrect end def challenge_solution_status_text(solution) sta...
true
a8ee7ba2c03ef3dc90e90c3d3b5a6aed6f321d2b
Ruby
morizotter/SwiftyDrop
/vendor/bundle/gems/fourflusher-2.0.1/lib/fourflusher/find.rb
UTF-8
4,506
2.671875
3
[ "MIT" ]
permissive
require 'fourflusher/simctl' require 'json' require 'rubygems/version' module Fourflusher # Metadata about an installed Xcode simulator class Simulator attr_reader :id attr_reader :name attr_reader :os_version def os_name @os_name.downcase.to_sym end def compatible?(other_version) ...
true
6927a41bff691adb5f908e10135735ded5ed3afd
Ruby
aemrich/collections_practice-001-prework-web
/collections_practice.rb
UTF-8
324
3.125
3
[ "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 do |a, b| if a == b 0 elsif a > b -1 elsif a < b 1 end end end def swap_elements(arr) end def reverse_array(arr) end def kesha_maker(arr) end def find_a(arr) end def sum_array(arr) end def add_s(arr) e...
true
886f516e1a743a50782496f49c157ce17703e090
Ruby
marSun/job
/app/models/page.rb
UTF-8
303
3.109375
3
[]
no_license
class Page def initialize(opt) @current_page = opt[:current_page] @total_page = opt[:total_page] end def next_page @current_page +=1 return (@current_page > @total_page) ? @total_page : @current_page end def has_next_page return @current_page < @total_page end end
true
1d85aea3467f00de9a37df64f6e4ca91f6c0bea9
Ruby
ChaeOkay/RubyHardway
/Completed_Exercises/ex36.rb
UTF-8
3,108
3.6875
4
[]
no_license
#Excercise 36: Designing and Debugging def prompt() print ">" end def ex() Process.exit(0) end def start() puts; puts "WELCOME TO THE RESTAURANT CHEZ RUBY!" puts "Would you liked some 'sparkling water', or 'still water'?" puts; prompt; water = gets.chomp.downcase if water == "s...
true
4615b3c609374fb7dcbf0d42b75dd21dcd5fc2c2
Ruby
thepaulduca/Jeopardy-
/jeopardy.rb
UTF-8
4,072
3.640625
4
[ "MIT" ]
permissive
require 'sqlite3' require_relative 'class_page' $DATABASE = SQLite3::Database.new("jeopardy.db") #create a table if it is not already in exsistence create_main_table = <<-SQL CREATE TABLE IF NOT EXISTS jeopardy( id INTEGER PRIMARY KEY, cat_id INT, question VARCHAR(255), answer VARCHAR(255), points INT, FOREIGN...
true
dd2561440d3d14c0f87bb9b7d5b81dbff2ae8805
Ruby
mkamener/rosalind
/spec/FASTA_parser_spec.rb
UTF-8
760
2.65625
3
[]
no_license
require 'FASTA_parser' require 'dna_string' describe FASTAParser do before(:each) do file = "./spec/FASTAParser_test.txt" @output = FASTAParser.parse_file(file) end it 'should load the test file and return an array of 3 elements' do expect(@output.length).to be 3 end it 's...
true