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
a39384f63070900424db71b491d9a1ae4089bc3f
Ruby
kenmasco/bookmarker
/app/server.rb
UTF-8
2,565
2.703125
3
[]
no_license
require 'sinatra' require 'data_mapper' require 'rack-flash' env = ENV["RACK_ENV"] || "development" # we're telling datamapper to use a postgres database on localhost. #The name will be "bookmark_manager_test" or "bookmark_manager_developemnt" depending on the environment DataMapper.setup(:default, "postgres://localh...
true
7b349bbc4a1e8f9a683ec9d072e313a09f74b15c
Ruby
emillindblad/standard-biblioteket
/lib/absolute.rb
UTF-8
417
4.15625
4
[]
no_license
# Public: Takes an integer as input and returns it's absolute value. Absolute value resembeles the positive value of the integer. # # number - The integer that will be returned with the absolute value of that integer. # # Examples # # absolute(100) # # => 100 # Returns the absolute value of the integer. def absolut...
true
ede450ba3833f78309fa87000ed6c17440fc491c
Ruby
n3m3sis42/story-jam-api
/app/models/spread.rb
UTF-8
1,970
2.734375
3
[]
no_license
class Spread < ApplicationRecord belongs_to :jam belongs_to :type has_many :card_spreads has_many :cards, through: :card_spreads has_many :stories, through: :jam has_many :user_jams, through: :jam has_one :chat, through: :jam def build_board card_data = self.type.order_and_position card_spreads...
true
21a0c1df008f7b8d7c781635a71a05253800ff34
Ruby
joffroy/RubyLearning
/wk3/prompt.rb
UTF-8
95
2.96875
3
[]
no_license
module Prompt def prompt(heading) puts heading STDOUT.flush gets.chomp end end
true
81cb3c66b72119bc57b44e1bafc38b9d5d0802f1
Ruby
cha63506/virgin_stats
/lib/virgin_stats/network_monitor.rb
UTF-8
1,634
2.703125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module VirginStats class NetworkMonitor @@ping_count = 1 @@server = "www.google.com" @@sleep_duration = 10 def self.ping_succeeds? `ping -q -c #{@@ping_count} #{@@server} 2> /dev/null` $?.exitstatus == 0 end def initialize @log_file_name = VirginStats.network_monitor_log_fi...
true
4b430d9ef567594c7f285e0ba712160d88020add
Ruby
vc7/Pixnetr
/Rakefile
UTF-8
667
2.515625
3
[]
no_license
class String def self.colorize(text, color_code) "\e[#{color_code}m#{text}\e[0m" end def cyan self.class.colorize(self, 36) end def green self.class.colorize(self, 32) end end desc 'CocoaPod related' task :pod_install do puts 'Installing pods...'.cyan `pod install` end desc 'Setup with e...
true
5bfa4222a0698d0cf0d4f9972dacb83ce3f7d63f
Ruby
AizarCabrera/backend_prework
/day_6/ex3.rb
UTF-8
662
3.78125
4
[]
no_license
class Car def initialize(year, model, color) @year = year @model = model @color = color @speed = 0 end def speed_up(number) @speed += number puts "You hit the gas and accelerate #{number} mph." end def brake(number) @speed -= number puts "You hit the brake and decelerate #{...
true
49541d7ecf18ac36f54c208179cc6334281b9cc6
Ruby
maryammouse/umedoc-dev-rails
/app/models/medical_degree.rb
UTF-8
1,553
2.59375
3
[]
no_license
# == Schema Information # # Table name: medical_degrees # # id :integer not null, primary key # degree_type :string(255) not null # awarded_by :string(255) not null # date_awarded :date not null # created_at :datetime # updated_at :datetime # class MedicalDegree < ...
true
cb9e95174b8c5f1c89626cedf0857ccf0455fe74
Ruby
falsedmitry/HackerRankPractice
/sum_vs_xor.rb
UTF-8
276
3.40625
3
[]
no_license
#!/bin/ruby def solve(n) if n >= 0 && n <= 10**15 number_of_xs = 0 (0..n).to_a.each do |x| if (n + x).to_s(2) == (n ^ x).to_s(2) number_of_xs += 1 end end return number_of_xs end end n = gets.strip.to_i result = solve(n) puts result
true
77e8b38b675d9ac8729368655e566e452b89369d
Ruby
burke/coursework
/fall2009/comp4140/a2/question6.rb
UTF-8
369
2.796875
3
[]
no_license
#!/usr/bin/env ruby # File: question6.rb # Author: Burke Libbey <burke@burkelibbey.org> # Modified: <2009-10-20 20:42:27 CDT> puts File.read('cmystery.txt').reverse.gsub(/[\s\n]/m,'').gsub(/Z/,' ') # Heh, it's just backwards. I noticed "INSTRUCTIONS". # TSURTHIS LIFE IS A TEST IF IT HAD BEEN AN ACTAUL LIFE Y...
true
f723c44c3b11ab7d81c480d5df7856deb44cc2e7
Ruby
cmingxu/dake
/app/models/route.rb
UTF-8
1,310
2.625
3
[]
no_license
# -*- encoding : utf-8 -*- class Route < ActiveRecord::Base attr_accessible :driver_names, :end_location_id, :end_when, :mobile, :paizhao, :paths, :start_location_id, :start_when, :xinghao, :vehicle_id belongs_to :end_location, :class_name => "Location" belongs_to :start_location, :class_name => "Location" bel...
true
bcf2bc79525f07879f388f3122ea7adf6992b121
Ruby
moshjeyers321/AppAcademyOpen
/projects/tic_tac_toe/tic_tac_toe_v3/game.rb
UTF-8
1,382
3.78125
4
[]
no_license
require_relative 'board.rb' require_relative 'human_player.rb' require_relative 'computer_player.rb' # require 'daru' class Game attr_reader :board def initialize(board_size, **players_hash) #accepts the board size AND a hash of players telling us if the player is human FALSE or computer TRUE # @playe...
true
8e5678018c7d18b28e2d3ae383416021757349e5
Ruby
thorncp/oo-tic-tac-toe
/lib/player_won.rb
UTF-8
244
2.78125
3
[]
no_license
class PlayerWon attr_reader :status, :text_view def initialize(status:, text_view:) @status = status @text_view = text_view end def current? status.player_won? end def render text_view.render_player_won end end
true
8a823bcc90f750ff929da617b83565e91427daa8
Ruby
davemaurer/exercisms
/ruby/difference-of-squares/difference_of_squares.rb
UTF-8
358
3.265625
3
[]
no_license
class Squares attr_reader :num def initialize(num) @num = num @numbers = (1..num).to_a end def square_of_sum @numbers.reduce(:+) ** 2 end def sum_of_squares @numbers.reduce(0) do |sum, num| sum + (num ** 2) end end def difference return 0 if @num == 0 square_of_sum - sum_of_squares end end...
true
7dbbc7d46fcb81af5ccdd781552085962d34b28a
Ruby
magicwifi/HRDoctor
/config/initializers/stringiohax.rb
UTF-8
347
2.515625
3
[]
no_license
# define class that extends IO with methods that are required by carrierwave class CarrierStringIO < StringIO def original_filename # the real name does not matter "photo.png" end def content_type # real content type, "image/png" or "image/jpeg" # data.match(/data:(.*);/)[1] ...
true
c584e3795f81de3bd140aa1d65f7109ebeb88f61
Ruby
jhartwell/ironruby
/Tests/Experiments/Scope/ClassVars.rb
UTF-8
567
3.65625
4
[]
no_license
module M def foo @@m = 5 end end class X include M def goo puts @@m end end x = X.new x.foo x.goo class A @@a = 1 class B @@b = 2 class C @@c = 3 module D @@d = 4 puts @@a rescue puts "!a" puts @@b rescue puts "!b" ...
true
e590cfb8b5d28abd1939464d2357fbb85cedae93
Ruby
Su0414/badges-and-schedules-v-000
/conference_badges.rb
UTF-8
977
3.8125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Write your code here. attendees = ["Edsger", "Ada", "Charles", "Alan", "Grace", "Linus", "Matz"] def badge_maker(name) return "Hello, my name is #{name}." end def batch_badge_creator(attendees) badges = Array.new attendees.each do |token| badges << ("Hello, my name is #{token}.") end return ...
true
25227a389c0ee234873e3acb566e8b423407803e
Ruby
Elilasol/Poke-Game
/Poke_Game/Poke-Game/src/pokemon.rb
UTF-8
4,138
3.140625
3
[]
no_license
class Pokemon def self.random_sex(chance) case chance when -1 female_chance = -1 when 0 female_chance = 0 when 1 female_chance = 5 when 2 female_chance = 25 when 4 female_chance = 50 when 6 female_chance = 75 when 8 ...
true
b8d79043b26359eb1d24f4b4f903d0fb2ef4a470
Ruby
andrewhamon/partygoer
/app/models/playback_state.rb
UTF-8
625
3.109375
3
[]
no_license
class PlaybackState TRACK_CHANGE_THRESHOLD = 0.5.seconds attr_reader :progress, :duration def initialize(playing:, progress:, duration:) @playing = playing @progress = progress @duration = duration end def self.from_spotify_hash(spotify_hash) new( playing: spotify_hash["is_playing"], ...
true
e8f0d23ea751adb454c9c4ac7e6a58a4fafd87e4
Ruby
matthallquist/regex-lab-v-000
/lib/regex_lab.rb
UTF-8
762
3.375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' def starts_with_a_vowel?(word) if word.match(/\A[aeiouAEIOU]/) true elsif word.match(/\A[^aeiouAEIOU]/) false end end def words_starting_with_un_and_ending_with_ing(string) string.scan(/\bun\w*ing\b/) end def words_five_letters_long(string) string.scan(/\b\w{5}\b/) end def first_word...
true
4cf7bc20f76b9f8818f27821b0ee14a6aed8dcb3
Ruby
kmhjs/slack-ruby-gem-message
/lib/slack-ruby-gem-message.rb
UTF-8
2,638
3.265625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'json' # # A module for define type, generate struct, and mapping. # module Response # # A module for type definition and validation. # Definitions are defined in JSON file. # module Type # Definition JSON file DEFINITION_FILE = File.expand_path('../../config/types.json', __...
true
f9967e613dfbbc09188473abe15fa0fe5ef78198
Ruby
marcomontes/myvideos
/app/models/youtube_adapter.rb
UTF-8
1,361
2.5625
3
[]
no_license
require 'rubygems' require 'google/api_client' class YoutubeAdapter DEVELOPER_KEY = 'AIzaSyDUuV3OAjGUaKEjBsvHSY31N03_d2PKvHw' YOUTUBE_API_SERVICE_NAME = 'youtube' YOUTUBE_API_VERSION = 'v3' def self.get_service client = Google::APIClient.new( :key => DEVELOPER_KEY, :authorization => nil, ...
true
3684bceffc234a8ed5035d6618f2bbd5ae783f82
Ruby
fuzioncloud/yolodice-validator
/lib/yolodice_validator.rb
UTF-8
4,440
3
3
[ "MIT" ]
permissive
# Copyright (c) 2016 Ethan White (YOLOdice.com) # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, p...
true
c333a52b68dc899b4e5c907fbd8b51580a6e97ce
Ruby
viewworld/NewBizzShoppen
/config/initializers/formtastic.rb
UTF-8
5,302
2.671875
3
[]
no_license
# Set the default text field size when input is a string. Default is 50. # Formtastic::SemanticFormBuilder.default_text_field_size = 50 # Set the default text area height when input is a text. Default is 20. # Formtastic::SemanticFormBuilder.default_text_area_height = 5 # Should all fields be considered "required" by...
true
e28bcae804c47ded5377f7882ca1d16de1abbd8f
Ruby
iwan/aggrego
/lib/aggrego/aggregate.rb
UTF-8
4,306
2.671875
3
[ "MIT" ]
permissive
module Aggrego class Aggregate FORCE_TO_SYM = true attr_reader :incl_atoms, :excl_atoms, :incl_molec, :excl_molec def initialize(incl_atoms, excl_atoms=[], incl_molec=[], excl_molec=[], rules={}) %w(incl_atoms excl_atoms incl_molec excl_molec).each do |a| v = eval(a) v = FORCE_TO_SY...
true
66fd264b99b4913555c4999803813dfaaaf42ae0
Ruby
BH-dojos/jokenpo-ruby
/spec/scissors_spec.rb
UTF-8
660
2.75
3
[]
no_license
require 'spec_helper' require_relative '../scissors' describe Scissors do let(:paper) { Paper.new } let(:rock) { Rock.new } it "draws with scissors" do expect(subject.result(subject)).to eq :draw end it "loses to rock" do winner = subject.result rock expect(winner).to eq :loses end it "beats...
true
ecfa3ac525326dd7924dce2952fb09eea1b581a9
Ruby
avenuematt/Launch_School_Ruby_Challenges
/Easy 1/Octal/octal.rb
UTF-8
267
3.546875
4
[]
no_license
class Octal def initialize(num) @num_str = num end def to_decimal return 0 if @num_str.match?(/[^0-7]/) total = 0 @num_str.chars.map(&:to_i).reverse.each_with_index do |num, idx| total += num * 8 ** (idx) end total end end
true
6a2d7dba1e5090f4fbf8987eedb7242d1ffe447b
Ruby
aldaeron/csci568
/project05/test_k_means.rb
UTF-8
5,287
2.765625
3
[]
no_license
require_relative 'k_means' # Test K Means function with Iris dataset iris_data_handle = File.open("iris.csv", "r") data_set_string = Hash.new data_set = Hash.new normalized_data_set = Hash.new data_title = Hash.new data_type = Hash.new data_size = 0 range_min = Hash.new range_max = Hash.new range = Hash.new cluste...
true
3992d9e5078c596c098e86853ad7eb13f1f2a086
Ruby
zhanglintc/tools-lite
/ruby/quick_start.rb
UTF-8
599
3.015625
3
[]
no_license
require 'Find' targetFolder = 'target_folder_path_here' def each_file target Find.find(target) do |path| if not File.directory? path yield path end end end def isTargetFile path fileName = File.basename(path) || "" fileExt = File.extname(path)[1..-1] || "" if ["ini"].include? fileExt.downcas...
true
be89b323bf445f2c91af83cc5ee0d297682f21f2
Ruby
markenmakotya/OpenFlow-visualizer
/ruby/switch.rb
UTF-8
645
3.09375
3
[]
no_license
class TopologyPort def initialize port @port = port end def up? @port.up? end def down end end class TopologySwitch attr_reader :ports def initialize datapath_id @datapath_id = datapath_id @ports = [] end def add port @ports << port end def delete port port.down @ports -= [ port ...
true
eff37a31b8c78364f71103cdf3948dad1df5bb59
Ruby
mattfreeman-london/boris_bikes_new
/practice_setups/ruby/rubypractice1/spec/docking_station_spec.rb
UTF-8
1,655
2.875
3
[]
no_license
require 'docking_station' describe DockingStation do it 'has a default capacity' do expect(subject.capacity).to eq DockingStation::DEFAULT_CAPACITY end describe '#dock' do it 'raises an error when the station is full' do bike = double(:bike) subject.capacity.times do subject.dock(bi...
true
acf2cbafba3a0790d9beb50c21713044cda950a7
Ruby
crisimonc/crisimonc
/Exercises/taskManager/router.rb
UTF-8
657
3.46875
3
[]
no_license
class Router def intialize(controller) @controller = controller end def run loop do print_actions answer = gets.chomp.to_i dispatch(answer) end end def print_actions puts "\n---" puts 'What do you want to do?' puts '1 - Display tasks' puts '2 - Add a new task' ...
true
c67da9dc41635da302f75b56e684dcc6498b742a
Ruby
h4ck3rm1k3/reek
/lib/reek/source/tree_dresser.rb
UTF-8
4,842
2.875
3
[ "MIT" ]
permissive
module Reek module Source # # Extensions to +Sexp+ to allow +CodeParser+ to navigate the abstract # syntax tree more easily. # module SexpNode def self.format(expr) case expr when Sexp then expr.format_ruby else expr.to_s end end def hash ...
true
d07e3c097cb60a0f69f5ae073413f164f70ac5a1
Ruby
DanielitoAlbinsson/danielgit1
/syntax.rb
UTF-8
86
3.078125
3
[]
no_license
names = ['Thomas', 'Kalle', 'Anders'] names.each do |name| puts "#{name} hello" end
true
80e64d7cc22bf1fab06feff16ca3b7196c1d28a7
Ruby
antonzaharia/algorithms
/Ruby/scramble.rb
UTF-8
430
3.671875
4
[]
no_license
class Scramble def initialize(str1, str2) @str1 = str1 @str2 = str2 end def play word = @str1.split("") arrOfBools = @str2.split("").map do |letter| if word.include?(letter) word.delete_at(word.index(letter)) true else ...
true
688f99be8cab9e629a8307dd0993b326883be04c
Ruby
dabit/persistent_settings
/spec/lib/persistent/settings.rb
UTF-8
6,659
2.6875
3
[ "MIT" ]
permissive
require 'spec_helper' describe Settings do describe :assignation? do context "the method name ends with =" do it "returns true" do Settings.assignation?("method=").should be_true end end context "the method name does not end with =" do it "returns false" do Settings.ass...
true
0dae0aaafff391ef6d43df5a7a34dd8419d81ad8
Ruby
um3on/prime-ruby-dumbo-web-121018
/prime.rb
UTF-8
175
2.78125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Add code here! def prime?(num) if num <= 1 return false end for x in 2..Math.sqrt(num) do if num % x == 0 return false end end return true end
true
2f2fb9d533e342ce742d6854ae60445352de045d
Ruby
just-ally/Ruby_Gym_Project
/models/member.rb
UTF-8
2,483
3.25
3
[]
no_license
require_relative('../db/sql_runner.rb') require_relative('./workout.rb') require_relative('./gymclass.rb') class Member attr_reader :id attr_accessor :member_name, :email, :premium_membership def initialize(options) @id = options['id'].to_i() if options['id'] @member_name = options['member_name'] @...
true
bdfab99a3bca3bc69d914bc51ab47d0372cb2380
Ruby
maltyeva/imdb
/scraper.rb
UTF-8
906
2.953125
3
[]
no_license
require 'nokogiri' require 'open-uri' def fetch_movies_url imdb = "https://www.imdb.com/chart/top" imdb_base_url = "https://www.imdb.com" imdb_read = open(imdb).read imdb_parse = Nokogiri::HTML(imdb_read) imdb_path = [] imdb_parse.search(".titleColumn a").each do |movie| imdb_path << movie.attribute("h...
true
3c2d285e7bd59577c72fb8f9aeea26d5e25eb038
Ruby
floatbox/eap-ota
/spec/lib/commission_formula_spec.rb
UTF-8
7,820
2.90625
3
[]
no_license
# encoding: utf-8 require 'spec_helper' describe Commission::Formula do before do Commission::Formula.clear_cache end include Commission::Fx specify { Fx("3").apply.should == 3 } specify { Fx("3.5").apply.should == 3.5 } specify { Fx("3.5").apply(23).should == 3.5 } specify { Fx("3.5%").apply(200)....
true
bda3e856520e96661125e9c29d83fc4d5673e976
Ruby
wrtcoder/openwrt-hotspot
/data_test.rb
UTF-8
1,117
2.703125
3
[]
no_license
#!/usr/bin/ruby require 'hotlib' def save_data(filename, data) File.open(filename, "w") do |f| Marshal.dump(data, f) end end def repair_record(obj, data) if obj.instance_of? HotRecord then if obj.state == HotState::PERMANENT then newrec = HotRecord.new(obj.mac) newrec.token = ...
true
4fea1485a077f3e28b81a3c83a7f772a2aed30a1
Ruby
huangkc/phase-0
/week-4/triangle-side/my_solution.rb
UTF-8
309
3.125
3
[ "MIT" ]
permissive
# I worked on this challenge [with: Eunice Choi]. # Your Solution Below def valid_triangle?(a, b, c) ((a+b>c) && (b+c>a) && (a+c>b))? true:false end =begin #This is the code before refactoring def valid_triangle?(a, b, c) if a+b>c && b+c>a && a+c>b return "true" else return "false" end end =end
true
42925c442162935bf28a605380c664a41b6e8c8a
Ruby
Kite0301/atcoder
/Beginner/020/a.rb
UTF-8
67
2.890625
3
[]
no_license
case gets.chomp.to_i when 1 puts 'ABC' when 2 puts 'chokudai' end
true
f3ed69b53ea307b64ca602e33ec59a5f625f9784
Ruby
paploo/sliderule_tester
/lib/tools/random.rb
UTF-8
1,096
3.15625
3
[ "BSD-3-Clause" ]
permissive
module Random def self.int(*args) min, max = process_range_args(0, 100, *args) return rand(max-min+1)+min end def self.float(*args) min, max = process_range_args(0.0, 1.0, *args) return rand()*(max.to_f-min.to_f) + min.to_f end def self.mag_float(*args) min, max = process_range_ar...
true
54a0a58b6c4d52e736c6a6c7026284ca742343c5
Ruby
cpjobling/proman_mmxiii
/app/models/person.rb
UTF-8
1,475
2.65625
3
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0" ]
permissive
class Person < User include Mongoid::Document field :title, :type => String field :forename1, :type => String field :forename2, :type => String, :default => '' field :forename3, :type => String, :default => '' field :preferred_name, :type => String, :default => '' field :surname, ...
true
ccf7c81e5f9d5afd01152aa433a7628c8698c92c
Ruby
davekessener/PokemonRuby
/src/lib/pokemon.rb
UTF-8
318
2.84375
3
[]
no_license
module Pokemon module Data class Pokemon attr_accessor :nickname, :species, :moves, :hp, :status def load(tag) @nickname = tag['nickname'] @species = Species[tag['species'].to_sym] @moves = tag['moves'].map { |m| Move[m.to_sym] } @hp = tag['hp'] @status = tag['status'].to_sym end end end end
true
9a4cc51e8244f05c64a630cc4e81e12ae34e5482
Ruby
aec2956/image-blur
/imageblur3.rb
UTF-8
1,361
3.734375
4
[]
no_license
class Image def initialize(image) @image = image end def find_ones ones = [ ] @image.each_with_index do |row, current_pixel_x_position| row.each_with_index do |pixel, current_pixel_y_position| if pixel == 1 ones << [current_pixel_x_position,current_pixel_y_position] ...
true
81728c42bb55d4430277ee64f9e2ded5335def4e
Ruby
sjaakvandenberg/codewars-ruby
/7_kyu/046_dropcaps.rb
UTF-8
1,192
4.5
4
[]
no_license
# 046_dropcaps.rb # http://www.codewars.com/kata/dropcaps # # Sjaak van den Berg # http://www.codewars.com/users/sjaakvandenberg # @svdb # DropCaps means that the first letter of the starting word of the paragraph # should be in caps and the remaining lowercase, same like you see in the # newspaper. # But for a chang...
true
eb01feb4dbb54d2638dcd7d2adf2abc30fd69e3c
Ruby
allenchen/research-cs194
/research/vendor/plugins/acts_as_indexed/lib/acts_as_indexed/configuration.rb
UTF-8
1,285
2.734375
3
[ "MIT" ]
permissive
# ActsAsIndexed # Copyright (c) 2007 - 2010 Douglas F Shearer. # http://douglasfshearer.com # Distributed under the MIT license as included with this plugin. module ActsAsIndexed # Used to set up and modify settings for acts_as_indexed. class Configuration # Sets the location for the index. Specify as an ...
true
8bee3424121477933c829f170a695671bfd97de4
Ruby
galisamas/BTsystem
/entities/coach.rb
UTF-8
225
2.984375
3
[]
no_license
require './entities/person.rb' # This is Coach class class Coach < Person def initialize(name, last_name, gender, level = 'assistant') super(name, last_name, gender) @level = level end attr_accessor :level end
true
3a5a9575321c463ab4ac193fb35c384d10fdb143
Ruby
ged/mues
/lib/mues.rb
UTF-8
2,130
2.5625
3
[]
no_license
#!/usr/bin/ruby # # The Multi-User Environment Server. # # This module provides a collection of modules, functions, and base classes for # the Multi-User Environment Server. Requiring it loads all the subordinate # modules necessary to start the server. # # # == Synopsis # # require 'mues' # MUES::Engine.start( ...
true
34fdab1e8973a14dc395dd9951f9e0998f7c0497
Ruby
Unitech/TAH-project
/app/models/table.rb
UTF-8
1,729
2.5625
3
[]
no_license
# == Schema Information # # Table name: tables # # id :integer not null, primary key # title :string(255) # description :text # capacity :integer # user_id :integer # table_available :boolean # theme ...
true
8b31e20c7e37eb78dd873427067b64fc4f1673ee
Ruby
amorshanty/AdressBook
/app/models/person.rb
UTF-8
258
2.515625
3
[]
no_license
class Person < ActiveRecord::Base validates_presence_of :name, :adress validates :name, uniqueness: true, length:{ maximum: 30 } def self.search(search) search_condition = "%" + search + "%" where('name LIKE ?', search_condition) end end
true
fee84c89db90e4c4fe26e3664cc917b0cde88017
Ruby
yuzixun/algorithm_exercise
/22/2.rb
UTF-8
599
3.203125
3
[]
no_license
# @param {Integer} n # @param {Integer[][]} reserved_seats # @return {Integer} def max_number_of_families(n, reserved_seats) count = 0 result = Hash.new(0) reserved_seats.each do |seat| row, column = seat if column == 2 || column ==3 result[row] |= 1 end if column == 4 || column == 5 ...
true
fa34ce45227d59f0ef8d16428962897e8442ffb4
Ruby
dominicsayers/mailchimp_api_v3
/lib/mailchimp_api_v3/member.rb
UTF-8
1,890
2.640625
3
[]
no_license
# frozen_string_literal: true module Mailchimp class List class Member < Instance # Class methods def self.add_id_to(data) clean_data = data.deep_stringify_keys return clean_data unless clean_data.key? 'email_address' clean_data.merge id: clean_data['email_address'].convert_t...
true
459bc6562a974c0cb3df1de46e197806dd91d36c
Ruby
FooDecoded/W4D2
/chess/board.rb
UTF-8
1,264
3.40625
3
[]
no_license
require_relative "pieces/piece.rb" require_relative "pieces/null_piece.rb" class Board def intialize @rows = Array.new(8) { Array.new(8) } # NullPieces add_pieces @sentinel = NullPiece.instance end def add_pieces() @rows.each_with_index |row, row_idx| row.each_with_index do |el, col_idx| ...
true
bfcbf7030892d2ea72d7518887b4e723509909b7
Ruby
RonWalker22/haymaker
/app/helpers/exchanges_helper.rb
UTF-8
336
2.53125
3
[ "MIT" ]
permissive
module ExchangesHelper def strip_dash_from_pair pair = params[:p] mid_point = pair =~ /-/ coin_1_ticker = [] coin_2_ticker = [] pair.size.times do |n| coin_1_ticker << pair[n] if n < mid_point coin_2_ticker << pair[n] if n > mid_point end "#{coin_1_ticker.join}#{coin_2_ticker.j...
true
c62147efa4bde4b31ef8ef88b8fc85d9ec21534c
Ruby
dbaynes/RubyFall2013
/week8/homework/features/step_definitions/tic-tac-toe.rb
UTF-8
3,543
3.140625
3
[ "Apache-2.0" ]
permissive
class TicTacToe SYMBOLS = [:X,:O] attr_accessor :player, :board, :status def initialize(current_player=nil,game_symbols=nil) @board = {:A1 => ' ', :A2 => ' ', :A3 => ' ', :B1 => ' ', :B2 => ' ', :B3 => ' ', :C1 => ' ', :C2 => ' ', :C3 => ' '} @status = status @cur...
true
c2785bab0f20b79128df218e29c0479ced61b870
Ruby
KeijiBranshi/Git
/ProjectEuler/4.rb
UTF-8
515
3.875
4
[]
no_license
#Largest palindromic number that is the multiple of two 3-digit numbers require './lib/palindrome.rb' include Palindrome $answer = 0 $x = 0 $y = 0 999.downto(100).each do |i| i.downto(100).each do |j| product = i*j =begin if product.to_s[0] == product.to_s[product.to_s.length-1] print (product) puts " = #{...
true
56d3253772fed5d74f46b21abe07f39582702452
Ruby
marymotherofdog/learn_ruby
/04_pig_latin/pig_latin.rb
UTF-8
776
3.890625
4
[]
no_license
def translate(string) vowels = ['a', 'e', 'i', 'o', 'u'] words = string.split(' ') word_array = words.each do |word| if vowels.include? word[0] word << "ay" elsif word[0..1].downcase == "qu" first_two = word[0..1].downcase word.reverse! word.chop! word.chop! word.rev...
true
1ba64a77cb6437707356cd670c76744a2ed2ed85
Ruby
Pekhov/TestGuru
/lib/clients/git_hub_client.rb
UTF-8
461
2.5625
3
[]
no_license
class GitHubClient ROOT_END_POINT = 'https://api.github.com' def initialize @http_client = setup_http_client end def create_gist(params) @http_client.post('gists') do |request| request.headers['Authorization'] = "token #{ENV['ACCESS_TOKEN']}" request.headers['Content-Type'] = 'application...
true
22dd33ccfa57c6b9ae1f93e2ad33bce392998f2f
Ruby
gocardless/ice_cube
/lib/ice_cube/builders/hash_builder.rb
UTF-8
378
2.625
3
[ "MIT" ]
permissive
module IceCube class HashBuilder def initialize(rule = nil) @hash = { :validations => {}, :rule_type => rule.class.name } end def validations @hash[:validations] end def []=(key, value) @hash[key] = value end def validations_array(type) validations[type] ||= []...
true
44a5d658f70364dce5680c45385fb4893255d852
Ruby
nmgokhale/Ruby-Programming
/src/Software Engineering Foundations/Object Oriented Programming/lecture.rb
UTF-8
771
3.828125
4
[]
no_license
# attr_reader - defines Getter methods # attr_writer - defines Setter methods # attr_accessor - defines both Getter & Setter methods class Dog # attr_reader :name, :age # Generates Getter methods for these attributes # attr_writer :name, :age # Generates Setter methods for these attributes attr_accessor :n...
true
056dd2b7d11ee98613c7d83f920312291a3f28fb
Ruby
SciRuby/mdarray
/test/colt/matrix/test_operations.rb
UTF-8
3,505
2.828125
3
[ "NetCDF", "BSD-2-Clause" ]
permissive
# -*- coding: utf-8 -*- ########################################################################################## # Copyright © 2013 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify, # and distribute this software and its documentation, without fee and without a signed # licensing agreement, i...
true
7b8483c5d8efe80938ab24826e7750a6e49aa8b5
Ruby
ai/evil-front
/evil-front/lib/evil-front/helpers/english_typograph.rb
UTF-8
510
3
3
[ "MIT" ]
permissive
module EvilFront::Helpers # Insert non-break spaces and mark quotes to have nice text. # Work only with English language. # # = english_typograph user.description # # You can send block: # # = english_typograph do # = user.name # = user.profession def english_typograph(text = nil, &blo...
true
f35fd43b7a3b333120daa9248cb8ccba0232b215
Ruby
clairemariko/project_one_money_tracker
/models/account.rb
UTF-8
784
3.015625
3
[]
no_license
class Account attr_reader( :transactions, :merchants, :tags) def initialize(options) @transactions = options["transactions"] @merchants = options["merchants"] @tags = options["tags"] end def list_merchants return @merchants.map{ |merchant| merchant.name } end def list_tags return @t...
true
82604b8440c7dde9b705ffddacb5470fbc0597c4
Ruby
dkmerys/anagrams
/lib/anagrams.rb
UTF-8
1,032
3.859375
4
[ "MIT" ]
permissive
require 'pry' class Anagram attr_reader(:user_word_1, :user_word_2) def initialize(user_word_1, user_word_2) @user_word_1 = user_word_1.downcase.gsub(/[!@#$%^&*()+={}"':;?><.,~]/, "*") @user_word_2 = user_word_2.downcase.gsub(/[!@#$%^&*()+={}"':;?><.,~]/, "*") end def word_checker(*words) vowels ...
true
c6082cfab69016d6116126c394cb26c643926d08
Ruby
kscali/appacademy_weeks
/W5D2/lib/board.rb
UTF-8
829
3.5
4
[]
no_license
require_relative "card.rb" class Board def initialize(size) if size.odd?# == true size += 1 end @board_size = size @board = Array.new(size) { Array.new(size) { Card.new(nil) } } end def populate values = [1,1,2,2,3,3,4,4].shuffle @board.eac...
true
31b58fc8e2715b5c21bf76e1026ac142de864cbf
Ruby
stephenedwardng/snake_and_ladders
/specs/board_spec.rb
UTF-8
440
2.71875
3
[]
no_license
require 'minitest/autorun' require 'minitest/rg' require_relative '../player' require_relative '../board' require_relative '../game' class TestBoard < MiniTest::Test def setup @game = Game.new() @player_1 = Player.new("Eddie") @player_2 = Player.new("John") @board = Board.new() end def test...
true
2146ebc0d03c53b3d6e7335dc4b5d6b1a8da9824
Ruby
lavekyl/vets-api
/modules/appeals_api/app/controllers/concerns/appeals_api/higher_level_reviews/pdf_form_field_v1_validator.rb
UTF-8
1,941
2.53125
3
[ "CC0-1.0", "LicenseRef-scancode-public-domain" ]
permissive
# frozen_string_literal: true require 'appeals_api/higher_level_review/phone' module AppealsApi module HigherLevelReviews class PdfFormFieldV1Validator INFORMAL_CONFERENCE_REP_NAME_AND_PHONE_NUMBER_MAX_LENGTH = 100 def initialize(request_body, request_headers) @request_body = request_body ...
true
43b3fbc2e26edda34377224ee3a9e04501adc1d3
Ruby
anibha88/Pine
/proc_demo.rb
UTF-8
78
2.578125
3
[]
no_license
toast = Proc.new do puts "Hari Sarvothama Vaayu Jeevothama" end toast.call toast.call toast.call
true
b48173cbbdc93bf63c497b1e4481707a162f0d38
Ruby
francosta/silicon-valley-code-challenge-london-web-career-021819
/tools/console.rb
UTF-8
1,819
2.65625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require_relative '../config/environment.rb' def reload load 'config/environment.rb' end # Insert code here to run before hitting the binding.pry # This is a convenient place to define variables and/or set up new object instances, # so they will be available to test and play around with in your console su1 = Startup...
true
b9cc9242322c25fa1ad177400a64fc2488bd851e
Ruby
mietek/icfp-contest-2012
/tools/gui-validator/board.rb
UTF-8
5,206
3.4375
3
[ "BSD-3-Clause" ]
permissive
class Board attr_reader :data, :moves_log, :score def initialize(file, interactive = true) @moves_log = [] @score = 0 @lambdas = 0 @interactive = interactive parse_board(file) @next_flood = @flooding if @flooding > 0 @steps_underwater = 0 end def make_move(direction) ...
true
e9eeb8e241669214d54c5c8d0ac421dd5999d7e4
Ruby
liman-rpg/ruby
/example_06/passenger_vagon.rb
UTF-8
799
3.515625
4
[]
no_license
require_relative 'vagon' class PassengerVagon < Vagon attr_accessor :number def initialize(size) @max_places = size @free_places = size valid? end def take_place @free_places -= 1 if @free_places > 0 end def free_place @free_places += 1 if @free_places < @max_places end def size...
true
bb8db482376ea612e116cda9941ef4240b32cc99
Ruby
bdtomlin/training
/edible.rb
UTF-8
169
3.140625
3
[]
no_license
module Edible def eat puts "yum" end end class Berry include Edible end class Pastry include Edible end b = Berry.new b.eat p = Pastry.new p.eat
true
f93519cea3671d9a894f68fb330dd446c030dac4
Ruby
StemboltHQ/harvest-shamer
/models/user.rb
UTF-8
475
2.90625
3
[]
no_license
class User attr_accessor :first_name, :last_name, :email, :entries def initialize(params = {}) @first_name = params[:first_name] || "" @last_name = params[:last_name] || "" @email = params[:email] || "" @entries = params[:entries] || [] end def blank_entries entries.select { |entry| !entry...
true
85ccefc72871674dc06fc5c2c3711cd6606dab8c
Ruby
momchianev/test
/study/5.rb
UTF-8
209
3.125
3
[]
no_license
# number that % 3 or 5 but not both chislo = 0 while chislo <= 1000 chislo = chislo + 1 if ( chislo % 3 == 0 or chislo % 5 == 0 ) and chislo % 15 != 0 puts chislo end end
true
9f90114134092fbfe7831cfab4eefc185a13ee0e
Ruby
moneil868/-Bitmaker-Aug-14th---02---Object-Oriented-Programming-Classes-and-Objects
/exercise2_cats_meow.rb
UTF-8
1,553
4.84375
5
[]
no_license
#Create a class called Cat class Cat # Every cat should have three attributes when they're created: name, preferred_food and meal_time def initialize(name, preferred_food, meal_time) @name = name @preferred_food = preferred_food @meal_time = meal_time end # Add an instance method called eats_at that ...
true
330918d412dd2fb7a59fc960a6f12cf50588fb31
Ruby
ernestas-poskus/ruby-ood
/creational/factory/factory.rb
UTF-8
1,061
3.21875
3
[ "MIT" ]
permissive
=begin @Author: Ernestas Poskus @Author-URI: out13.com @LinkedIn: linkedin.com/in/ernestasposkus/ @GitHub: github.com/ernestas-poskus ----- @date: 12/2/13 - 5:29 PM Project: Factory pattern @Definition: defines an interface for creating an object, but let subclasses decide which class to instantiat...
true
68bce33be0e48fefe420b3604bafe06d2b15067a
Ruby
Ttang8/problem_sets
/two_sum.rb
UTF-8
256
3.578125
4
[]
no_license
def two_sum(nums, target) hash = {} nums.each_with_index do |num, idx| check = target - num if hash[check] && hash[check] != idx return [idx, hash[check]] else hash[num] = idx end end end
true
8b1720f18696f23f15da202696d8cb97bb24b41a
Ruby
andyw8/digibankdemo
/spec/models/dashboard_spec.rb
UTF-8
768
2.5625
3
[]
no_license
require_relative "../../app/models/dashboard" describe Dashboard, "#account" do it "returns the passed in account" do account = double(:account) dashboard = Dashboard.new(account) expect(dashboard.account).to eq account end end describe Dashboard, "#account_balance" do it "returns the balance of t...
true
281ad036c53813273cc7c5a2b81002c3daaf9fd6
Ruby
tanlaan/top_linked_lists_ruby
/lib/linked_list.rb
UTF-8
3,348
3.53125
4
[]
no_license
class LinkedList # Allows LinkedList.head to be called attr_reader(:head) def initialize(head_node = nil) @head = head_node end def append(value) # adds a new node containing value to the end of the list current_node = @head until current_node.next_node == nil ...
true
7eab518cea521ce9bafc49214b48a47bb819294d
Ruby
vikhyat/latex-to-unicode
/test.rb
UTF-8
6,558
3.09375
3
[]
no_license
# coding: utf-8 require 'test/unit' require './lib/latex-to-unicode.rb' class TestConverter < Test::Unit::TestCase def test_atoms # Ensure that all symbols are translated correctly File.open('./lib/data/symbols').readlines.each do |l| sym, res = l.split assert_equal res, LatexToUnicode::convert(s...
true
1bc3f737e2ccf8fdde5ef306532eb354ef0929ee
Ruby
learn-academy-2019-echo/rails-assessment-6-kalvin-k
/rails.rb
UTF-8
2,533
4.15625
4
[]
no_license
# ASSESSMENT 5: INTRO TO RAILS # Coding practical questions # 1. Create a method called hello_world that takes a language code (e.g. "es", "de", "ru", "ja") as an argument and returns the appropriate version of "Hello, World" for the given language. The default should be English. Test your code with THREE method calls...
true
cf2d0a1a68d038a2984fe44d17b311593c75c257
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/cs169/combine_anagrams_latest/10220.rb
UTF-8
317
3.609375
4
[]
no_license
def combine_anagrams(words) anagrams = [] words.each do |word| group = anagrams.select {|g| anagrams?(g.first, word) }.first if group group << word else anagrams << [ word ] end end anagrams end def anagrams?(word1, word2) word1.upcase.chars.sort == word2.upcase.chars.sort end
true
f862edca8e71f6d76f3371ab130051fd8c3cc582
Ruby
xlash/Hockey_Salary_Capgeek
/scrapper.rb
UTF-8
987
2.765625
3
[]
no_license
require 'rubygems' require 'mechanize' require 'json' a = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' } require 'csv' csv_text = File.read('liste_attaquants3.csv') csv = CSV.parse(csv_text, :headers => false) csv.each do |row| name_array = row[1].split(" ") name_array a.get('http://cap...
true
d4ab5408cb2edc83aacdde1c12256d1cc4e195e2
Ruby
sruthyv/count
/word_count_test.rb
UTF-8
1,013
2.625
3
[]
no_license
require "test/unit" require_relative "word_count" class WordCountTest < Test::Unit::TestCase def test_lines_count expected_response = 13 generated_response = WordCount.new(file_name: 'file.txt').line_count assert_equal expected_response, generated_response end def test_word_count expected_respon...
true
db5676aba2339155c2ab1d10c2403897a8629467
Ruby
baozoumanhua/elk-rtf
/logstash/vendor/bundle/jruby/1.9/gems/ftw-0.0.42/lib/ftw/agent.rb
UTF-8
16,101
2.84375
3
[ "Apache-2.0", "Artistic-1.0", "Artistic-2.0" ]
permissive
require "ftw/namespace" require "ftw/request" require "ftw/connection" require "ftw/protocol" require "ftw/pool" require "ftw/websocket" require "addressable/uri" require "cabin" require "openssl" # This should act as a proper web agent. # # * Reuse connections. # * SSL/TLS. # * HTTP Upgrade support. # * HTTP 1.1 (RFC...
true
f12739835f68e59665d040cb43afb6f5ee3e7554
Ruby
benpolinsky/el_photography
/app/models/checkout.rb
UTF-8
329
2.796875
3
[]
no_license
# A Checkout Object further standardizes PaymentProcessor # Perhaps I've stripped away too much responsibility.. class Checkout attr_reader :processor def initialize(args) @processor = args[:processor] end def pay! processor.process! end def complete!(args) processor.complete!(args) ...
true
250322288394d5cb20459e34949d80fbb5a82183
Ruby
BenjaminDelacombaz/POO2
/exercices/ex_08_visitor/main.rb
UTF-8
697
3.5625
4
[ "MIT" ]
permissive
require_relative './browsable_word_search_tree' require_relative './browsable_word_array' require_relative './words_by_length' require_relative './words_starts_by' function_array = BrowsableWordArray.new # Read the passed or default file containing function names functions_array = File.readlines(ARGV[0] || 'functions....
true
d211bae5cfa8827f76c4953f5a29140ea1eb8584
Ruby
VijayEluri/DUBwise
/shared/misc/messenger.rb
UTF-8
2,619
2.875
3
[]
no_license
# mailto: ligi atttt ligi dotttt de require 'socket' require 'fcntl' class IPSocket def portInfo(out = STDOUT) out.puts "local: #{addr[1]}\n" + "remote: #{peeraddr[1]}" end end if ARGV.length!=1 || !ARGV[0].include?(":") puts "USAGE:" puts "$> ruby messenger.rb [ip:port]" puts "" puts "using ...
true
c952f092f9be46e9520f2d89309dede361cb3ea4
Ruby
lnabrigo18/Ruby-Activities
/activity6_int.rb
UTF-8
1,213
4.21875
4
[]
no_license
class Box def initialize(shape, length, width, height) @shape = shape @length = length @width = width @height = height end def details puts "Shape: #@shape" puts "Dimensions: #@length x #@width x #@height inches" puts "Area: Calculations for Square an...
true
0c2b976d5f45c56273d6c4d7280f3bbdc2187981
Ruby
emiliano1/your-mechanic-st_test
/mechanic_scheduler.rb
UTF-8
1,284
3.1875
3
[]
no_license
class MechanicScheduler ALLOWED_COMMANDS = %w(add remove).freeze attr_reader :list def initialize reset end def reset @list = [] end def print puts @list.inspect end def add(from, to) return @list << [from, to] if @list.size.zero? @list = @list.flatten.sort if from > @list...
true
d563e5a838eb46f787a4b59c35025a76e730aad6
Ruby
paulccarey/checkout
/spec/checkout/types_spec.rb
UTF-8
1,081
2.765625
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'spec_helper' module Checkout RSpec.describe Types do describe 'Money' do it 'parses the string and instantiates a Money instance with the correct currency' do money_instance = described_class::Money['€100'] expect(money_instance).to be_instance_of(::M...
true
96afb83e5c8ef452adb0e7f91539da7d13f9338d
Ruby
digital-fabric/eno
/lib/eno/query.rb
UTF-8
4,826
2.78125
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Eno # Query represents an SQL query. class Query # Initializes a new query. # # @param **ctx [Hash] query context values # @param &block [Proc] query code # @return [void] def initialize(**ctx, &block) @ctx = ctx @block = block end #...
true
d7447b6da28aeb2248378ed644aba22264f63fab
Ruby
omarsar/midas_api
/2_preprocessing/Carlos_emotion_classifier_API.rb
UTF-8
2,472
2.8125
3
[]
no_license
require 'net/http' require 'cgi' require 'csv' require 'json' require 'uri' require 'mongo' require 'set' include Mongo def post(payload) payload = payload.to_json uri = URI("http://192.168.2.30:8080/webresources/jammin/emotion") req = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'applicati...
true
568e59a57d124f64088e08c91437b90663c6486e
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/filtered-submissions/645a056180234a04a678da0c101d4bf1.rb
UTF-8
200
3.25
3
[]
no_license
def compute(seq1, seq2) total = 0 seq1.split('').each_with_index do |base, index| break if index + 1 >= seq2.length total+=1 if base != seq2[index] and index < seq2.length end total end
true
f9f40c1aeeec2c36cd59e7a21a3eecc2f0371a6d
Ruby
paulinhamp/bookstore
/spec/support/mocks/redis.rb
UTF-8
288
2.59375
3
[]
no_license
module Support module Mocks class Redis def initialize @hash = {} end def set(key, value) @hash[key] = value.to_s end def get(key) @hash[key] end def del(key) @hash.delete(key) end end end end
true
dce97075ce6a8ab4d6957d1d3985a2dba1af6694
Ruby
cloudarena/ffcrm-misc
/spec/unit/product_spec.rb
UTF-8
664
2.78125
3
[ "MIT" ]
permissive
require 'spec_helper' describe Product do describe "attributes name and price" do it " should set attribute properly with intialize" do p = Product.new(:name => "Skirt", :price => 23.3) p.name.should eq("Skirt") p.price.should eq(23.3) end it "set & read attribute" do p = Produc...
true
d4407016863926f6000d157862b4c8b911ef7985
Ruby
alirezaandersen/NightWriter
/test/night_reader_test.rb
UTF-8
1,222
2.890625
3
[]
no_license
require "./lib/night_reader" require "minitest/autorun" require "minitest/pride" require 'pry' class NightReaderTest < Minitest::Test def setup @infile = "./test/converter_test/braille_input.txt" @outfile = "./test/converter_test/english_output.txt" @night = NightReader.new(@infile,@outfile) end ...
true