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
27ea8051a3584cc027ad05dfeabaf8d0179f9ad2
Ruby
stevejackson/priphea
/app/services/embedded_art_extractor.rb
UTF-8
2,127
2.765625
3
[]
no_license
class EmbeddedArtExtractor attr_accessor :filename def initialize(filename) @filename = filename end def write_to_cache! temporary_file = extract_picture_data_to_tmp_file return nil unless temporary_file write_cover_art_to_cache(temporary_file) end def write_cover_art_to_cache(temporary_...
true
8fbeee50a43e5177d95dd5b71d529bfcaacc715e
Ruby
blevy115/ruby_fundamentals1
/exercise4-2.rb
UTF-8
154
3.53125
4
[]
no_license
puts "What is your age?" age = gets.to_i diff = (age-25).abs if age > 105 puts "I;m not sure I believe you" else puts "We are #{diff} years apart." end
true
e592a1866e45cedc83c5bee164ae138d67662004
Ruby
thisisDom/phase-0-tracks
/ruby/iteration_drill.rb
UTF-8
4,500
3.375
3
[]
no_license
# Array Drills zombie_apocalypse_supplies = ["hatchet", "rations", "water jug", "binoculars", "shotgun", "compass", "CB radio", "batteries"] # 1. Iterate through the zombie_apocalypse_supplies array, # printing each item in the array separated by an asterisk # ---- p zombie_apocalypse_su...
true
c0ca7e14f73e05991fa0befaf55589382ee7d19d
Ruby
Steff01/First_ruby
/lib/00_hello.rb
UTF-8
255
3.953125
4
[]
no_license
def ask_first_name puts "What is your first name" first_name = gets.chomp return first_name end def say_hello(first_name) puts "Bonjour, #{first_name}!" end def greet first_name = ask_first_name say_hello(first_name) end greet
true
a8d714b9d0a1f12ea47279e5c9bad4eb81f94d7b
Ruby
vinny13/RosettaCodeData
/Task/Read-a-configuration-file/Ruby/read-a-configuration-file.rb
UTF-8
562
2.640625
3
[]
no_license
fullname = favouritefruit = needspeeling = seedsremoved = false IO.foreach("fruit.conf") do |line| line.chomp! key, value = line.split(nil, 2) case key when /^([#;]|$)/; # ignore line when "FULLNAME"; fullname = value when "FAVOURITEFRUIT"; favouritefruit = value when "NEEDSPEELING"; needspeeling = true ...
true
cbb16aee682f40c71a8e53328e4056ffd6af18f8
Ruby
michaelginalick/phase_0_unit_2
/week_5/3_guessing_game_solo_challenge/my_solution.rb
UTF-8
1,478
3.890625
4
[]
no_license
# U2.W5: Build a simple guessing game SOLO CHALLENGE # I worked on this challenge [by myself, with: ]. # 2. Pseudocode # Input: # Output: # Steps: # 3. Initial Solution #Define an instance method GuessingGame#guess which takes an integer called guess as its input. #guess should return the symbol :high if the ...
true
24447d077256f880308291c5fc96ff93c349cb14
Ruby
marth00165/oo-inheritance-code-along-seattle-web-060319
/lib/car.rb
UTF-8
184
2.734375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require_relative "./vehicle.rb" require "pry" class Car < Vehicle #inherited def go "VRRROOOOOOOOOOOOOOOOOOOOOOOM!!!!!" #edits the method from vehicle end end binding.pry 0
true
67e1e274e59278876f5bcf5661f5ff59561b2f4f
Ruby
ljsuo/ProjectEulerProblems
/projeuler24/pe24.rb
UTF-8
218
3.9375
4
[]
no_license
arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] def permute(arr) return arr.permutation.to_a end def find_mil(arr) # Since indexed at 0, take index right before 1 million return arr[999999] end puts find_mil(permute(arr))
true
fac4a5566e2b6b385e25d374a1c773f6090bdd0b
Ruby
jsvd/test-repo
/update_pr.rb
UTF-8
1,920
2.921875
3
[ "Apache-2.0" ]
permissive
require 'json' def find_gemspec_version gemspec_path = Dir.glob("*.gemspec").first spec = Gem::Specification::load(gemspec_path) spec.version.to_s end def compute_next_version(version, bump_type) major, minor, patch = version.segments case bump_type when "major"; major = major.to_i.succ.to_s; minor = patc...
true
8c161bf4d5f28772ae70895bd479f767bf4426e2
Ruby
riverans/videocache-ruby
/lib/ext.rb
UTF-8
220
2.53125
3
[ "MIT" ]
permissive
# # (C) Copyright Kulbir Saini <saini@saini.co.in> # Product Website : http://cachevideos.com/ # class NilClass def integer? false end end class String def integer? !!(self =~ /\A(0(?![0-9]+)|[1-9]+[0-9]*)\Z/) end end
true
fdfff56b8d42ce30b109998ebd260b9a0a8ff056
Ruby
rafaelfranca/chatstats
/app.rb
UTF-8
573
2.6875
3
[]
no_license
require 'sinatra' require 'json' get '/:app/:name' do users = {} log = File.open("#{params[:name]}.txt", "rb").read log.gsub!(/\r\n?/, "\n") log.each_line do |line| chat = line.split(":") username = chat[0].force_encoding('utf-8') if params[:app] == "whatsapp" if /(\d{2}\/\d{2}\/\d{2}\s\d...
true
f7b65853f7b413098e14af3e44634b9eb6955fe0
Ruby
jeffcwolf/booktoread
/app/controllers/static_pages_controller.rb
UTF-8
4,095
2.765625
3
[]
no_license
require 'open-uri' require 'json' class StaticPagesController < ApplicationController def home #Obtain book list names for subsequent use in API requests @listnames_url = "http://api.nytimes.com/svc/books/v3/lists/names.json?api-key=#{NYT_BOOKSAPI_KEY}" @raw_results_list = open(@listnames_url).read ...
true
809495c4988df342f789ed3fac35b4317a2f0558
Ruby
chinchifou/Condingame_Geometry
/tests.rb
UTF-8
1,272
2.890625
3
[ "MIT" ]
permissive
require 'minitest/autorun' require_relative 'module_Geometry.rb' include Geometry class TestGeometry < Minitest::Test # GENERAL TEST PATTERN # test individual constructor # normal value # unexpected value # impossible value # test individiual modifiers # test interactions def test_sol...
true
d54919229f59924f34da70e3bff62deb122dbf4a
Ruby
zandelisenekal/terminal_app_plant_pet
/src/new_game.rb
UTF-8
1,152
3.59375
4
[]
no_license
require_relative "simulation_game.rb" require 'tty-font' require 'colorize' font = TTY::Font.new(:doom) puts font.write("Welcome!").colorize(:green) # prints Welcome message to screen using gem when game starts if ARGV[0] == "p" # type 'p' in command line for a preview of your plant puts " {o}{o}{o...
true
19c1bd0ffd000d893bf4cb85dda0af87333914bf
Ruby
RanjunSingh/WeatherScraper
/Hello.rb
UTF-8
854
4.0625
4
[]
no_license
# basic output puts "-----------------Output----------------" puts "Hello World" # basic input puts "\n-----------------Input----------------" puts "Input a number" input = gets puts "This was your number: " + input # basic loop puts "\n-----------------Iteration----------------" puts "regular for, like python" fo...
true
b79512a53442ebd796e29e9fb9b6a25d28a424bd
Ruby
saloni1911/warm-up-exercises
/26.6.17 - starbucks coffee/coffee.rb
UTF-8
4,244
4.09375
4
[]
no_license
# https://gist.github.com/kasun-maldeni/b38a4bcdb17078f48b5179ff9fc85d21/ # Write a program that holds on to coffee orders. # c1 = Coffee.new('latte','2 sugars','medium','Darryl') # Write the .to_s method for this class so when you puts c1 you will have "Darryl's latte, medium, 2 sugars require 'pry' class Coffee ...
true
ffafe9390d402f97f602d6cd7c4bf69767832739
Ruby
crossmann/ruby-example
/Inheritance.rb
UTF-8
243
3.8125
4
[]
no_license
# Sample example with inheritance of a class class ParentClass def sayHello puts "Say hello from: #{self}" end end p_inst = ParentClass.new p_inst.sayHello class ChildClass < ParentClass end c_inst = ChildClass.new c_inst.sayHello
true
30eb792bd8444cde90c5624207a8f1ddbed1595f
Ruby
michael-sd/Ruby_Programs
/alcohol.rb
UTF-8
254
3.953125
4
[]
no_license
def human_age(age) if age < 21 return "You are not legally allowed to buy alcohol in the US" else return "You are legally allowed to buy alcohol in the US" end end puts "What is your age?" age = gets.chomp.to_f puts human_age(age)
true
a23b49094d2279431e1fde5027c4ac8577bdefdb
Ruby
func-i/painsquad
/app/services/pain_severity_service.rb
UTF-8
668
2.5625
3
[]
no_license
class PainSeverityService def self.analyze(submission) new(submission).perform end def initialize(submission) @submission = submission end def perform set_pain_severity end private def set_pain_severity pain_severity = if @submission.current_pain_answer.value > 30 # => Notify...
true
031b73be53b70b91e71adef80d834eaafd2e75a1
Ruby
Stella-Nthenya/Ruby-Object-Oriented-Programming-Exercises
/120_oop_exercises/easy_1/refactoring_vehicles.rb
UTF-8
1,084
3.671875
4
[]
no_license
# Consider the following classes: class Vehicle attr_reader :make, :model def initialize(make, model) # can take additional parameter wheels here @make = make @model = model # @wheels = wheels end def to_s "#{make} #{model}" end end class Car < Vehicle # def initialize(make, model) # ...
true
f0c77831d365ab93336cc429018ccdee54350992
Ruby
juliannatetreault/ttt-10-current-player-bootcamp-prep-000
/lib/current_player.rb
UTF-8
230
3.390625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def turn_count(board) counter = 0 board.each do |character| if character == "X" || character == "O" counter += 1 end end counter end def current_player(board) if turn_count(board) % 2 == 0 "X" else "O" end end
true
3d8a9cea96e38e52c35f1b3a4b3d770b0151c746
Ruby
benmerkel/lrthw
/chapter_3/ex3.rb
UTF-8
1,264
4.46875
4
[]
no_license
# Several strings within don't use any interpolation so only # single quotes were necessary. # Outputs a string puts 'I will now count my chickens:' # This is dividing 30 by 6 and then adding 25 puts 'Hens', 25 + 30 / 6 # This is multiplying 25 by 3, then remainder of 75/4 # and subtracting that from 100 puts 'Roost...
true
7040e49dd792f3ca650b99abaf745f2a6c5bdd25
Ruby
Knolle-03/PT17
/file_utils.rb
UTF-8
419
3.21875
3
[]
no_license
class MyFileError < IOError; end # rth module FileUtils def self.count_characters(filename) raise MyFileError, "#{filename} is not valid" unless File.readable?(filename) text = File.read(filename).delete(' ').split('') hash = {} text.each do |v| hash[v] = 0 if hash[v].nil? hash[...
true
7129d5edc22b7b9a2ad66a634c95b09979b773e1
Ruby
azhi/BSUIR_labs
/7sem/CSN/lab2/chat_serv_udp.rb
UTF-8
826
2.625
3
[]
no_license
require 'socket' require 'pry' socket = Socket.new(:INET, :DGRAM) local_adr = Addrinfo.udp("127.0.0.1", 2222) @clients = [] @threads = [] socket.bind(local_adr) begin loop { msg, client_adr = socket.recvfrom(255) if msg.start_with?("REGISTER") p new_client = {name: msg.sub('REGISTER ', '').chomp, addr...
true
dd0fc0b961ce36a20b1c9f26419507397d282de3
Ruby
pancake-batfish/BankAccounts
/lib/checking_account.rb
UTF-8
816
3.328125
3
[]
no_license
require_relative 'account' module Bank class CheckingAccount < Bank::Account attr_accessor :checks_used def initialize(id, balance) super reset_checks end def withdraw(amount) @withdrawal_fee = 1 super end def withdraw_using_check(amount) raise ArgumentError....
true
84956961a6b945db10e88570530dc18d64dd3531
Ruby
carlos-m-marques/kithward-api
/lib/tasks/dunno.rake
UTF-8
5,456
2.625
3
[]
no_license
require 'listing_dictionary' require 'community_dictionary' require 'processing' require 'converter' require 'scriptster' desc "Really dunno so far" task :community_crunch => :environment do processing = Processing.new(COMMUNITY) processing.crunch report = "" community = Community.find(3770) report << "Com...
true
46a8f74fb37639602c2069254c6a11fadc185cba
Ruby
cored/munchkins
/lib/munchkins/policies/games/maximum_amount_of_players.rb
UTF-8
300
2.609375
3
[]
no_license
module Policies module Games class MaximumAmountOfPlayers MAXIMUM_AMOUNT_OF_PLAYERS = 6 def self.validate(game) if (game.players.count > MAXIMUM_AMOUNT_OF_PLAYERS) "Maximum amount of players is #{MAXIMUM_AMOUNT_OF_PLAYERS}" end end end end end
true
6bd11b7941b1b27fd406866961fe15c581a7e3b4
Ruby
samuraraujo/SondaSerimi
/modules/alignment/DezhaoSong-aligner.rb
UTF-8
2,428
2.78125
3
[]
no_license
#Key selection implemented at http://disi.unitn.it/~p2p/RelatedWork/Matching/70310640.pdf #Automatically Generating Data Linkages Using a Domain-Independent Candidate Selection Approach #Dezhao Song and Jeff Heflin #Author: Samur Araujo ########################################################################## class Dezh...
true
5edc6127be2e17a01f6360833769cc093bbfe33a
Ruby
mariasoria/ruby_education
/Scripts to learn/scope.rb
UTF-8
933
4.03125
4
[]
no_license
# Publicos -> Public (por defecto) # Privados -> Private (únicamente desde dentro de la clase). Clase hija también los hereda # Protegidos -> Protected (puede llamarse desde otras clases siempre que sean del mismo tipo) class Humano def initialize privado end def publico puts "Soy publico" ...
true
5fa8a956e7b6975c82c91445a83eb6cff6121bfe
Ruby
onemonthweb/ruby-teaching
/3-variable.rb
UTF-8
69
2.875
3
[]
no_license
a = 14 b = 5 puts a + b puts a - b puts a * b puts a / b puts a % b
true
b8f4b41909d064b9c6d9dcbadf60f965e3475aba
Ruby
bronzdoc/olery_gem
/lib/olery/scraper.rb
UTF-8
412
3.21875
3
[ "MIT" ]
permissive
module Olery # <Scraper> Will start scraping for data with the configured resources class Scraper attr_reader :word def initialize(word) @word = word end # Run the scraper def run Olery.configuration.resources.each do |resource| puts "Looking for hotels in #{resource.host} ...
true
bfc2036c462887d4c0b8a619e5331048e392cce7
Ruby
benjaminb10/Ui-Bibz
/lib/ui_bibz/ui/grid/grid.rb
UTF-8
2,765
2.984375
3
[ "MIT" ]
permissive
module UiBibz::Ui # Create a Grid # # This element is an extend of UiBibz::Ui::Component. # # ==== Attributes # # * +content+ - Content of element # * +options+ - Options of element # * +html_options+ - Html Options of element # # ==== Options # # You can add HTML attributes using the +html_o...
true
360ea14c9868a7ef34de38b32940847fd64f2d93
Ruby
sularzyk/smartflix
/app/services/omdb_movie_creator.rb
UTF-8
713
2.75
3
[]
no_license
# frozen_string_literal: true require 'httparty' class OmdbMovieCreator include HTTParty def initialize(omdb_response) @omdb_response = omdb_response end def call omdb_response['Response'] == 'True' ? add_movie_to_the_db : log end private attr_reader :omdb_response def log title = omd...
true
ba5e90956e0d97b102fa6be29fdaea2e8b2dff49
Ruby
psbora2/Compeitive-Coding-Problems-Ruby
/problems /stack/sliding-window-maximum.rb
UTF-8
965
3.8125
4
[]
no_license
# https://leetcode.com/problems/sliding-window-maximum/ def max_sliding_window(nums, k) result = [] sliding_window = [] nums.each_with_index do |el, index| sliding_window = insert_in_sliding_window(nums, sliding_window, index, k, el) if index >= k -1 result << nums[sliding_wind...
true
a1cc5b142690ce3d3b0257a532dd311aa4351000
Ruby
ottaviana/learnrubythehardway
/ex3_1.rb
UTF-8
121
3.40625
3
[]
no_license
puts "Is it true that #{2 > 3} ?" puts "Is it true that 2 is greater than 3? #{2 > 3}" puts 20.3 - 10.5 / 3 + 6.4 - 0.45
true
750882a01473e3096763cd304f540dabece9a438
Ruby
sblausten/learn-to-program
/10.3_shuffle.rb
UTF-8
495
4.09375
4
[]
no_license
=begin 10.3 Shuffle. Now that you’ve finished your new sorting algorithm, how about the opposite? Write a shuffle method that takes an array and returns a totally shuffled version. As always, you’ll want to test it, but testing this one is trickier: How can you test to make sure you are getting a perfect shuffle...
true
a539f4a0afc6e90d7f78ff77ab8ce1b1a9ce9580
Ruby
Zero-jp/Test_journal
/app.rb
UTF-8
2,608
2.640625
3
[]
no_license
# frozen_string_literal: true require 'forme' require 'roda' # Connecting all files in the "models" directory require_relative 'models' # Core class class App < Roda # Specifying the path to the root of the application opts[:root] = __dir__ # Here it is write that the root of the app is that file # A...
true
7311cb9f607251ccce6428f6e398ae9c651ae12c
Ruby
PabloEPP/estructuras_de_control
/1_1_2.rb
UTF-8
145
3.34375
3
[]
no_license
#Modifica el valor asignado a la variable 'a' para que se cumpla la condición. a = 5 if a == 5 puts 'La condición es verdadera.' end
true
bcade581b46b3a2a28387a4c060a7a01ff1a56e3
Ruby
rafaeldl/Mithra
/core/gerador.rb
UTF-8
2,407
3.265625
3
[]
no_license
require 'yaml' def gera_individuo(turma) individuo = [] 5.times do |dia| individuo[dia] = [] 4.times do |periodo| individuo[dia][periodo] = @disciplinas.sample end end acertos = calcula_acertos(individuo, turma) individuo = {individuo: individuo, acertos: acertos, turma: turma} @melhor_in...
true
5e51defdbd5459607ed2cfbd95975dd25c97faf9
Ruby
mjsivertsen/doc_apppointment_scheduler
/app/models/appointment.rb
UTF-8
864
2.734375
3
[]
no_license
class Appointment < ApplicationRecord belongs_to :patient belongs_to :doctor # wanted to make the date and time not stupid and ugly but having a hard time figuring it out # def convert_time(datetime) # time = Time.parse(datetime).in_time_zone("Pacific Time (US & Canada)") # time.strftime("%-d/%-m/%y...
true
6b397bceed813dbeda1e583e3c638167294a2c7c
Ruby
liviaishak/NutriLoop
/app/models/user.rb
UTF-8
1,825
2.5625
3
[]
no_license
class User < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable validates :fname, :lname, :age, :gender, :height, :wei...
true
5a5038c293b374d978e23fee95e55175b6dfb041
Ruby
s11rikuya/ruby-perfect-lesson
/5-5-3-3.rb
UTF-8
156
2.9375
3
[]
no_license
hash = {foo: 1, bar: 2, baz: 3} hash.select! {|key, val| val.odd?} p hash hash = {foo: 1, bar: 2, baz: 3} hash.reject! {|key, val| val.odd?} p hash
true
50e8721df3b1a1861642396db7721a250f52e2b9
Ruby
augheywashu/gitish
/blobstore.rb
UTF-8
1,561
2.796875
3
[ "BSD-3-Clause" ]
permissive
require 'gdbm' require 'digest/sha1' require 'fileutils' class BlobStore def initialize(store,options) @storedir = options['storedir'] || raise("BlobStore: storedir option not defined") FileUtils::mkdir_p(@storedir) @store = store @blobs = GDBM.new(File.join(@storedir,"blobs.db"),0666,options['readon...
true
32bc2f36d104c7fcec9a2079b962ebcff348123d
Ruby
EricMbouwe/Enumerables
/enumerable.rb
UTF-8
2,412
3.25
3
[ "MIT" ]
permissive
module Enumerable def my_each return to_enum(__method__) unless block_given? i = 0 while i < size yield(to_a[i]) i += 1 end self end def my_each_with_index return to_enum(__method__) unless block_given? i = 0 while i < size yield(to_a[i], i) i += 1 en...
true
fed3d7de00b39ae0b248797bf070cdc8f549298a
Ruby
Slothkrew/Napper
/app/models/nap.rb
UTF-8
433
2.5625
3
[]
no_license
require 'data_mapper' class Nap include DataMapper::Resource property :id, Serial property :body, String, :required => true property :author, String, :required => true property :posted, DateTime def posted_date if posted if DateTime.now.to_s.include? Date.today.to_s posted.strftime...
true
babcb25aadf3ed21b8790eb71118eb745b73f25b
Ruby
jazziining/Ruby_Fundamentals2
/exercise5.rb
UTF-8
249
4.125
4
[]
no_license
#Methods #Converts Fah to Cel temp_fahrenheit = gets.to_i def converts ( temp_fahrenheit ) temp_celsius = ( temp_fahrenheit - 32 ) * 5 / 9 puts "#{temp_fahrenheit} Fahrenheit equals to #{temp_celsius} celsius" end converts ( temp_fahrenheit )
true
c3a9c6a8a1595c65edd7b59b478ba63d89430323
Ruby
jdunwoody/image_batch_processor
/spec/lib/models/camera_make_spec.rb
UTF-8
952
2.640625
3
[]
no_license
require './lib/models/camera_make' module Models describe CameraMake do describe '#add_model' do let(:camera_make) { CameraMake.new('Camera Name') } it 'creates a camera model' do model = camera_make.add_model('Camera Make', 'thumbnail') expect(camera_make.models.size).to eq(1) ...
true
b6b0362d20c3d05e3fa4b842e59b48a90653b742
Ruby
JS-Bogart/aA_Classwork
/W4D5/anagrams.rb
UTF-8
1,200
4.25
4
[]
no_license
#TC O(n!), SC O(n!) def first_anagram?(str1, str2) return false if str1.length != str2.length anagram = str1.chars.permutation(str1.length).map { |ele| ele.join("") } anagram.include?(str2) end # p first_anagram?("gizmo", "sally") #=> false # p first_anagram?("elvis", "lives") #=> true #TC O(n^2), S...
true
b21354b1fa8637406b77f3e25032071b74e74b79
Ruby
castor4bit/leetcode
/0100/110.Balanced_Binary_Tree/test_110.rb
UTF-8
506
2.90625
3
[]
no_license
require 'test/unit' require './110' require '../../structures/treenode' class LeetCodeSolutionTest < Test::Unit::TestCase def test_110 root = TreeNodeUtil.array_to_treenode([3, 9, 20, nil, nil, 15, 7]) assert_equal true, is_balanced(root) root = TreeNodeUtil.array_to_treenode([1, 2, 2, 3, 3, nil, nil, 4...
true
dfdcc223095426ca64f1a39a6a39f08fdbd521d1
Ruby
yasumasamakino/keiba
/batch/horseShisuuKeisanBatch.rb
UTF-8
36,942
2.765625
3
[]
no_license
# URLにアクセスするためのライブラリの読み込み require 'open-uri' # Nokogiriライブラリの読み込み require 'nokogiri' require "date" class Calculation class << self # def chakusaScoreCalc(score, sabunTimeSecond, addValue) # if sabunTimeSecond < 0.1 then # return score += 9 # elsif sabunTimeSecond == 0.1 then # return score += ...
true
3f9b210f64da2f178f7d0664f4df865aac71838f
Ruby
cachafla/dm-more
/dm-is-state_machine/lib/dm-is-state_machine/is/dsl/state_dsl.rb
UTF-8
1,180
2.59375
3
[ "MIT" ]
permissive
module DataMapper module Is module StateMachine # State DSL (Domain Specific Language) module StateDsl # Define a state of the system. # # Example: # # class TrafficLight # include DataMapper::Resource # property :id, Serial # ...
true
a84ecfe497153893675cd185f7cf24ab3d2255ca
Ruby
AlexanderCleasby/ruby-music-library-cli-online-web-pt-102218
/lib/musicimporter.rb
UTF-8
272
2.8125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class MusicImporter attr_reader :path def initialize(path) @path=path end def files Dir[@path+"/*"].map{|filename| filename.split('/').last } end def import self.files.each{|file| Song.create_from_filename(file)} end end
true
7ca9c340a62c8780750a62cd0d0589021354e127
Ruby
PeaWarriorLabs/ruby-oo-practice-flatiron-mifflin-exercise-nyc04-seng-ft-053120
/lib/Manager.rb
UTF-8
1,022
3.515625
4
[]
no_license
class Manager attr_reader :name, :department, :age @@all = [] def initialize(name, department, age) @name = name @department = department @age = age save end def save self.class.all << self end def self.all @@all end def employe...
true
50c21e9c2783780b58c864f29fe17aa16b5de174
Ruby
ethransom/tic-tac-toe
/lib/player.rb
UTF-8
208
3.359375
3
[ "MIT" ]
permissive
module TicTacToe class Player attr_reader :symbol def initialize symbol @symbol = symbol end def puts msg Kernel::puts "#{@symbol.to_s}: #{msg}" end end end
true
ac600b6c71296eec45ce5cd4148c945a63029679
Ruby
makanazilla/RubyTheHW
/ex13.rb
UTF-8
341
3.46875
3
[]
no_license
first, second, third = ARGV puts "What's your first variable?" first = $stdin.gets.chomp puts "What's your second variable?" second = $stdin.gets.chomp puts "What's your third variable?" third = $stdin.gets.chomp puts "Your first variable is: #{first}" puts "Your second variable is: #{second}" puts "Your third va...
true
0d36e09a25b62ce306e8fa8a8e4d1c04d395b257
Ruby
musiccity365/pfwtfp-stats-with-subroutines-dc-web-mod1-repeat
/lib/stats.rb
UTF-8
1,410
3.5625
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'pry' def mean(array) sum = 0.0 array.each do |item| sum += item end sum / array.size end def median(array) order = array.sort! median = (array.size - 1) / 2 if array.size.odd? #helper(array) order[median] else median2 = median + 1 (order[median] ...
true
687af08f18e5a4236d3f678937548efc92b903c3
Ruby
milodky/Ruby4Fun
/SpaceTest.rb
UTF-8
82
2.84375
3
[]
no_license
def f(x) x * x end if __FILE__ == $0 puts f(2 + 3) + 1 puts f (2 + 3) + 1 end
true
f7e9eadb574de144d7f10037a2dad2f1d5041d4a
Ruby
figuedmundo/QE_training_BDT_ruby
/Edmundo/tasks/practiceCelciusFahrenheit.rb
UTF-8
163
3.46875
3
[]
no_license
def cel_to_fah(value) ((9 * value ) / 5.0) + 32 end def fah_to_cel(value) return ((5 * (value -32)) / 9.0) end puts cel_to_fah 99 puts(fah_to_cel 60)
true
33253d57e841922aa94373e5f9887a5a30b7a089
Ruby
bannio/mars
/spec/models/sales_order_line_spec.rb
UTF-8
1,457
2.609375
3
[]
no_license
require 'spec_helper' describe SalesOrderLine do let(:sales_order) { create(:sales_order) } before :each do @attr = { name: "item name", description: "description of line", quantity: 2, unit_price: 2.0, total: nil, sales_order_id: ...
true
c4e9f42dff39c85de168c351c5608f86a56a5886
Ruby
jack-nie/phone_list_checker
/lib/reader/txt_reader.rb
UTF-8
314
3.046875
3
[]
no_license
module Reader class TxtReader attr_accessor :path def initialize(path) @path = path end def each_line open { |file| file.each_line { |line| yield line if block_given? } } end private def open File.open(path, 'rb') { |file| yield file } if path end end end
true
90dbed16aae57d6e6afb2d301332d43c8373ae56
Ruby
eregon/adventofcode
/2020/16b.rb
UTF-8
1,088
2.625
3
[]
no_license
fields, mine, others = File.read('16.txt').split("\n\n") fields = fields.lines.map { |line| name = line[/^([\w ]+):/, 1] [name, line[/^[\w ]+: ((\d+-\d+)( or \d+-\d+)*)$/, 1].split(' or ').map { |range| range =~ /(\d+)-(\d+)/ and ($1.to_i..$2.to_i) }] } valid = fields.flat_map(&:last) mine = mine.lines.drop...
true
f642a0a16685bf96132e81d5fa2ecd632f1b9690
Ruby
swapnilp0x00/Splitbills
/app/models/bill.rb
UTF-8
1,091
2.53125
3
[]
no_license
class Bill < ApplicationRecord belongs_to :user , class_name: 'User', foreign_key: :user_id, primary_key: :id has_many :bill_parts, class_name:"BillPart", foreign_key: :bill_id , primary_key: :id, inverse_of: :bill , dependent: :delete_all # remember to uncomment validates_presence_of :event, :date, :location,...
true
0444564d3d62b1dd9152e8f733a4c8960bce64f7
Ruby
blairad/cinema_homework
/models/customer.rb
UTF-8
1,784
3.203125
3
[]
no_license
require_relative('../db/sql_runner') require_relative('./films') require_relative('./tickets') # require_relative('./customer') require('pry') class Customer attr_reader :id attr_accessor :funds, :name def initialize(options) @id = options['id'].to_i if options['id'] @name = options['name'] @fun...
true
8ab164597d687589e871a288fea9353b05f0b0df
Ruby
PhilHuangSW/Leetcode
/repeated_substring_pattern.rb
UTF-8
1,620
4.40625
4
[]
no_license
#################### REPEATED SUBSTRING PATTERN #################### # Given a non-empty string check if it can be constructed by taking a # substring of it and appending multiple copies of the substring together. # You may assume the given string consists of lowercase English letters # only and its length will not...
true
60b47a4e942767c35f1e734436a82a3ef69878a1
Ruby
skrepkoed/thinknetica_course
/RubyBasics/Lesson7/modules/railway_route_module.rb
UTF-8
2,032
2.984375
3
[]
no_license
require_relative 'validation_module' require 'pry' module RailwayRoute include Validations::RouteValidations include ExceptionsModule::RailwayExceptions # binding.pry private def create_route validate_stations_amount(stations) rescue InsufficientStationsAmount => e puts e.message create_statio...
true
18615cfd918c5a15ab122c6baaa0c9dec0383a41
Ruby
kurukuruk/stoffle
/lib/stoffle/ast/binary_operator.rb
UTF-8
353
3.15625
3
[]
no_license
class Stoffle::AST::BinaryOperator < Stoffle::AST::Expression attr_accessor :operator, :left, :right def initialize(operator, left = nil, right = nil) @operator = operator @left = left @right = right end def ==(other) operator == other&.operator && children == other&.children end def chil...
true
e772a121c45d129f312a87b01750931f0610eb4b
Ruby
ShishirSK/food-exercise-and-glycation
/blood-sugar-simulation.rb
UTF-8
7,186
3.453125
3
[]
no_license
#!/usr/bin/env ruby # CLI interface to accept records of food intake and # exercise and simulate the blood sugar levels require 'time' require 'csv' BASE_SUGAR_LEVEL = 80.0 # Inputs and reference data @food_db = {} @exercise_db = {} @user_inputs = [] # Status mapping strcutures @food_impact = {} @exercise_impact =...
true
a48b07d5cf0cca0b882c73ba3da3767cfd60cf6b
Ruby
ppj/robot
/spec/board_spec.rb
UTF-8
5,687
2.8125
3
[]
no_license
# frozen_string_literal: true require_relative "../lib/board.rb" require_relative "../lib/robot_placement_checker.rb" require "rspec/its" RSpec.describe Board do subject(:board) { described_class.new } describe "a new board" do its(:max_x) { is_expected.to eq(5) } its(:max_y) { is_expected.to eq(5) } ...
true
4a22b170658a3169106419752f52d4656e60ca9e
Ruby
firespring/mogbak
/lib/create.rb
UTF-8
1,873
2.6875
3
[ "MIT" ]
permissive
#Creates a backup profile to be used by Backup class Create attr_accessor :db, :db_host, :db_port, :db_pass, :db_user, :domain, :tracker_host, :tracker_port, :workers include Validations #Run validations and create the backup profile #@param [Hash] o hash containing the settings for the backup profile def in...
true
17ca3d4e5f42a07feb92ff82c2ec3eec1af84f63
Ruby
leancloud/objc-sdk
/AVOS/.ci/UnitTestParser/xcresult.rb
UTF-8
13,448
2.546875
3
[ "MIT", "Apache-2.0" ]
permissive
# copy from https://github.com/fastlane-community/trainer/blob/307d52bd6576ceefc40d3f57e34ce3653af10b6b/lib/trainer/xcresult.rb module XCResult # Model attributes and relationships taken from running the following command: # xcrun xcresulttool formatDescription class AbstractObject attr_accessor :type...
true
73667c2973f105a92d6048b54fc5db02b2e8511b
Ruby
a1exwang/jumping_horses
/produce_data.rb
UTF-8
562
3.40625
3
[]
no_license
def near(a, b) x = a.to_i / 10 y = a.to_i % 10 i = b.to_i / 10 j = b.to_i % 10 x - i != 0 && y - j != 0 && ((x-i).abs + (y-j).abs) == 3 end def construct_table(size) table = {} size.times do |x| size.times do |y| if (x + y) % 2 == 0 line = {} size.times do |i| size.tim...
true
73fa9d46e489e8b47b903329edefba4e4046e8d5
Ruby
leo11511/eup_repos
/ruby/code/movie.rb
UTF-8
521
3.125
3
[]
no_license
class Movie # attr_writer :title # attr_reader :title attr_accessor :title def initialize(ptitle, prank=0) @title =ptitle.capitalize @rank = prank end def status hit? ? "Hit" : "Flop" end # # def title # # @title # # end # attr_reader :title # # def title=(ptitle) # # @title = ptitle ...
true
7cbfa8ea2b39edc2e9fd6806e5e04d3b2624c6ec
Ruby
jackrobbins1/school-domain-chicago-web-career-040119
/lib/school.rb
UTF-8
764
3.9375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# code here! require "pry" class School attr_reader :roster, :name # @roster = {} def initialize(name) @name = name @roster = {} end def add_student(name, grade) unless roster.has_key?(grade) roster[grade] = [] end roster[grade] << name end def grade(num) roster[num] e...
true
669dc0f38a83ccc6da89eebc89774dddce9dde56
Ruby
erikasinio/Test
/RUBY ACTIVITIES/ACTIVITY 4/confection.rb
UTF-8
334
3.296875
3
[]
no_license
class Confection def prepare puts "Baking at 350 degrees for 25 minutes" end end class Cupcake < Confection def prepare super puts "Applying Frosting" end end class BananaCake < Confection; end cupcake = Cupcake.new puts cupcake.prepare banana_cake = BananaCake.new puts banan...
true
fe402d01681e71a43384afd64ce2b5f96b405958
Ruby
Vizzuality/ushelf
/rmagick/ruby/1.8/gems/refinerycms-i18n-0.9.8.7/config/locales/cz.rb
UTF-8
5,191
2.765625
3
[ "MIT" ]
permissive
# Czech translations for Ruby on Rails # by Karel Minařík (karmi@karmi.cz) { :'cz' => { # ActiveSupport :support => { :array => { :two_words_connector => ' a ', :sentence_connector => 'a', :skip_last_comma => true } }, # Date :date => { :formats => { ...
true
c5ae44bbbcd9db284e975d9a0ead984c8515de5a
Ruby
css1990x/EulerProblems
/euler_9/euler_9.rb
UTF-8
343
3.078125
3
[]
no_license
def euler_9 (1...500).to_a.each do |a| (1...500).to_a.each do |b| (1...500).to_a.each do |c| if ((a ** 2) + (b ** 2) == (c ** 2)) && ((a + b + c) == 1000) return "the solution to euler 9 is #{(a * b * c)} " end end end ...
true
1fbe4ca15e7c49e1f54907662910f3d55ea9be5b
Ruby
fionahiklas/wh-questions
/test/q2/test_calculate_coins_objects.rb
UTF-8
1,091
2.75
3
[ "MIT" ]
permissive
require 'test/unit' require 'q2/calculate_coins' class TestCalculateCoinsObjects < Test::Unit::TestCase def test_coin_and_multiplier_new result = Q2::CoinAndMultiplier.new assert(result!=nil, "Result was nil") assert(result.coin_index == 0, "Coin index was #{result.coin_index}") assert(result.multi...
true
b8df7ec96efc677a387c1b51f5562f36bf659989
Ruby
BrianTheCoder/cool_breeze
/lib/cool_breeze/association.rb
UTF-8
989
2.8125
3
[ "MIT" ]
permissive
module CoolBreeze class Association include Enumerable def initialize(klass, name, options = {}) @list_name = "#{name}_list" @klass = klass klass.instance_index :"#{name}_list", :list end def for(instance) @list = instance.method(@list_name) self end ...
true
49e709262457268486080259a7ca6be9d919e762
Ruby
bpeek/launch_school
/intro_to_programming_exercises/end_of_book_8.rb
UTF-8
340
2.5625
3
[]
no_license
hash_1 = {crabs: "pinch", bees: "sting", squids: "strangle", boas: "squirt ink", penguins: "if is ain't black and white, peck, scratch, and bite"} hash_2 = {:crabs => "pinch", :bees => "sting", :squids => "strangle", :boas => "squirt ink", :penguins => "if is ain't black and white, peck, scratch, and bite"} print hash...
true
f222e1b979130012401c2ce9ce552d4cca7dc38c
Ruby
tatsuki-kamei/euler
/problem6.rb
UTF-8
154
3.46875
3
[]
no_license
a = 0 b = 0 puts "計算したい数字を入力してください" n = gets.to_i n.times do |i| a += (i+1)**2 b += i+1 end b = b**2 sum = b -a puts sum
true
3cf4c91aa02363058cfb6eb445ae65011738727b
Ruby
kirster/test-guru
/app/models/badge_criteria_check.rb
UTF-8
1,455
2.703125
3
[]
no_license
class BadgeCriteriaCheck class << self def check_criterias(user) Badge.all.each do |badge| case badge.rule_name when 'Category' then category_rule(user, badge) when 'Level' then level_rule(user, badge) when 'Attempt' then attempt_rule(user, badge) end ...
true
9771d3b09d8da8a3c2fb1a7d1c0c05370325845d
Ruby
maciejk77/boris-bikes_pair
/spec/docking_station_spec.rb
UTF-8
1,370
2.84375
3
[]
no_license
require './lib/docking_station' # class ContainerHolder; include BikeContainer; end # describe BikeContainer do # let(:bike) { Bike.new } # let(:holder) { ContainerHolder.new } # it 'should accept a bike' do # expect(holder.bike_count).to eq(0) # holder.dock(bike) # expect(holder.bike_count).to eq...
true
b507c0a290d75733805362f0d97f9b5107fbb6d0
Ruby
orfah/samples
/s/1/loadbalancer/lib/balancer/loadbalancer.rb
UTF-8
6,401
2.859375
3
[]
no_license
# # LoadBalancer class. # # Sits in front of any number of hosts, each of which must be # configured with an address and healthcheck_target. # # LoadBalancer may be configured to return the next host as: # - Round-Robin (default) # - Load Feedback # - Random # - Asymetric Load # # A check of all host target files w...
true
4b9a82670593f14aaeac954737a565cc74bc9ada
Ruby
sarahl3/kwk-l1-looping-while-until-kwk-students-l1-bal-061818
/lib/while.rb
UTF-8
121
2.5625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def using_while levitation_force = 6 while levitation_force <= 9 puts "Wingardium Leviosa" levitation_force += 1 end
true
30572674b90e0cd4b589625e899fdabcc505df7b
Ruby
jhartwell/ironruby
/Tests/Experiments/19/opt_block_reference.rb
UTF-8
181
2.890625
3
[]
no_license
=begin def foo return 1,2, end def bar *args, &b p args, b end x = -> {} bar foo, not(), not(1), &x =end def foo x = (1 ? return : return; 2) end foo
true
db6333f05e21c999cbb3f18645a6f827dc6d996e
Ruby
shelleyyz/WDi28-Homework
/shelley_zhang/week_04/day_01/calculator.rb
UTF-8
3,570
4.40625
4
[]
no_license
# Explanation # You will be building a calculator. A calculator can perform multiple arithmetic operations. Your function should allow the user to choose which operation is expected, enter in the values to perform the operation on, and ultimately view the result. # Specification: # A user should be given a menu of oper...
true
06495ec7c9ad5b99e01ad08033eac393c4025f72
Ruby
deepigarg/rubyx
/lib/ruby/statement.rb
UTF-8
1,037
3.28125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module Ruby # Base class for all statements in the tree. Derived classes correspond to known language # constructs # # Compilers or compiler passes are written by implementing methods. # class Statement # Many statements exist in the sol layer in quite a similar arrangement # Especially for differ...
true
e18099937d8bb60d2b1f2f260c446b9215cb7075
Ruby
lbvf50mobile/til
/20230120_Friday/20230120.rb
UTF-8
801
3.46875
3
[]
no_license
# Leetcode: 491. Non-decreasing Subsequences. # https://leetcode.com/problems/non-decreasing-subsequences/ # = = = = = = = = = = = = = = # Accepted. # Thanks God, Jesus Christ! # = = = = = = = = = = = = = = # Runtime: 349 ms, faster than 100.00% of Ruby online submissions for Non-decreasing Subsequences. # Memory Usage...
true
f9a42980afd3a86bb5a0bff7d90174e61550270e
Ruby
arcanoid/facts_by_date
/lib/facts_by_date.rb
UTF-8
6,801
2.78125
3
[ "MIT" ]
permissive
require "facts_by_date/version" module FactsByDate class Generator ROOT = File.expand_path("../..", __FILE__) def self.facts_for_today(options = {}) converted_date = Date.today facts = [] if File.exist?("#{ROOT}/data/facts/#{converted_date.month}/#{converted_date.day}.json") file ...
true
6cf64dfd78fd9c1097bd061bce7e09de6c952117
Ruby
Angeldude/madlibs
/app/models/template.rb
UTF-8
1,168
3.21875
3
[]
no_license
class Template < ApplicationRecord def to_param title.parameterize end def replace_words original = template(story) to_replace = words_to_replace(story) { original: original, replace: to_replace } end def final_story(replacer, indexed) # replacer...
true
802f58094359187b3061dcd35e9bb2c0a44ce3c1
Ruby
jerryzlau/july_cohort
/w5d4/intro_javascript_exercises/test.rb
UTF-8
1,258
3.484375
3
[]
no_license
def twoSum(array) indices = [] (0...array.length).each do |idx| (idx+1...array.length).each do |idxx| indices << [idx,idxx] if array[idx] + array[idxx] == 0 end end indices end def transpose(array) result = Array.new(array[0].length) { Array.new(array.length) } (0..array.length-1).each do |i|...
true
036bcf1fdd9cac7725448a4cc8174debdcb22f4a
Ruby
julissa/railsbridgeboston_dot_org
/lib/eventbrite.rb
UTF-8
1,165
2.640625
3
[]
no_license
require "httparty" require_relative "eventbrite/event" require_relative "eventbrite/null_event" class Eventbrite include HTTParty base_uri "https://www.eventbriteapi.com/v3" def upcoming_event event_list.first end private def event_list if user_events_response.success? && !events_from_response....
true
5b2977194f769ad1f08b4d9147d4124741a90f41
Ruby
yanisvieilly/first-shmup
/ship.rb
UTF-8
797
3.09375
3
[]
no_license
class Ship SPEED = 4 WIDTH = 32 HEIGHT = 32 def initialize(window) @window = window @image = Gosu::Image.new(@window, 'assets/ships.png', false, 80, 320, WIDTH, HEIGHT) @x = @window.width / 2 - WIDTH / 2 @y = @window.height - HEIGHT - 18 end def move_up @y -= SPEED unless @y <= 0 end...
true
69285342cdd30c31828aa1033b1bea1dfe8cbaef
Ruby
shairontoledo/rghost
/lib/rghost/grid/field_format.rb
UTF-8
738
2.640625
3
[]
no_license
$LOAD_PATH << File.dirname(__FILE__)+File::SEPARATOR+"../" require 'rghost/ps_object' require 'rghost/ruby_to_ps' module RGhost::Grid module FieldFormat extend RGhost::RubyToPs #Format Time/Date to %d/%m/%Y def self.eurodate(value) string(value.strftime("%d/%m/%Y")) end #Cut all bla...
true
3e6fb0f239d3ad55ef902a5485dd5556494a6ee9
Ruby
magic003/supergossip
/lib/supergossip/routing/on_routing.rb
UTF-8
5,972
2.640625
3
[ "MIT" ]
permissive
require 'thread' require 'socket' require 'date' module SuperGossip; module Routing # This implements the routing algorithm for ordinary nodes. class ONRouting < RoutingAlgorithm # Initialization def initialize(driver,supernode_table,protocol) super(driver,supernode_table,protocol)...
true
6bdae0077a4d6b0bec050e08c84146c69332b21a
Ruby
tanakh/ICFP2011
/comparator/play.rb
UTF-8
476
3.03125
3
[]
no_license
#!/usr/bin/env ruby if ARGV.length < 1 STDERR.puts <<USAGE ./play.rb log-filename behave exactly as is recorded in log-filename USAGE exit end open(ARGV[0], 'r') {|fp| while log = fp.gets cmd = log[0] line = log[1..-1] case cmd when ">" puts line STDOUT.flush when "<" lin...
true
efba382e17a4d12ded4107d1e7b0b6f439b15592
Ruby
epalace510/pEuler
/largestPrimeFactor.rb
UTF-8
445
3.421875
3
[]
no_license
#-- From the Project Euler series. This is question number 3, which can be found at https://projecteuler.net/problem=3 def factor(num) for i in 2..num do if num % i == 0 factor=i break end end reVal=[factor, num/factor] return reVal end largestFactor=0 num = 600851475143 while num!=1 do ...
true
ff199c94b8d103f368869e5bebaf670204359b05
Ruby
soitun/hashie
/lib/hashie/extensions/dash/predefined_values.rb
UTF-8
2,600
3.125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module Hashie module Extensions module Dash # Extends a Dash with the ability to accept only predefined values on a property. # # == Example # # class PersonHash < Hashie::Dash # include Hashie::Extensions::Dash::PredefinedValues # # property :gender, valu...
true
ec3f5cabb5245f44b1186fb6fe0693ec71862960
Ruby
roycetech/rast
/examples/quoted.rb
UTF-8
202
2.609375
3
[]
no_license
# frozen_string_literal: true class Quoted def identify_sentence_type(sentence) return 'exclamation' if (sentence[/.*!/]) return 'question' if (sentence[/.*\?/]) 'statement' end end
true
10cff394f93a410db0cdb4b779223e479e72cbe8
Ruby
Jacob-Co/intro_to_ruby
/ruby_basics/methods/exercise_day_or_night.rb
UTF-8
146
3.328125
3
[]
no_license
daylight = [true, false].sample def time_of_day(time) puts "It's daytime!" if time puts "It's nighttime!" if !time end time_of_day(daylight)
true