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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
988de6d58e01cb5b70222cb99a2ab130c1bd1712 | Ruby | cflee/is103 | /project2/p2q1-scanline.rb | UTF-8 | 1,420 | 3.5625 | 4 | [
"MIT"
] | permissive | # scanline fill implementation adapted from somewhere on the internet
def lightning(a, y, x)
# nothing to do if this is already 0
return a if a[y][x] == 0
# retrieve the dimensions for bounds checking later
height = a.length # y
width = a[0].length # x
sl = 0
sr = 0
# prepare the stack
st = []... | true |
d965796388f7e58eaad172200baa32c482a3da1a | Ruby | bleavitt92/Launch-School | /Small_Problems/easy5/letterswap2.rb | UTF-8 | 262 | 4.3125 | 4 | [] | no_license |
#easier or shorter way:
def first_and_last_swap(word)
word[0], word[-1] = word[-1], word[0]
word
end
def swap_each(string)
result = string.split(' ').map do |word|
first_and_last_swap(word)
end
puts result.join(' ')
end
swap_each("hey you") | true |
8d50ab3f2eb52bd2177b09275bffbc5e3b8a841a | Ruby | kevinjcoleman/fantasyfootballdata | /app/models/concerns/stats_calculator.rb | UTF-8 | 184 | 2.796875 | 3 | [] | no_license | module StatsCalculator
def self.total_points(league,stats)
league.stats_for_calculations.inject(0) do |value, (k, v)|
value += stats.send(k) * v
end.round(2)
end
end
| true |
d5a87477855e956bc03cab3ebc06f70115c081c2 | Ruby | hemorej/surprise-cron | /libexec/surprise.rb | UTF-8 | 2,533 | 2.5625 | 3 | [
"MIT"
] | permissive | class Surprise
attr_reader :failed_jobs, :failure_threshold, :frequency_start, :interval_start, :interval_end, :block, :interval, :frequency, :runs
VERSION = '0.1'
def initialize(interval, frequency, check = true)
if check
opts = {:interval => interval, :frequency=> frequency}
Surprise.validate_... | true |
a47122ee37b8a07a2ec29ad74d6e1fe78253762d | Ruby | thanghm/Api-Thanghm | /app/models/match.rb | UTF-8 | 1,857 | 2.546875 | 3 | [] | no_license | class Match < ActiveRecord::Base
enum status: { completed: 1}
scope :completed, -> {where("status = ?", statuses[:completed])}
belongs_to :home_player, :class_name => Player, :foreign_key => "home_player_id"
belongs_to :away_player, :class_name => Player, :foreign_key => "away_player_id"
def self.matchs_searc... | true |
10dab0270f851208bc5b2f9f84308ae4343e72a8 | Ruby | drichert/brens | /spec/brens/text_spec.rb | UTF-8 | 2,586 | 3.03125 | 3 | [
"MIT"
] | permissive | require "spec_helper"
module Brens
describe Text do
let(:str) { "This is a\ntest.\t" }
subject { described_class.new(str) }
its(:to_a) { should == ["This", "is", "a", "test."] }
describe "attr methods" do
describe "readers" do
it { should respond_to(:words) }
it { should re... | true |
cc8ae9be4a15cc10e559b3e4ab91f38dbcb9df95 | Ruby | pmonfort/flatten | /test/test_flatten.rb | UTF-8 | 1,092 | 2.9375 | 3 | [] | no_license | # frozen_string_literal: true
require 'minitest/autorun'
require 'minitest/spec'
require 'flatten'
describe Flatten do
let(:flatten) { Flatten.new }
describe 'processes valid array' do
let(:result) { flatten.process(array) }
describe 'flat array' do
let(:array) { [1, 2, 3] }
it 'returns the... | true |
ea90fbdb8ed38af23a581771a6bce9a4c717bbee | Ruby | PollyCR/ruby-boating-school-london-web-080519 | /app/models/instructor.rb | UTF-8 | 1,016 | 3.046875 | 3 | [] | no_license | class Instructor
@@all = []
def self.all
@@all
end
def initialize(name)
@name = name
@@all << self
end
attr_reader :name
def find_student_and_test(student:, test_name:)
BoatingTest.all.find{|test| (test.student == student) && (test.name == test_name)}... | true |
0769f251ceafa9ae24a007b143e528d08d568bc9 | Ruby | harryobas/ratling_dog | /lib/ratling_dog/chorus.rb | UTF-8 | 162 | 2.609375 | 3 | [
"MIT"
] | permissive | class Chorus
def initialize
@song_line_gen = SongLineGen.new
end
def lines()
@song_line_gen.generate_song_lines(:chorus)
end
end | true |
746011c2e53acd6853dfff45b79146961804789a | Ruby | DanceDance99/agm | /test/models/shuttle_test.rb | UTF-8 | 5,419 | 2.546875 | 3 | [] | no_license | require 'test_helper'
class ShuttleTest < ActiveSupport::TestCase
valid_attributes = {:amount => 0, :round_trip_amount => 0, :group_amount => 0, :group_round_trip_amount => 0}
test "test shuttle saves" do
shuttle = Shuttle.new(valid_attributes)
assert shuttle.save
end
test "shuttle should crea... | true |
879df6169aef062e1c78f30d230b5ac9576dee9b | Ruby | victoriak94/reinforcement9 | /reinforcement9.rb | UTF-8 | 1,027 | 3.296875 | 3 | [] | no_license |
class TodoList
def initialize
@tasks = []
end
def add_task(task)
@tasks << task
end
end
class Task
def initialize(description, due_date)
@description = description
@due_date = due_date
end
#Reader
def description
@description
end
def due_date
@due_date
end
#Write... | true |
394b5c06e00a5a31b31fe0052b50609351cb8c07 | Ruby | BTewell/whiteboarding | /wb-5.rb | UTF-8 | 546 | 4.5 | 4 | [] | no_license | # Write a method that accepts an array of numbers as a parameter, and returns the number of how many 55’s there are in the array. For example, if the input is [55, 4, 7, 55, 9, 1, 55, 2, 3, 55, 0], the output should be 4. NOTE: DO NOT USE RUBY’s built-in “count” method.
def tracker_method(input_array)
counter = 0
... | true |
3eeac3cbef14c65a8e53db4bed02f5d0c99b358e | Ruby | leon-joel/misc | /block/dsl4.rb | UTF-8 | 1,682 | 3.5 | 4 | [] | no_license | # トップレベルのインスタンス変数を削除するために、スコープをフラット化する。
lambda {
setups = []
events = []
# セットアップBlockの登録
Kernel.send :define_method, :setup do |&block|
setups << block
end
# イベント名と発火条件を登録
Kernel.send :define_method, :event do |description, &block|
events << { description: description, condition: block}
end
... | true |
ee747f6bd5425dd1774909cc70547e74bcc513bf | Ruby | sonchez/programming_exercises | /methods/exercise_5.rb | UTF-8 | 259 | 3.921875 | 4 | [] | no_license | def scream(words)
words = words + "!!!!"
puts words
end
scream("Yippeee")
# It prints "Yippeee!!!!"
# the argument is passed to the method parameter.
# It then has "!!!!" string added.
# the merged string is passed to the variable "words", then printed. | true |
b948da23d244da2f4e475b107765f083b106d1c6 | Ruby | arunmur/baloonware | /spec/models/stats/total_distance_travelled_spec.rb | UTF-8 | 669 | 2.578125 | 3 | [] | no_license | require './models/stats'
require './models/measurement'
require 'rspec/its'
describe Stats::TotalDistanceTravelled do
subject {
stat = described_class.new
measurement = Measurement.from_recording("2010-01-01T00:00|10,5|10|AU")
stat = stat.record(measurement)
measurement = Measurement.from_recording("... | true |
1e882a0ce13ea90cd50db7d8f0d8fe939a162925 | Ruby | MarcoKlemenc/aydoo2017tp | /ejercicio-calendario/spec/sumador_recurrencia_anual_spec.rb | UTF-8 | 690 | 2.71875 | 3 | [] | no_license | require 'rspec'
require_relative '../model/sumador_recurrencia_anual'
describe 'SumadorRecurrenciaAnual' do
it 'es posible sumarle un anio a una fecha' do
sumador = SumadorRecurrenciaAnual.new
fecha_inicial = DateTime.new(2016, 3, 14, 16, 0, 0)
fecha_esperada = DateTime.new(2017, 3, 14, 16, 0, 0)
ex... | true |
9dbb2b5bce4e5a4f3e72900b8b8353e5eea8d465 | Ruby | KatherineEvans/Fake-Business | /store_item_module.rb | UTF-8 | 353 | 2.5625 | 3 | [] | no_license | module StoreFront
module Sellable
def car_sales_pitch
return "Car for sale! Model: #{car_name}, Color: #{car_color}, Price: #{car_price}"
end
def car_discount
@car_price = @car_price * 0.95
end
def bidding_war
@car_price = @car_price * 1.1
end
def car_sold
@car_f... | true |
1fc8675ec54b21d85f170d8fb7e2f446204b3b84 | Ruby | IandIUsername/mymyflix | /spec/models/video_spec.rb | UTF-8 | 5,144 | 2.8125 | 3 | [] | no_license | require 'spec_helper'
describe Video do
it { should belong_to(:category) }
it { should validate_presence_of(:title) }
it { should validate_presence_of(:description) }
it { should have_many(:reviews).order("created_at desc")}
#it { should have_many(:reviews).order('pos') }
end
# describe Video do
# it "s... | true |
e41127454f38a519aa9ba1ed839401d68b16415d | Ruby | aculich/hyperarchy | /server/vendor/monarch/server/lib/monarch/model/expressions/and.rb | UTF-8 | 953 | 2.515625 | 3 | [] | no_license | module Monarch
module Model
module Expressions
class And < Expression
class << self
def from_wire_representation(representation, repository)
operands = representation["operands"].map do |operand_wire_representation|
Expression.from_wire_representation(operand_wire... | true |
cf34b4b573484b1a6a42c68629e43e5a47c2b72f | Ruby | danghanh99/git2 | /m2.rb | UTF-8 | 39 | 2.71875 | 3 | [] | no_license | def take(s, len = 1 )
s[len..-1]
end | true |
017711f88dc616d57e41f1f63c6ee3401e531cae | Ruby | united-drivers/vehiclepedia | /_plugins/entity-json.rb | UTF-8 | 1,382 | 2.53125 | 3 | [
"Unlicense"
] | permissive | require 'json'
module Jekyll
class JSONPage < Page
def initialize(site, base, dir, name, content)
@site = site
@base = base
@dir = dir
@name = name
self.data = {}
self.content = content
process(@name)
end
def read_yaml(*)
# Do nothing
end
def r... | true |
72f2a8fd372e55afda083ce7a978b5be7de96c9b | Ruby | and-the-rest/dirty-scripts | /dups/dups.rb | UTF-8 | 2,260 | 2.90625 | 3 | [] | no_license | #!/usr/bin/env ruby
# dups.rb - a tiny utility that removes duplicate files
# from a given directory.
#
# @author :rmNULL
# @license :public
#
# TODO:
# 1. Add support for recursive deletion.
# 2. Improve interactive mode interface.
# 3. Deal with directories and links.
require 'digest'
require 'optparse'
def pos... | true |
715e20093b1db25c327421960d03172b9806de73 | Ruby | liamzhang40/aA-projects | /W2D3/TDD/spec/tdd_spec.rb | UTF-8 | 1,200 | 3.484375 | 3 | [] | no_license | require 'rspec'
require 'tdd'
describe '#my_uniq' do
it 'should remove all duplicates' do
expect([1, 2, 1, 3, 3].my_uniq).to eq([1, 2, 3])
end
end
describe '#two_sum' do
it 'should all pairs of positions that sum to zero' do
expect([-1, 0, 2, -2, 1].two_sum).to eq([[0, 4], [2, 3]])
end
end
describe... | true |
adbdf1c295075a5ce598a75fd393eb9d14f5204d | Ruby | puredevotion/Teratorn | /omf/omf-5.2/visyoNet/src/ruby/visyonet/visModel/UNUSED/Shape.rb | UTF-8 | 1,092 | 3.046875 | 3 | [
"MIT"
] | permissive |
#
# shape
#
class Shape
attr_accessor :id, :isVisible, :labelText, :labelTextColor, :alpha, :position
def initialize(layer = nil, id = nil, visible = true, labelText = "",
labelTextColor = nil, position = nil, alpha = 255)
@id = id
@isVisible = visible
@labelText = labe... | true |
321bfce57bce4371d3d8abfe049c9d499066f6f0 | Ruby | ericboehs/advent_of_code | /2016/day_1.rb | UTF-8 | 6,343 | 3.328125 | 3 | [] | no_license | # The first day in the Advent of Code challenges
module DayOne
# Represents the path to the Easter Bunny Headquarters as intercepted by the Elves
class Path
# The four directions of a compass ordered clockwise. Used to determine our heading based on relative
# directions (i.e. left and right)
CARDINAL_D... | true |
c375eedaa66a3b4f4d96343a71e84ca34b2a04ad | Ruby | dewyze/putter | /lib/putter/print_strategy.rb | UTF-8 | 476 | 2.75 | 3 | [
"MIT"
] | permissive | require "colorize"
module Putter
module PrintStrategy
Default = Proc.new do |data|
prefix = "\tPutter Debugging: #{data.label} ".colorize(:cyan)
if data.line.nil?
line = " "
elsif data.line[0] != "/"
line = "./#{data.line} "
else
line = ".#{data.line} "
end
... | true |
aec70304772b1e7dc8e8188323ff95c1ee7bb26f | Ruby | jamesflorentino/git-update-ghpages | /bin/git-update-ghpages | UTF-8 | 3,952 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env ruby
# git update-ghpages user/repo -b gh-pages -p manual/ -i
require 'fileutils'
require 'tmpdir'
module Params
def extract(what) i = index(what) and slice!(i, 2)[1] end;
def first_is(what) shift if what.include?(self.first); end
def self.[](*what) what.extend Params; end
def ===(argv) ... | true |
88431815ce7164e654ab258b07bf07d5478abb63 | Ruby | awesome/music-transcription | /lib/music-transcription/value_change.rb | UTF-8 | 1,652 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Music
module Transcription
# A value change event, with a value and transition.
#
# @author James Tunnell
#
# @!attribute [rw] duration
# @return [Numeric] The duration of the event. Must be in the range MIN_OFFSET..MAX_OFFSET
#
# @!attribute [rw] value
# @return [Numeric] The value of the event.
#
class Va... | true |
66a2096231f777c5fcaada2389b8bd0775acd8c8 | Ruby | oguzsoft/Ruby | /arrays/array3.rb | UTF-8 | 134 | 2.875 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: utf-8
kişi ={
ad: "Oğuzkaan",
soyad: "Gündüz",
tel: "(555) 555 55 55",
}
puts kişi.values
| true |
5fc8b990acb0bce4de3ba3981f1359e198b4508e | Ruby | guoyu07/my_colleges | /app/models/city.rb | UTF-8 | 849 | 2.609375 | 3 | [] | no_license | # -*- encoding : utf-8 -*-
# == Schema Information
#
# Table name: cities
#
# id :integer not null, primary key
# province_id :integer not null
# nick_name :string(255)
# real_name :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
cla... | true |
38f3d8935c63d8af27f91df8f2ec3b5d4d88d1f6 | Ruby | jaxdid/learn_to_program | /ch12-new-classes-of-objects/one_billion_seconds.rb | UTF-8 | 237 | 3.03125 | 3 | [] | no_license | birthday = Time.local(1987, 6, 30)
birthday_billion = birthday + 1000000000
# current_time = Time.new
happened = Time.new < birthday_billion ? "will turn" : "turned"
puts "I #{happened} one billion seconds old on: #{birthday_billion}." | true |
b89e1a63c29917e3547dcc493786d91af3949f26 | Ruby | Coursemology/polyglot | /lib/coursemology/polyglot/language.rb | UTF-8 | 3,829 | 2.765625 | 3 | [] | no_license | # frozen_string_literal: true
if defined?(ActiveRecord)
# :nocov:
# TODO: This is for compatibility with the Web application. A future refactoring might be able
# to remove this dependency.
class Coursemology::Polyglot::Language < ActiveRecord::Base; end
# :nocov:
else
class Coursemology::Polyglot::Language... | true |
c0c1894836bd6b516d290aec1ca3f0a651d61f75 | Ruby | moqingxinai/pujara-emnlp17 | /scripts/lib/load.rb | UTF-8 | 6,398 | 3.1875 | 3 | [] | no_license | require_relative 'constants'
require_relative 'math-utils'
module Load
# Ranks are 0 - 1
# Shortcut for Load.energies(path, true, true).
def Load.ranks(path, &block)
return Load.energies(path, true, true, &block)
end
def Load.energies(path, normalize = false, intKeys = true, &block)
if (blo... | true |
363fd6a51b38cb98eb628becbc1fa7be3a3dff62 | Ruby | klorealf/phase-0-tracks | /ruby/list/list.rb | UTF-8 | 554 | 3.859375 | 4 | [] | no_license | class TodoList
attr_accessor :list
def initialize(arr)
@list = arr
end
def get_items
@list
end
def add_item(item)
list << item
list
end
def delete_item(item)
@delete_item=list.delete(item)
#list
end
def get_item(id)
... | true |
97dcbf14f3cf38a40ca1fb95a1cd134a489f8f35 | Ruby | bsdave/ruby-parallel-forkmanager | /examples/use_pfm.rb | UTF-8 | 584 | 2.875 | 3 | [] | no_license | #!/usr/bin/env ruby
require "rubygems"
require "parallel/forkmanager"
max_procs = 5
pfm = Parallel::ForkManager.new(max_procs)
items = (1..10).to_a
pfm.run_on_start do |pid, ident|
print "run on start ::: #{ident} (#{pid})\n"
end
pfm.run_on_finish do |pid, exit_code, ident|
print "run on finish ::: ** PID: #{p... | true |
5206023b14f46a38367e308c6eef381783ee8a33 | Ruby | INTERSAIL/remote_models | /test/dummy/test/models/course_test.rb | UTF-8 | 2,080 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class CourseTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
def course()
course = Course.create(name: 'Test', teacher_id: 1)
Net::HTTP.expects(get: '[{"id":1, "first_name":"PAOLINO", "last_name":"PAPERINO"}]') if ENV['MOCK']
course
end
def cour... | true |
a0bc1ee85f3ac2ed6301c669c4502c807b872203 | Ruby | tomchapin/all_the_badges | /spec/models/concerns/cachable_spec.rb | UTF-8 | 3,714 | 2.84375 | 3 | [] | no_license | require 'spec_helper'
describe Cacheable do
let(:klass) do
klass = Class.new do
include Cacheable
cache_keys(:lorem, :ipsum).each do |method|
define_method(method) { "value for #{method}" }
end
end
stub_const 'CacheableClass', klass
end
let(:instance) { klass.new }
desc... | true |
7f90869c4795b95d97786cedaa486985d9ffa4cc | Ruby | danniBr/Prueba-Clase-16 | /prueba.rb | UTF-8 | 1,786 | 3.5625 | 4 | [] | no_license | lineas = []
File.open('notas.csv', 'r') { |file| lineas = file.readlines.each.map(&:chomp) }
# variables
option = 0
notaminima = 5.0
# 1
def crea_promedio(lineas)
file = File.new('promedio.txt', 'w')
lineas.each do |item|
nombre = item.split(', ')[0]
notas = item.split(', ')[1..5].each.map(&:to_i)
sum... | true |
8eceb485eb99873e07cbfe9936e44db6e2d24d10 | Ruby | eliastre100/Advent-of-Code-2020 | /specs/day 12/day_12_spec.rb | UTF-8 | 5,749 | 3.53125 | 4 | [
"MIT"
] | permissive | require 'rspec'
require_relative '../../day 12/ship'
require_relative '../../day 12/fixed_ship'
RSpec.describe Ship do
let(:subject) { described_class.new(:east) }
describe '#initialize' do
it 'is facing the correct direction' do
expect(subject.direction).to be :east
end
it 'starts at (0, 0)' d... | true |
f3829b6746e747bf126bd89de21836dc73a7ac13 | Ruby | soylent/jschema | /lib/jschema/validator/items.rb | UTF-8 | 2,157 | 2.703125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module JSchema
module Validator
# Determines how child instances validate for arrays
class Items < ValidatorBase
private
self.keywords = %w[items additionalItems]
def validate_args(items, additional_items)
additional_items_valid? additional_items
... | true |
8fae32a9005f1d7d7126497b015f4e304ce2b23f | Ruby | sul-dlss/sul-requests | /app/models/folio/service_point.rb | UTF-8 | 1,320 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
module Folio
# A place where FOLIO items can be serviced (e.g. a pickup location)
class ServicePoint
attr_reader :id, :code, :name, :pickup_location, :is_default_pickup, :is_default_for_campus
# rubocop:disable Metrics/ParameterLists
def initialize(id:, code:, name:, is_d... | true |
851a1df6fc215684bee204cb34f494c0e4969a63 | Ruby | ysk1180/atcoder-rate-notify | /lambda_function.rb | UTF-8 | 1,649 | 2.875 | 3 | [] | no_license | require 'net/http'
require 'json'
require 'aws-record'
require 'slack-notifier'
USER_IDS = ['toyon', 'katoken', 'ysk1180', 'lastgleam', 'yoitengineer', 'morix1500']
class AtcoderRate
include Aws::Record
string_attr :user_id, hash_key: true
integer_attr :rate
end
def fetch_data(user_id)
url = URI.parse("https... | true |
a6bc586aa440d3c7f20792705eefa111017ce5c6 | Ruby | leonimanuel/ruby-music-library-cli-online-web-sp-000 | /lib/genre.rb | UTF-8 | 508 | 3.03125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Genre
extend Concerns::Findable
attr_accessor :name, :songs
@@all = []
def initialize(name)
@name = name
@songs = []
end
def self.create(name)
genre = Genre.new(name)
genre.save
genre
end
def self.all
@@all
end
def self.destroy_all
@@all.clear
end
def save
@@all << self
end
d... | true |
1551ef852d75d300a5f702cc7eb15ee8e0b2ac25 | Ruby | atduskgreg/templarx | /templarx.rb | UTF-8 | 894 | 2.71875 | 3 | [] | no_license | require 'erb'
class Templarx
TEMPLATE_PATH = File.join(File.dirname(__FILE__), '/drum_definition.erb')
attr_accessor :probabilities
attr_accessor :default_probability
attr_accessor :start_channel
def initialize opts={}
opts = {:probability => 0.5,
:definition_path => File.join(File.dirn... | true |
06c8fe0f920a1af048f794246e7e31d186a2fa3a | Ruby | davidbalbert/eventless | /examples/mutex.rb | UTF-8 | 434 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'bundler/setup'
require 'eventless'
require 'eventless/thread'
m = Mutex.new
scratch_pad = []
m.lock
th = Thread.new do
puts "locking"
m.lock
scratch_pad << :after_lock
end
puts "status: #{th.status}"
Thread.pass while th.status and th.status != "sleep"
puts "Should be empty: #{... | true |
2a74d11751b5e97e1be5d43e815bed84c38a4655 | Ruby | ManageIQ/inventory_refresh | /lib/inventory_refresh/save_collection/saver/default.rb | UTF-8 | 2,464 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | require "inventory_refresh/save_collection/saver/base"
module InventoryRefresh::SaveCollection
module Saver
class Default < InventoryRefresh::SaveCollection::Saver::Base
private
# Updates the passed record with hash data and stores primary key value into inventory_object.
#
# @param reco... | true |
26ba2ccc971051f9013c320d9bd795b69ffdbabb | Ruby | dbcls/umakadata_gem | /lib/umakadata/models/resource_uri.rb | UTF-8 | 1,752 | 2.671875 | 3 | [
"MIT"
] | permissive | module Umakadata
class ResourceURI
module NegotiationTypes
TURTLE = 'text/turtle'.freeze
RDFXML = 'application/rdf+xml'.freeze
HTML = 'text/html'.freeze
ANY = '*/*'.freeze
end
class << self
include NegotiationTypes
def activity_type_for(negotiation_type)
case ... | true |
b859ee7e5403e00c1a279959231829d51045efc9 | Ruby | markwang201/wool | /app/models/push_baidu.rb | UTF-8 | 1,300 | 2.78125 | 3 | [] | no_license | require 'net/http'
#urls = ['http://www.jianfanli.top/articles/4', 'http://www.example.com/2.html']
# urls = (1..10).map { |index| "http://www.jianfanli.top/articles/#{index}" }
#
# uri = URI.parse('http://data.zz.baidu.com/urls?site=www.jianfanli.top&token=kOGehuNh96sIxz5P&type=mip')
# req = Net::HTTP::Post.new(uri.... | true |
a2696eb1b3f5de94c344751517ceb6a32219a3f8 | Ruby | akeyhero/the-light-of-errors | /lib/gpio.rb | UTF-8 | 395 | 3.15625 | 3 | [
"MIT"
] | permissive | require 'yaml'
class GPIO
CONFIG = YAML.load_file 'pins.yml'
def initialize(pin_name)
@pin = CONFIG[pin_name.to_s].to_i
`gpio -g mode #{@pin} out`
end
def on!
`gpio -g write #{@pin} 1`
nil
end
def off!
`gpio -g write #{@pin} 0`
nil
end
def read
`gpio -g read #{@pin}`.str... | true |
1d9b9469722f5a23de0ec35ac153762411db5c30 | Ruby | Tai-Chi/Secret_Cloud | /lib/securable.rb | UTF-8 | 959 | 2.5625 | 3 | [] | no_license | require 'base64'
require 'rbnacl/libsodium'
# Encrypt and Decrypt from Database
module Securable
# Generate key for Rake tasks (typically not called at runtime)
def generate_key
key = RbNaCl::Random.random_bytes(RbNaCl::SecretBox.key_bytes)
Base64.strict_encode64 key
end
# Call setup once to pass in c... | true |
7e4f1dad4402840130d10480d353bd2c2f44b7f6 | Ruby | gbuesing/notebooks | /utils/gnuplot_helper.rb | UTF-8 | 953 | 2.953125 | 3 | [] | no_license | require 'gnuplot'
def decision_plot weights, groups
out = Gnuplot::Plot.new do |plot|
groups.each do |data, label|
plot.data << point_group(data, label)
end
plot.data << decision_boundary(weights)
yield plot if block_given?
end
IRuby.display out
end
def cost_plot errors
out = ... | true |
78e27b4ffde8605a950c15fa2988a989f010c508 | Ruby | ruby-machinist/pathfinder | /lib/pathfinder/navigation_system.rb | UTF-8 | 4,626 | 3.546875 | 4 | [
"MIT"
] | permissive | require 'pathfinder/navigation_entities/position'
require 'pathfinder/navigation_entities/direction'
require 'pathfinder/navigation_entities/placement'
module Pathfinder
# Navigation class is responsible for storing and updating robot's position and direction,
# passing movement requests to the mobility system and... | true |
34a2123ecb3ba78d7504c43148139b6a74dc33ca | Ruby | mcdonaldcarolyn/apples-and-holidays-online-web-prework | /lib/holiday.rb | UTF-8 | 2,445 | 3.796875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def second_supply_for_fourth_of_july(holiday_hash)
# given that holiday_hash looks like this:
# {
# :winter => {
# :christmas => ["Lights", "Wreath"],
# :new_years => ["Party Hats"]
# },
# :summer => {
# :fourth_of_july => ["Fireworks", "BBQ"]
# },
# :fall => {
... | true |
8482ab4dfedfe296a50f40598042d7948451978f | Ruby | chasestubblefield/built-with-clone | /lib/url_analyzer.rb | UTF-8 | 924 | 2.734375 | 3 | [] | no_license | require 'faraday'
require 'nokogiri'
class UrlAnalyzer
def initialize(url)
@url = url
end
def body
@body ||= response.body.force_encoding('utf-8')
end
def is_html?
response.headers['content-type'].starts_with?('text/html')
end
def contains_text?(text)
body.include?(text)
end
def i... | true |
ee07f3aa542a5cf088f9ab6cc80d7ebd7e23f9da | Ruby | mbornoz/veewee | /lib/fission/vm.rb | UTF-8 | 11,098 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'fission/leasesfile'
require 'shellwords'
require 'fission/error'
module Fission
class VM
attr_reader :name
def initialize(name)
@name = name
end
#####################################################
# Path Helpers
#####################################################
# Re... | true |
95ca0363d1a29dc298689aa81686a54e234a9e63 | Ruby | BookingSync/chaos-rb | /lib/chaos/instability/i_o_wait.rb | UTF-8 | 268 | 2.625 | 3 | [
"MIT"
] | permissive | class Chaos::Instability::IOWait
attr_reader :sleep_provider
private :sleep_provider
def initialize(sleep_provider: Kernel)
@sleep_provider = sleep_provider
end
def call(duration_in_seconds:)
sleep_provider.sleep(duration_in_seconds)
end
end
| true |
05f8d9f167d9d3674ee997e8cba45e1241527cad | Ruby | Incanus3/sudoku-2d-ui | /lib/sudoku/ui/main_window/layout.rb | UTF-8 | 1,466 | 2.703125 | 3 | [] | no_license | module Sudoku
module UI
class MainWindow
class Layout
attr_reader :board_size, :font_size
attr_reader :text_spacer, :button_spacer
attr_reader :texts_height, :buttons_height
attr_reader :info_text_y_offset, :state_text_y_offset, :event_text_y_offset
attr_reader :board... | true |
eeb6f1e5adc875b1a105b66d3be4d8b59f50b576 | Ruby | helenyueyu/W2D5 | /myhashmap/lib/p02_hashing.rb | UTF-8 | 714 | 3.484375 | 3 | [] | no_license | class Integer
# Integer#hash already implemented for you
end
class Array
def hash
self.each_with_index.map{|x,idx| [x, idx]}.map{|x| x[0]*x[1]}.sum.hash
end
end
class String
def hash
self.chars.each_with_index.map{|x, idx| [x, idx]}.map{|x| x[0].ord*x[1]}.sum.hash
end
end
class Hash
# This retu... | true |
3be45ea9f4c26b5e8bb8c2855ba185f4fbaa6325 | Ruby | ta1kt0me/AOJ | /0011/0011.rb | UTF-8 | 375 | 2.796875 | 3 | [] | no_license | line_count = STDIN.gets.chomp.to_i
points = Array.new(STDIN.gets.chomp.to_i) { STDIN.gets.split(',').map { |i| i.chomp.to_i } }
puts (1..line_count).map { |i|
position = i
points.each do |point|
case position
when point[0]
position = point[1]
when point[1]
position = point[0]
end
end
... | true |
a42368c6bcd220a3f09ea9445159d64db6d4889f | Ruby | DaniyarKulmanov/GameBlackJack | /player.rb | UTF-8 | 698 | 3.40625 | 3 | [] | no_license | class Player
attr_reader :name
attr_accessor :money, :cards, :points
def initialize(name)
@name = name
@money = 100
@cards = []
@points = 0
end
def add_card(card_info)
@cards << card_info
add_points card_info[:points], card_info[:alter_points]
end
def add_points(points, alter_po... | true |
f18975eeaacd16d2ee6b64e914386775764b5576 | Ruby | BlackPhoenixPandora/Machine | /lib/akiva/core_brain/actions/template.rb | UTF-8 | 1,041 | 2.84375 | 3 | [
"MIT"
] | permissive | # Akiva::Brain.update do
#
# add_action :name_of_action do |response|
# # 'response' is the same hash passed to all before_actions and to the action itself
# # The following keys are set from the start:
# response[:filter_matched] => {regex: /[original regex capturing the following (?<stuff_captured>.+)/,... | true |
4b364f1183f7ed37fb4f42219f913cc56012bb79 | Ruby | sidvoretskiy/Home_Tasks | /06/railroadcar.rb | UTF-8 | 437 | 2.890625 | 3 | [] | no_license | class RailroadCar
attr_accessor :number
attr_reader :occupied
def initialize(max_value)
@max_value = max_value
@occupied = 0
end
def load(value)
if (@occupied + value) <= @max_value
@occupied += value
else false
end
end
def unload(value)
if (@occupied - value) >= 0
@occ... | true |
0175248313479fa3c8f1a69179f36120e9ac08f3 | Ruby | shun-mat/blog | /function-output/test.rb | UTF-8 | 1,907 | 3.828125 | 4 | [] | no_license | class School
attr_accessor :name,
:address,
:number_of_students,
:founding_years,
:introduction_video_url,
:introduction_statement
def initialize(name, address, number_of_students,founding_years,
introduction_... | true |
f080ef96aa78763e73965daf022a71c60cccd08e | Ruby | alexdovzhanyn/SevenDeadlySinsRevamp | /lib/game/gui/button.rb | UTF-8 | 678 | 2.796875 | 3 | [] | no_license | class Button
def initialize(x, y, z, w, h, text, onclick = ->(){})
@x, @y, @z, @w, @h, @text, @onclick = x, y, z, w, h, text, onclick
end
def draw
Gosu.draw_rect(@x - 4, @y + 5, @w + 8, @h, 0x552a2735, @z + 1)
Gosu.draw_rect(@x, @y, @w, @h, 0xff2a2735, @z + 2)
Gosu.draw_rect(@x + 4, @y + 4, @w -... | true |
93cb38cf5b1f678320858fd705f4d56933f1636a | Ruby | RyanPKirlin/Spnsrco | /app/models/user.rb | UTF-8 | 1,467 | 2.640625 | 3 | [] | no_license | class User < ActiveRecord::Base
attr_accessible :email, :password, :password_confirmation
attr_accessor :password
before_save :encrypt_password
validates_confirmation_of :password, :on => :create
validates_presence_of :email
validates_uniqueness_of :email
# validates_blank_of is something that's built i... | true |
574fcf488aa38f732172e63b37d173a89cd074ae | Ruby | timrobinson88/lifesimulator | /spec/services/reproduction_cycle_spec.rb | UTF-8 | 1,325 | 2.8125 | 3 | [] | no_license | require "spec_helper"
describe ReproductionCycle do
before do
Cell.create!(satiety: 10, propensity_to_move: 100, propensity_to_reproduce: 100, x: 1, y:0, has_mated: false, has_moved: false)
Cell.create!(satiety: 10, propensity_to_move: 100, propensity_to_reproduce: 100, x: 0, y:0, has_mated: false, has_mov... | true |
500486957c51a759ee1b073b2e6bcb2b46ad29d1 | Ruby | joshyokela/gittest | /student.rb | UTF-8 | 55 | 2.59375 | 3 | [] | no_license | # student.rb
class Student
puts 'i am a student'
end
| true |
ed41f5ec6bc900b1cf78bbae0c27ec01b61469da | Ruby | kevconfar/guided-module-one-final-project-houston-web-100818 | /lib/scraper.rb | UTF-8 | 3,719 | 3.359375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'nokogiri'
require 'open-uri'
require 'byebug'
require_relative '../config/environment'
def hrefs
html = open("https://www.hauntedrooms.com/haunted-places")
doc = Nokogiri::HTML(html)
return doc.css('div.entry-content li a').map { |link| link['href'] }
end
def href_arr # creates an array of urls... | true |
d680d45103e0e19a89580be6c35bd9c3df70f166 | Ruby | alexcutschall/black_thursday | /lib/invoice.rb | UTF-8 | 990 | 2.96875 | 3 | [] | no_license | class Invoice
attr_reader :id,
:customer_id,
:merchant_id,
:status,
:created_at,
:updated_at,
:parent
def initialize(data, parent = nil)
@id = data[:id].to_i
@customer_id = data[:customer_id].to_i
@merchant_id... | true |
5f43d51ab209ca2f3bcc8a6dd6c203825544aad4 | Ruby | pentsko/training | /2/cart.rb | UTF-8 | 336 | 3.203125 | 3 | [] | no_license | class Cart
attr_reader :items
def initialize
@items = []
end
def add_item(item)
@items.push item
end
def remove_item
@items.pop
end
def validate
@items.each do |i|
puts 'Item has no price' if i.price.nil?
end
end
def delete_invalid_items
@items.delete_if { |i| i.price.n... | true |
f205228222ea7376485e516d40223ed2d9780073 | Ruby | denzyl/tealeaf | /LearntoProgram/Chapter9/chapter9.rb | UTF-8 | 981 | 3.921875 | 4 | [] | no_license | # def say_moo number_of_moos
# puts "mooooo..."*number_of_moos
# 'yellow submarine'
# end
# def double_this num
# num_times_2 = num*2
# puts num.to_s+' doubled is '+num_times_2.to_s
# end
# double_this 44
# x = say_moo 3
# puts x.capitalize + ', dude...'
# puts x
def ask question
while true
puts question
r... | true |
e6dcb0e288ed8f4691265731f89227234c5288aa | Ruby | twillw/craigslist | /app/models/city.rb | UTF-8 | 346 | 2.59375 | 3 | [] | no_license | class City < ActiveRecord::Base
has_many :posts
def self.allowed_types
[
'Toronto', 'Ottawa', 'Montreal', 'Winnipeg', 'Regina', 'Edmonton', 'Calgary', 'Victoria', 'Vancouver',
'Quebec City', 'Kingston', 'Kitchener-Waterloo', 'Halifax'
]
end
validates :name, presence: true, inclusion: { :in =>... | true |
b9228e88b7a9e091c138f0de5c1242017a7e28a1 | Ruby | EverestMons/ruby | /ruby_projects/blocks.rb | UTF-8 | 457 | 4.25 | 4 | [] | no_license | # def test
# puts "you are in the test block"
# yield
# puts "you are again, in the test block"
# yield
# end
#
# test {puts "Hi"}
# def another_one
# yield 8
# puts "What a number"
# yield 19
# puts "Katherine's age "
# end
#
# another_one {|i| puts "Here's the number #{i}"}
def divider num
puts "T... | true |
7598e009d95244eb7b48f9011fcddf15ccfd6b4e | Ruby | samwize/fastlane | /fastlane_core/lib/fastlane_core/itunes_transporter.rb | UTF-8 | 8,337 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'pty'
require 'shellwords'
require 'credentials_manager/account_manager'
module FastlaneCore
# The TransporterInputError occurs when you passed wrong inputs to the {Deliver::ItunesTransporter}
class TransporterInputError < StandardError
end
# The TransporterTransferError occurs when some error happens
... | true |
4e3ae85d98a019a1383c4c858e3cda48c8c976e8 | Ruby | dkelly205/animal_shelter_project1 | /specs/customer_specs.rb | UTF-8 | 776 | 2.796875 | 3 | [] | no_license | require 'minitest/autorun'
require_relative '../models/customer.rb'
class TestCustomer < Minitest::Test
def setup
@customer = Customer.new({
'first_name' => 'John',
'last_name' => 'Smith',
'address' => '10 Smith Road, Glasgow, G66 1PP',
'phone_number' => '01411111111'
})
end
d... | true |
9e365cf7887309e725288f62dfe08d09282518b6 | Ruby | mattbradley/mattlang | /lib/mattlang/location.rb | UTF-8 | 362 | 2.875 | 3 | [] | no_license | module Mattlang
# A code location in some source file.
# A nil filename probably means the source came from the REPL.
class Location
attr_accessor :source, :filename, :line, :col
def initialize(source: nil, filename: nil, line: nil, col: nil)
@filename = filename
@line = line
@source = ... | true |
24de3e008382104930fc6011c488d8bae81278c0 | Ruby | evmorov/xml-test | /spec/sax-machine_spec.rb | UTF-8 | 3,588 | 2.75 | 3 | [] | no_license | require 'spec_helper'
require 'sax-machine'
require 'nokogiri'
module SamMachineMapping
class StudentContacts
include SAXMachine
element :phone
end
class Student
include SAXMachine
element :id
element :name
element :sex
element :schoolId, as: :school_id
element :contacts, class: ... | true |
54050f454bb7f0354a5c2bc6fc933e535e2455c1 | Ruby | apopheny/RB100 | /pine06_new_numerals_4-9.rb | UTF-8 | 2,299 | 4.625 | 5 | [] | no_license | puts ">> Give me a number to convert to old Roman numerals:"
arabic_numeral = gets.to_i
puts ">> Your Roman numeral is:"
ix = false
iv = false
def thousands(number)
m = number / 1000
if number % 1000 > 0
m_modulus = number % 1000
else
m_modulus = 0
end
m.times { |m| print "M"}
five_hundreds(m_... | true |
d44d13e4760d2e6c3c4c8e317ab28490dfc60ea7 | Ruby | jaredsanchez/Project_Steak | /app/models/person.rb | UTF-8 | 4,681 | 2.671875 | 3 | [] | no_license | class Person < ActiveRecord::Base
extend ApplicationHelper
has_and_belongs_to_many :events
attr_accessible :name, :first_name, :last_name, :progress, :active, :favorite, :email,
:linkedin_connection, :phone_number, :cal_net_dept_name, :hr_dept_name, :job_title, :room_number, :building
def self.s... | true |
facb256024788b3acca3b3939b94eb10cab63f6b | Ruby | capjuancode/captain_america | /ending.rb | UTF-8 | 1,941 | 3.28125 | 3 | [] | no_license | require './actions'
module Ending
include Actions
# This runs from Riddle
def win_ending
puts "Mr.H: you thinking that i am going to let you go that easy"
puts "Captain America see the opportunity attacks Mrs H and leaves him unconscious."
puts "Captain America He destroyed the base\n\n"
sleep (4)... | true |
a02834cbc61096c5ee7a50568cab1820e05e8c6b | Ruby | freegit9527/practice-code | /language/ruby/chapter1to8/dogs.rb | UTF-8 | 213 | 3.25 | 3 | [] | no_license | #!/usr/bin/ruby
class Dog
attr_reader :bark
attr_writer :bark
end
dog = Dog.new
dog.bark = "Woof!"
puts dog.bark
puts dog.instance_variables.sort
p Dog.instance_methods.sort - Object.instance_methods
| true |
affb30a007399880b7921f26f98dda6fd7136dd1 | Ruby | sureshrmdec/app_academy | /W2/D2_NickArora/Chess/chess.rb | UTF-8 | 1,191 | 3.921875 | 4 | [] | no_license | require_relative 'board'
class Chess
def initialize
@board = Board.new
@current_player = 'White'
end
def run
until game_over?
# render board
# prompt current_player for input
# move_player
# swap current_player
@board.render
end
puts "White has won!" if @boar... | true |
387b91d044ec0a2ae9887c47f60369b3430a30e8 | Ruby | chicobentojr/programacao-de-computadores | /listas/01-programas-sequenciais/questao-20.rb | UTF-8 | 556 | 2.75 | 3 | [] | no_license | dist = gets.to_i
o1_vel = gets.to_i
o2_vel = gets.to_i
op_tempo = gets.to_f
litro_preco = gets.to_f
custo_parado = gets.to_f
consumo = 10
tempo_viagem = (dist / (o1_vel + o2_vel * 1.0))
ponto_final = o1_vel * tempo_viagem
tempo_total = (tempo_viagem * 2 + op_tempo)
o1_litro = (ponto_final * 2 / consumo)
o2_litro = ((d... | true |
2c0f670a5307c0365d2d7d9f337878ce1849e985 | Ruby | boringbread/PlayWithRuby | /Section 2/simple_calculator.rb | UTF-8 | 435 | 4.0625 | 4 | [] | no_license | 30.times{print "-"}
puts
puts "HERE IS SIMPLE CALCULATOR"
30.times{print "-"}
puts
puts "Enter your first number"
num_1 = gets.chomp
puts "Enter your second number"
num_2 = gets.chomp
puts "The first number multiplied by second number is #{num_1.to_i * num_2.to_i}"
puts "The first number addition by second nu... | true |
1de67dd3ca204e84c8c3055773f2885fb99f9bad | Ruby | adambeynon/opal | /spec/opal/core/language/fixtures/send.rb | UTF-8 | 2,066 | 2.765625 | 3 | [
"MIT"
] | permissive | module LangSendSpecs
# module_function
def self.fooM0; 100 end
def self.fooM1(a); [a]; end
def self.fooM2(a,b); [a,b]; end
def self.fooM3(a,b,c); [a,b,c]; end
def self.fooM4(a,b,c,d); [a,b,c,d]; end
def self.fooM5(a,b,c,d,e); [a,b,c,d,e]; end
def self.fooM0O1(a=1); [a]; end
def self.fooM1O1(a,b=1); [... | true |
cbf1e774115cfccd69742e60a7cdcdf693df0789 | Ruby | yujinakayama/japan_etc | /lib/japan_etc/database_provider/nagoya_expressway.rb | UTF-8 | 2,042 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'japan_etc/database_provider/base'
require 'japan_etc/tollbooth'
require 'faraday'
require 'nokogiri'
module JapanETC
module DatabaseProvider
# http://www.nagoya-expressway.or.jp/etc/etc-lane.html
class NagoyaExpressway < Base
def source_url
'https://www.n... | true |
fd2f902793fd1c4cb5153d6d940d57947c6a8652 | Ruby | BrennonTWilliams/the_digest | /app/models/user.rb | UTF-8 | 757 | 2.578125 | 3 | [] | no_license | class User < ActiveRecord::Base
has_and_belongs_to_many :articles
# Validations
validates_presence_of :email, :first_name, :last_name, :username
validates :email, format: { with: /(.+)@(.+).[a-z]{2,4}/, message: "%{value} is not a valid email" }
validates :username, length: { minimum: 3 }
validates :pass... | true |
ecce3f4b2c7f7dd556e6fc45c8823fe5cd3c0ed7 | Ruby | loushark/bank_tech_test | /lib/bank_account.rb | UTF-8 | 762 | 3.34375 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'statement'
require 'date'
#:nodoc:
class BankAccount
attr_reader :name
def initialize(name, statement = Statement.new)
@name = name
@statement = statement
end
def deposit(amount)
save_deposit_to_statement(amount)
end
def withdraw(amount)
s... | true |
bd488bc6281d5e891cde028f1819d9a34b54634c | Ruby | vittalgit/lynda-ruby-course | /kata/classes_classy_extensions.rb | UTF-8 | 327 | 3.53125 | 4 | [
"MIT"
] | permissive | class Cat < Animal
def initiatilize(name)
@name = name
end
def speak
@name + " meows."
end
end
# RSpec.describe "Cat" do
# it "" do
# kitty = Cat.new(some_parameter)
# expect(kitty.name_of_method(some_parameter)).to eq (some_parameter) #method guess being called on instance guesser
# end... | true |
a851070d50c0edb510f6045edd45d64d3e660688 | Ruby | bilbof/feed | /lib/feed.rb | UTF-8 | 1,649 | 2.984375 | 3 | [] | no_license | require 'concurrent'
require 'feedjira'
require 'httparty'
require 'loofah'
require "./lib/cache"
class Feed
def self.me(feed, from_cache: true)
Concurrent::Promises.future(feed[:url], feed[:expiry], from_cache) do |url, expiry, from_cache|
self.fetch_from_url(url, expiry, from_cache)
rescue => e
... | true |
adf0d15b4f96bdacb4d90e5b94df7a7fbeb61ab1 | Ruby | pitosalas/coursegen | /lib/coursegen/course/helpers/table_helpers.rb | UTF-8 | 591 | 2.8125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Class TableHelper provides methods for creating a table.
class TableHelper
def initialize(css_styles)
@css_styles = css_styles
@bm = BootstrapMarkup.new
end
def headers(*labels)
@bm.table_begin(@css_styles)
@bm.headers_begin
labels.each do |h|
@bm.header_begin
@bm.header_content... | true |
3dd3b2d2c3a7ccdf345492fe1fce456d972fe76f | Ruby | bklynate/Tealeaf_pre_course_work_rb | /case_statement.rb | UTF-8 | 138 | 3.65625 | 4 | [] | no_license | # case_statement.rb
a = 9
case a
when 5
puts "a is 5"
when 6
puts "a is 6"
else
puts "I am not sure wtf 'a' is...."
end | true |
6ebb6faaee209a4dcdcfa61a45b2b43b49a334f8 | Ruby | miloscomplex/regex-lab-onl01-seng-pt-061520 | /lib/regex_lab.rb | UTF-8 | 673 | 3.171875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def starts_with_a_vowel?(word)
word.match? /\b[aeiou]/i
end
def words_starting_with_un_and_ending_with_ing(text)
text.scan(/\b[u][n][a-z]*[i][n][g]/)
end
def words_five_letters_long(text)
text.scan(/\b[A-Za-z]{5}\b/)
end
def first_word_capitalized_and_ends_with_punctuation?(text)
# text.match? /[A-Z][\sA-Za-... | true |
757e89ab8539c3103b77e2a14f0dc7bc82299075 | Ruby | tleewu/chess | /empty_piece.rb | UTF-8 | 135 | 2.515625 | 3 | [] | no_license | class EmptyPiece < Piece
def initialize(board, position, color = :no_color)
super(board, position, " ", :no_color)
end
end
| true |
0f895b101a9f5602948c3d1dc91e0243281f9688 | Ruby | CodeCoreYVR/feb-2016-fundamentals | /day_2_ruby/methods/divide.rb | UTF-8 | 183 | 3.234375 | 3 | [] | no_license | # example of a 'guard clause' (return earlier from a method to 'guard' against certain known problems)
def divide(a,b)
return "Can't divide by 0" if b == 0
a/b
end
p divide(6,0)
| true |
251a1c2840198c61efd226d40fe0c506206d655a | Ruby | karino-minako/paiza-c-rank-level-up-menu | /for-loop-4.rb | UTF-8 | 482 | 3.578125 | 4 | [] | no_license | # 各 c_i (1 ≤ i ≤ m) について、各 S_j (1 ≤ j ≤ n) に c_i が出現するかをそれぞれ調べ、
# 出現する場合は "YES" を、そうでない場合には "NO" を、そのつど出力してください。
m = gets.to_i
c = m.times.map{gets.chomp}
n = gets.to_i
s = n.times.map{gets.chomp}
for i in 1..m do
for e in 1..n do
confirm = s[e-1].include?(c[i-1])
if confirm == true
puts "YES"
el... | true |
6c9cd6a58570dc97122adad4ad013d3325f8051c | Ruby | emsk/bundle_outdated_formatter | /lib/bundle_outdated_formatter/formatter/terminal_formatter.rb | UTF-8 | 487 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'tty-table'
require 'bundle_outdated_formatter/formatter'
module BundleOutdatedFormatter
# Formatter for Terminal
class TerminalFormatter < Formatter
def convert
table.render(@style.to_sym, padding: [0, 1]).chomp
end
private
def table
return TTY::Table.new([@columns]) if @outd... | true |
b60b6c235d4e351d83afe68d0fdfa6c3d9e812f2 | Ruby | abukhajilnour/home | /app/models/idea.rb | UTF-8 | 1,088 | 2.515625 | 3 | [] | no_license | class Idea < ActiveRecord::Base
belongs_to :user
has_many :comments, dependent: :destroy
has_one :idea_detail
has_many :likes, dependent: :destroy
has_many :liked_users, through: :likes, source: :user
has_many :joins,dependent: :destroy
has_many :joined_users, through: :joins, source: :user
#validates... | true |
33d5241596caf0b5b38f9148928872cef7ff8c94 | Ruby | learn-co-students/nyc-web-082420 | /04-oo-associations/app/models/animal.rb | UTF-8 | 1,128 | 3.640625 | 4 | [] | no_license | class Animal
attr_accessor :name, :noise, :owner, :intelligence
attr_reader :species
@@all = []
def initialize(species, name, noise, owner=nil) # =nil as default arg so we're ok without an owner
@species = species
@name = name
@noise = noise
@intelligence = 5
@o... | true |
583a79ec055fa0a3b966b633966fcf1daea58c8a | Ruby | CrystalToh/LearnRubyTheHardWay | /ex24.rb | UTF-8 | 1,204 | 4.1875 | 4 | [] | no_license | # Print a sentence
puts "Let's practice everything."
# Escape sequences
puts "You\'d need to know \'bout escapes with \\ that do \n newline and \t tabs."
# Paragraph
poem = <<MULTI_LINE_STRING
\t The lovely world
with logic so firmly planted
cannot discern \n the needs of love
not comprehend passion from intuition
an... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.