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
40d4a45e36169c364342ef557c7c3f67e33c561e
Ruby
gchapim/tvdb_api_v2
/lib/tvdb_api/tvdb_api_wrapper.rb
UTF-8
3,087
2.609375
3
[]
no_license
require 'httparty' require 'json' include TheTvdbApi class TvdbApiWrapper def self.get_token(api_key) raise ArgumentError, 'api_key must be filled' if api_key.blank? response = token_from_login(api_key) token_from_response(response) end def self.call_action(action, token, params=nil, subaction=nil...
true
374ca5e4e8c2c71a13c0acf112f7bdd018312cda
Ruby
MurasakiArtemis/compiladores-practica1
/convert_spec.rb
UTF-8
978
2.921875
3
[]
no_license
require 'rspec' require_relative 'automaton' require_relative 'converter' file = '2_thomp.txt' string = 'bc' describe 'Converter' do it 'should convert a previously generated automaton' do automaton = Automaton.new automaton.read_file(file) converter = Converter.new automaton valid = automaton.an...
true
3de2b21e5947f3210f0339efbfe8c6d2bedc9ce5
Ruby
eriksantoro/tip_calculator
/tip_calculator3.rb
UTF-8
1,979
4.3125
4
[]
no_license
print "Enter the cost of your meal before tax: " meal = Float (gets) # Convert string to float while meal <= 0 print "Please enter a number greater than 0: " meal = Float (gets) end print "Enter the tax rate as a percentage: " tax = Float (gets) while (tax < 0 || tax > 100) print "Please enter a number greater than...
true
7280d3c487058e9d2afe55ab5207f38edc3d3404
Ruby
jrich20/Teaching-Portfolio
/student-projects/Star Data Project/app/models/sample_model.rb
UTF-8
616
2.515625
3
[]
no_license
require 'httparty' class SampleModel attr_accessor :name, :age end data = HTTParty.get('https://api.sne.space/catalog') $sne_name = [] $sne_disc = [] $sne_host = [] $sne_type = [] data.each do |key,value| if(data[key]["claimedtype"].empty? == false && data[key]["discoverdate"].empty? == false && data[key]["host...
true
b3523816f29d9af1fa5bef9b156a0f16445efe90
Ruby
MastersAcademy/ruby-course-2018
/ruby_basic/olena.zamkova/task8.rb
UTF-8
297
3.828125
4
[]
no_license
class Array def read_from_stdin $stdin.each_line do |line| self.push(line.strip) end end def sort_descendant self.sort { |x, y| y <=> x } end end array = [] print 'Enter array members: ' array.read_from_stdin puts "Sorted array: #{array.sort_descendant.join(', ')}"
true
d7ec16dff3d4dec44b5fb44287248efd62391f52
Ruby
santiagolepe/GameOfTheLife
/game.rb
UTF-8
2,791
3.4375
3
[]
no_license
class Game def initialize @rows = 20 @cols = 20 @step = 0 puts "\e[H\e[2J...:: GaMe oF ThE LiFe ::...\n\n" puts "1.- Glinder 2.- Block 3.- Blinker 4.-Pulsar 5.-Custom random \n\n" puts "Choose option:" option = gets.to_i #start the game run(option) end def run(option) #create...
true
0732a7ae490a2f36e6d3f1e7c2ec44590735dcf8
Ruby
AlexStoll/Ruby_Intro
/Excercises/rubybasics/Misc/hash_styles.rb
UTF-8
213
3.578125
4
[]
no_license
# Make a hash in both ways hash_new = {dog: "red", mouse: 4, big: [1, 2, 3]} p hash_new hash_old = { :dog => "red", :mouse => 4, :big => [1, 2, 3], :fifteen => 15, :three_four => [3, 4] } p hash_old
true
fd17eaf38ce581a5b5be00e3c30e44ba9bb12344
Ruby
Jeantirard/TheHackingProject2018
/semaine3/jeudi/lib/townhalls_follower.rb
UTF-8
1,862
3.15625
3
[]
no_license
require 'bundler' Bundler.require # this class search for townhalls twitter accounts, parse it to the JSON file # and follow townhalls handlers class Townhalls_follower attr_accessor :data def initialize @session = init_rest @handles = Array.new(0) @data = json_to_hash end #init rest initialize a new REST...
true
9e0b73edd2da90de93bba6d8ad4ab727578bec46
Ruby
osulibraries/ims
/lib/export/export.rb
UTF-8
571
2.5625
3
[]
no_license
module Export class ExportBase attr_accessor :fedora_root_url # during initialization either we feed in a root url, or we get it from config file def initialize(fedora_root_url=nil) @fedora_root_url = fedora_root_url || get_fedora_root_url end private # Returns fedora url from config ...
true
d9eef069244d7d5c9552e394890f905fec57039f
Ruby
melodicodyssey/wk1d3
/smoothie.rb
UTF-8
3,598
3.453125
3
[]
no_license
$smoothie_ingredients = { 'flax seeds' => '1 tbsp', 'chia seeds' => '1 tbsp', 'coconut flakes' => '1 tbsp', 'spirulina' => '1 tsp', 'pumpkin seeds' => '1 tbsp', 'oatmeal' => '1/4 cup', 'coco powder' => '1 tbsp', 'peanut butter' => '1 tbsp', 'almonds' => '1/4 cup', 'walnuts' => '1/4 cup', 'spinach' => '1/4 cup', 'greek ...
true
d00f02c92a0cf292919b588561fa075f18dbafc4
Ruby
deanraguso/dc_tech_challenge
/spec/models/talk_spec.rb
UTF-8
2,608
2.703125
3
[]
no_license
require_relative "../../src/models/Event" require_relative "../../src/models/Speaker" require_relative "../../src/models/Talk" describe Talk do describe '.initialize' do context "given a non-existent event" do it "doesn't create the talk." do Event.clear_events ...
true
4dbc4bbcc29e3d8e7238872c10633d574be08cf3
Ruby
Xaiana/101_Programming_Foundations
/lesson_4/fruit.rb
UTF-8
710
4.09375
4
[]
no_license
produce = { 'apple' => 'Fruit', 'carrot' => 'Vegetable', 'pear' => 'Fruit', 'broccoli' => 'Vegetable' } =begin select the fruit in the produce hash turn keys into an array first select the keys return only if key's value is 'Fruit' append to selected_fruit array return array exit if counter is greater than pro...
true
06a181923f458979408c14199904b5538614da1d
Ruby
2GMon/schemoid
/ruby/schemoid_eval.rb
UTF-8
1,371
2.71875
3
[ "MIT" ]
permissive
module SchemoidEval include SchemoidEnvironment def eval_lambda(expression, environment) parameters = expression[1] body = expression[2] [:closure, parameters, body, environment] end def eval_let(expression) parameters, arguments, body = let_to_parameters_arguments_body(expression) new_exp...
true
366fabacacd3c87deae501388e64c905db001c05
Ruby
aarondevon/square_array-v-000
/square_array.rb
UTF-8
107
3.4375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def square_array(array) square_array = [] array.each { |e| square_array << e ** 2} square_array end
true
73e983d4e5cc3cc51646dc107eb68e76f6eb25ce
Ruby
thinasc/dojo
/2016/dojo2016-07/src/ruby_warrior.rb
UTF-8
928
2.9375
3
[]
no_license
class Player def play_turn(warrior) if warrior.feel.wall? warrior.pivot! else if warrior.feel(:backward).empty? && @direcao == nil warrior.walk! :backward else if warrior.feel(:backward).captive? warrior.rescue! :backward @direcao = 1 else ...
true
fdc92446f2a39307b72f5e05337d921a95e9a790
Ruby
ayahito-saji/radius
/stack_radius/radius.rb
UTF-8
1,111
2.84375
3
[]
no_license
null_obj = [:instance, :null_class, nil, nil] stack = [] env = {} operations = [ [:statements, 3], [:null, 0], [:ref_var, 2], [:identifier, 0, "a"], [:null, 0], [:def_var, 3], [:new_number, 0, 1], [:identifier, 0, "a"], [:null, 0] ] while operations.length > 0 # オペレータ operatio...
true
e41ded3b4518a1c8c58f87fd4eb851c48b77966f
Ruby
adam2222/chess_adam_intrator
/pieces/queen.rb
UTF-8
212
2.90625
3
[]
no_license
require_relative '../piece' require_relative 'sliding' class Queen < Piece include Sliding def to_s self.color == :black ? " ♛ " : " ♕ " end def directions HORIZONTAL + DIAGONAL end end
true
111613cffc6eee2e2642db25299302049281fd43
Ruby
xgsarnold/weather_report
/wreport.rb
UTF-8
422
2.703125
3
[]
no_license
require './condition.rb' require './forecast.rb' require './astronomy.rb' require './alert.rb' require './hurricane.rb' # require 'httparty' # # puts "Please enter the zipcode for the area for which you would like to know the weather." # # zip = gets.chomp # # reponse = HTTParty.get("http://api.wunderground.com/api/#{...
true
6151bb3e74252e60b0eede8adde99ad1b8a0a84f
Ruby
Shelvak/maxirino
/app/controllers/towns_controller.rb
UTF-8
1,507
2.515625
3
[ "MIT" ]
permissive
class TownsController < ApplicationController before_action :set_town, only: [:show, :edit, :update, :destroy] # GET /towns def index @title = t('view.towns.index_title') @towns = Town.all.page(params[:page]) end # GET /towns/1 def show @title = t('view.towns.show_title') end # GET /town...
true
96ac54ea1f83cd4ed8ac4fcabeabd2cde15e505f
Ruby
denkoroku/library_project
/library_app/models/join.rb
UTF-8
839
3.15625
3
[]
no_license
require_relative('../db/sql_runner') class Join attr_reader :id, :topic_id, :book_id def initialize(options) @id = options['id'].to_i @topic_id = options['topic_id'].to_i @book_id = options['book_id'].to_i end #create def save sql = "INSERT INTO book_topic_join(topic_id, book_id)VALUES($1, $...
true
357b7c3795f6c42641922f37d1ca9f71071657c8
Ruby
tysonmote/splashy
/lib/splashy/bucket.rb
UTF-8
726
3.375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
module Splashy private # Private: Collects elements and maintains a count. class Bucket attr_reader :name def initialize( name ) @name = name @elements = [] end def <<( element ) @elements << element end def elements( count = nil ) if count ...
true
b04196a3a8c363d2a09c80ee5da5cff611b38c82
Ruby
mocchi0420/project-euler
/euler034.rb
UTF-8
1,552
3.328125
3
[]
no_license
# coding: utf-8 # Problem 34 「桁の階乗」 # 簡単な方針 # # 今回も取りうる限界の値から考える。 # 今回のパターンだと、9999999……となった場合にはn*9!(※nは桁数)が取りうる最大値となる。 # この場合、n*9!が元の数を越える(=元の数を表現できる)ためにはn*9! - (10^n - 1) > 0となる最大のnが分かればいい。 # この場合だとn=6が限界値。 # # あとは30問目と同じノリで...と思ったら、30問目とは同じノリにできない理由があるので考える。 # 具体的には0!=1が存在してしまう問題である。 # このため、[0,0,0,0,3,4]は、問30では34も3...
true
bca04fb0d4846ff82236d58db7314db59d70ae5f
Ruby
GarrettSmith/UW-CA-Testing-System
/app/models/section.rb
UTF-8
1,466
2.765625
3
[]
no_license
# == Schema Information # # Table name: sections # # id :integer not null, primary key # number :integer # room_number :string(255) # created_at :datetime # updated_at :datetime # professor_id :integer # course_id :integer # semester_id :integer # # A collection of tests with s...
true
52544354a7183e2d8138b7c32799f3315bf8d8bd
Ruby
achhetr/default_ruby_project_configuration
/spec/store_spec.rb
UTF-8
2,906
2.90625
3
[]
no_license
require "store" describe Store do let(:inventory) do { "Watermelons" => [ { count: 3, price_in_cents: 699 }, { count: 5, price_in_cents: 899 }, ], Pineapples: [ { count: 2, price_in_cents: 995 }, { count: 5, price_in_cents: 1695 }, { count: 8, price_in_ce...
true
83ffcee24ffd409ab871784e5f49ef6af338cd36
Ruby
slabounty/lisp
/lib/lisp/parser.rb
UTF-8
805
3.1875
3
[ "MIT" ]
permissive
module Lisp class Parser class LispSyntaxError < StandardError; end def parse(tokenized_program) read_from_tokens(tokenized_program) end def read_from_tokens(tokens) # "Read an expression from a sequence of tokens." fail LispSyntaxError, 'unexpected EOF while reading' if tokens.len...
true
ba8f803cfc6e95ad20feb50a3e34e7a55f9f3536
Ruby
tIFFANY1804/bank_account
/spec/services/account/deposit_service_spec.rb
UTF-8
862
2.53125
3
[]
no_license
require 'rails_helper' RSpec.describe Account::DepositService do subject { described_class } describe '#execute!' do let!(:account) { create(:account) } it 'create an account object' do deposit = subject.new(account_id: account.id, amount: 250.40) expect(deposit.execute!).to eq('R$ 250,40')...
true
dcacae5e93322ed889733dd0efa683fd5a59c143
Ruby
daachi/github_cli
/lib/github_cli/commands/repositories.rb
UTF-8
3,988
2.609375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# encoding: utf-8 module GithubCLI class Commands::Repositories < Command namespace :repo # TODO: format_type options[:format] desc 'list', 'Lists all repositories for the authenticated user' method_option :org, :type => :string, :aliases => ["-o"], :desc => 'List repositories for...
true
52588eac994b86b0daea19be17f47bfd4f4be0aa
Ruby
csail/6006psets_ng
/2/code/circuit/circuit_test.rb
UTF-8
710
2.546875
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require 'test/unit' if ENV['QUEUE'] require './full_circuit.rb' else require './circuit.rb' end class CircuitTest < Test::Unit::TestCase Dir['tests/*.in'].sort_by(&:to_i).each do |in_file| method_name = File.basename(in_file).split('.', 2).first define_method :"test_#{in_file}" do...
true
7b8cd72dbcf595ddddf5f511d2306b1af31fe468
Ruby
subhankarkoley/ruby_tutorial
/Chapter_4/spec/Two_Series2_spec.rb
UTF-8
753
4.03125
4
[]
no_license
# Series2 # Given two integers A and B. Print all numbers from A to B inclusively, in ascending order, if A < B, or in descending order, if A ≥ B. #def series2 (start,finish) # for i in start..finish # puts i # end #end #puts series2(1,10) require "/home/subhankar/Ruby/ruby_tutorial/Chpter_4/Two_Series2.rb" describ...
true
0ba81a586b4bf1f5e134b09bc161ea87b601374d
Ruby
mxchenxiaodong/rack
/code/rack_6.rb
UTF-8
536
2.546875
3
[]
no_license
require 'rack' # 一个web程序用不同的代码来处理不同的url,这就是所谓的路由系统。 # 最简单的路由系统就是一个URL 对应 一个代码块。 # run 方法是Rack::Builder已经定义的。用来存最原始的app rack程序. app = Rack::Builder.new { map '/hello' do run lambda {|env| [200, {}, ["hello"]]} end map '/bye' do run lambda {|env| [200, {}, ["bye"]]} end map '/haha' do run lambd...
true
bc4bd6dd47b7bcd25e9a47087bd696ac674af126
Ruby
engineyard/ey_cli
/lib/ey_cli/term.rb
UTF-8
1,320
2.640625
3
[ "MIT" ]
permissive
module EYCli class Term require 'highline' attr_reader :terminal def initialize(input = $stdin, output = $stdout) HighLine.color_scheme = HighLine::SampleColorScheme.new @terminal = HighLine.new(input, output) end def choose_resource(collection, message, prompt) say(message) ...
true
7d8adc2dcf0a137ff411399ea04cd5a9ee803f36
Ruby
alfie-max/benchmarking-ruby-scripts
/hash_storage/hash_storage.rb
UTF-8
363
2.671875
3
[]
no_license
require 'benchmark' Benchmark.bm do |x| x.report do 1000000.times do my_hash = {} my_hash[:t] = 1 my_hash[:b] = 2 end end x.report do 1000000.times do my_hash = {} my_hash.store(:t, 1) my_hash.store(:b, 2) end end x.report do 1000000.times do my_h...
true
a4a74893b97399b84d40b5789ee77c631569b0c0
Ruby
wschenk/willschenk.com
/content/labnotes/2023/using_mrsk/app_nonredis.rb
UTF-8
126
2.625
3
[]
no_license
require 'sinatra/base' class App < Sinatra::Base get '/' do "Hello world!!!" end get '/up' do "Yup" end end
true
4e5145ddc1bf2a1b4373ed2773bef35ad3e3ac9b
Ruby
DanBradbury/LeagueApi
/lib/league_api/stats.rb
UTF-8
638
2.5625
3
[ "MIT" ]
permissive
module LeagueApi class Stats @base_url = "https://na.api.pvp.net/api/lol/na/v1.3/stats/by-summoner/" def self.make_request(str, params=nil, region=nil) LeagueApi.make_request(@base_url, str, params, region) end def self.ranked(id, season="SEASON4", region=nil) params = {"season" => sea...
true
ab65a46d0db7f6b161e4355e3a3e126df3d7ee48
Ruby
shakacode/react_on_rails
/rakelib/examples.rake
UTF-8
2,334
2.546875
3
[ "LicenseRef-scancode-proprietary-license", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
# frozen_string_literal: true # Defines tasks related to generating example apps using the gem's generator. # Allows us to create and test apps generated using a wide range of options. # # Also see example_type.rb require "yaml" require "rails/version" require_relative "example_type" require_relative "task_helpers" ...
true
cfae18a96a6000aa7ff9f32cffd1ddec67d5576f
Ruby
marina101/advent-of-code-2020
/day10/part1.rb
UTF-8
635
3.390625
3
[]
no_license
def print_result(value) puts "the value is: #{value}" end def process(test: false) input = test ? test_string : File.read('input.txt') adapters = input.split("\n").map(&:to_i).sort device_j = adapters.max + 3 adapters << device_j differences = { 1 => 0, 2 => 0, 3 => 0 } prev = 0 adapt...
true
31a31748b7e0e88d4ac5d157fa61b0eae8af45ad
Ruby
nooccarr/App-Academy-Classwork
/W4D3/pieces/pawn.rb
UTF-8
453
2.984375
3
[]
no_license
require_relative "../piece.rb" require_relative "stepable" class Pawn < Piece include Stepable def symbol :P end def moves forward_steps + side_attacks end def at_start_row? pos[0] == 1 || pos[0] == 6 end def forward_dir if color == blue re...
true
9127ce307e5d0ee93e39fa9cf2f8f5b1a30e4c8c
Ruby
jarouca/questions-site
/spec/features/markdown_support_spec.rb
UTF-8
1,463
2.609375
3
[]
no_license
require "rails_helper" feature "markdown support for questions and answers" do # As a user # I want to write my questions and answers with markdown # So I can easily format my questions and answers # # Acceptance Criteria # # - I can write my questions and answers using markdown syntax # - Questions an...
true
e721eb38c71809c46800bd32946f1475f060a757
Ruby
michaelglass/sql-skeleton
/db/bootstrap_postgres.rb
UTF-8
434
2.828125
3
[]
no_license
# copy/pasted from the sqlite readme require 'pg' # Open a database db = PG.connect # # Create a table # db.exec <<-SQL # create table activity_duration( # activity varchar(30), # num_hours int # ); # SQL # Execute a few inserts { 'Work' => 0, 'Eat' => 100, 'Commute' => 100, 'Watch TV' ...
true
14057eee5d15c378195b9a7f1ec234f8cf834fe1
Ruby
kymmt90/yokohama.rb
/222.rb
UTF-8
414
3.390625
3
[]
no_license
CELESTIAL_STEM = %w(庚 辛 壬 癸 甲 乙 丙 丁 戊 己) EARTHLY_BRANCH = %w(申 酉 戌 亥 子 丑 寅 卯 辰 巳 午 未) def stem_and_branch(year) "#{CELESTIAL_STEM[year % 10]}#{EARTHLY_BRANCH[year % 12]}" end puts stem_and_branch(1868) # 戊辰戦争 puts stem_and_branch(1911) # 辛亥革命 puts stem_and_branch(1966) # 丙午 puts stem_and_branch(1924)...
true
5d6c19e2880c4e0fdc05d4ea449abdbb16fe92be
Ruby
Balaji-Ramasubramanian/COVID-Info-Centre-Bot
/facebookBot/strings.rb
UTF-8
3,390
2.71875
3
[]
no_license
# @author Balaji class MessengerBot # Supported Languages SUPPORTED_LANGUAGE = { "en" => "default", "ta" => "ta_IN" } # Greeting Text: GREETING_MESSAGE = { "en" => "Hey! This bot helps you to get the latest news about COVID-19, Get helpdesk numbers, or FAQs about the virus.", "ta" => "வணக்கம்!" } # Qu...
true
e61001f00bb836d5d82aed68238560d02f668d43
Ruby
deepak23verma/learn_ruby
/03_simon_says/simon_says.rb
UTF-8
453
3.875
4
[]
no_license
def echo(str) str end def shout(str) str.upcase end def repeat(str, num=2) ((str + " ") * num).chop end def start_of_word(str, num) str[0..(num-1)] end def first_word(str) array = str.split(" ") array[0] end def titleize(phrase) phrase.capitalize! little_words_string = "and the over" array = phrase.split(...
true
d2f7ff4085f748826717663df4851d86d19da1ef
Ruby
anna328p/aoc2019
/ruby/days/10/part1.rb
UTF-8
377
3.0625
3
[]
no_license
#!/usr/bin/env ruby # Advent of Code 2019 - Day 10 - Part 1 input = File.readlines('input.txt').map(&:chars) asteroids = input.flat_map.with_index { |r, idx| r.map.with_index {|c, idx| c == '#' ? idx : nil}.compact.map { |f| [idx, f] } } p asteroids.map { |a| asteroids.map { |b| [Math.atan2(b[1] - a[1], b[0] - a[...
true
111f6bee6c344385470233c8ce11d32b73467356
Ruby
dewantara-hz/onboarding-ruby
/lib/onboarding.rb
UTF-8
1,915
3.359375
3
[]
no_license
# Listing dependency require 'nokogiri' require 'net/http' require 'json' # The main onboarding driver # # This class is a simple response validator to determine whether response is valid json, xml, or html # class Onboarding attr_accessor :url # Create the object with default url to localhost # # Arg...
true
fc3cdb763ad6cf73f2c57a638480c050cc76e81b
Ruby
willbryant/ruby-pg
/lib/pg/basic_type_mapping.rb
UTF-8
7,890
2.640625
3
[ "PostgreSQL", "BSD-2-Clause", "Ruby" ]
permissive
#!/usr/bin/env ruby require 'pg' unless defined?( PG ) class PG::BasicTypeMapping ValidFormats = { 0 => true, 1 => true } attr_reader :connection attr_reader :text_types attr_reader :binary_types def initialize(connection) @connection = connection @types = build_types @text_types = @types[0].freeze @b...
true
784fe580852290dabf2b6a015d8ca9b3b96aa7b0
Ruby
apalski/oo-student-scraper-v-000
/lib/student.rb
UTF-8
1,047
3.546875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Student attr_accessor :name, :location, :twitter, :linkedin, :github, :blog, :profile_quote, :bio, :profile_url # Array to contain all the students and their attributes hashes @@all = [] # Initialize a new student by being able to mass assign their # attributes a key and value according to what the ...
true
773061c2a82d54c6a45ded9f6323b8cf3ba39f35
Ruby
viswanand95/juhomi
/ex 24 more practice.rb
UTF-8
566
3.8125
4
[]
no_license
puts "start practice" poem = <<END \tThe new world with the new sun cannot find \n the needs of love and cannot compre passion from intuition and requires an explanation \n\t\twhere there is none. END puts "------------" puts poem puts "------------" cal = 10-2+12 puts "the answer is #{cal}" def f...
true
fb4b59b57f5f60666bfc23eb2565a1cfb7e68285
Ruby
AaronGerry/Learn-Ruby-The-Hard-Way
/ex10.rb
UTF-8
562
3.671875
4
[]
no_license
tabby_cat = "\t I'm tabbed in." persian_cat = "I'm split\non a line." backslash_cat = "I'm \\ a \\ cat." # Using ''' prints the text exactly as it is written, so the "\n\t* Grass" shows on the same line; is not tabbed or on it's own line. fat_cat = ''' I\'ll do a list: \t* Cat food \t* Fishies \t* Catnip\n\t* Grass ''...
true
8c862ec0320bd38c579145de20a34aae9c0dc37d
Ruby
danilojpl/Eps-LFA
/codigoMorse.rb
UTF-8
16,645
3.296875
3
[]
no_license
class TransdutorMorse attr_accessor :mensagem, :count, :arrayMsg def initialize (mensagem) @arrayMsg = mensagem.split('') @count = 0 @mensagem = '' end def iniciar q0 end def q0 case @arrayMsg [count] when "." @count = @count+1...
true
52800790831fff7439dcd47e2f2d5510add0c1bf
Ruby
asivitz/mld-game
/matrix_graphics.rb
UTF-8
1,345
3.53125
4
[]
no_license
require 'matrix' def vec(x,y) Vector.elements([x,y]) end class Vector def x self[0] end def y self[1] end def x= other self[0] = other end def y= other self[1] = other end def normalize return self / self.r end end class Array def x self[0] ...
true
5eb3b39e2f7f1faf74827b786f0ccb9c153ea6d5
Ruby
Jayad25/W2D5
/LRU/lib/p01_int_set.rb
UTF-8
1,942
3.546875
4
[]
no_license
class MaxIntSet def initialize(max) @store = Array.new(max,false) end def insert(num) is_valid?(num) @store[num-1] = true end def remove(num) @store[num-1] = false end def include?(num) validate!(num) end private def is_valid?(num) raise "Out of bounds" if (0 > ...
true
251325035aa907f4f2b0662bf68efe119b5b773e
Ruby
superedriver/algo_ruby
/src/sorting/merge.rb
UTF-8
1,431
3.9375
4
[]
no_license
def merge(left, right) result = [] i, j = 0, 0 n, m = left.size, right.size while i < n && j < m if left[i] < right[j] result.push(left[i]) i += 1 else result.push(right[j]) j += 1 end end while i < n result.push(left[i]) i += 1 end while j < m result.pu...
true
4abe4ac182b1f1509ae06fbeacf8f9dd58ac36bf
Ruby
marthaberner/playlist-ruby-exercise
/playlist.rb
UTF-8
891
3.5
4
[]
no_license
class Playlist attr_accessor :playlist, :now_playing def initialize(playlist = []) @playlist = playlist @now_playing = nil end def empty? playlist.empty? end def add_song(song) playlist << song end def song_names playlist.map { |song| song.title } end def remove_song(song) ...
true
ccc96275af9884ea99d76ea7c5b8c64b5907ebcf
Ruby
dkrompic/shop
/test/models/product_test.rb
UTF-8
1,026
2.5625
3
[]
no_license
require 'test_helper' class ProductTest < ActiveSupport::TestCase # test "the truth" do # assert true # end test "product attributes marked as mandatory must not be empty" do product = Product.new assert product.invalid? assert product.errors[:title].any? assert product.errors[:description...
true
000e5e55945cbd40b2331931b99884fb85d81576
Ruby
enukane/utils
/3gpp-band.rb
UTF-8
1,990
3.3125
3
[]
no_license
#!/usr/bin/ruby arg = ARGV.shift DOCOMO_BAND = { 1 => :LTE, 3 => :LTE, 19 => :LTE, 21 => :LTE, 28 => :LTE, 42 => :LTE, "n78" => :NR, "n79" => :NR, "n257" => :NR, } AU_BAND = { 1 => :LTE, 3 => :LTE, 11 => :LTE, 18 => :LTE, 26 => :LTE, 28 => :LTE, 41 => :LTE, 42 => :LTE, "n77"...
true
907e0b35747e51ef0b07e6094d6a8ad275f020d6
Ruby
afast/chess-rate-server
/lib/db_ref/db_factory.rb
UTF-8
2,314
2.78125
3
[]
no_license
class DbRef::DbFactory cattr_accessor :db_ref_full @@db_ref_full = [] def self.pgn2fen(file_path) @@game_number_path = file_path.gsub('.pgn', '_GameNumber.txt') @@bd_ref_path = file_path.gsub('.pgn', '_BD-REF.txt') @@pgn_path = file_path @@file_path = file_path.gsub('.pgn', '.txt') puts "exe...
true
69451a15cdb592456bdcba2f0efa58af2075deb1
Ruby
snyderbc/phase-0-tracks
/ruby/game/game.rb
UTF-8
2,257
4.46875
4
[]
no_license
class WordGame attr_reader :mystery_word, :guesses, :guesses_available, :guessed_word, :guesses_remaining def initialize(mystery_word) @mystery_word = mystery_word @guesses = 0 @guesses_available = mystery_word.length + 3 @guessed_word = mystery_word.tr("abcdefghijklmnopqrstuvwxyz", "_") end ...
true
6a3cfe8935ee481bce99f8b68f1cd35ce9494fe1
Ruby
bhollan/project-euler-even-fibonacci-q-000
/lib/testing.rb
UTF-8
136
2.78125
3
[]
no_license
require_relative '../lib/even_fibonacci' puts even_fibonacci_sum(10) puts even_fibonacci_sum(100) puts even_fibonacci_sum(1000000000)
true
37b219f2c3dc52fc1cca4c35574a50869e2003c5
Ruby
pascalhamel/crowdbase
/lib/crowdbase/core/utils.rb
UTF-8
781
2.875
3
[]
no_license
module Crowdbase module Utils class << self def recursive_symbolize_keys!(hash) hash.symbolize_keys! hash.values.each do |h| if h.kind_of? Array h.each { |vv| recursive_symbolize_keys!(vv) if vv.kind_of? Hash } elsif h.kind_of? Hash recursiv...
true
b9b3c30167623164643a20f2e0eb7c8d1ed85a17
Ruby
jhartwell/ironruby
/Tests/Experiments/Methods/method_events_libraries.rb
UTF-8
125
2.703125
3
[]
no_license
class Module def method_added name puts "#{self.name}##{name}" end end require 'yaml' p [1,2,3].to_yaml
true
b554a451c56e4a9aa4b4f189c0a68e2e6f879926
Ruby
kitlangton/tree_trie_tro_trum
/lib/dictionary_tree.rb
UTF-8
2,062
3.421875
3
[]
no_license
class DictionaryTree attr_reader :root def initialize(dictionary = nil) @root = LetterNode.new(nil, nil, [], nil, 0) build_tree(dictionary) if dictionary end def build_tree(dictionary) dictionary.each do |word, definition| insert_word(word, definition) end end def definition_of(word...
true
b32f9805ac3c4fc6493692c12675300d27475e76
Ruby
izziez/ruby-practice
/temp.rb
UTF-8
1,270
4.3125
4
[]
no_license
puts "What is temperature?" todays_temp = gets.chomp.to_i puts "is it raining- yes or no" todays_weather = gets.chomp.to_s def going_hiking(temp, rain) if temp > 105 || temp < -5 puts "your thermostat is broken!" elsif temp >= 50 && rain == "no" puts "#{temp} degrees is perfect for hiking!" elsif tem...
true
044395727284e45301157d11b2b7779a14005a89
Ruby
websdotcom/websgem
/lib/config/webs_constants.rb
UTF-8
1,952
2.78125
3
[]
no_license
module Webs module PermissionLevel LEVEL = { :anyone => { :name=>'Anyone', :value=>-255 }, :none => { :name=>'None', :value=>0 }, :requesting => { :name=>'Requesting Members', :value=>10 }, :limited => { :name=>'Limited Members', :value=>25 }, :member => { :name=>'Members', :value=>5...
true
38eb50f398782a20e355f444f3bc228956a1f40d
Ruby
daisuke-nomura/gtfs-to-parse
/stops.rb
UTF-8
807
2.578125
3
[ "MIT" ]
permissive
require 'gtfs' require 'json' require 'parse-ruby-client' results = [] source = GTFS::Source.build('google_transit.zip') file = "stops.json" source.stops.each do |s| h = Hash.new h[:stop_id] = s.id h[:stop_code] = s.code h[:stop_name] = s.name h[:stop_desc] = s.desc h[:stop_latlon] = Parse::GeoPoint.new({...
true
de2dc677d4f9e7221b2d4ccfcc0a53f741b39b7e
Ruby
GMach234/Ruby-VSCode
/Module 2 - Solving some problems/Ruby Problem Solving/max_number.rb
UTF-8
310
4.09375
4
[]
no_license
#Input valid integer values, add to array numbers = [] until numbers[0] =~ /^-?[0-9]+$/ print "Enter a number: " numbers[0] = gets.chomp end until numbers[1] =~ /^-?[0-9]+$/ print "Enter another number: " numbers[1] = gets.chomp end #Print max of array values puts "Max: #{numbers.max}"
true
4349f966d11060a7b5c56e503a0c69ccf2f3fd55
Ruby
ElizabethDay/pdf-prawn
/page4.rb
UTF-8
606
3
3
[]
no_license
require 'prawn' class Page attr_accessor :pdf def initialize(pdf) @pdf = pdf @background = "parchment.jpg" end def add_background @pdf.canvas do @pdf.image @background, at: [0, @pdf.bounds.height], width: @pdf.bounds.width, height: @pdf.bounds.height end end def add_hello_t...
true
ec8cf9b4e43616b9fa77f5df46c9f7c54f584f72
Ruby
averysmith65/launch_school
/subscription_course/lesson4/practice_problems_additional_practice/practice_prob5.rb
UTF-8
97
2.90625
3
[]
no_license
flintstones = %w(Fred Barney Wilma Betty BamBam Pebbles) puts flintstones.index {|x| x[0,2] == "Be"}
true
605816cc12cb34f911c556a7e12d4cec307fb3e7
Ruby
Ahndaehwan/code
/dynamic_programming/min_coins_sum_spec.rb
UTF-8
1,301
3.171875
3
[]
no_license
require 'debugger' require_relative 'min_coins_sum' describe "Dynamic Programming" do let (:coins) {[1, 5, 10, 25, 50]} describe :min_coins_sum do it "should return 0 for 0 cents" do min_coins_sum(0, coins).should eq 0 end it "should return 1 for 1 cents" do min_coins_sum(1, coins).sh...
true
ad0741138c0ff72200024453d534448b20ba48c9
Ruby
alkesh26/skycast
/app/services/compute.rb
UTF-8
1,172
2.953125
3
[]
no_license
class Compute attr_reader :channel attr_accessor :channel_distances, :min_clicks, :previous_channel_number, :previous_of_previous_channel_number def initialize(channel) @channel = channel @min_clicks = set_initial_min_clicks @channel_distances = channel.distances initialize_previous_channels e...
true
3ed5a0a53d1606a2d4133945a8aa4069dd68e966
Ruby
acushlakoncept/coding-challenges
/ruby/recursive/palindrome.rb
UTF-8
226
3.59375
4
[]
no_license
# frozen_string_literal: true def palindrome(string) if string.length == 1 || string.length.zero? true elsif string[0] == string[-1] palindrome(string[1..-2]) else false end end puts palindrome('hannah')
true
349374bbe23472bf01e575e2223294d394a7c0ad
Ruby
Thundzz/StackUnderflow
/app/helpers/users_helper.rb
UTF-8
439
2.6875
3
[]
no_license
# -*- coding: utf-8 -*- module UsersHelper def show_study(study) if study == 1 "<span class=\"label label-info\">Informatique</span>" elsif @user.study == 2 "<span class=\"label label-success\">Matméca</span>" elsif @user.study == 3 "<span class=\"label label-warning\">Electronique</span...
true
20c2980dbd1426a79e3ddd4bbe1ad32cd184023e
Ruby
penguin2716/MikutterSocketServer
/mikutter_socket.rb
UTF-8
559
2.984375
3
[]
no_license
#!/usr/bin/env ruby # -*- coding: utf-8 -*- # Echo client program require 'socket' HOST = 'localhost' PORT = 3939 # The same port as used by the server inputstr = '' if(ARGV.length == 0) STDOUT.puts 'input text (end with EOF)...' while line = STDIN.gets if(line == nil) break; end inputstr += line...
true
e682b53b6b653eaef561ee8f80b34cefd84ab60d
Ruby
esugano/prime-ruby-v-000
/prime.rb
UTF-8
89
2.53125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Add code here! require 'prime' require 'pry' def prime?(int) Prime.prime?(int) end
true
e10bbc886abe1e54aa5374e80790af846edd1bf0
Ruby
timrogers/starling-terminal
/lib/starling_terminal/transaction_row.rb
UTF-8
1,078
2.71875
3
[ "MIT" ]
permissive
# frozen_string_literal: true module StarlingTerminal # A presenter to convert Starling::Resources::TransactionResource instances to # presented rows for our transactions table class TransactionRow # Converts a Starling Bank transaction into a row to be displayed in our transactions # table # # @...
true
b648c0121f215e834d5ddb2954c1d81e867938a0
Ruby
cheryldillard/capstone
/frontend.rb
UTF-8
2,454
3.203125
3
[]
no_license
require "unirest" require "pp" while true system "clear" puts "Your Personal Prescription Manager! Select an option:" puts "[signup] Signup (create a user)" puts "[login] Log in (create a jwt)" puts "[logout] Log out (destroy the jwt)" puts puts "[1] Enter a Prescription" puts "[2] Show all Prescrip...
true
037418afa3d8725a3eb92badedb5fd374d62daf0
Ruby
othaderek/module-one-final-project-guidelines-dumbo-web-051319
/lib/user.rb
UTF-8
3,076
3.0625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class User < ActiveRecord::Base has_many :user_characters has_many :characters, through: :user_characters def print_characters pastel = Pastel.new puts "Characters List " self.characters.each_with_index do |character, index| puts "" ascii_knight puts "" puts "∆∆∆∆∞∞∞∞∆∆∆∆∞∞∞∞∆...
true
e1241a5dfa5dfdd50274b92305b53d29743acbe5
Ruby
SinkLineP/RubyOnRails-18.08.2021
/Ruby on Rails/repozitories/Lesson-26-/app.rb
UTF-8
1,532
2.75
3
[ "MIT" ]
permissive
#encoding: utf-8 require 'rubygems' require 'sinatra' require 'sinatra/reloader' require 'sqlite3' def get_db return SQLite3::Database.new 'base.sqlite' end configure do db = get_db db.execute 'CREATE TABLE IF NOT EXISTS "users" ( "Id" INTEGER PRIMARY KEY AUTOINCREMENT, "Username" TEXT, "Phone" TEXT, "Datas...
true
4ff576869614948f4e08917bfbdd661f2bf4758e
Ruby
Pharserror/lcfont
/config/initializers/integer.rb
UTF-8
235
3.171875
3
[]
no_license
class Integer < Numeric def to_hours days, hrs = self.divmod(24) if hrs != 0 return "Same-Day" else if days > 1 return "#{days} days" else return "#{days} day" end end end end
true
9f6186e5c2c86f94d5de99b8a4a93f4875e2c126
Ruby
grebes15/phase-0-tracks
/ruby/67_game_class/wordgame_spec.rb
UTF-8
941
3.21875
3
[]
no_license
require_relative 'wordgame' describe Wordgame do let(:wordgame) { Wordgame.new("andreas")} it "guesses the correct word from the secret word" do wordgame.check_word("andreas") expect(wordgame.check_success).to eq "Congratulations, you have guessed the word!" end it "guesses the incorrect word from the secr...
true
5b4bbf60a4c6ec3de5f3691aad13ecf71c0ab3b6
Ruby
ffeldhaus/rOCCI
/lib/occi/core/attribute_property.rb
UTF-8
1,446
2.59375
3
[ "Apache-2.0" ]
permissive
module Occi module Core class AttributeProperty include Occi::Helpers::Inspect attr_accessor :_type, :_required, :_mutable, :_default, :_description, :_pattern # @param [Hash] properties # @param [Hash] default def initialize(properties={}) case properties when O...
true
831237a58c4217f3299cabe95c9aeab3664fb905
Ruby
MDSipahi/OrneklerleRubyProgramlama
/ornek042.rb
UTF-8
461
3.046875
3
[]
no_license
class CepTelefonu # Sınıf adı büyük herf ile başlar. Sabittirler. @ekran @bellek @cpu @renk def initialize(ekran, bellek, cpu, renk) @ekran= ekran @bellek= bellek @cpu= cpu @renk= renk end def ozellikler puts "yeni telefonumuzun ekranı #{@ekran} ekran" +" " "#{@bellek} gb hafizaya sahip ve Ayrıca #{@cpu} ...
true
187a5cd10e98e41ef194de9d9a4f90e25f78d187
Ruby
jo-hackson/phase-0-tracks
/ruby/secret_agents.rb
UTF-8
1,875
4.34375
4
[]
no_license
# Pseudocode # Define two methods, Encrypt & Decrypt # Encrypt Method----- # Index starts at 0. then counts +1 letter forward until -1 str.length # At each Index print .next # if a 'z' is encountered. make it into an 'a' def encrypt(str) index = 0 while index < str.length str[index] = if str[index].include? ...
true
da04dadc7cfb2e3b323cfebd6a775a071ab96a85
Ruby
markle/clinical_trials
/lib/clinical_trials/trial.rb
UTF-8
813
2.875
3
[]
no_license
#just a container for the data from the scripps getter module ClinicalTrials class Trial def initialize(trial = {}) @trial = trial clean if @trial['nct_num'] end def clean if nct_num != nil nct_num.gsub!(/[^A-Za-z0-9]/, "") nct_num.strip! end end def dum...
true
296ac1a796ecb9bf6dbb1fc8d635960bd4fd518d
Ruby
piazz23/understand
/lib/understand/configuration.rb
UTF-8
1,784
2.75
3
[ "MIT" ]
permissive
module Understand class Configuration attr_accessor :fields_separator, :log_file_folder, :db_name attr_reader :gem_path, :processes_logs_folder, :log_file_pattern, :db_configuration, :db_location def initialize(connection_flag=true) @gem_path = File.dirname(__FILE__).gsub(/(\/[\w]+){2}$/, ''...
true
14d6ee4eecdfd4b531f8fd02d76e74cddc825d41
Ruby
freebz/Beginning-Ruby
/ch11/ex11-22.rb
UTF-8
334
3.109375
3
[]
no_license
# Thread Operations from Within Threads Themselves Thread.new do 10.times do |i| print i $stdout.flush Thread.stop end end Thread.list.each { |thread| thread.run } 2.times { Thread.new { 10.times { |i| print i; $stdout.flush; Thread.pass } } } Thread.list.each { |thread| thread.join unless thread == ...
true
0f85bd3205d4206f83b5ae18dbeab88553d303ee
Ruby
etiennemustow/oystercard
/spec/oystercard_spec.rb
UTF-8
2,314
3.015625
3
[]
no_license
require 'oystercard' describe Oystercard do it 'has a balance of zero' do expect(subject.balance).to eq(0) end describe '#top_up' do it { is_expected.to respond_to(:top_up).with(1).argument } end it 'raises an error if the maximum balance is exceeded' do maximum_balance = Oystercard::MAXIMU...
true
36bfacc4c0976addbecb46e9bb0c399c44d68a05
Ruby
tiago-macedo/calcr
/test.rb
UTF-8
3,522
3.59375
4
[ "MIT" ]
permissive
require './calculator.rb' def lexer_run puts "LEXER RUN TEST" puts "==============" lexer = Lexer.new lexer.line = "2 + 2 - 3" puts lexer.run puts "-----" lexer.line = "" puts lexer.run puts "-----" lexer.line = "(2+ ) 3.14 -" puts lexer.run puts "-----" begin lexer.line = "abcde" ...
true
f4a2298b90c9c05dc2b1f47b66f746e1548a02b6
Ruby
emilcecarlisa/rideshare-rails
/app/models/passenger.rb
UTF-8
280
2.71875
3
[]
no_license
class Passenger < ApplicationRecord has_many :trips validates :name, presence: true validates :phone_num, presence: true def total_cost total = 0 trips.each do |trip| if trip.cost total += trip.cost end end return total end end
true
e78ab794530db1967fb38284627be0947a4a5f9d
Ruby
chan0123/rstreamor
/lib/rstreamor/file.rb
UTF-8
578
2.671875
3
[]
no_license
module Rstreamor class File def initialize(file_url, file_size, content_type) @url = file_url @content_type = content_type @file_size = file_size end def url @url end def content_type @content_type end def size # Because of encoding, the string size ...
true
8b5d1b097e77802241cdbb1b74494e32e7b5b392
Ruby
pyama86/popper
/lib/popper/cli.rb
UTF-8
2,213
2.546875
3
[]
no_license
require 'popper' require 'thor' module Popper class CLI < Thor class_option :config, type: :string, aliases: '-c' class_option :log, type: :string, aliases: '-l' class_option :daemon, type: :boolean, aliases: '-d' class_option :pidfile, type: :string, aliases: '-p' default_task :pop desc "pop...
true
6d5bff1f818908667ce203a61c00fb4d068690f9
Ruby
LottaCK/fsc-twitter-client
/tweet.rb
UTF-8
107
2.65625
3
[]
no_license
class Tweet attr_accessor :id, :text def initialize(id, text) @id = id @text = text end end
true
03e8a968024acf468cd98fc02c32788775e54f81
Ruby
ja-mes/rent
/test/models/payment_test.rb
UTF-8
2,260
2.734375
3
[]
no_license
class PaymentTest < ActiveSupport::TestCase def setup @payment = payments(:one) end test "payment should be valid" do assert @payment.valid? end test "user should be present" do @payment.user = nil assert_not @payment.valid? end test "customer should be present" do @payment.customer...
true
9bfc752c962b5412fd2c820bf60a58ce097d7cb4
Ruby
kurahaupo/therapeutic-refactoring
/codejunk/hard_work.rb
UTF-8
412
3.296875
3
[]
no_license
module Codejunk def spurious_hard_work(s = "I <3 Magic!") s.gsub(/[^a-z]/i, '').downcase end def spurious_transformations [1, 2, 3].map(&:to_s).join end def spurious_complexity s = rand(2) == 0 ? "abcde" : "abc" cutoff = s.length > 4 ? 4 : s.length s[0..cutoff] end def spurious_str...
true
9424f24ede265c62de252ebedfeefe45ca24beb1
Ruby
rruiz858/LIMS
/app/helpers/view_vendor_files_helper.rb
UTF-8
2,042
2.515625
3
[]
no_license
module ViewVendorFilesHelper require 'io/console' def jstree_result_hash(path) @my_temp_array = Array.new @results = Array.new @counter = 0 path_string = path + '/*' Dir.glob(path_string) do |file| recursive_method(file, '#') end @sorted_array = @my_temp_array.sort_by{|hash| hash[...
true
08e223c8cead6cf928daadc5e771769ccd2ceedd
Ruby
GirijaViswa/ruby-oo-complex-objects-school-domain-sfo-web-120919
/lib/school.rb
UTF-8
611
3.3125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class School def initialize(name) @school_name = name @roster = {} end def roster @roster end def add_student(name,grade_no) if !@roster[grade_no] @roster[grade_no] = [name] else @roster[grade_no] << name end ...
true
01d3040e101218b29109523fcc35004447f435cc
Ruby
hiroto-onda/furima-35221
/spec/models/item_spec.rb
UTF-8
3,505
2.59375
3
[]
no_license
require 'rails_helper' RSpec.describe Item, type: :model do before do @item = FactoryBot.build(:item) end describe '商品出品' do context '商品が出品できるとき' do it "正しい値が存在すれば出品できる" do expect(@item).to be_valid end end context '商品が出品できないとき' do it "商品画像がないとき"...
true
e080e742459bf971cc204744a357fe52f30bef84
Ruby
miriamhit02/seattle_grace_2105
/spec/hospital_spec.rb
UTF-8
1,951
2.8125
3
[]
no_license
require './lib/doctor' require './lib/hospital' RSpec.describe Hospital do it 'has a hospital name' do meredith = Doctor.new({name: "Meredith Grey", specialty: "General Surgery", education: "Harvard University", salary: 100_000}) alex = Doctor.new({name: "Alex Karev", specialty: "Pediatric Surgery", educatio...
true
9aa76ba40da471843f5e3032c6b36eb4051812b8
Ruby
drougojrom/test-guru
/app/models/contact.rb
UTF-8
428
2.734375
3
[]
no_license
require 'active_model' class Contact include ActiveModel::Model VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i attr_accessor :name, :email, :text validates :name, presence: true validates :email, presence: true, format: { with: VALID_EMAIL_REGEX } validates :text, presence: true def initia...
true
5ff0c473881c9bef59e1093611eeb6f163a9c746
Ruby
hamanish/watson-ruby
/lib/watson.rb
UTF-8
3,020
2.71875
3
[ "MIT" ]
permissive
require_relative 'watson/command' require_relative 'watson/config' require_relative 'watson/fs' require_relative 'watson/parser' require_relative 'watson/printer' require_relative 'watson/formatters' require_relative 'watson/remote' require_relative 'watson/github' require_relative 'watson/bitbucket' require_relative '...
true
bcc96c736f8acbc485c1770f455bf927d2d33066
Ruby
eyyeung/Rent-a-cat-ruby-on-rails-web-app
/app/models/cat.rb
UTF-8
861
2.90625
3
[]
no_license
require 'date' class Cat < ApplicationRecord COAT_COLOR=%w(black white tuxeto mixed orange ginger grey) validates :name, :user_id, :birth_date, :description, :sex, :color, presence: true validates :name, uniqueness: true validates :sex, inclusion: { in: ['F','M']} validates :sex, length: { is: 1} ...
true