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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e25f7511b2189c44693492fea9fded1f32a94e99 | Ruby | luismottacampos/flyertalk_mileagerun_forum_parse | /mileage_run_forum_parse.rb | UTF-8 | 841 | 3.03125 | 3 | [] | no_license | #!/usr/bin/env ruby
#Needed to get the html page with the forum topics
require 'rubygems'
require 'nokogiri'
require 'open-uri'
#URL for the forum
flyertalk_url = 'http://www.flyertalk.com/forum/mileage-run-deals-372/'
#Array of airline two letter codes to match against
airlines = ["DL" , "AS" , "KL" , "AF"]
#Array... | true |
b988369dcbd638d6549edb0476e047d3043edb6c | Ruby | Naser2/module-one-final-project-guidelines-dumbo-web-091718 | /db/seeds.rb | UTF-8 | 2,618 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
# t.string :name
# t.string :kind
# t.string :temperament
# t.integer :age
# birds
coocoo = Pet.create({name: "Coocoo", kind: "bird", temperament: "friendly", age: 22})
charlie = Pet.create({name: "Charlie", kind: "bird", temperament: "friendly", age: 4})
moe = Pet.create({name: "Moe", kind: "bird", temperament: "... | true |
06f42ebe04d87eb2661a67d6be7563882fe0f1c5 | Ruby | jmax315/ratcatcher | /spike/pipes_and_io.rb | UTF-8 | 651 | 2.609375 | 3 | [] | no_license | rd, wr = IO.pipe
krd, kwr = IO.pipe
if !fork
rd.close
kwr.close
puts "Kid(1) got #{krd.readline}"
puts "Kid(1) got #{krd.readline}"
puts "Sending message to parent"
wr.puts "1"
wr.puts "Hi Mom"
puts "Kid(2) got #{krd.readline}"
puts "Kid(2) got #{krd.readline}"
wr.puts "1"
wr.puts "Hi Dad"
... | true |
a8a4954a45b2ad599df4f1c928686b344a67990b | Ruby | KenyiCode/learn_ruby | /06_timer/timer.rb | UTF-8 | 1,023 | 3.75 | 4 | [] | no_license | class Timer
#write your code here
attr_accessor :Seconds, :Minutes, :Hours
def initialize
@Seconds = 0
@Minutes = 0
@Hours = 0
end
def seconds
@Seconds
end
def seconds= (secs)
@Seconds = secs
end
def time_string
hrs = 0
mins = 0
secs = @Seconds.to_i
if (secs > 6... | true |
ca6242e67d0b22d0879540f96c0e56e7f16d307e | Ruby | fig/scheduleless | /app/presenters/dashboard/whose_working_presenter.rb | UTF-8 | 1,488 | 2.515625 | 3 | [] | no_license | module Dashboard
class WhoseWorkingPresenter
attr_reader :locations
def initialize(locations, manage=false)
@locations = locations
@manage = manage
end
def closing_time_for(location)
location_hours_for(location).closing
end
def location_partial_for(location)
if locat... | true |
baadaceb39b3d964102e5f058f2f440176616fb3 | Ruby | Dthurow/adventofcode2020 | /day5_pt2.rb | UTF-8 | 2,723 | 3.96875 | 4 | [] | no_license | #!/usr/bin/env ruby
#puzzle: input is a series of "boarding passes". each boarding pass is a series of
#F's and B's followed by L's and R's
#The first 7 characters will either be F or B;
#these specify exactly one of the 128 rows on the plane (numbered 0 through 127).
#Each letter tells you which half of a region the... | true |
d1984a57d7c9d5d31f346589e82b5dd23480571a | Ruby | sirech/yai | /lib/yai/lucky_one.rb | UTF-8 | 2,056 | 2.96875 | 3 | [
"MIT"
] | permissive | module Yai
class LuckyOne
attr_reader :client, :team, :excluded, :location
def initialize(client, team:, excluded:, location:)
@client = client
@team = team
@excluded = Array(excluded)
@location = location
end
def choose
members, assignees, reporters = prepare_lists
... | true |
8a1ed6b35788a34c72768cc70d4df3d97d0b67a7 | Ruby | fdsea33/praesens | /vendor/plugins/simple_localization/lib/lang_section_proxy.rb | UTF-8 | 4,051 | 3.203125 | 3 | [
"MIT"
] | permissive | module ArkanisDevelopment #:nodoc:
module SimpleLocalization #:nodoc:
# This little thing is a big part of the magic of doing things behind Rails
# back. Basically it mimics an variable (ie. number, array, hash, ...) by
# redirecting all calls to another variable of that kind. The target object
#... | true |
50218175535da0f6e5e031be2c678f155c67eb6e | Ruby | logicminds/cots | /lib/puppet/functions/cots/resolve.rb | UTF-8 | 1,516 | 2.546875 | 3 | [] | no_license | # extremely helpful documentation
# https://github.com/puppetlabs/puppet-specifications/blob/master/language/func-api.md#the-4x-api
Puppet::Functions.create_function(:'cots::resolve') do
# the function below is called by puppet and and must match
# the name of the puppet function above. You can set your
# require... | true |
a961eac5dbb1f770a45c9764b238b2247f083cf1 | Ruby | AlmazKo/Php-manual-parser | /lib/php_manual_parser/dbl/entity.rb | UTF-8 | 931 | 2.71875 | 3 | [
"BSD-3-Clause"
] | permissive | module PhpManualParser
class Entity
@@args = {}
def self.attr_accessor(*args)
super *args
args.each { |var|
var = ('@' + var.to_s).to_sym
if @@args[self]
@@args[self] << var
else
@@args[self] = [var]
end
}
nil
end
def pk_v... | true |
8bc5aec6da5c90615604ee5e8e90dccc5e57228e | Ruby | JaDogg/__py_playground | /reference/examples-v3/csharp/ruby/t3.rb | UTF-8 | 81 | 2.609375 | 3 | [
"MIT"
] | permissive | class A
def method
return 1
end
end
class B
def method
return A.new
end
end
| true |
20922fcad37eabb05f9d51f0cf51f41ccbdb4869 | Ruby | Cartermatic/badges-and-schedules-onl01-seng-ft-070620 | /conference_badges.rb | UTF-8 | 605 | 3.625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | names = ["Edsger", "Ada", "Charles", "Alan", "Grace", "Linus", "Matz"]
def badge_maker(name)
"Hello, my name is #{name}."
end
def batch_badge_creator(names)
badge_list = []
names.each do |name|
badge_list << "Hello, my name is #{name}."
end
return badge_list
end
def assign_rooms(attendees)
results = ... | true |
2dfba51c4e8615231b127bd07f42e0f7e905e3e5 | Ruby | ForwardFinancing/ach_client | /lib/ach_client/providers/soap/i_check_gateway/ach_transaction.rb | UTF-8 | 4,051 | 2.625 | 3 | [
"BSD-3-Clause"
] | permissive | module AchClient
class ICheckGateway
# ICheckGateway implementation for AchTransaction
class AchTransaction < Abstract::AchTransaction
# When ICheck API gives us an error response containing a correction, the response field looks like this:
# DECLINED - Notice of Change (XXX - Change Data: YYYY... | true |
fca44143036ce58db7371148dfde8491ebaa8066 | Ruby | 512dev/food-delivery-sinatra | /ruby_files/app/controllers/sessions_controller.rb | UTF-8 | 497 | 2.6875 | 3 | [] | no_license | require_relative '../repositories/employee_repository.rb'
require_relative '../views/session_view.rb'
class SessionsController
def initialize(repo)
@employees = repo
@view = SessionView.new
end
def sign_in
username = @view.get(:username)
password = @view.get(:password)
user = @employees.fin... | true |
a9e84372037aa929c7a66c7253c54f2b2079b141 | Ruby | blm768/stat-monitor | /lib/statmonitor/eot_socket_wrapper.rb | UTF-8 | 1,690 | 3.328125 | 3 | [
"MIT"
] | permissive | module StatMonitor
#Wraps a socket so messages are separated by EOT characters
class EOTSocketWrapper
attr_reader :socket
#Creates a new EOTSocketWrapper around a socket
def initialize(socket)
@socket = socket
@buf = ''
end
#Reads from the socket until an EOT is found
#
#Ex... | true |
e89ee6b058097b845e88f58a1a400b78ac851d4f | Ruby | buren/wayback_archiver | /bin/wayback_archiver | UTF-8 | 2,151 | 2.71875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'optparse'
require 'wayback_archiver'
# Default values
urls = nil
strategy = 'auto'
log = STDOUT
log_level = Logger::INFO
concurrency = WaybackArchiver.concurrency
limit = WaybackArchiver.max_limit
hosts = []
optparse = OptionParser.new do |parser|
parser.banner = 'Usage: wayback_archiv... | true |
f1b6cec3c4fe64582125b7dee6cfa6d837513001 | Ruby | Eldwick/LoLoL | /db/seeds.rb | UTF-8 | 1,507,332 | 2.84375 | 3 | [] | no_license | # LISTS
List.destroy_all
# all lists array contains titles of all seed lists - add title here
all_lists = [
"10 Largest Countries",
"10 Winningest F1 Drivers (all time)",
"All Solar System Planets",
"5 Richest Actors"
]
all_lists.each do |i|
List.create( title: i )
end
# LIST ENTRIES
Entry.destroy_all
# Dumm... | true |
959559076dd441c6c46315b034bd5ef165dd897f | Ruby | adrrian17/verat | /lib/verat/feature.rb | UTF-8 | 984 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'git'
module Verat
class Feature
def self.start(feature)
puts "Creating branch: feature/#{feature}"
repo = Git.open(Dir.pwd)
repo.branch("feature/#{feature}").checkout
puts "Branch created succesfuly. Current branch: feature/#{feature}"
end
def self.finish(feature, opti... | true |
8c8d7f8978fba058f855903e1d9df129b19abf12 | Ruby | care0hlyn/allergies-ruby | /lib/allergies.rb | UTF-8 | 373 | 3.34375 | 3 | [] | no_license | def allergies(number)
new_array = []
number = number
food = {128 => 'cats', 64 => 'pollen', 32 => 'chocolate', 16 =>'tomatoes',
8 => 'strawberries', 4 =>'shellfish', 2 => 'peanuts', 1 => "eggs"}
food.each do |score, allergy|
if (number >= score)
number -= score
new_array << allergy
... | true |
29f299213dfa7636b11e104af5c782893bbc4bd6 | Ruby | HarlemSquirrel/ruby-music-library-cli-v-000 | /lib/song.rb | UTF-8 | 1,295 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song
attr_accessor :name, :artist, :genre
@@all = []
def initialize(name, artist = "", genre = "")
@name = name
artist.add_song(self) unless artist == ""
genre.add_song(self) unless genre == ""
self
end
def self.create(name)
song = self.new(name)
song.save
song
end
de... | true |
44437ae9f032eaf34e03e3647194cb40e3029278 | Ruby | bytheway/chefspec | /lib/chefspec/extensions/chef/lwrp_base.rb | UTF-8 | 2,313 | 2.65625 | 3 | [
"MIT"
] | permissive | # Override Chef LWRP creation to remove existing class to avoid redefinition warnings.
class Chef
module RemoveExistingLWRP
def self.extended(klass)
class << klass
alias_method :build_from_file_without_removal, :build_from_file
alias_method :build_from_file, :build_from_file_with_removal
... | true |
2a9505cfab53ee70dcfd3c0f1fcdb39d452a66d8 | Ruby | alexdorner/TeamRuby | /RubyMGIN/Test.rb | UTF-8 | 351 | 2.875 | 3 | [] | no_license | require "test/unit"
require_relative './Functions'
class TestProzent < Test::Unit::TestCase
def testfunc
assert_equal(0.0, Functions.new().prozent(1.0, 1.0))
assert_equal(50.0, Functions.new().prozent(2.0 ,1.0))
assert_equal(-100.0, Functions.new().prozent(1.0 ,2.0))
assert_equal(100.0, Functions.new... | true |
75e8a4d1100036884a4059a6108d5fd5b1d2ff0a | Ruby | derek2041/cs408-back | /gleam/app/models/user.rb | UTF-8 | 760 | 2.828125 | 3 | [] | no_license | require 'bcrypt'
class User < ApplicationRecord
has_many :bookmarks, dependent: :destroy
has_many :comments, dependent: :destroy
has_many :posts, dependent: :destroy
def self.is_validated(credentials)
# Return false if username or password fields are invalid
if credentials["username"] == nil || credentials... | true |
0bdb34edca2f854138a9368c9765062df7621c8b | Ruby | andyprickett/launch-school | /exercises/100-ruby-basics/05-loops-2/08_only_even.rb | UTF-8 | 187 | 3.53125 | 4 | [] | no_license | number = 0
until number == 10
number += 1
# check if number is odd. if so, skip to next iteration
next if number.odd?
# if we didn't skip to next, print number
puts number
end
| true |
e39ec8a5b0a0f4bd62356d36cbe623137c71bc67 | Ruby | rockingchairllc/LGPNewLook | /app/models/zip_loc.rb | UTF-8 | 589 | 2.65625 | 3 | [] | no_license | class ZipLoc < ActiveRecord::Base
# matt- zip code should not be an integer -- lots of zip codes start with a 0
validates_presence_of :zip, :lat, :lng
validates_uniqueness_of :zip
# veesh - will remove this function later just saving it in case anything breaks
def movies_and_theaters_near_zip(radius_in_mile... | true |
57853b60b22839e54fca67342b3b7657ff242b4d | Ruby | nikitasingh/RubyTraining | /Assignments-ruby/square.rb | UTF-8 | 485 | 3.8125 | 4 | [] | no_license | def square
puts "Enter number to find its square roots"
number=Array.new
number=[gets]
puts "you want to enter more numbers? (y/n)"
ans=gets.chomp
while ans=='y' || ans=='Y'
puts "enter another number"
num=gets
number.push(num)
puts "you want to add more (y/n"
ans=gets.chomp
end
puts "square of the numbers"
i=0
size... | true |
c9fda46fd1feb6a24114763ea52c6d3483ad1ae1 | Ruby | hnmn/termux-rootfs | /termux-rootfs/data/data/com.termux/files/usr/lib/ruby/gems/2.4.0/gems/patch_finder-1.0.2/lib/patch_finder/core/thread_pool.rb | UTF-8 | 1,253 | 2.78125 | 3 | [
"BSD-3-Clause"
] | permissive | module PatchFinder
class ThreadPool
attr_accessor :mutex
# Initializes the pool.
#
# @param size [Fixnum] Max number of threads to be running at the same time.
# @return [void]
def initialize(size)
@size = size
@mutex = Mutex.new
@jobs = Queue.new
@pool = Array.new(@s... | true |
3a49a0c8c9bc253a07a158c9c0e97aafc2a72263 | Ruby | Allison-Northrop/BankAccounts | /lib/checking_account.rb | UTF-8 | 1,299 | 3.59375 | 4 | [] | no_license | require 'csv'
require_relative 'account'
module Bank
class CheckingAccount < Account
def initialize(id, balance)
super(id, balance)
end
def withdraw(amount)
if (@balance - amount) - 1 < 0
puts "You've exceeded the balance"
return @balance
else
@balance = (@bala... | true |
c17fb935f1d7a47bc7d54b91af53151f7dae96ba | Ruby | mk13/learnRails | /work/practiceOne/app/models/account.rb | UTF-8 | 477 | 2.890625 | 3 | [] | no_license | class Account < ActiveRecord::Base
belongs_to :user
validates :user_id, :account_number, presence: true, uniqueness: true
validate :price_must_be_at_least_a_cent
def withdraw(amount)
adjust_balance_and_save(-amount)
end
def deposit(amount)
adjust_balance_and_save(amount)
end
private
def adjust_bala... | true |
40d604b63d98e10cc0f66f6f5ca9db340edec08b | Ruby | itspriddle/bubblicious | /lib/password_generator.rb | UTF-8 | 206 | 2.8125 | 3 | [] | no_license | module PasswordGenerator
extend self
def generate_password(length = 8)
chars = ("A".."Z").to_a + ("a".."z").to_a + ("0".."9").to_a
Array.new(length) { chars[rand(chars.size)] }.join
end
end
| true |
981f563ca70f2d5f1187c2a36d1cdaae11b3996b | Ruby | shadabahmed/leetcode-problems | /0090-subsets-ii.rb | UTF-8 | 519 | 3.234375 | 3 | [] | no_license | # @param {Integer[]} nums
# @return {Integer[][]}
def subsets_with_dup(nums)
subsets(nums.sort)
end
def subsets(nums, idx = 0, stack = [], res = [])
return res.push(stack.flatten) if idx == nums.length
dup_length = 1
while idx + dup_length < nums.length && nums[idx] == nums[idx + dup_length]
dup_length +=... | true |
61d9aff91c6a4d1980a6e749b376b7354ec2cbb5 | Ruby | Naveen1789/ruby_code | /leetcode/algorithms/letter_combinations_017.rb | UTF-8 | 1,133 | 3.640625 | 4 | [] | no_license | # @param {String} digits
# @return {String[]}
def letter_combinations(digits)
return [] if digits == ''
mapping = ['0', '1', 'abc', 'def', 'ghi', 'jkl', 'mno', 'pqrs', 'tuv', 'wxyz']
str = ''
solution = []
find_combination(digits, str, solution, mapping)
solution
end
def find_combination (digit... | true |
4325a6d980304958f94d2d6e950f64c1ad1fd33a | Ruby | jpace/arbolobra | /lib/arbolobra/tree.rb | UTF-8 | 663 | 3.125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby -w
# -*- ruby -*-
require 'arbolobra/node'
class Arbolobra::Tree
attr_reader :root
attr_reader :nodes
def initialize lines, separator = "/"
if lines
@root = Arbolobra::Node.new "."
lines.each do |line|
elements = line.chomp.split separator
create_nodes e... | true |
2c033af38d70b9627aa56649bd5efc56f6a3fc13 | Ruby | zmil44/RubyTallTale | /TallTale_Exercise.rb | UTF-8 | 4,616 | 3.75 | 4 | [] | no_license | #------------------------------------------
# Script name: TallTale_Exercise.rb
# Versoion: 1.0
# Author: Zachary Miller
# Date: March 30 2018
# Description: This script takes user input and places it into a story
#------------------------------------------
class Screen
def cls
puts ("\n"*25)
puts "\a"
end
end
... | true |
5ccc369ca4c62bebdd64a26e066047d27f98c456 | Ruby | byronformwalt/Ruby-Practice | /Interview Questions/question_012.rb | UTF-8 | 751 | 2.84375 | 3 | [] | no_license | #!/usr/bin/env ruby
# Print numbers between 45 to 4578 without repeating digits.###
# Ex: 45-ALLOWED;55(repeatng digits)(-NOT ALLOWED. Frnd tld ths 2 me.he tried diff concepts but interviewer wanted an OPTIMAL ONE..LETS C WHO WRITE THIS WITH SIMPLE LOGIC..
# ref: http://www.careercup.com/page?pid=software-engineer-i... | true |
a13a4f14bc2acf143ce34227e2b1923892489bfe | Ruby | jai-singhal/djangopy | /vendor/bundle/ruby/2.3.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser/vendor/http-parser-java/tools/lowcase.rb | UTF-8 | 244 | 3.046875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-proprietary-license"
] | permissive |
0.upto(255) { |i|
printf "\n" if i%16 == 0
printf " " if i%8 == 0
s = ("" << i)
if s =~ /[A-Z0-9\-_\/ ]/
print "0x#{i.to_s(16)},"
elsif s =~ /[a-z]/
print "0x#{s.upcase[0].to_s(16)},"
else
print "0x00,"
end
}
| true |
03af64fb93b0d2144868ebf58635db458caf2c6b | Ruby | egunjobi1/kwk-l1-user-input-mini-lab-kwk-students-l1-bos-070918 | /trip.rb | UTF-8 | 889 | 4.625 | 5 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Code your prompts here!
# First, puts out a string asking where the tourist would like to stay.
puts "Let's plan your trip! Where would you like to stay?"
# Then, set a variable called stay to get the user's input. Make sure to capitilize that input.
stay = gets.chomp.capitalize #don't forget to Capitilize the in... | true |
b16a778f319292bbcbf9a5c4da7466c4ef0bf515 | Ruby | nguyenhmp/ruby-september-2016 | /Lawrence/rails/mathdj.rb | UTF-8 | 309 | 3.53125 | 4 | [] | no_license | class MathDojo
attr_accessor :sum
def initialize()
@sum = 0
end
def add(*arg)
@sum += arg.flatten.reduce(:+)
return self
end
def sub(*arg)
@sum -= arg.flatten.reduce(:+)
return self
end
end
dojo1 = MathDojo.new.add([20,20], 1).sub([20,20]).sum
puts dojo1
| true |
274df23729d900dd1de07870f51a3ef82a3bdced | Ruby | belsouza/backupexercises | /antigos/Arcabouco/uri/produto/produto.rb | UTF-8 | 117 | 3.03125 | 3 | [] | no_license | def produto( a, b )
return a * b
end
a = gets.to_i
b = gets.to_i
prod = produto(a, b)
puts "PROD = %d" % [prod]
| true |
7f68d6e0e3ff0322e7cd03d5fe0e7f7c88c9b12a | Ruby | ryuchan00/ruby_for_beginners | /sample/self2.rb | UTF-8 | 290 | 3.625 | 4 | [] | no_license | # 7.5.1 selfのつけ忘れで不具合が発生するケース
class User
attr_accessor :name
def rename_to(name)
self.name = name
end
end
user = User.new
p user.name # 何も格納されていないのでnil
p user.rename_to('Taro')
p user.name # Taroになっているはず
| true |
012cff30c8f9883a48dc5898f3cf3730164e21eb | Ruby | heroku/hatchet | /spec/hatchet/lock_spec.rb | UTF-8 | 2,534 | 2.515625 | 3 | [
"MIT"
] | permissive | require "spec_helper"
require 'yaml'
describe "LockTest" do
before(:all) do
puts(`bundle exec hatchet lock`)
end
it "app with failure can be locked to prior commit" do
Hatchet::GitApp.new("lock_fail").deploy do |app|
expect(app.deployed?).to be_truthy
end
end
it "app with failure can be l... | true |
ae8dfc915cd0321cfcba76f9dadbc517bc763512 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/accumulate/3f9e19adbeb440db96583fb55bf2255b.rb | UTF-8 | 133 | 3.1875 | 3 | [] | no_license | class Array
def accumulate(&block)
return self if self.empty?
[block.call(self.shift)] + self.accumulate(&block)
end
end
| true |
412c0af73dc3070466a40ab718cafa8b6ec5ff03 | Ruby | Jake0Miller/Foothills-Bootcamp-Prep | /ttt-6-position-taken-rb-bootcamp-prep-000/lib/position_taken.rb | UTF-8 | 192 | 3.15625 | 3 | [] | no_license | def position_taken?(board,index)
if board[index] == "" || board[index] == " "
return false
end
if board[index] == "X" || board[index] == "O"
return true
end
return false
end
| true |
9eb7e521b4bd8e7f748b77547d2f0dd2fb2981d1 | Ruby | htaox/SearchWorks | /lib/search_works/links.rb | UTF-8 | 1,993 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | module SearchWorks
class Links
PROXY_REGEX = /stanford\.idm\.oclc\.org/
delegate :present?, :first, :last, :each, :map, :select, :find, to: :all
def initialize(links = [])
@links = links
end
def all
@links || []
end
def fulltext
all.select(&:fulltext?).reject(&:finding... | true |
ac4ac0eb5d7b75dc74f3754d3e9382ec5e3a54e1 | Ruby | chubarovNick/thunderer | /lib/thunderer/channel_parser.rb | UTF-8 | 565 | 2.890625 | 3 | [
"MIT"
] | permissive | module Thunderer
module ChannelParser
class << self
def interpolate_channel channel, object
channel.gsub(/:\w*\b/, interpolation_hash(channel, object))
end
private
def interpolation_hash channel, object
{}.tap do |result|
channel.scan(/:\w*\b/).map do |interpol... | true |
d0b47bd781153cdaf9f26588117b4805a4f0a916 | Ruby | yds12/sudoku | /match_ui.rb | UTF-8 | 5,047 | 2.703125 | 3 | [] | no_license | require './match'
class MatchUI
BoardFontSize = 30
PlayerFontSize = 24
PanelFontSize = 24
NumPadX = 8
NumPadY = ((G::BoardTile - BoardFontSize) / 2).to_i
PlayerNumPadX = 10
PlayerNumPadY = ((G::BoardTile - PlayerFontSize) / 2).to_i
attr_reader :over
def initialize
@match = Match.new
@over =... | true |
d351e8170f0d65265249b6c2536b620aefca7d69 | Ruby | oso-mate/import-export | /exporter.rb | UTF-8 | 227 | 2.546875 | 3 | [] | no_license | require 'json'
class Exporter
def self.export(data, file_name)
formatted_data = format(data)
file = Kernel.open(file_name, 'w')
JSON.dump(formatted_data, file)
end
def self.format(data)
data
end
end | true |
d618c33ec4a931fab2d9ce0adf74eb8f0d31478d | Ruby | civol/HDLRuby | /lib/HDLRuby/hruby_db.rb | UTF-8 | 10,091 | 3.1875 | 3 | [
"MIT"
] | permissive | require "HDLRuby/hruby_base"
require "HDLRuby/hruby_bstr"
# @deprecated hruby_db.rb (former hruby_low.rb) is deprecated.
warn "hruby_db.rb (former hruby_low.rb) is deprecated."
##
# Low-level libraries for describing digital hardware.
#######################################################
module HDLRuby::L... | true |
708c9ff8b0fba593a37cd91673efca093b8a0f21 | Ruby | benjineering/rakai | /lib/rakai/bin_data/s1000/index_entry.rb | UTF-8 | 2,161 | 2.890625 | 3 | [] | no_license | require 'rakai/bin_data/base'
require 'rakai/bin_data/s1000/akai_string'
module Rakai
module BinData
module S1000
=begin rdoc
With the S1000, Akai abandon ASCII (mostly) and use their own alphanumeric code,
which I shall refer to as AKAII:
Character ASCII AKAII
--------------------------------... | true |
7e86fbde688880a200a04ab7d15c820379600d4d | Ruby | truongmkevin/TTS-Ruby-Practice | /loopswitharrays.rb | UTF-8 | 589 | 3.921875 | 4 | [] | no_license | scores = [100, 80, 75, 93, 50]
counter = 0
sum = 0
# # While loop with arrays - BUT THIS IS SHUNNED
# while counter < scores.length
# sum += scores[counter]
# counter += 1
# end
# puts "The sum of the scores #{scores} is #{sum}"
# puts "The average of the scores #{scores} is #{sum/scores.size}."
# Each loop wit... | true |
5f921e8b3a4cb818d336d63d64be0a394da9f335 | Ruby | itggot-edwin-eliasson/GA_repository | /lib/enemy.rb | UTF-8 | 1,590 | 3.390625 | 3 | [] | no_license | class Enemy
attr_accessor :x, :y
def initialize
@x = 1000
@y = 100
@direction = :right
@speed = 2
@image = Gosu::Image.new('media/enemy3.png')
@g = 0.5
@org_y = @y
@t = 0
@vel_y = 0
@on_ground = false
@alive = true
... | true |
07f6358d3fe0ec1b2363d287a3e464d87a2e4a80 | Ruby | nehagrg/rubys1 | /block/b1.rb | UTF-8 | 121 | 2.5625 | 3 | [] | no_license | def demo
puts"this is the demo method"
yield
yield
puts"this is also ademo method"
end
demo{puts"hello i am block"}
| true |
ead3c779e99ac999c60ae777da8c37b448db68ec | Ruby | udzura/reddish-shell | /mrbgems/mruby-reddish-parser/mrblib/reddish_parser/element/word_list.rb | UTF-8 | 707 | 3.265625 | 3 | [
"MIT"
] | permissive | module ReddishParser
module Element
class WordList
def initialize(word)
# Array<Array<Word>>
@list = [[]]
add(word)
end
def add(word)
if word.type == WordType::SEPARATOR
@list.push([]) unless @list.last.empty?
else
@list.last.push(wor... | true |
9b7c4b7577061b86c6440feaf236e36efa6511d6 | Ruby | spuder/sandbox | /prime/prime2.rb | UTF-8 | 720 | 3.875 | 4 | [] | no_license |
def is_divisible(anumber)
if anumber == 1 || anumber == 2
puts "1 and 2 are exceptions to the formula, they are prime"
return true
end
#This has a problem because it thinks 14 is prime, and doesn't check for 2's
(3..Math.sqrt(anumber)).step(2) do |n|
if anumber % n == 0
puts " #{anumber} is divisible by #... | true |
1971b8e625a15a8cc6535042b6e1e551a9cd6585 | Ruby | shaistaabidd/ror-training | /Challenges_week3/filter_array.rb | UTF-8 | 418 | 4.46875 | 4 | [] | no_license | #Create a function that takes an array of strings and integers, and filters out the array so that
#it returnsan array of integers only.Examplesfilter_array([1, 2, 3, "a", "b", 4])
#[1, 2, 3, 4]➞filter_array(["A", 0, "Edabit", 1729, "Ruby", "1729"]) [0, 1729]➞filter_array(["Nothing", "here"]) []
def filter_a... | true |
9fabe84c4002f1eea78c2ff4ac3950f60b102f8f | Ruby | mihir787/enigma | /lib/decryptor.rb | UTF-8 | 939 | 3.0625 | 3 | [] | no_license | require_relative 'date_offset'
require_relative 'rotation_calculator'
require_relative 'rotor'
require_relative 'decryptor'
require_relative 'file_processor'
class Decryptor
attr_reader :encrypted_file_name, :decrypted_file_name, :key, :date
def initialize(encrypted_file_name, decrypted_file_name, key, date)
... | true |
b0b47690d2e5f361bcc881335c4fccf0c023cecb | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/14bdfb65ffb44ffea6a99d3cd946df52.rb | UTF-8 | 162 | 3.5 | 4 | [] | no_license | class Hamming
def self.compute(a, b)
total = 0
a.each_char.with_index do |char, index|
total += 1 if char != b[index]
end
total
end
end
| true |
c5f86d7ea9b9ade254194ea4e681c22ce3773fb6 | Ruby | mpakus/excurso | /lib/trace.rb | UTF-8 | 598 | 3 | 3 | [
"MIT"
] | permissive | ##
# Lib works with hash container and support fifo rule over it
class Trace
# attr_reader :values
def initialize(container = '', limit = 3)
@container = container
@limit = limit
# container[:key] should be array
@values = container[:last]
@values = [] if @values.blank?
if values.... | true |
6c794e892180e561bc5315c9d20d91c2d9390ac5 | Ruby | ifad/iot | /app/device.rb | UTF-8 | 1,722 | 3 | 3 | [
"MIT"
] | permissive | require 'json'
require 'rubyserial'
require File.expand_path('../db.rb', __FILE__)
class Device
attr_accessor :port, :rate
attr_reader :serialport
FAKE_COLUMNS = {
ph: (6.2..6.6),
co2: (35.0..45.0),
no2: (0.0..40.0),
soil_moisture: (0.0..100.0),
radiation: (0.0..1.0)
}
TABULABLE_COLUMN... | true |
5cebecdbeda00e8ab0f0a3e44c40eb2d14647d45 | Ruby | jacki890/apprenticeship | /grandma.rb | UTF-8 | 475 | 3.859375 | 4 | [] | no_license | puts 'Say something to your grandma.'
you_say = 'whatever you want'
bye = 0
while bye < 3
you_say = gets.chomp
if you_say == 'BYE'
bye = (bye + 1)
if bye == 3
puts 'BYE, SONNY. NICE CHATTING WITH YOU!'
else
puts 'Oh, don\'t go, Sonny.'
end
elsif you_say == you_say.upcase
pu... | true |
fc9c9255be8e718d5c8c8789c4c3c70a69dc5323 | Ruby | rh0delta/LHL | /Ruby/fizzbuzz.rb | UTF-8 | 227 | 3.453125 | 3 | [] | no_license | values = []
for i in 1..100
if i % 3 == 0 && i % 5 == 0
i = "FizzBuzz"
values << i
elsif i % 3 == 0
i = "Fizz"
values << i
elsif i % 5 == 0
i = "Buzz"
values << i
else
values << i
end
end
puts values
| true |
dde0d6885ee1e471a4000919da0a6c5a8a7f28c9 | Ruby | aanand-aditya/ruby-training | /test/test_arr_freq.rb | UTF-8 | 259 | 2.515625 | 3 | [] | no_license | require 'test/unit'
require_relative './freq'
class TestFrequecy < Test::Unit::TestCase
def test_arr_freq
arr = Array[1,2,3,2,1,2,3];
h = {1 => 2, 2 => 3, 3 => 2};
expected = Frequency.new.arr_freq(arr)
assert_equal expected, h
end
end | true |
0a06735fb6410130882043ea4b6929638613f186 | Ruby | sarastanton/ruby-objects-has-many-lab-v-000 | /lib/song.rb | UTF-8 | 231 | 3.15625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song
attr_accessor :artist, :name
def initialize(name)
@name = name
end
def artist_name
result = nil
result = self.artist.name if @artist
#make sure won't break if song has no artist (return nil)
result
end
end
| true |
00bd6a8ecd47e03815102a4fa5beb504be71c815 | Ruby | jamiemonserrate/stack_machine | /lib/stack_machine_emulator.rb | UTF-8 | 719 | 3.484375 | 3 | [] | no_license | class StackMachineEmulator
FAILURE_CODE = -1
def initialize
@stack = Stack.new
end
def evaluate(expression_string)
return FAILURE_CODE unless ExpressionString.valid?(expression_string)
ExpressionString.new(expression_string).each_expression_character do |expression_character|
begin
... | true |
3f3ca7cb9da069a0343002e8baee6df27798c8c3 | Ruby | cmaher92/launch_school | /coursework/rb101/lesson_4/practice_problems/string_assignment.rb | UTF-8 | 224 | 3.71875 | 4 | [] | no_license | # capitalize the first letter of each word in the str
str = "joe's favorite color is blue"
# str.split.map(&:capitalize).join(' ')
# p str.split.map { |word| word[0] = word[0].capitalize + word[1..(word.size)] }.join(' ')
| true |
5019f5056c44203cbfe1583d77ca4d0e7ba0debd | Ruby | lloeki/normandy | /lib/channel.rb | UTF-8 | 2,985 | 3.078125 | 3 | [
"MIT"
] | permissive | class Channel
class Closed < StandardError; end
def initialize(size = nil)
@q = size ? SizedQueue.new(size) : Queue.new
@closed = false
@mutex = Mutex.new
@waiting = []
end
private def lock!(&block)
@mutex.synchronize(&block)
end
private def wait!
@waiting << Thread.current
@m... | true |
6264df3fce0c7ea1fe0e8db12a580912697691c7 | Ruby | chiwenchen/myflix | /spec/models/video_spec.rb | UTF-8 | 3,037 | 2.578125 | 3 | [] | no_license | require 'spec_helper'
describe Video do #'describe' is the syntax for test, and the Video is the model name matchs the model we are going to test.
#shoulda-matchers gem can test common rails functionality
it {should validate_presence_of(:title)}
it {should validate_presence_of(:description)}
it {should belong... | true |
7376360ff3edb721d20ed0e9a2b3be2ba63aadd6 | Ruby | dalewb/activerecord-tvland-nyc-web-040218 | /app/models/actor.rb | UTF-8 | 378 | 2.703125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Actor < ActiveRecord::Base
has_many :characters
has_many :shows, through: :characters
def full_name
"#{self.first_name.capitalize} #{self.last_name.capitalize}"
end
def list_roles
self.characters.map do |role|
"#{self.characters[0].name} - #{self.characters[0].show.name}"
... | true |
6d5f280db9e7866acc17fa4d6f6f257c94ecab7f | Ruby | LytayTOUCH/SOMA-JackCo | /app/models/stock_in.rb | UTF-8 | 986 | 2.515625 | 3 | [] | no_license | class StockIn < ActiveRecord::Base
include UuidHelper
belongs_to :warehouse, foreign_key: :warehouse_id
belongs_to :material, foreign_key: :material_id
belongs_to :labor, foreign_key: :labor_id
validates :warehouse_id, length: {maximum: 36}, :presence => { message: "Warehouse is required." }
validates :ma... | true |
c0225c34ac4d19a890e2e79a94cd699bfaa524b9 | Ruby | sarita2129/PractiseCode | /Ruby/lesson3/hashes.rb | UTF-8 | 903 | 3.328125 | 3 | [] | no_license | secret_identities = {
"The Batman" => "Bruce Wayne",
"Superman" => "Clark Kent",
"Wonder Woman" => "Diana Prince",
"Freakazoid" => "Dexter Douglas"
}
secret_identities.each do |x,y|
puts "#{x}: #{y}"
end
my_hash = {
"firstname" => "Rekha",
"lastname" => "Menon",
"city" => "Mumbai",
"state" => "Maharashtra"
... | true |
1672ac0ba4c503bb06514d3b704ca220d2691b94 | Ruby | takefumi24/ruby_workbook | /drill28.rb | UTF-8 | 610 | 3.546875 | 4 | [] | no_license | # 同じ結果を得るためにも、様々なコードの記述方法があります。
# 以下のコードをワンライナーに書き換える方法について、2パターン以上のコードを記述してください。
array = [1, 2, 3, 4, 5].map do |el|
if el.odd?
el
end
end.compact!
array = [1, 2, 3, 4, 5].map {|el| el if el.odd?}.compact!
array = (1..5).select(&:odd?)
p array
# 解答
array = [1, 2, 3, 4, 5].map { |el| el if el.odd? }.compact!... | true |
a498b368303760a1653900dd5b4127fcd28834d1 | Ruby | DanielFarber/wdi | /w01/d02/Classwork/storytime/story.rb | UTF-8 | 586 | 3.484375 | 3 | [] | no_license | story = [
'Fry is born without a delta brainwave',
'As a result, Fry is cryogenically frozen until 2999',
'In the future, Fry works on a spaceship',
'The spaceship hits a wormhole and crashes in 1941 Roswell, NM',
]
index = 0
read = "y"
while index < story.length && read == "y"
puts story[index]
unless inde... | true |
687c7f7aa6db09e8ca49a537f5b1495f4febee35 | Ruby | dieGomes1/qa_ninja | /unitarios/spec/bank/saque_cc_spec.rb | UTF-8 | 1,432 | 2.84375 | 3 | [] | no_license | require_relative '../../app/bank.rb'
describe ContaCorrente do
describe 'saque' do
context 'Saque em Conta Corrente realizado' do
before(:all) do
@cc = ContaCorrente.new(1000.00)
@cc.sacar(200.00)
end
it 'então saldo é atualizado' do
expect(@cc.saldo).to eq 795.00
... | true |
fd3fbbb3e92b9655f8ea4aa09a409ccb0a2454f3 | Ruby | dniman/some_repository | /lesson4/train.rb | UTF-8 | 1,807 | 3.390625 | 3 | [] | no_license | class Train
attr_reader :number, :speed, :current_station, :carriages
def initialize(number)
@number = number
@carriages = []
@speed = 0
end
# Увеличение скорости
def speed_up(value)
@speed += value
end
# Торможение
def speed_down(value)
@speed = value > speed ? value - speed : 0
... | true |
a8cd18164db00cf208f06a9a887bcd48d340b45f | Ruby | stevej763/conways-game-of-life-tdd | /spec/game_grid_spec.rb | UTF-8 | 5,862 | 2.859375 | 3 | [] | no_license | require 'game_grid'
require 'grid_factory'
describe 'GameGrid' do
describe 'get_grid_as_array' do
context "with 3 rows and 3 columns" do
number_of_rows = 3
number_of_columns = 3
grid = GridFactory.new.build(number_of_rows, number_of_columns)
underTest = GameGrid.new(grid.get_grid_as_ar... | true |
98cee6e99aa64f9efa2b00589edde7fa9233e663 | Ruby | 8emi95/elte-ik-script | /ea/ea13/debug1.rb | UTF-8 | 1,221 | 3.3125 | 3 | [] | no_license |
i,j = 0,1
while j < 100000
j *= 3
i += 1
end
puts "i: #{i}, j: #{j}"
# $ ruby -r debug debug1.rb
# Debug.rb
# Emacs support available.
# debug1.rb:3:i,j = 0,1
# (rdb:1) list
# [-2, 7] in debug1.rb
# 1
# 2
# => 3 i,j = 0,1
# 4 while j < 100000
# 5 j *= 3
# 6 i += 1
# 7 end
# (r... | true |
99a5baf6a7d63d84669cb955616e1a5fc5ab48ca | Ruby | Jennwil/reverse-each-word-v-000 | /reverse_each_word.rb | UTF-8 | 135 | 3.21875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(sentence)
array = sentence.split
array.collect do |reverse|
reverse.reverse!
end
array.join(" ")
end
| true |
08521e66fb88149a7404bf75f9f076e6c3822be0 | Ruby | cfoust/leetcode-problems | /problems/substring-with-concatenation-of-all-words/solution.rb | UTF-8 | 110 | 2.671875 | 3 | [] | no_license | # @param {String} s
# @param {String[]} words
# @return {Integer[]}
def find_substring(s, words)
end | true |
3706abf7057467673e3fe47c38fb6c42563407b2 | Ruby | DanielSLew/Leet_Code_Problems | /30_day_chall/10_flatten_multilevel_double_linked_list.rb | UTF-8 | 1,121 | 3.5625 | 4 | [] | no_license | # Given a doubly linked list in addition to the next and previous pointers
# It could have a child pointer which may or may not point to a separate
# doubly linked list
# child lists may have one or more children of their own, etc
# keep track of results in an array
# When we visit a node, push node.val onto the arr... | true |
2ad4eaaefb14b262913f4d66d152bdce45fb2281 | Ruby | khaivubui/w2d3_classwork | /first_tdd/towers_of_hanoi/lib/board.rb | UTF-8 | 498 | 3.78125 | 4 | [] | no_license | class Board
attr_accessor :grid
def initialize
@grid = Array.new(3) { [] }
end
def populate
@grid[0] = [3,2,1]
end
def move_piece(arg)
from = arg[0]
to = arg[1]
raise "From stack is empty" if @grid[from].empty?
unless @grid[to].empty? || @grid[from].last < @grid[to].last
ra... | true |
5947f4ec7a0e226a69fb1071863ab1a786fd1a07 | Ruby | 7e11/Dodge | /space.rb | UTF-8 | 1,622 | 2.609375 | 3 | [] | no_license | class CP::Space
attr_accessor :impulseDown, :impulseUp, :impulseRight, :impulseLeft, :gravChange, :itemExists, :itemCollision
def initDodge
self.damping = 0.01 #Apply some ambient friction to the space.
self.gravity = CP::Vec2.new(0.0, (9.81 * SCREEN_HEIGHT/2))#Gravit... | true |
4aa4028f29953e879fc9c115b671ba7c312858bc | Ruby | xeger/backticks | /lib/backticks/cli.rb | UTF-8 | 4,215 | 3.296875 | 3 | [] | no_license | module Backticks
module CLI
# Command-line parameter generator that relies on traditional *nix getopt
# conventions. Getopt doesn't know about GNU conventions such as short and
# long options; it doesn't know about abbreviations; it doesn't know about
# conventions such as `--X` vs. `--no-X` or `-d` v... | true |
aa9877be05fa9a7e32b2e0079029b8ed8bda4a19 | Ruby | the-iron-yard-indy-ror-oct-2015/course_notes | /by_week/week4/day4/homework_review/app/models/color.rb | UTF-8 | 101 | 2.671875 | 3 | [] | no_license | class Color
attr_accessor :to_name
def initialize(string)
self.to_name = string
end
end
| true |
df043e5bb16b8537c423da9b501d931bc09dc0c6 | Ruby | snikolau/bitmap-editor | /spec/integration/command_parser_spec.rb | UTF-8 | 2,786 | 2.625 | 3 | [] | no_license | require 'spec_helper'
RSpec.describe BitmapEditor::CommandParser do
describe '#run' do
let(:file) { File.expand_path('spec/fixtures/example.txt') }
let(:expected_output) do
<<~EOS
O O X O
J J X J
O O X Y
EOS
end
subject { described_class.new.run(file) }
it 're... | true |
762672b9bb68e71a695320a77e7963b2477a1ce5 | Ruby | fasteragile/herbgobbler | /tests/specs/erb_file_spec.rb | UTF-8 | 5,941 | 3.046875 | 3 | [] | no_license | require 'backports'
require_relative '../spec_helper'
describe ErbFile do
it "should parse be able to load data from a string" do
ErbFile.from_string( "<%= 'doug is great' %>" ).should_not == nil
end
it "should parse and shatter and erb string into it's component parts" do
erb_file = ErbFile.from_string... | true |
785d0ca39a0ac130b3c909bcf1cad7882e82433b | Ruby | patrickdean/euler | /ruby/eulerproblems/problem029.rb | UTF-8 | 208 | 3.328125 | 3 | [] | no_license | # Project Euler problem 029
ary = (2..100).to_a
terms = []
ary.product(ary).each { |a, b| terms << a ** b }
count = terms.uniq.size
puts "Unique terms of a**b for 2 <= a <= 100 and 2 <= b <= 100: #{count}" | true |
d704a8b892dc09230a286f3bdfc5ba65e24a21cf | Ruby | anselon/leetcode | /count_and_say.rb | UTF-8 | 638 | 3.75 | 4 | [] | no_license | # @param {String} s
# @return {String}
def count_and_say_0(s)
s_idx = 0
chunk =[]
solution = ''
while s_idx < s.length
chunk << s[s_idx]
first = chunk[0]
s_idx+=1
while s[s_idx] == first
chunk << s[s_idx]
s_idx+=1
end
print chunk.join.to_s + "\n"
... | true |
9687516f5a8586506768754e8af24070dd12e9f7 | Ruby | scottvonscott/oxford-comma-onl01-seng-ft-050420 | /lib/oxford_comma.rb | UTF-8 | 654 | 3.46875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(array)
if array.length == 1
array.join()
elsif array.length == 2
array.join(" and ")
else array.length > 2
new_array1 = []
new_array2 = []
new_array1 << array[0..-2]
new_array2 << array[-1]
new_array1.join(", ") + ", and " + new_array2.join()
end
end
# def ... | true |
c5ebab40a3e4bd6038dc32239abb7c8ee0dbec12 | Ruby | hackedunit/cloudnet | /spec/models/invoice_item_spec.rb | UTF-8 | 2,904 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | require 'rails_helper'
describe InvoiceItem do
let (:invoice_item) { FactoryGirl.create(:invoice_item) }
it 'should be valid' do
expect(invoice_item).to be_valid
end
it 'should not have any attributes related to cost assigned to it' do
expect(invoice_item.read_attribute(:net_cost)).to be_nil
expe... | true |
22373e48f557f1e55795a252e2e219e4652983ab | Ruby | cjlarose/webmock-net-http-headers-bug | /make_request.rb | UTF-8 | 427 | 2.546875 | 3 | [] | no_license | require 'net/https'
require 'uri'
def make_request_net_http
uri = URI.parse 'https://api.github.com/users/octocat/orgs'
auth_header = 'Bearer 1234'
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
# r... | true |
ee77edb767830b9000c334bee84c50cb7520f6ce | Ruby | Nosajool/League-Of-Valor | /lib/rift_battle.rb | UTF-8 | 16,127 | 2.734375 | 3 | [] | no_license | class RiftBattle
attr_reader :log
attr_reader :battle_id
def initialize(roster,opp_roster)
@team = Array.new
@event_num = 0
@opp_team = Array.new
@turn = 0
@attacker = roster[0].user
@defender = opp_roster[0].user
create_battle_record(roster,opp_roster)
roster.each do |champ|
@te... | true |
587bfe6de41f06dd74a8d65bfcd00e3df1f058c0 | Ruby | tiagobabo/advent-of-code-2018 | /lib/2/part_2.rb | UTF-8 | 387 | 3.578125 | 4 | [] | no_license | def difference(a, b)
a.chars.map.with_index.count { |char, i| char != b[i] }
end
def remove_equal_char(a, b)
a.chars.select.with_index { |char, i| char == b[i] }.join
end
ids = File.readlines('input.txt', chomp: true)
ids.each do |id|
ids.each do |comparing_id|
if difference(id, comparing_id) == 1
put... | true |
51ff0b158669dd1b38f213b5bf2a233c26a3b992 | Ruby | OksankaV/Weather | /range_weather.rb | UTF-8 | 6,016 | 3.484375 | 3 | [] | no_license | class RangeWeather
TEMPERATURE = "temperature"
PRESSURE = "pressure"
WIND_POWER = "wind_power"
HUMIDITY = "humidity"
DAY = "day"
NIGHT = "night"
attr_accessor :hash
def initialize
@hash = {}
end
def push(date, weather)
if @hash.has_key?(date) ... | true |
e7e719280569a275a489fd993925a06095a885b6 | Ruby | benjaminhenriquez/sql-library-lab-web-0916 | /lib/querying.rb | UTF-8 | 1,175 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def select_books_titles_and_years_in_first_series_order_by_year
"select books.title, books.year
from books join series
on books.series_id = series.id
where series.id = 1"
end
def select_name_and_motto_of_char_with_longest_motto
"select name, motto
from characters
order by length(motto) desc limit 1;"
end
def se... | true |
e8026677204d012928768e4057205be304a5b7d9 | Ruby | tayjames/backend_prework | /day_3/ex29.rb | UTF-8 | 816 | 4.03125 | 4 | [] | no_license | people = 20
cats = 30
dogs = 15
if people < cats
puts "Too many cats! The world is doomed!"
end
if people > cats
puts "Not many cats! The world is saved!"
end
if people < dogs
puts "The world is drooled on!"
end
if people > dogs
puts "The world is dry!"
end
dogs += 5
if people >= dogs
puts "People are g... | true |
fc8a5cd7438d17d783422b0883a20177499eae86 | Ruby | JonathanYiv/hangman | /lib/hangman.rb | UTF-8 | 3,603 | 3.875 | 4 | [] | no_license | require_relative 'gameboard.rb'
require 'json'
class Hangman
attr_accessor :gameboard, :lose, :win
def initialize
@gameboard = GameBoard.new
@lose = false
@win = false
end
def play
welcome
@gameboard.display
instructions
prompt_load if Dir.exist?("./saves")
turns
end
def welcome
puts %{
_ ... | true |
251edc54f6602295ce0e83eab21ed0a90a80e6cd | Ruby | Eractus/CWRK-W2D2 | /chess/piece.rb | UTF-8 | 289 | 3.484375 | 3 | [] | no_license | class Piece
attr_reader :color, :symbol, :board
attr_accessor :pos
def initialize(pos, color, board)
@pos = pos
@color = color
@board = board
end
def symbol
" ♟ "
end
def display_symbol
self.color == :b ? self.symbol.blue : self.symbol.red
end
end
| true |
f23a8dcf40d1d1ac6021fc24175ed1c8adba671e | Ruby | jvanderz22/level_up_exercises | /data_science/lib/data_science/calculations.rb | UTF-8 | 2,043 | 3.3125 | 3 | [
"MIT"
] | permissive | require_relative 'parser.rb'
require 'Statistics2'
class Calculations
attr_reader :data, :current_leader
def initialize(json)
@data = Parser.new(json).data
@current_leader = find_current_leader
end
def sample_size
data.length
end
def percent_conversion(cohort)
conversions(cohort).to_f/at... | true |
6efe1fde5b95313b3e53bc3b50458021492a4500 | Ruby | toptal/crystalball | /lib/crystalball/rspec/prediction_pruning/examples_pruner.rb | UTF-8 | 1,889 | 2.6875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Crystalball
module RSpec
module PredictionPruning
# A class to prune given world example groups to fit the limit.
class ExamplesPruner
# Simple data object for holding context ids array with total examples size
class ContextIdsSet
attr_re... | true |
8046e23384537ed41a47a02eaec50144e1869d3f | Ruby | takumi-kojima0901/js.practice | /method.rb | UTF-8 | 44 | 2.859375 | 3 | [] | no_license | def calc(a,b)
puts a * b
end
calc(2,3)
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.