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
24c7b424617565380fc4ca6f9b3d26bb320f3dc2
Ruby
jmhinric/project_euler
/problem04.rb
UTF-8
886
3.90625
4
[]
no_license
require 'pry' def find_max_palindrome first_set = (100..999).to_a second_set = (100..999).to_a products = [] first_set.each do |num1| second_set.each do |num2| products << num1 * num2 if is_palindrome?(num1 * num2) end end return products.max end def is_palindrome?(number) return number.t...
true
0d1a178f3eaa9bf6c49530a1f44b4cb6d01ef28c
Ruby
CodeNeophyte/launch_school_101_lesson3
/Easy_2/question_3.rb
UTF-8
265
3.328125
3
[]
no_license
# throw out the really old people (age 100 or older). ages = { "Herman" => 32, "Lily" => 30, "Grandpa" => 402, "Eddie" => 10 } p ages.reject { |k, v| v > 100 } p ages.select { |k, v| v < 100 } # additional & better solution p ages.keep_if { |_, age| age < 100 }
true
80bf9a653c57f51d0fb6191f7a6e5c6c78f936a4
Ruby
JBoshart/Scrabble
/lib/player.rb
UTF-8
1,061
3.828125
4
[]
no_license
class Player attr_reader :name, :word WIN_CONDITION = 100 def initialize(name) @name = name @words = [] @word_score = 0 end def plays return @words end def play(word) if self.won? == true return false end @word_score = Scoring.score(word) @words << word return ...
true
5441856c30724b2a388d319805151583b60392b6
Ruby
Madh93/rips
/lib/rips/instructions/jal.rb
UTF-8
427
2.53125
3
[ "MIT" ]
permissive
require "rips/instructions/instruction" module Rips module Instructions class Jal < Instruction attr_reader :variables, :length # @variables: types of instruction's variables # @length: length in bits for each variable def initialize super("jal",Formats::BFormat.new(0b101000)) ...
true
742e4788220d44da2dc62828b68f2ab657c80bc6
Ruby
Tapjoy/chore
/lib/chore/hooks.rb
UTF-8
1,093
2.765625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module Chore # Abstracts the notion of registering and running hooks during certain points in the lifecycle of chore # processing work. module Hooks # Helper method to look up, and execute hooks based on an event name. # Hooks are assumed to be methods defined on `self` that are of the pattern # hook...
true
ac620222419c767ad3b2d7fce49f8356991f4cf4
Ruby
joshado/graylog2-web-interface
/app/models/historic_server_value.rb
UTF-8
384
2.546875
3
[]
no_license
class HistoricServerValue include MongoMapper::Document key :type, String key :created_at, Integer def self.used_memory(minutes) get("used_memory", minutes) end private def self.get(what, minutes) self.all(:conditions => { :type => what }, :order => "$natural DESC", :limit => minutes).collect {...
true
d0f48e17b1deaddb33ad3c300aa56150637a6047
Ruby
DamonClark/introtoruby
/variables/example2a.rb
UTF-8
245
4.21875
4
[]
no_license
puts "How old are you?" age = gets.chomp.to_i puts "In 10 years your will be: " puts age + 10 puts "In 20 years your will be: " puts age + 20 puts "In 30 years your will be: " puts age + 30 puts "In 40 years your will be: " puts age + 40
true
f04724211a02a0862f50b63120beb77b3b138146
Ruby
lostpupil/leetcode-cn
/950.rb
UTF-8
317
3.8125
4
[ "MIT" ]
permissive
# @param {Integer[]} deck # @return {Integer[]} deck = [35, 22, 40, 11, 8, 2, 49, 31, 27, 29] def deck_revealed_increasing(deck) arr = [] deck.sort.reverse.each_with_index do |i, idx| arr << i arr << arr.shift if idx < deck.count - 1 end arr.reverse end p deck_revealed_increasing(deck)
true
8e1545c4d268cef3d192489cd2b6575627344f88
Ruby
ce3po/Projetos_Ruby
/aula01/pessoa.rb
UTF-8
368
3.578125
4
[]
no_license
# encoding: utf-8 class Pessoa attr_accessor :nome, :telefone def initialize(nome, telefone) @nome=nome @telefone=telefone end def relatorio puts "Meu nome é #{@nome} e telefone é #{@telefone}" end end pessoas = [] p1 = Pessoa.new("Fulano", "231") pessoas << p1 p2 = Pessoa.new("abc", "222") pessoas << ...
true
d2e5880c510f5ebd498d9698c6a735cdc4b71146
Ruby
skanev/evans
/lib/formatted_code/highlighter.rb
UTF-8
871
2.78125
3
[]
no_license
module FormattedCode class Highlighter def initialize(source, language) @source = source @language = language end def lines @lines ||= begin tokens = lexer.lex(@source) formatter = Rouge::Formatters::HTML.new HTMLLineFormatter.new(formatter).lines_...
true
1320338f798f8ba203ca54528024c7142a079e70
Ruby
jyllsarta/priconner
/app/models/stage.rb
UTF-8
817
2.890625
3
[]
no_license
# == Schema Information # # Table name: stages # # id :integer not null, primary key # area :integer default(0), not null # location :integer default(0), not null # is_hard :integer default(0), not null # class Stage < ApplicationRecord has_many :drops def name ...
true
804211b408462552cba0dac2ebdc3c4c7b8f9b38
Ruby
quyongqiang/ruby-examples
/meta_test/object_model/methods.rb
UTF-8
364
2.8125
3
[]
no_license
require './my_class.rb' class MySubclass end MyClass.methods.grep /to/ obj = MyClass.new obj.instance_variable_set("@x", 3) p obj.instance_variables MyClass.class MyClass.superclass MyClass.superclass.superclass MySubclass.ancestors obj1 = MySubclass.new p self p "MySubclass ancestors:", MySubclass.ancesto...
true
7266491af8042846386397f9e2ae24056ae72a61
Ruby
n3m3sis42/tweet-shortener-web-060517
/tweet_shortener.rb
UTF-8
756
3.53125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def words_to_be_substituted { "hello" => "hi", "to" => "2", "two" => "2", "too" => "2", "for" => "4", "four" => "4", "be" => "b", "you" => "u", "at" => "@", "and" => "&" } end def word_substituter(tweet) dictionary = words_to_be_substituted tweet.split(" ").map { |word| dictionary.keys.incl...
true
c47b357e19cb32284bc238f39995d43cd7ca605c
Ruby
linkyndy/pallets
/lib/pallets/context.rb
UTF-8
357
2.75
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module Pallets # Hash-like class that additionally holds a buffer for all write operations # that occur after initialization class Context < Hash def []=(key, value) buffer[key] = value super end def merge!(other_hash) buffer.merge!(other_hash) super end def buffer ...
true
030d1247227daa23451ecff0eea97c3694598b94
Ruby
ryuseitaked/RubyonRails
/ruby/lesson3.rb
UTF-8
97
3.125
3
[]
no_license
puts "webcamp".upcase # 「webcamp」という文字列を大文字に変換してください。
true
49adc3969a9cbb3f67b8ef0eca370d168933d1d0
Ruby
Alexander-Blair/ruby-kickstart
/session3/challenge/1_blocks.rb
UTF-8
307
4.1875
4
[ "MIT" ]
permissive
# Write a method, reverse_map, which invokes a block on each of the elements in reverse order, # and returns an array of their results. # # reverse_map(1, 2, 3) { |i| i * 2 } # => [6, 4, 2] def reverse_map(*vals, &block) vals.each.with_index { |val, i| vals[i] = block.call val } vals.reverse end
true
b4ff341d5282f89cd4e47b0238a1f4bb7e56f6c0
Ruby
Meghadandappanavar/ruby_code
/ass4.rb
UTF-8
367
3.234375
3
[]
no_license
numbers=[6,2,1,8,10] puts"#{numbers.sort}" output=[] numbers.each do |num| if num == numbers.sort[0] elsif num == numbers.sort[numbers.length-1] else output.push(num) end end puts"#{output}" sum=0 output.each do |n| sum=sum+n end puts sum =begin elsif num == "#{numbers.min}" else outp...
true
55a79763a549a59f6c2fc5cd65f3a0964c004924
Ruby
ppjk1/chris-pines-learn-to-program
/ch06_bottles.rb
UTF-8
319
3.90625
4
[]
no_license
bottles = 99 while bottles > 0 puts "#{bottles} bottles of beer on the wall," puts "#{bottles} bottles of beer," puts "You take 1 down, pass it around," bottles -= 1 if bottles == 0 puts "No more bottles of beer on the wall." else puts "#{bottles} bottles of beer on the wall." end puts "" end
true
592a9bc27f70bed6d5333701a6fa1de4b5e2269d
Ruby
sbagdat/ruby-challenges
/challenge01/solutions/solution00.rb
UTF-8
2,135
3.265625
3
[ "MIT" ]
permissive
# ------------------------------------------------------------------------------------------| # | TALİMATLAR | # ------------------------------------------------------------------------------------------| # | 0. İlk iş olarak metin dosyasındak...
true
2734c4cbce54464dbab0b08566c72dcc22299d56
Ruby
sohooo/favbuster
/favbuster.rb
UTF-8
2,038
3.015625
3
[]
no_license
# FavBuster Script ----------- by Sven Sporer 2011 # This script deletes all tweets marked as favorites. # --------------------------------------------------- # Usage: # 1) First, call initial_auth.rb to get the access token and secret. # 2) Create a config.yaml with the following content: # # oauth: # ...
true
b5b2cb1ae2c3d53b336fea9dd3207f09ef629dd9
Ruby
AlexAlt/address_book
/spec/email_spec.rb
UTF-8
1,211
2.890625
3
[]
no_license
require('rspec') require('email') describe(Email) do before() do Email.clear() end describe('#address') do it('returns the address for the email') do test_email = Email.new(:address => "help@help.com", :type => "personal") expect(test_email.address()).to(eq("help@help.com")) end end ...
true
11fae1e27df93cb1da0ed9bca11e7d038d9e279a
Ruby
joeymariano/patchshair
/db/seeds.rb
UTF-8
1,166
2.765625
3
[]
no_license
# Default Categories bass = Category.create(name: 'Bass') lead = Category.create(name: 'Lead') pad = Category.create(name: 'Pad') percussion = Category.create(name: 'Percussion') arpeggio = Category.create(name: 'Arpeggio') noise = Category.create(name: 'Noise') # Create User 1 and a patch joey = User.create(usernam...
true
87028df7942c447d7648c98fffd7883a9a478e04
Ruby
superchen14/leetcode
/ruby/034.rb
UTF-8
374
3.53125
4
[]
no_license
# @param {Integer[]} nums # @param {Integer} target # @return {Integer[]} def search_range(nums, target) first_index = nums.index(target) return [-1, -1] if first_index.nil? second_index = first_index while second_index < nums.length && nums[second_index + 1] == target do second_index += 1 end [first_i...
true
9890a9e871c601638cf48a9b0beeca86d502ced2
Ruby
cmw/radiant-forum-extension
/lib/forum_tags.rb
UTF-8
7,510
2.8125
3
[]
no_license
module ForumTags include Radiant::Taggable class TagError < StandardError; end desc %{ To enable page commenting, all you have to do is put this in your layout: *Usage:* <pre><code><r:comments:all /></code></pre> In order that pages can still be cached, we show a reply link ...
true
b2d4adf0bbd8709c0da95183dc56cfc9b570a7d5
Ruby
macbury/detox
/app/services/channels/rss/fetch.rb
UTF-8
938
2.609375
3
[]
no_license
module Channels module Rss # Download feed content and update channel information # Return feed source class Fetch < Service use Sanitizer::Full, as: :sanitize use Urls::Normalize, as: :normalize_url use DownloadFeed, as: :download_feed def initialize(channel) @channel = c...
true
ed17b61cf539521d3399f7c345fdfb6f63e612de
Ruby
tmattel/blackhawk_api
/lib/blackhawk_api/client/resources/product.rb
UTF-8
3,806
2.578125
3
[ "MIT" ]
permissive
module BlackhawkApi # The Product Management API enables client applications to work with information about individual products. # In functionality that enables selling of cards, you application calls the Product Management Service to # provide customers information about specific products in your catalog. clas...
true
f96a2db47d04283731b230e3b5d50f8ed05e1767
Ruby
jonpetersen/hvseposapp
/vendor/bundle/ruby/2.5.0/gems/apriori-ruby-0.0.9/spec/lib/apriori/item_set_spec.rb
UTF-8
2,126
2.71875
3
[ "MIT" ]
permissive
describe Apriori::ItemSet do before do data = FactoryGirl.build(:sample_data) @item_set = Apriori::ItemSet.new(data) end context '#mine' do it 'returns all association rules meeting the minimum support and confidence' do expect(@item_set.mine(50,90)).to eql({"Mango=>Keychain"=>100.0, "Onion=>Ke...
true
4953d018f50da8b68d3724b1b91ba7815e8bef95
Ruby
phoenix12394/fileajob
/lib/tasks/sample_data.rake
UTF-8
1,311
2.515625
3
[]
no_license
require 'faker' namespace :db do desc "Fill database w sample data" task :populate => :environment do Rake::Task['db:reset'].invoke make_users make_locations make_categories make_microposts end end def make_users admin = User.create!(:name => "Admin", :email => "admin@admin.com", :passwo...
true
afc9774136dfd66222959ba5d28a3c5cf36cb824
Ruby
srajiang/app-academy-classwork
/w1/w1d4/perilous_procs/phase_3.rb
UTF-8
6,193
3.578125
4
[]
no_license
def selected_map!(arr, prc1, prc2) arr.map! { |ele| prc1.call(ele) ? prc2.call(ele) : ele } nil end # is_even = Proc.new { |n| n.even? } # is_positive = Proc.new { |n| n > 0 } # square = Proc.new { |n| n * n } # flip_sign = Proc.new { |n| -n } # arr_1 = [8, 5, 10, 4] # p selected_map!(arr_1, is_even, square) ...
true
45782e1b3e9fbdee1cba0df8c95506e4ddda1121
Ruby
xenda/s9-e2
/lib/hang_up/engine.rb
UTF-8
4,886
3.25
3
[]
no_license
require 'rbconfig' module HangUp class Engine include GameTurns include Summonings include GameMessages attr_accessor :deck, :players, :screen, :words, :map PLAYER_NUMBER = 4 FOLLOWERS_PER_GAME = 4 def initialize(deck) @screen = Screen.new shuffle_cards(deck)...
true
69667ca0b4ffb44bf5692fade95e1746fda22bd1
Ruby
jamiejpace/shy-shadow-4807
/spec/models/garden_spec.rb
UTF-8
1,635
2.515625
3
[]
no_license
require 'rails_helper' RSpec.describe Garden do describe 'relationships' do it { should have_many(:plots) } end describe 'instance methods' do describe '.unique_plants_short_harvest' do before :each do @garden = Garden.create!(name: "Jamie's Garden", organic: true) @plot1 = @garden...
true
8f0d4602d97b74d7a43932809a60e4b521681ae1
Ruby
coateds/DevOpsOnWindows
/RubyScripts/BoxClass.rb
UTF-8
519
3.375
3
[]
no_license
class Box attr_accessor :length, :width, :height, :weight, :distance def initialize @@materials_cost = 0.01 #1 cent per square inch @@rate = 0.01 #1 cent per pound per mile end def self.rate= rate @@rate = rate end def self.materials_cost= cost @@materials_cost...
true
0d81f2311fe5c5e42fced0005fd6d6324a43ad64
Ruby
janno-p/jannop
/app/models/coin.rb
UTF-8
1,526
2.53125
3
[]
no_license
class Coin < ActiveRecord::Base NOMINAL_VALUES = ['2.00', '1.00', '0.50', '0.20', '0.10', '0.05', '0.02', '0.01'] =begin Coin sizes: 1c - 95px 2c - 110px 5c - 125px 10c - 116px 20c - 130px 50c - 148px 1e - 136px 2e - 150px =end has_attached_file :image, url: '/coins/:id_:style_:basename...
true
151c969562a2e5831ecbbb742aafc8628ecdefce
Ruby
nmyers93/codewars-ruby
/bits.rb
UTF-8
195
3.65625
4
[]
no_license
def count_bits(n) arr = [] new_num = n while new_num > 0 do arr << new_num % 2 #todo new_num /= 2 end bits = arr.select {|a| a == 1} puts bits.length end count_bits(1234)
true
98e652174f4b4b99453fe21c5ae6b6f5975fc3e8
Ruby
steffenm/activerecord-neo4j-adapter
/lib/neo4j/result.rb
UTF-8
910
2.734375
3
[]
no_license
module Neo4j class Result include Enumerable attr_accessor :columns, :data def initialize(model_columns, model_data) @columns = model_columns @data = model_data end def each(options = {}) case options[:as] when :hash result = [] @data.each do |row| ...
true
42467cdcf9bbf4635daf68d7f80bd0f8dd8fa6f6
Ruby
ScottDenton/oo-relationships-practice-seattle-web-career-012819
/app/models/CF_projects.rb
UTF-8
765
2.9375
3
[]
no_license
class Project attr_accessor :title, :goal, :amount_remaining, :creator @@all = [] def initialize(title, goal, creator) @title = title @goal = goal @creator = creator @amount_remaining = goal @@all << self end def self.all @@all end def self.no_pledges projects = Project.all.m...
true
3afd546290d5905abe38a1f58136df4472b45c7b
Ruby
shorrockin/adventofcode2019
/13.rb
UTF-8
1,972
3.390625
3
[]
no_license
# frozen_string_literal: true # https://adventofcode.com/2019/day/13 require 'pry' require './boilerplate' require './intcode' Tile = Struct.new(:x, :y, :id) class Game < Boilerstate attr_accessor :program, :score, :positions, :ball, :paddle def parse(input) @program = Intcode.new(input, reader: @options[:r...
true
fa87dca729e7c6395bab861d2664b280f2e5a1a8
Ruby
dylanerichards/tic-tac-toe
/cell.rb
UTF-8
135
2.875
3
[]
no_license
class Cell attr_accessor :value def initialize(value: :blank) @value = value end def blank value == :blank end end
true
e5e5340b082060fe4b625a53d8da2752e5ba5e77
Ruby
evanhughes3/tutorials
/algorithms/ruby/evernote_questions.rb
UTF-8
603
3.828125
4
[ "MIT" ]
permissive
# https://evernote.com/careers/challenge.php # Frequency Counting of Words / Top N words in a document. # Given N terms, your task is to find the k most frequent terms from given N terms. arr = ['Fee', 'Fee', 'Fee', 'Fi', 'Fo', 'Fum', 'Fi', ] def count_of_words(array_of_words, top_number) count_hash = Hash.new(0)...
true
3624cabcd6cee2241ea2867b5a409335e07c97af
Ruby
NARKOZ/gitlab
/lib/gitlab/client/tags.rb
UTF-8
3,987
2.625
3
[ "BSD-2-Clause", "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# frozen_string_literal: true class Gitlab::Client # Defines methods related to tags. # @see https://docs.gitlab.com/ce/api/tags.html module Tags # Gets a list of project repository tags. # # @example # Gitlab.tags(42) # # @param [Integer, String] project The ID or name of a project. ...
true
391e3b7337838442bfc664f465ae1a70c7dac1fa
Ruby
Podenniy/falconmotors
/db/migrate/20131002205209_combine_items_in_cart.rb
UTF-8
1,115
2.515625
3
[]
no_license
class CombineItemsInCart < ActiveRecord::Migration def up #замена нескольких записей для одного и тогоже # товара в корзине одной записью Cart.all.each do |cart| #подсчет колличества каждогго товара sums = cart.line_items.group(:spare_part_id).sum(:quantity) sums.each do |spare_part_...
true
767dd7f07e589a95808d9b456479f5cc337180a0
Ruby
christopher-hague/rspec-student-testing
/student.rb
UTF-8
852
3.234375
3
[]
no_license
class Student attr_accessor :true_pal, :clique, :intelligence attr_reader :name, :teacher, :homeroom @@all = [] def initialize(student_info) @name = student_info[:name] @true_pal = student_info[:true_pal] @clique = student_info[:clique] @teacher = student_info[:teacher] @homeroom = student...
true
48494f636e3fbeb9b152b444e403e72367d49d5b
Ruby
srinjoychakravarty/final_hospital_app
/app/models/doctor.rb
UTF-8
1,853
2.609375
3
[]
no_license
class Doctor < ActiveRecord::Base attr_accessible :email, :first_name, :gender, :last_name, :phone, :specialization has_many :appointments has_many :patients ,:through => :appointments before_save :format_phone validates :email, :first_name, :gender, :last_name, :phone, :specialization, :presence => true va...
true
9fc8184c38f3da5f5971555f5295c18ee2f8590d
Ruby
sylantyev/adam
/src/app/helpers/asset_data_store.rb
UTF-8
839
2.890625
3
[]
no_license
# Copyright:: (c) Kubris & Autotelik Media Ltd 2008 # Author :: Tom Statter # Date :: Nov 2008 # License:: MIT ? # Store actual data against an Asset's structure, for creating populated output and conversions # TODO - Create iterator directly over @value_map class AssetDataStore attr_accessor :value_map ...
true
cc99e9e086294abc34124ed2d40fe3ea436c5af5
Ruby
mrrusof/algorithms
/corner-to-corner-matrix-traversal/main.rb
UTF-8
897
3.953125
4
[]
no_license
#!/usr/bin/env ruby =begin Given a square matrix of integers, find the maximum sum of elements on the way from the top-left cell to the bottom-right cell. From a given cell, you may only move to the cell to the right or the cell below. Example. The answer for the following matrix is 29. 1 2 3 4 5 6 7 8 9 =end def...
true
e54d623b760fee013f281532785ef7e290101d79
Ruby
97-Jeffrey/ar-exercises
/exercises/exercise_6.rb
UTF-8
731
3.21875
3
[]
no_license
require_relative '../setup' require_relative './exercise_1' require_relative './exercise_2' require_relative './exercise_3' require_relative './exercise_4' require_relative './exercise_5' puts "Exercise 6" puts "----------" # Your code goes here ... @store1.employees.create(first_name: "Khurram", last_name: "Virani",...
true
ac00852d4eaecbfe5afa343b126aa711fc4a9d0f
Ruby
polyfox/moon-packages
/lib/moon/packages/path_finding/__astar.rb
UTF-8
5,306
2.71875
3
[ "MIT" ]
permissive
__END__ module PathFinding module AStar # Initializes Astar for a map and an actor def self.init(map, actor) self.map = map self.actor = actor self.move_cache = {} end # The default heuristic for A*, tries to come close to the straight path def self.heuristic_closer_path(sx, sy,...
true
822685396d9020011c45a96730f144f4e59f1e91
Ruby
garimaj2108/phase-0-tracks
/ruby/santa.rb
UTF-8
2,276
4.1875
4
[]
no_license
# Declared a Santa class class Santa attr_reader :age, :ethnicity attr_accessor :gender # Instance method speak greets for holidays! def speak puts "Ho, ho, ho! Haaaappy holidays!" end # This instance method takes a cookie type as parameter def eat_milk_and_cookies(cookie_type) puts "That was a goo...
true
00a4c67862a523fa7fe82a7708c1d149d40ebc3b
Ruby
jjromeo/practice-directory
/directory.rb
UTF-8
4,169
3.9375
4
[]
no_license
@students = [] # an empty array accesible to all methods @check @name @cohort @hobby @dob @cob def input_students puts "Please enter the names of the students" puts "To finish, just hit return twice" @name = STDIN.gets.slice(0..-2) # while the name is not empty, repeat this code while !@name.empty? do puts "W...
true
e56714cfe1833437d02a554aa3e2d4c49b6f0189
Ruby
jeremyevans/erubi
/lib/erubi/capture_end.rb
UTF-8
2,603
2.890625
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'erubi' module Erubi # An engine class that supports capturing blocks via the <tt><%|=</tt> and <tt><%|==</tt> tags, # explicitly ending the captures using <tt><%|</tt> end <tt>%></tt> blocks. class CaptureEndEngine < Engine # Initializes the engine. Accepts the same a...
true
0893f7195d012e82d0dfa10dc16e7d11416cb39c
Ruby
Tubbz-alt/WADRC-BCP-Scripts
/bin/tensor_transpose.rb
UTF-8
1,089
2.578125
3
[]
no_license
#!/usr/bin/env ruby $:.unshift File.join(File.dirname(__FILE__),'..','lib') require 'optparse' require 'tensor' def run! # Parse CLI Options and Spec File options = parse_options # Create a DTI Preprocessing Flow Task and run it. tensor = Tensor.new(options[:tensor_file]) tensor.to_fsl_txt(options[:output_...
true
81aac4152e18151fe9d5a610c7a415e776bb21d2
Ruby
platanus/linedump-gem
/lib/linedump/stream_wrapper.rb
UTF-8
999
2.984375
3
[ "MIT" ]
permissive
module Linedump class StreamWrapper MAX_LENGTH = 2048 attr_reader :stream def initialize(_stream, _block) @stream = _stream @block = _block @buffer = [] @eof = false end def eof? @eof end def process_lines begin loop do chunk = @s...
true
5064adf27f7ff0dc745101f4ce6ad86900e76385
Ruby
acltc/vg_tools
/lib/helper_tools/checking_methods.rb
UTF-8
307
3.109375
3
[ "MIT" ]
permissive
module CheckingMethods def moved_to_a_valid_square? %w{▒ ╔ ═ ╗ ╝ ╚ ║}.none? { |character| current_square_on_map.include?(character) } end def win? current_square_on_map == target end private def current_square_on_map map[current_square[0]][current_square[1]] end end
true
342eebab3b89714b92c2759f962c5eae75571b74
Ruby
zlschatz/phase-0
/week-5/pad-array/my_solution.rb
UTF-8
4,158
4.25
4
[ "MIT" ]
permissive
# Pad an Array # I worked on this challenge [by myself, with: Amaar] # I spent [2 hours with Amaar, 1 hour solo, 1 hour office hours] hours on this challenge. # Complete each step below according to the challenge directions and # include it in this file. Also make sure everything that isn't code # is commented in t...
true
83e5b234c2ffbe8daf2bfecfccef06579e0a79d7
Ruby
ramblex/euler
/euler-9.rb
UTF-8
457
3.796875
4
[]
no_license
# # A Pythagorean triplet is a set of three natural numbers, a b c, for which, # a2 + b2 = c2 # For example, 32 + 42 = 9 + 16 = 25 = 52. # There exists exactly one Pythagorean triplet for which a + b + c = 1000.Find the # product abc. # a = 500 while a > 0 b = 500 while b > 0 c = Math.sqrt((a*a) + (b*b)) ...
true
b3bcd252db4a498bea52f38d31ac431a0c8edc97
Ruby
nesquena/tokyo_cabinet_examples
/examples/table2.rb
UTF-8
285
2.515625
3
[]
no_license
require 'rubygems' require 'rufus/tokyo' t = Rufus::Tokyo::Table.new('../data/table2.tct') t['bob'] = { 'num' => '12' } t['frank'] = { 'num' => '20' } t['george'] = { 'num' => '5' } p t.query { |q| q.add_condition 'num', :numge, '12' q.order_by 'word' q.limit 5 } t.close
true
64bac4ea7343843c78cccc93f76980619883d708
Ruby
fedetaglia/wdi_sydney_3
/students/federico_tagliabue/w1d3/subway.rb
UTF-8
2,892
3.0625
3
[]
no_license
lines = Hash.new lines["N"] = ["times square", "34th", "28th", "23rd", "union square", "8th"] lines["L"] = ["8th", "6th", "union square", "3rd", "1st"] lines["6"] = ["grand central", "33rd", "28th", "23rd", "union square", "astor", "place"] # I ASSUME THERE IS ONLY ONE INTERSECTION ! intersections = (lines["N"] & ...
true
3dec71763fe99fd35b2a20da6ce907ecb47b8bad
Ruby
r-cochran/mtg-bot
/searchTO.rb
UTF-8
177
2.609375
3
[ "MIT" ]
permissive
class SearchTO attr_accessor :name, :set def needs_help? @name == "help" end def show_sets? @name == "set list" end def has_set? !@set.nil? && @set != "" end end
true
4496832a6d4d9010f6f9e351af4244f361791489
Ruby
NNWaller/oo-kickstarter-cb-000
/lib/project.rb
UTF-8
440
3.21875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Project attr_accessor :title, :backers def initialize(title) @title = title @backers = [ ] end #The add_backer method accepts a Backer as an argument and stores it in a backers array #We are also telling the backer to add the Project instance to the @backed_projects #array that is loca...
true
cb36238011448dcfe59774968ecfb53b6a150a9d
Ruby
cgregs32/leetcode_algo
/ruby/grading_students.rb
UTF-8
255
3.4375
3
[]
no_license
def gradingStudents(grades) return grades.map do |grade| next grade if grade < 38 next grade if (grade % 5) < 3 rounded = grade.round(-1) rounded > grade ? rounded : rounded + 5 end end grades = [73,67,38,33] p gradingStudents(grades)
true
1a38ee3f934e5e6b0069f8e09dc2176b91570bdd
Ruby
Leandro-b-03/teelogger
/lib/teelogger/filters/assignment.rb
UTF-8
1,109
2.65625
3
[ "MITNFA" ]
permissive
# # TeeLogger # https://github.com/spriteCloud/teelogger # # Copyright (c) 2014,2015 spriteCloud B.V. and other TeeLogger contributors. # All rights reserved. # require 'teelogger/filter' module TeeLogger module Filter ## # The Assignment filter takes strings of the form <prefix><word>=<value> and # obfu...
true
02ebe21cddeeaf573cfee59aa17b231cb17aab10
Ruby
karashchuk/LessonRuby_01
/lesson_01_methods.rb
UTF-8
2,385
3.640625
4
[]
no_license
#Для класса Fixnum: # Метод, увеличивающий число на единицу puts 11.next puts 11.succ # Метод проверяющий является ли число нулём puts 0.zero? # Метод возвращающий модуль числа puts -12.abs # #Для класса Float: # Метод, округляющий вещественное число вниз до целой части puts 15.6.to_i # Метод, возв...
true
fd89b9770129febddd0c41ad0aadd39546009196
Ruby
gearlles/gitlab-changelog-generator
/gitlab_client.rb
UTF-8
1,886
2.625
3
[ "MIT" ]
permissive
require 'gitlab' class GitlabClient attr_accessor :project_name def initialize(endpoint, private_token, project_name) Gitlab.endpoint = endpoint Gitlab.private_token = private_token @project_name = project_name projects = nil begin projects = Gitlab.project_search(project_name) if ...
true
5b3d8342bf50b1a1f569e3d3dd202900b882c266
Ruby
jcoglan/advent-of-code
/2016/18/solution.rb
UTF-8
552
2.984375
3
[]
no_license
input_path = File.expand_path('../input.txt', __FILE__) rows = File.read(input_path).strip.lines PATTERNS = ['^^.', '.^^', '^..', '..^'] def new_row(row) cells = row.size.times.map do |i| window = [i-1, i, i+1].map { |j| j < 0 ? '.' : (row[j] || '.') }.join('') PATTERNS.include?(window) ? '^' : '.' end ...
true
f2915f07291cc4dd1136c2d8a407b749ec463162
Ruby
GalacticPlastic/ironhack
/Week1/Day2/PP_EmployeePayroll/lib/salaried_employee.rb
UTF-8
340
2.890625
3
[]
no_license
class SalariedEmployee < Employee include SalariedPay attr_accessor(:salary) def initialize(name, email, salary) @name = name @email = email @salary = salary end def calculate_salary gross_weekly_pay # => gross_weekly_pay calls: @salary / 52.0 net_weekly_pay = gross_weekly_pay * 0.82 #returns the net...
true
d1522cee0e1def47284803f268cd25250c1d3ee6
Ruby
pgcosta/battleship-game
/spec/player_spec.rb
UTF-8
373
2.796875
3
[]
no_license
require_relative '../boat' require_relative '../board' require_relative '../player' describe Player do it "should calculate the health of all the boats" do player = Player.new board = Board.new boat1 = Boat.new(3) boat2 = Boat.new(3) board.boats = [boat1, boat2] player.board = board expe...
true
39fe045f1fd3c7f206db9246e77a78f4554ced54
Ruby
filipebarcos/metaprogramming-talk
/method_calls/include.rb
UTF-8
212
3.296875
3
[]
no_license
module MyModule def my_method "my_method called on MyModule" end end class MyClass include MyModule def my_method "my method called on MyClass" end end my_class = MyClass.new puts my_class.my_method
true
e9393630e6570035c7131afa021d7795154f686a
Ruby
riekure/ruby-book
/caption8/product_2.rb
UTF-8
743
3.65625
4
[]
no_license
# ログ出力用のメソッドを提供するモジュール module Loggable def log(text) puts "[LOG] #{text}" end end class Product # Loggableモジュールのメソッドを特異メソッド(クラスメソッド)としてミックスインする extend Loggable def self.create_products(names) # logメソッドをクラスメソッド内で呼び出す # (つまりlogメソッド自体もクラスメソッドになっている) log 'create_products is called....
true
0b8387b84746ef33bb9bc03836c07b448c1800b7
Ruby
ipoval/mongo-ruby-driver
/lib/mongo/cursor.rb
UTF-8
6,443
2.640625
3
[ "Apache-2.0" ]
permissive
# Copyright (C) 2009-2014 MongoDB, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in ...
true
6c8c63fde1884288c64c86d6f92e910c9b511fb1
Ruby
mattduboismatt/sound-persistence
/app/models/user.rb
UTF-8
546
2.78125
3
[]
no_license
class User include ApplicationHelper attr_reader :first_name, :last_name, :gender, :favorite_color, :date_of_birth def initialize(user_params) @first_name = user_params.fetch(:first_name,nil) @last_name = user_params.fetch(:last_name,nil) @gender = user_params.fetch(:gender,nil) @favorite_color...
true
aa7dc9e9ba61304e383d67ddf056c948c15209b4
Ruby
emiliodacosta/w1d3
/recursion.rb
UTF-8
1,708
3.796875
4
[]
no_license
require 'byebug' def range(min, max) return [] if max <= min rec = range(min+1, max) rec.unshift(min) end def sum_rec(array) return array.first if array.length == 1 array.first + sum_rec(array[1..-1]) end def sum_iter(array) sum = 0 array.each do |num| sum += num end sum end def exp(b, n) ...
true
8a52016a38d78e7bf3c329544c4b8d59a0d9eaeb
Ruby
aslamz/appium
/lib/support/helpers/file_helpers.rb
UTF-8
1,496
3.0625
3
[ "Apache-2.0" ]
permissive
module Appium module Helpers # # File/FileUtils wrapper methods # # File.exist? def exist? *args File.exist? *args end # File.exists? def exists? *args File.exists? *args end # File.dirname def dirname *args File.dirname *args end # File.basena...
true
294192b1bbd7f1baef60e84f2a57c29c0ba5089b
Ruby
anaerobeth/Bravo-exercises
/test_scores.rb
UTF-8
875
3.484375
3
[]
no_license
require 'CSV' total_above_90 = 0 total_above_80 = 0 total_above_70 = 0 total_less_70= 0 above_90 = [] above_80 = [] above_70 = [] less_70 = [] # test_scores.csv is found in # https://gist.github.com/anaerobeth/ec82e261f98fc8da4105 CSV.foreach('test_scores.csv', headers: true) do |row| score = row[1].to_f if s...
true
d990e4876d463ff8d6d4c9d4f640147bf361a254
Ruby
rejennarate/short_stories
/catmethod.rb
UTF-8
1,276
4.1875
4
[]
no_license
# cat method @maji = 0 @tristan = 0 def cat question while true puts question reply = gets.chomp.downcase if reply == "a" @tristan = @tristan + 1 break elsif reply == "b" @maji = @maji + 1 break elsif reply == "c" break else puts "please select 'a' or 'b'." end #break end end ...
true
2ad8d3463df952cbecb3c27b1f94cb7b52e70fc9
Ruby
WilfriedDeluche/erp_project
/app/helpers/companies_helper.rb
UTF-8
311
2.765625
3
[]
no_license
module CompaniesHelper def contact_name(company) chaine = "" chaine += "#{company.contact_first_name.capitalize} " unless company.contact_first_name.nil? # otherwise error in case attr is nil chaine += company.contact_last_name.upcase unless company.contact_last_name.nil? chaine end end
true
c05068727e86bb0cce1a1d87099998a959a67047
Ruby
dapengli2005/clock-api
/app/models/clock_entry.rb
UTF-8
763
2.546875
3
[]
no_license
class ClockEntry < ApplicationRecord belongs_to :user ALLOWED_ACTION_TYPES = %w(IN OUT) DATETIME_GRACE_PERIOD = 5.minutes # in case user's clock is not synced (not likely, but just in case) validates :action_type, inclusion: { in: ALLOWED_ACTION_TYPES, message: "%{value} is not supported...
true
22c408445749122b0211c3ba6f1a493a7b35c500
Ruby
ronwoch/classwork
/ruby/last.rb
UTF-8
745
2.90625
3
[]
no_license
#!/usr/bin/ruby #========================================================================================= # Ronald Wochner # Wed May 24 11:34:12 PDT 2017 # Version 1 # Simple ruby script to explore control statements #========================================================================================= data = `l...
true
5c8a20ef1a2b86507fe62f41f3c2faaffaaf1251
Ruby
cyberarm/ftc_skystone_game
/lib/game_objects/robot.rb
UTF-8
1,605
2.9375
3
[]
no_license
module Game class Robot < Game::GameObject def setup @image = Gosu::Image.new(GAME_ROOT_PATH + "/assets/robot.png") @position += (@image.width / 2) / 2 @angle = 90.0 end def update super forward if Gosu.button_down?(Gosu::KB_UP) || Gosu.button_down?(Gosu::KB_W) backw...
true
70b294f6b5c24bcc8d59c2547b34455b60102c7a
Ruby
yangchuanosaurus/rubymonk
/2 - Ruby Primer - Ascent/8 - Finding and Fixing Bugs/logging.rb
UTF-8
2,226
3.765625
4
[]
no_license
# Logging require 'logger' # The caller method returns the stack trace as an array # which is pretty convenient if you want to programmatically introspect it. def c puts "I'm in C. You know who called me?" puts caller end def b c end def a b end a # debug < info < warn < error < fatal < unknown. logger = L...
true
b0fa1f2e8416883c4334bf6e5a5897fe8616e73e
Ruby
albahri/TrashTrack
/app/api_client.rb
UTF-8
841
3.078125
3
[]
no_license
require './lib/api.rb' require 'nokogiri' # CRUD example with an api def list_posts(api_object) puts "Current Post:" doc = Nokogiri::XML.parse api_object.read contents= doc.xpath('posts/post/content').collect {|e| e.text } puts contents.join(", ") puts "" end api = Api.new list_posts(api) ...
true
17c52b11b98387c21cbd0fb34f828bbe1ad0069b
Ruby
stebbie/learnruby
/ex5.rb
UTF-8
481
3.640625
4
[]
no_license
my_name = 'Zed A. Shaw' my_age = 35 inches = 74 my_weight = 180 my_eyes = 'blue' my_teeth = 'white' my_hair = 'brown' my_height = inches * 2.54 puts "Let's talk about #{my_name}." puts "He's #{my_height} inches tall" puts "He's #{my_weight} pounds heavy" puts "Actually that's not too heavy" puts "He's got #{my_eyes} ...
true
dba9e07db763b07f95c3144e1db7ecc387bfb57b
Ruby
bhabig/ruby-intro-to-hashes-lab-v-000
/intro_to_ruby_hashes_lab.rb
UTF-8
1,946
3.015625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' def new_hash {} end def actor actor = {name: "Dwayne The Rock Johnson"} end def monopoly monopoly = {} monopoly[:railroads]= {} monopoly end def monopoly_with_second_tier monopoly = {} monopoly[:railroads]= {} monopoly[:railroads][:pieces]= 4 monopoly[:railroads][:names]= {} monopoly[:railro...
true
fc0de8f434230a9d87943819e070fccedda880f6
Ruby
tobykurien/adventofcode2018
/1/1.rb
UTF-8
251
2.84375
3
[ "MIT" ]
permissive
d = [] f = File.open('data.txt') f.each_line{|line| d << line.to_i} puts d.sum() acc = 0 dup = nil seen = {0=>true} while not dup d.each do |v| i = v + acc acc += v if seen[i] dup = i puts dup return end seen[i] = true end end
true
bc796fec71a8739ee5a7acef31ac6a39f02d9656
Ruby
MollieS/noughtsandcrosses
/spec/board_spec.rb
UTF-8
1,631
3.515625
4
[]
no_license
require 'board' describe Board do context 'positions' do it 'shows the rows' do expect(subject.rows).to eq([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) end it 'shows the columns' do expect(subject.columns).to eq([[1, 4, 7], [2, 5, 8], [3, 6, 9]]) end it 'shows the diagonals' do expect(s...
true
f82982060c9729ae1fcc6f859d9554f915403fa4
Ruby
shipp11/winning-ticket
/winningticket_test.rb
UTF-8
1,007
2.921875
3
[]
no_license
require "minitest/autorun" require_relative "winningticket.rb" class Testwinningticket < Minitest::Test def test_assert_1_is_1 assert_equal(1, 1) end def test_assert_that_there_is_an_array_for_winning_numbers winners = [1234, 4567, 6789] my_ticket = 1234 assert_equal(Array, winning_nums(winners, my_ticket)...
true
8c9713f9bf7d04182f2fa6124d36d9428f797114
Ruby
thib123/TPJ
/Notes/Ruby/sample_code/ex0466.rb
UTF-8
1,397
3.015625
3
[ "MIT" ]
permissive
# Sample code from Programing Ruby, page 250 require 'tk' class GifViewer def initialize(filelist) setup_viewer(filelist) end def run Tk.mainloop end def setup_viewer(filelist) @root = TkRoot.new {title 'Scroll List'} frame = TkFrame.new(@root) image_w = TkPhotoImage.new TkLabel.n...
true
f676854882328aea86eb7fe463792e7f34997703
Ruby
Lixxmint/thinknetica
/Lesson_2/mounth.rb
UTF-8
606
3.71875
4
[]
no_license
=begin 1. Сделать хеш, содеращий месяцы и количество дней в месяце. В цикле выводить те месяцы, у которых количество дней ровно 30 =end mounth = {:January => 31, :February => 28, :March => 31, :April => 30, :May => 31, :June => 30, :July => 31, :August => 31, :September => 30, :October =>...
true
217d4857547fefd48904ad8a71bd885fcf27a4d2
Ruby
mikecurran/launchschool
/101/lesson_4/twenty-one.rb
UTF-8
5,342
3.65625
4
[]
no_license
#!/usr/bin/env ruby DEALER_LIMIT = 17 GAME_LIMIT = 21 WINNING_SCORE = 5 SUITS = %w(Hearts Diamonds Spades Clubs).freeze VALUES = %w(2 3 4 5 6 7 8 9 10 Jack Queen King Ace).freeze def prompt(msg) puts "=> #{msg}" end def clear_screen system('clear') || system('cls') end def initialize_deck VALUES.product(SUITS)...
true
4eeca3ef0cd5009b1423223bbba6bbc9aaf40636
Ruby
asilvadev/QA-automacao-RockLov
/api/spec/scenarios/session_post_spec.rb
UTF-8
1,838
2.578125
3
[ "MIT" ]
permissive
describe "POST /session" do context "login com sucesso" do before(:all) do payload = { email: "betao@hotmail.com", password: "pwd123", } @result = Sessions.new.login(payload) end it "validar status code" do expect(@result.code).to eql 200 end it "validar i...
true
c68aa95b291e92c924292db40153da7cd2cf7c5b
Ruby
simonjamain/designexporter-plugin-businesscard
/main
UTF-8
3,803
2.546875
3
[]
no_license
#!/usr/bin/env ruby # encoding: utf-8 require 'nokogiri' require 'csv' require 'yaml' require 'fileutils' require 'shellwords' ACCEPTED_FONTS_EXTENSIONS = %w( .ttf .otf ) ACCEPTED_CONFIGFILE_EXTENSIONS = %w( .yml ) SOURCES_EXTENSION = 'svg' def isValidFontFile?(fontFile) ACCEPTED_FONTS_EXTENSIONS.i...
true
fa03e4e89a2bfc8a4739137124bdb925035ca39c
Ruby
IamNorma/whats-in-my-food
/app/facades/search_facade.rb
UTF-8
180
2.640625
3
[]
no_license
class SearchFacade def fetch_food_data(food) response = FoodService.new.search(food) response[:foods].map do |food_data| Food.new(food_data) end end end
true
76c6c18ae460fe7f7f1aefcf85bb3c15bcae394a
Ruby
Steveo00/launchschool
/ruby_basics/methods/exercise_10.rb
UTF-8
277
3.890625
4
[]
no_license
def name(arr) arr.sample end def activity(arr) arr.sample end def sentence(word1, word2) "#{word1} went #{word2} today!" end names = ['Dave', 'Sally', 'George', 'Jessica'] activities = ['walking', 'running', 'cycling'] puts sentence(name(names), activity(activities))
true
cd2c2a94c53def903adda4e15300cd497b30a210
Ruby
AlexRoadsign/Ruby_basics1-2
/lib/01_hello.rb
UTF-8
75
2.90625
3
[]
no_license
def say_hello (prefix = "Bonjour") puts "#{prefix}" end return say_hello
true
0f8c7873320275dcf33ab23bd2df31cc878f2b06
Ruby
spetluri/ruby-class-variables-and-class-methods-lab-v-000
/lib/song.rb
UTF-8
821
3.390625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Song attr_accessor :name, :artist, :genre @@count = 0 @@genres = [] @@artists = [] def initialize(name,artist,genre) @name = name @artist = artist @genre = genre @@count += 1 @@genres << genre @@artists << artist end def self.count # => 30 @@count end def self.a...
true
72401e772f449be3698057a5b180453239df5b64
Ruby
tranngocsam/turbine
/spec/turbine/graph_spec.rb
UTF-8
3,770
3.015625
3
[]
no_license
require 'spec_helper' describe 'Turbine::Graph' do let(:graph) { Turbine::Graph.new } let(:node) { Turbine::Node.new(:jay) } let(:other) { Turbine::Node.new(:gloria) } describe 'adding a new node' do context 'when the graph is empty' do before { graph.add(node) } it 'should add...
true
e4a49eb765cd8076251a505221b5612957a429f7
Ruby
ajamarco/programming-univbasics-nds-nds-to-insight-raw-brackets-lab-london-web-010620
/lib/nds_extract.rb
UTF-8
539
2.671875
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
$LOAD_PATH.unshift(File.dirname(__FILE__)) require 'directors_database' def directors_totals(nds) pp nds result = { } puts nds.length nds.length.times do |index| #puts nds[index].length result[nds[index][:name]] = 0 puts "MOVIES BY #{nds[index][:name]}" nds[index][:movies].length.tim...
true
c52c0a226e7a5d51c6692398dbfd9a4c658c50f4
Ruby
opal/opal
/stdlib/json.rb
UTF-8
3,627
3.03125
3
[ "MIT" ]
permissive
# backtick_javascript: true module JSON class JSONError < StandardError end class ParserError < JSONError end %x{ var $hasOwn = Opal.hasOwnProperty; function $parse(source) { try { return JSON.parse(source); } catch (e) { #{raise JSON::ParserError, `e.message`}; }...
true
2cca1c0d6236fa1b8ccdc106f2fa2591f8a41503
Ruby
Mattieuga/CodeNow-May2014
/yasminenassar and jessi67/calc.rb
UTF-8
627
3.5625
4
[]
no_license
begin puts "First number?" user1 = gets.to_i puts "Second number?" user2=gets.to_i puts "Operation?" op= gets.chomp if op== "+" puts "#{user1} + #{user2} = #{user1 + user2}" elsif op== "-" puts "#{user1} - #{user2} = #{user1 - user2}" elsif op== "*" puts "#{user1} * #{user2} = #{user1 * user2}" elsif op== "/"...
true
8bb55b5a7ab8c8396d7bf6e7a8012f51464a71ba
Ruby
ondrejfuhrer/rocket-library
/app/models/rental.rb
UTF-8
1,506
2.65625
3
[ "MIT" ]
permissive
class Rental < ActiveRecord::Base validates_with RentalValidator, on: :create state_machine initial: :active do event :return do transition any => :returned end before_transition any => :returned do |rental| rental.returned_at = Time.now end after_transition any => :returned do |...
true
9fa6e8cbf60604fb62a25c8a9ff4a6c1517d2878
Ruby
netoconcon/batch-503-live-code
/acronymize.rb
UTF-8
384
3.421875
3
[]
no_license
def acronymize(sentence) sentence_array = sentence.split(" ") acronym = "" sentence_array.each do |word| acronym += word[0].upcase end return acronym end puts acronymize("Frequently Asked Question") # == "FAQ" # ["Frequently", "Asked", "Question"] puts acronymize("") # == "" puts acronymize("AWAY FROM K...
true