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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c29ec4285716efced3d96f19b44489015457925e | Ruby | ssepa001/hotelexpress | /lib/AmenityMask.rb | UTF-8 | 162 | 2.828125 | 3 | [] | no_license |
class AmenityMask
attr_accessor :amenityName
attr_accessor :bitMask
def initialize(mask, name)
@bitMask = mask
@amenityName = name
end
end
| true |
aeb645f3a7a3bffee55d97190e0d0467885a2893 | Ruby | PastyPurpleTrolls/game-contest-server | /spec/support/files.rb | UTF-8 | 217 | 2.765625 | 3 | [] | no_license | def file_contents(filename)
contents = ''
File.open(filename) do |f|
contents = f.readlines(nil)[0]
end
contents
end
def expect_same_contents(a, b)
expect(file_contents(a)).to eq(file_contents(b))
end
| true |
8e20440b1c0d774922e9e15c58365329ac714bed | Ruby | jpearl01/16s_analysis | /old_version/16s_parser.rb | UTF-8 | 2,307 | 3.09375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'axlsx'
require 'trollop'
#The idea behind this program is to be able to pass hierarchy files from the MultiClassifier.jar program
#which identifies where 16s sequences are from and create excel files with graphs of the data.
#Usage:
#Setup options hash
opts = Trollop::options do
opt :... | true |
7be61497b12ff8a57aa9d7db4d363897d3c47d2f | Ruby | nickpisciotta/coding_exercises | /fibbonacci_challenge.rb | UTF-8 | 261 | 3.71875 | 4 | [] | no_license |
quantity = 15
def fib_sequence(number)
array = [0, 1]
(number - 2).times do
sum = array[-1] + array[-2]
array << sum
end
(array.size/5).times {|i| puts array.slice(i*5, 5).join(" ").center(1,)}
end
puts fib_sequence(quantity).inspect
| true |
59f7ce0790c4d9ba59292bd2c9be49be72d4a2ed | Ruby | yodel-cms/yodel | /lib/yodel/mime_types/mime_type_set.rb | UTF-8 | 1,181 | 2.8125 | 3 | [] | no_license | class MimeTypeSet
attr_accessor :types
def initialize
@default = nil # default mime type when no other can be matched
@types = {} # index by type name (:html)
@extensions = {} # index by type extensions (html, htm)
@mime_types = {} # index by mime types (text/html)
end
def each
... | true |
96151f9ad6f48ca91419c31e99e9bf97f0f3bb2c | Ruby | 0agautam/Training | /ruby/range.rb | UTF-8 | 180 | 3.1875 | 3 | [] | no_license | #!/usr/bin/ruby -w
#Program to get input untill you type start input with 'start' and then end with 'end'
def range_
while gets
print if /start/../end/
end
end
range_
| true |
815d1bd7751fed2cb841df0b4e8afbab55dbe6b3 | Ruby | zerowidth/lightbar | /controller/animations.rb | UTF-8 | 3,546 | 3.203125 | 3 | [
"MIT"
] | permissive | require_relative "color"
require_relative "serial_controller"
module Animations
# Animation: wipe color across display a pixel at a time.
#
# color - the Color to wipe
#
def color_wipe(color)
length.times do |num|
self[num] = color
show
end
end
# Animation: movie theater light chaser... | true |
75ca09931cb988c5653c724e766cac110aecdbbf | Ruby | maedama/mysql-partitioner | /lib/mysql/partitioner/cli.rb | UTF-8 | 2,218 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'optparse'
require 'logger'
require 'yaml'
require 'mysql2'
require 'mysql/partitioner/strategy'
require 'mysql/partitioner/session'
require 'deep_hash_transform'
module Mysql
module Partitioner
class Cli
def run()
options = {
:dry_run => false,
:debug => fals... | true |
2d6f44ceabbd0784dd7ab809cd7cb964afa05a2d | Ruby | yunjin-cloud/2020-winter | /Number/1.rb | UTF-8 | 46 | 3.1875 | 3 | [] | no_license | puts(10+5)
puts(10-5)
puts(10*5)
puts(10/5) | true |
de0e6f375518be7ab71331fdfbb6edb6bb9f1db4 | Ruby | amckinnell/advent_of_code_2020 | /day_07/puzzle_07_1/lib/bag_regulations_input.rb | UTF-8 | 948 | 3.21875 | 3 | [] | no_license | class BagRegulationsInput
def initialize(input)
@input = input
end
def parsed_input
@input.split("\n").map { |line| parse_line(line) }.to_h
end
private
def parse_line(line)
# "clear red bags contain 2 blue bags, 4 light brown bags." ->
# ["clear red bags", "2 blue bags 4 light brown bag... | true |
33c75a4cd413539858cf034a6a9bc80b739a0706 | Ruby | rjacobson16/Algorithms-and-Data-Structures | /LRU_cache/lib/p01_int_set.rb | UTF-8 | 1,640 | 3.34375 | 3 | [] | no_license | class MaxIntSet
def initialize(max)
@set = Array.new(max)
end
def insert(num)
if num > @set.size || num < 0
raise 'Out of bounds'
else
@set[num] = num
end
end
def remove(num)
@set[num] = nil
end
def include?(num)
@set.include?(num)
end
private
def is_valid?(nu... | true |
1a2e8d3dcad9261d30ed2273295cf53e6fe8d018 | Ruby | osohq/oso | /languages/ruby/lib/oso/polar/data_filtering.rb | UTF-8 | 876 | 2.53125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
module Oso
module Polar
# Data filtering interface for Ruby
module DataFiltering
# Represents relationships between resources, eg. one-one or one-many
class Relation
attr_reader :kind, :other_type, :my_field, :other_field
# Describe a Relation from o... | true |
1ad56c0347c46ee92ad12d4bd20120b7ba28ab60 | Ruby | AndrewSGreig/week1_day3 | /quiz.rb | UTF-8 | 396 | 4.09375 | 4 | [] | no_license | # my_number = 5
# p "what number am i thinking of?"
#
# value = gets.chomp.to_i()
#
# while(value != my_number)
# if(value > my_number)
# p "too high"
# else
# p "too low"
# end
#
# value = gets.chomp.to_i()
# end
#
#
# p "YEEEESSSSS, you guessed it correctly"
while(true)
p "type something"
line =... | true |
fcfa65ab7b1d1d931bfd48ec1df8817134397db9 | Ruby | stevenihewitt/googleAPI | /search.rb | UTF-8 | 435 | 2.75 | 3 | [] | no_license | require "./googleAPI"
require "./doc_matrix"
#Index that snippets are at.
snippet = 2
#Create a new DocMatrix
matrix = DocMatrix.new
#Create a new search
search = GoogleAPI.new
search.add_query("Parenting 101") #add query
results = search.return_search_results #get google search results
results.each do |result|
... | true |
568bab21a2239f66c0e51a96f5ad022c2ea60485 | Ruby | NightFeather/plurk | /lib/plurk/client/endpoints.rb | UTF-8 | 4,855 | 2.609375 | 3 | [] | no_license | module Plurk
class Client
# wrap up some frequesntly used (maybe) api endpoints
module Endpoints
# Access "/APP/Users/me"
# Cached version
# @return [User] current user the bot login with
def get_me
return @me if @me
get_me!
end
# Access "/APP/Users/me"
... | true |
1582620f5f79eed5595d2e63a630d5010546f702 | Ruby | valentinorusconi/ruby-exercises | /command-query/exercises/wallet_spec.rb | UTF-8 | 1,544 | 3.03125 | 3 | [
"MIT"
] | permissive | require 'rspec'
require_relative 'wallet'
RSpec.describe Wallet do
it 'starts at zero' do
wallet = Wallet.new
expect(wallet.cents).to eq(0)
end
xit 'can add pennies' do
wallet = Wallet.new
wallet << :penny
expect(wallet.cents).to eq(1)
3.times { wallet << :penny }
expect(wallet.ce... | true |
5d28fded7b59977ae0413c24660006aea8b08798 | Ruby | Ayukito/Ruby-File-Loader | /Ruby File Loader/Project/pokemonsdk/scripts/01300 UI/00800 Pokemon_Shop/00030 ScrollBar.rb | UTF-8 | 1,109 | 2.671875 | 3 | [] | no_license | module UI
module Shop
class PkmScrollBar < SpriteStack
# @return [Integer] current index of the scrollbar
attr_reader :index
# @return [Integer] number of possible indexes
attr_reader :max_index
# Number of pixel the scrollbar use to move the button
HEIGHT = 128
# Base Y ... | true |
735ff6382951847fc6a2313734acef15824e37f2 | Ruby | slagyr/battleship | /battleship/__resources/gems/gems/white_horseman-1.3/spec/white_horseman/analyst_spec.rb | UTF-8 | 1,946 | 2.78125 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../spec_helper'
require 'white_horseman/analyst'
require 'white_horseman/battlefield'
require 'white_horseman/cell_status'
describe WhiteHorseman::Analyst do
before(:each) do
@hit_map = WhiteHorseman::Battlefield.new
@hit_map.set_all(WhiteHorseman::CellStatus.new)
@live... | true |
423aac62e56793e1763b6bd760ff14db53dc8546 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/space-age/13d752281a7c4bcbb941e6a8570b6ed5.rb | UTF-8 | 614 | 3.59375 | 4 | [] | no_license | class SpaceAge
def initialize(seconds)
@seconds = seconds
end
def seconds
@seconds
end
def method_missing(method, *args, &block)
if method.to_s =~ /on_(.+)/ && RELATIVE_PERIOD[$1.to_sym]
on_planet($1.to_sym)
else
super
end
end
private
RELATIVE_PERIOD = { earth: 1.0, me... | true |
b2b59c665464a5c4789bd7dc36126fc4a8298a03 | Ruby | awrznc/scribble | /rust/src/ffi/shared_lib/load_source/app.rb | UTF-8 | 489 | 2.75 | 3 | [] | no_license | ## gem "ffi"
# require 'ffi'
# module LibTest
# extend FFI::Library
# ffi_lib './target/debug/libfoo.dylib'
# attach_function :foo, [], :int
# end
# LibTest::foo
require 'fiddle/import'
module FFI
extend Fiddle::Importer
# Win : libxxx.dll
# Mac : libxxx.dylib
# Linux : libx... | true |
705bfc047953bf7729e3944b12eb474814606a09 | Ruby | honnza/drops | /setgame.rb | UTF-8 | 359 | 2.9375 | 3 | [] | no_license | DECK = %w{rgb hsf stc}.reduce [""] do |as, ds|
as.flat_map{|a| ds.chars.map{|d| a+d}}
end
def solve(cards)
cards.combination(3).select do |c3|
c3.map(&:chars).transpose.all?{|p3|p3.uniq.size.odd?}
end
end
def gen_cases(n)
n.times.map do
cards = DECK.shuffle.take(9)
solution = solve cards
p [ca... | true |
4372eb6ae771f614f1f2bc08b45205549e6e30de | Ruby | technancy/training-ruby | /patterns/null_object_pattern/guaranteed_address_line.rb | UTF-8 | 406 | 3.0625 | 3 | [] | no_license | class GuaranteedAddressLine
def self.find(line)
AddressLine.find(line) || MissingAddressLine.new
end
class AddressLine
attr_reader :name
def initialize(line)
@name = line
end
def self.find(line)
if line == '' || line == nil
nil
else
new(line)
end
... | true |
6f0e32cdf0a3bfa96f9caa88764ed2e8d26ce367 | Ruby | khangpham/FanSQS | /lib/FanSQS/poller.rb | UTF-8 | 1,202 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'thread'
module FanSQS
class Poller
class << self
def start(qnames = [])
@queues_cache = FanSQS::QueuesCache.new(qnames)
loop do
@queues_cache.fetch.each do |queue|
FanSQS.pool.schedule do # Allows for multiple concurrent (non-blocking) HTTP requests to SQS
... | true |
db830d5bac2cdf91382b186fe708f1e96f45a55e | Ruby | aritode/rb_remaster | /L-01/2_area_of_a_triangle.rb | UTF-8 | 302 | 3.390625 | 3 | [] | no_license | print 'Введите основание треугольника: '
# bottom = Float(gets.chomp)
bottom = STDIN.gets.to_f
print 'Введите высоту треугольника: '
height = STDIN.gets.to_f
area = bottom * height * 0.5
print "Площадь треугольника: #{area}"
| true |
1b263f92a8d7a4a43e8f0ad8e5261c5b447ba823 | Ruby | rranshous/dropbox_clone | /app.ru | UTF-8 | 2,072 | 2.78125 | 3 | [] | no_license | $: << File.absolute_path('.')
require 'savable'
require 'savable_to_h'
require 'humanize'
require 'racker'
class DropboxClone
include Racker
def files *file_path
puts "files: file path: #{file_path}"
r = _files file_path.join('/'), @request.params[:revision]
r[:body] = JSON.generate r[:body] unless r... | true |
7b1afaf9e736bd797db242c4dfe24144be2f765d | Ruby | andrewmichienzi/osProject3 | /main.rb | UTF-8 | 4,017 | 2.734375 | 3 | [] | no_license | require 'rubygems'
require 'sinatra'
require 'slim'
require_relative 'project3'
#
# Main
#
#
# /next
# This steps to the next instruction in container and displays. It also
# resets the current page table id if that page doesn't exist in memory
# anymore
#
get '/next' do
$container.nextStep()
$memory = $container.... | true |
ae72d37e5dfb398fb38030b8b7358842bfea5cea | Ruby | cmfasulo/LEARN-Academy | /Week 4/Ruby_Day_2_1/vehicle.rb | UTF-8 | 384 | 3.640625 | 4 | [] | no_license | class Vehicle
def initialize(year)
@year = year
@lights_on = false
@turn_signal = "off"
end
def year
@year
end
def lights_on=(boolean)
@lights_on = boolean
end
def lights_on?
@lights_on
end
def turn_signal=(direction)
@turn_signal = direction
end
def turn_signal
... | true |
9684c0a86698d1c7fcfed8ae2780c608cc99d299 | Ruby | banister/local_eval | /test/test.rb | UTF-8 | 6,318 | 2.6875 | 3 | [] | no_license | direc = File.dirname(__FILE__)
require 'rubygems'
require "#{direc}/../lib/local_eval"
require "#{direc}/helper1"
puts "Testing LocalEval version #{LocalEval::VERSION}..."
puts "With Remix version #{Remix::VERSION} and Object2module version #{Object2module::VERSION}"
puts "Ruby version #{RUBY_VERSION}"
describe Loca... | true |
5f0421831d01e09f282daff9f0f4030031eb8569 | Ruby | syxanash/sinatra-apps | /matilde/passwordgenerator.rb | UTF-8 | 6,019 | 3.484375 | 3 | [] | no_license | require 'securerandom'
class PasswordGenerator
attr_accessor :size, :mnemonic
def initialize(params = {})
@lowercase_chars = ('a'..'z').to_a
@uppercase_chars = @lowercase_chars.map{|w| w.upcase}
@numbers_chars = ("0".."9").to_a
@extra_chars = %w(_ : ! ? # ~ @ . , % ; $ ... | true |
60ca49622cba8928d4f75749a0ebb8114e3d24b3 | Ruby | ashleygwilliams/game_of_life | /spec/cell.rb | UTF-8 | 980 | 2.796875 | 3 | [] | no_license | require "../lib/cell"
describe Cell, "#act" do
context 'alive' do
let(:cell) {Cell.new(4,4)}
it "should remain alive if it has 3 neighbors" do
cell.alive = true
cell.act(3)
expect(cell.future).to be_true
end
it "should die if it has 4 neighbors" do
cell.alive=true
c... | true |
656c136168081820a87476b31e1a514db8da1748 | Ruby | AJFaraday/process_game | /lib/common_components/avatar.rb | UTF-8 | 721 | 2.59375 | 3 | [] | no_license | module CommonComponents
module Avatar
def init_avatar(options)
@avatar_name = options[:avatar] || 'peasant'
@colour = options[:colour] || 'green'
@avatar = Gosu::Image.new(
if File.exists?(full_avatar_path)
full_avatar_path
else
basic_avatar_path
end
... | true |
100ac6daec0f6b6741087aa7ccaa2134a224926c | Ruby | marianodominguez/samples | /rubywarrior/mariano-intermediate/level8.rb | UTF-8 | 2,345 | 3.28125 | 3 | [] | no_license |
class Player
def initialize
@action=0
@plan = []
@ticking = []
@captives = []
@captive_enemies = []
@all_addr = [:left, :right, :forward , :backward]
end
def find_ticking warrior
units = warrior.listen
@ticking = []
@captives = []
units.each do |u|
... | true |
d77a2f08ac59e8a696874efae92b95350d8f196c | Ruby | ralake/Takeaway | /lib/message.rb | UTF-8 | 506 | 2.625 | 3 | [] | no_license | require 'twilio-ruby'
module Message
def send_message(customer, order)
@client = Twilio::REST::Client.new ENV['ACCOUNT_SID'], ENV['AUTH_TOKEN']
@client.account.messages.create({
from: ENV['TWILIO_NUMBER'],
to: customer.mobile_number,
body: "Thanks for ordering!\nYou have ordered - \n\n#{... | true |
da8692fdfc7c16617c2c7ac599e76956a1743adf | Ruby | meltar/Ruby-Euler-Problems | /2014/problem5.rb | UTF-8 | 481 | 4.3125 | 4 | [] | no_license | # Smallest multiple
# Problem 5
#
# 2520 is the smallest number that can be divided by each of the numbers from 1 to 10
# without any remainder.
#
# What is the smallest positive number that is evenly divisible by all the numbers from
# 1 to 20?
def smallest_multiple max
found = false
current_number = 0
until foun... | true |
13ced1cfe650897d3ad128f42604af4921247ad7 | Ruby | ed-karabinus/project-euler-10001st-prime-q-000 | /lib/10001st_prime.rb | UTF-8 | 869 | 3.859375 | 4 | [] | no_license | # Implement your procedural solution here!
def prime_number_for(number)
if number == 1
2
elsif number == 2
3
elsif number == 3
5
else
counter = 2
index = 5
offset = 0
until counter == number
if index % 6 == 1
if is_prime?(index)
if counter == number - 1
... | true |
029caeba45ceeb7ed8a6484fe53d2682997e7d67 | Ruby | rails/activerecord-session_store | /lib/active_record/session_store/sql_bypass.rb | UTF-8 | 4,862 | 2.71875 | 3 | [
"MIT"
] | permissive | require "active_support/core_ext/module/attribute_accessors"
module ActiveRecord
module SessionStore
# A barebones session store which duck-types with the default session
# store but bypasses Active Record and issues SQL directly. This is
# an example session model class meant as a basis for your own cla... | true |
21b853fdb8094b7563c9d3d42d5b6b87f09ea6d7 | Ruby | Fish234/mayor-de-3 | /mayor_de_3.rb | UTF-8 | 139 | 3.265625 | 3 | [] | no_license | a = ARGV[0].to_f
b = ARGV[1].to_f
c = ARGV[2].to_f
if a>=b && a>=c
puts "#{a}"
elsif b>=c
puts "#{b}"
else
puts "#{c}"
end | true |
ac8c8c40f9c4c22951c831547834af8a91b4750b | Ruby | karthi07/rb-linter | /lib/code_errors.rb | UTF-8 | 617 | 3.28125 | 3 | [] | no_license | require 'colorize'
class LintErrors
attr_reader :errors
def initialize
@errors = {}
end
def add_error(index, type, error_str)
if @errors[index].nil?
@errors[index] = [[type, error_str]]
else
@errors[index].append([type, error_str])
end
end
def show_errors
puts 'No Errors ... | true |
19050ce82d0f74eea491d77112da82b501ae8318 | Ruby | Maghamrohith/ruby-programs | /class1.rb | UTF-8 | 530 | 3.5 | 4 | [] | no_license | class Student
#first_name,last_name,age,gender,course
#sets up the reader method
#attr_reader :first_name,:last_name,:age,:gender,:courses
#sets up the writer method
#attr_writer :first_name,:last_name,:age,:gender,:courses
attr_accessor :first_name,:last_name,:age,:gender,:courses
end
s1=Student.new
... | true |
fe412e04df2681ba2e9fa71526240ab940e843e5 | Ruby | mgleon08/json-logic-ruby | /lib/json_logic/operation.rb | UTF-8 | 2,324 | 2.75 | 3 | [
"MIT"
] | permissive | module JSONLogic
class Operation
LAMBDAS = {
'var' => ->(v, d) { d.deep_fetch(*v) },
'missing' => ->(v, d) { v.select { |val| d.deep_fetch(val).nil? } },
'missing_some' => ->(v, d) {
present = v[1] & d.keys
present.size >= v[0] ? [] : LAMBDAS['missing'].call(v[1], d)
},
... | true |
a715ffed21b310ddf469d1f071711904653437f4 | Ruby | siralomarahmed/100DaysOfCode | /SourceCode/Ruby/day071.rb | UTF-8 | 1,692 | 4.96875 | 5 | [] | no_license | # More on Loops in Ruby
k = 100
puts "The variable before the for loop k = #{k}"
## Basic For Loop in Ruby
numbers = [3, 5 ,7]
for k in numbers
puts k
end
puts "You can still output the variable outside the for loop block of code. k = #{k}"
## Getting Index with Each
colors = ["Red", "Blue", "Green", "Yellow"]
... | true |
e3c9919e59f3bde1379480316def8c3abb5116f8 | Ruby | PavelBezpalov/alexa-fop | /app/lib/intents/register_user.rb | UTF-8 | 2,075 | 2.578125 | 3 | [] | no_license | module Intents
class RegisterUser
attr_reader :user, :request, :session
attr_accessor :response
attr_accessor :end_session
def initialize(user, request)
@user = user
@request = request
@session = request.session
@response = AlexaRubykit::Response.new
@end_session = false... | true |
7f428677604946b42138f26e49a9551f03e91bf3 | Ruby | ruby/rake | /test/test_rake_thread_pool.rb | UTF-8 | 3,196 | 2.875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require File.expand_path("../helper", __FILE__)
require "rake/thread_pool"
class TestRakeTestThreadPool < Rake::TestCase # :nodoc:
include Rake
def test_pool_executes_in_current_thread_for_zero_threads
pool = ThreadPool.new(0)
f = pool.future { Thread.current }
pool.join
... | true |
fa31f61a5269659c13860efa44800450220e0cfa | Ruby | glowychan/ar-exercises | /exercises/exercise_7.rb | UTF-8 | 540 | 2.890625 | 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'
require_relative './exercise_6'
puts "Exercise 7"
puts "----------"
# Your code goes here ...
print 'Enter store name:'
new_store ... | true |
6cfdc58cb4e1186be7e3ebd66163ec4c45c66d33 | Ruby | marick/rubactive | /lib/rubactive/rubactive.rb | UTF-8 | 8,002 | 3.4375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'forwardable'
# Rubactive provides two kinds of values-that-react-to-changes-in-other-values.
#
# Sometimes you want to think of the changing value as being something
# that "magically" changes over time (typically in reaction to changes
# in other values). That perspective is implemented by TimeVaryingValue.
... | true |
034b2d09c5f660b947fa0cbffb81241a1d1791e4 | Ruby | anhapril/learn-co-sandbox | /first_method.rb | UTF-8 | 289 | 3.296875 | 3 | [] | no_license | def say_hello
puts "about to greet you"
puts "Hello world, from a method"
puts "just greeted you"
end
def say_hello_four_times
say_hello
say_hello
say_hello
say_hello
end
def times_four_thousand(mystery)
mystery * 4000
end
puts times_four_thousand (times_four_thousand(65))
| true |
525259411c51c1a64cdf6f33b8c52b1277e41425 | Ruby | TrustTheVote-Project/Tabulator | /test/emgr_data_handler.rb | UTF-8 | 3,907 | 2.703125 | 3 | [] | no_license | #!/usr/bin/ruby
require "yaml"
# This is a temporary class used to process some test datasets from the DC and
# Viginia elections held in November 2010.
class TempEmgrDH # Temporary EMGR Data Handler for Tabulator
def initialize
@debug = false
end
def die(message)
print message + "\n"
exit(1)
... | true |
8bfe78de5493e3bd8cde1a963b0334c04bec31a5 | Ruby | lv7777/browserext.github.io | /scripts/minutes_cleaner.rb | UTF-8 | 1,290 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
if ARGV.size != 2 || ARGV[0] == "--help" || ARGV[0] == "-h"
STDERR.puts ""
STDERR.puts "Lightly post-processes draft minutes as generated by RRSAgent"
STDERR.puts "into the format suitable for inclusion in the browserext repos"
STDERR.puts ""
STDERR.puts ... | true |
030f192fc66ea643c8409a4d6be00672a3e65641 | Ruby | roshni-patel/slack-cli | /lib/slack.rb | UTF-8 | 4,460 | 3.28125 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative 'workspace'
require 'table_print'
require 'dotenv'
require 'csv'
require 'awesome_print'
def save_message_history(message, recipient)
CSV.open("message_history.csv", "a") do |file|
file << [recipient.name, recipient.slack_id, message]
end
end
def get_message_history(select... | true |
ba0f642c4b112fc50fcbc2b8590016fae60d364d | Ruby | jmvx/project-euler | /euler25.rb | UTF-8 | 503 | 3.640625 | 4 | [] | no_license | #!/usr/bin/env ruby
# Fibonacci numbers using the recursive algorithm (slow)
def fib(val)
val.times do |x|
if x == 0 then $sequence << 0
elsif x == 1 then $sequence << 1
else $sequence << $sequence.last(2).reduce(:+)
if $sequence.last.to_s.size == 1000 then return true
end
end
end
r... | true |
b530c55092dfd44038c414f594a9a63933a5addc | Ruby | pinglinh/user_echo_server_2 | /lib/user_echo_server.rb | UTF-8 | 632 | 3.203125 | 3 | [] | no_license | require_relative 'command_line_view'
require_relative 'user_echo_input'
class UserEchoServer
EXIT = "exit"
def initialize(input=STDIN, output=STDOUT)
@input = UserEchoInput.new(input)
@output = CommandLineView.new(output)
end
def start
@output.welcome_message
@output.instruction_message
@us... | true |
8d0fdd89996b2adc54948829abde405a65c2f5d7 | Ruby | sistemavestigios/vestigios | /old_vestigios/models/batale/errortog.rb | UTF-8 | 1,860 | 2.5625 | 3 | [] | no_license | class Batale::Errortog
include Mongoid::Document # Módulo necessário para persistir esse objeto como documento no banco de dados
include Mongoid::Timestamps # Módulo responsável por setar os timestamps created_at e updated_at do documento
field :name, type: String # Nome da classe de erro
has_many :definitions... | true |
fe71f6d13ad63545c07b2badb3088098f7077c3e | Ruby | maximkoo/ruby-repo | /bm.rb | UTF-8 | 882 | 3.203125 | 3 | [] | no_license | require 'benchmark' # стандартный гем, ставить не надо
puts (Benchmark.measure do # измеряем блок
(0..1000000).each do |i|
a="abc"; # на каждом проходе создается объект-строка
end;
end);
puts (Benchmark.measure do
(0..1000000).each do |i|
a=:abc; # на каждом проходе используем один и тот же символ, экономия ок... | true |
b5ab29262ae36cc55bc97ccc422f5231f0ed74ff | Ruby | Geekfish/studio-game | /lib/studio_game/die.rb | UTF-8 | 311 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative 'auditable'
module StudioGame
class Die
include Auditable
attr_reader :number
def initialize(min = 1, max = 10)
@min = min
@max = max
end
def roll
@number = rand(@min...@max)
audit
@number
end
end
end
| true |
88eddc157ca59a0d4faf09a12805a72e73d33c09 | Ruby | Osvimil/RubyCourse | /clasejercicio3.rb | UTF-8 | 313 | 4.09375 | 4 | [] | no_license | class Figura
def initialize(x,y)
@x=x
@y=y
end
attr_writer :x, :y
attr_reader :x, :y
def mostrar
print("X: ",x)
puts
print("Y: ",y)
puts
end
def desplazar(x,y)
@x+=x
@y+=y
end
end
punto1 = Figura.new(20,30)
punto1.mostrar
punto1.desplazar(3,7)
punto1.mostrar
| true |
2acd1a5b5bad06cbf190eb6128e242193b58ce3a | Ruby | unokun/ruby-memo | /advance/10/practice.rb | UTF-8 | 773 | 3.671875 | 4 | [] | no_license | # frozen_string_literal: true
require 'date'
def number?(str)
(str =~ /\A[0-9]+\z/) != nil
end
def input(val_name, min, max)
loop do
puts "#{val_name}を入力してください(#{min}-#{max}のいずれかの整数で入力)"
v = gets.chomp.to_s
next unless number?(v)
retv = v.to_i
next unless retv.between?(min, max)
return ... | true |
634a8d0d5917bc0a8dad83b243d8424f949b06bd | Ruby | selinaerhabor/battle | /spec/player_spec.rb | UTF-8 | 676 | 2.703125 | 3 | [] | no_license | require 'player'
describe Player do
subject(:sel) { Player.new('Sel') }
subject(:gemini) {Player.new('Gemini')}
describe '#name' do
it 'returns the name' do
expect(sel.name).to eq 'Sel'
end
end
describe '#hit_points' do
it 'returns the hit points' do
expect(gemini.hit_points).to eq d... | true |
a8b53ad286710d25bab8ff53927cf05d72bdf6fb | Ruby | SophiaLWu/chess | /lib/chess/knight.rb | UTF-8 | 618 | 3.390625 | 3 | [
"MIT"
] | permissive | module Chess
# Represents the knight piece
class Knight < Piece
attr_accessor :moves
attr_reader :symbol
def initialize(color, location)
super
@symbol = @color == "white" ? "\u{2658}" : "\u{265E}"
@moves = possible_moves
end
def possible_moves
x, y = location
mo... | true |
7518d06c0967d2be00d2c72e7a47451fd7718895 | Ruby | karenjho/object_oriented_programming | /sales_taxes.rb | UTF-8 | 1,195 | 3.828125 | 4 | [] | no_license | # define Good class with name, quantity, price, tax rate and import duty
class Good
attr_accessor :name, :quantity, :unit_price
attr_reader :tax_rate, :import_duty
def initialize(name, quantity=1, unit_price)
@name = name
@quantity = quantity.to_i
@unit_price = unit_price.to_i
@tax_rate = 0.10
... | true |
941c3c7f2197bcc58ad5f0f15e78c65e448ba214 | Ruby | jruby/jruby-parser | /spec/positions/name_spec.rb | UTF-8 | 2,118 | 2.640625 | 3 | [] | no_license | require_relative '../helpers'
describe Parser do
VERSIONS.each do |v|
it "should get name position for lvars [#{v}]" do
carets_parse("^foo = 1; ^foo", v).tap do |_, (asgn, var)|
asgn.should have_name_position(0, 0, 0, 3)
var.should have_name_position(0, 0, 9, 12)
end
end
it "s... | true |
dc9d9e6adb27f08d92889618adf1ff85e23637a4 | Ruby | lgrains/mp3 | /features/step_definitions/mp3tunes_steps.rb | UTF-8 | 1,200 | 2.5625 | 3 | [] | no_license |
Given /^the following mp3tunes exist:$/ do |table|
# table is a Cucumber::Ast::Table
table.hashes.each do |hash|
mp3tune = Factory(:mp3tune, hash)
end
end
When /^I follow "([^"]*)" for "([^"]*)"$/ do |link_title, mp3_title|
mp3 = Mp3tune.find_by_title(mp3_title)
When %{I follow "#{link_title}" within "... | true |
fc9ef6889445f900d8b57ffddcc5ea44b0b58f2c | Ruby | hiboabd/makers_learning_journey | /practicals/week-two/behaviour_not_state/spec/tic_tac_toe_spec.rb | UTF-8 | 482 | 2.765625 | 3 | [] | no_license | require 'tic_tac_toe'
describe Board do
subject(:board) { described_class.new}
describe ' #display_board' do
it 'Display board method prints board to screen' do
expect(board.display_board).to eq board.board
end
end
describe ' #add_turn' do
it 'should increment the array' do
expect { boa... | true |
8dd2f29dbd3746d5943c0d33b3fcc287f5e868d4 | Ruby | adamcameron/otherLanguages | /ruby/codeschool/rubyBits2/blocks/blockGiven.rb | UTF-8 | 112 | 3.21875 | 3 | [] | no_license | def print
if block_given?
yield
else
puts "no block"
end
end
print {puts "block"}
print
| true |
243776ff55ba556b878d556d90ddc1b7e1a1cfa2 | Ruby | Frozenmouth/exo-ruby | /exo_07c.rb | UTF-8 | 114 | 2.703125 | 3 | [] | no_license | user_name = gets.chomp
puts user_name
# ici on te demande ton nom qui s'affichera 2 fois sur 2 lignes grace a puts | true |
c66bbe37dcf9e5746810b75664fd2dcbeb8a8751 | Ruby | mattetti/merb_babel | /lib/merb_babel/m_l10n.rb | UTF-8 | 4,653 | 2.671875 | 3 | [
"MIT"
] | permissive | module ML10n
LANGUAGE_CODE_KEY = 'mloc_language_code'.freeze
COUNTRY_CODE_KEY = 'mloc_country_code'.freeze
class << self
# TODO add a mutex for when we load the localizations, in case people want to load the localizations
# at runtime
# all localizations are saved in this class variable
# l... | true |
111a9823d3456f1dac7e8b866974ce5cf14cf5f2 | Ruby | rcqls/R4rb | /lib/R4rb/init.rb | UTF-8 | 2,345 | 2.515625 | 3 | [] | no_license | ## Attention "...\n..." have to be replaced by "...\\n..."
## example : 'cat("toto\n")' fails but not 'cat("toto\\n")'
## more surprisingly, this fails even in comment '# cat("toto\n")'
module R2rb
def R2rb.init(args=["--save","--slave","--quiet"])
@@initR=R2rb.initR(args) unless R2rb.alive?
end
def R2rb.... | true |
21d99b497ead497e411c4f1c4c0c23803fd0ec8a | Ruby | psaha84/toy_robot | /main.rb | UTF-8 | 197 | 3.015625 | 3 | [] | no_license | require_relative 'lib/simulator'
simulator = Simulator.new
puts "Enter command (EXIT to quit): "
loop do
command = gets
break if command =~ /exit/i
simulator.execute_command(command)
end
| true |
8375a9916c867c74014eca5076c78aefca15932e | Ruby | ngotau/redmine_timesheet | /app/helpers/timecards_helper.rb | UTF-8 | 3,362 | 2.734375 | 3 | [] | no_license | module TimecardsHelper
#convert full time format to HH:MM format
def format_time(time)
if (time != nil)
return time.strftime("%H:%M")
else
return ""
end
end
#convert object
def format_time_card(time_card)
if (time_card == nil)
return
end
t... | true |
ef7d4c0ecf49ef89be91c6964f6bc89ec20cffee | Ruby | UNC-Libraries/sierra-postgres-utilities | /lib/sierra_postgres_utilities/data/records/generic.rb | UTF-8 | 3,408 | 2.640625 | 3 | [] | no_license | module Sierra
module Data
# Methods common to Sierra records (Bib, Item, etc. -- things reflected in
# record_metadata.)
module GenericRecord
# @example
# #=> "#<Sierra::Data::Item i1000001a @values={:id=>450972566081, ...
# :is_available_at_library=>true}>"
def inspect
... | true |
869424c5284f8c6bd53ba832e23eafb7eb3f2780 | Ruby | BackupTheBerlios/nursery-svn | /trunk/rubywars/src/ship.rb | UTF-8 | 1,129 | 3.140625 | 3 | [] | no_license | # Ship class definitions
#
# This is one part of:
#
# Rubywars (working title) -- A scrolling space shooter game
# Copyright (C) Greg Colombo, John Croisant 2005
require 'src/rocket'
require 'rubygame'
class Ship < Rocket
def initialize(*args)
super
@launch = []
end
# Draw the ship using the default Rubyga... | true |
6bfb97d1057a3dcdfb521bb43924c490bc47528c | Ruby | astragalo/ruby-examples | /Metodos_acc.rb | UTF-8 | 199 | 3.609375 | 4 | [] | no_license | class HolaMundo
def initialize(nombre="Sin nombre")
@nombre = nombre
end
attr_accessor:nombre
end
obj= HolaMundo.new("Dr Astragalo")
#El atributo es convertido a un metodo
puts obj.nombre
gets() | true |
1e35861adf6b7cf8faa83c99519bc074df0173db | Ruby | cirediatpl/oo-my-pets-yale-web-yss-052719 | /lib/owner.rb | UTF-8 | 566 | 3.171875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Owner
attr_reader :species, :pets
attr_accessor :name
@@all = []
def initialize(species)
@species = species
@@all << self
@pets = {:fishes => [], :dogs => [], :cats => []}
end
def self.all
@@all
end
def self.count
@@all.count
end
def self.reset_all
@@all.clear
end
... | true |
6616a1700b43f004581a8d88e5dc303060e89452 | Ruby | duranangela/enigma | /test/encrypt_decrypt_test.rb | UTF-8 | 1,880 | 2.984375 | 3 | [] | no_license | require './test/test_helper'
require 'minitest/autorun'
require 'minitest/pride'
require './lib/encrypt_decrypt'
class EncryptDecryptTest < Minitest::Test
def test_it_exists
cipher = EncryptDecrypt.new('enc', 'this is so secret ..end..', '12345', '051618')
assert_instance_of EncryptDecrypt, cipher
end
... | true |
d35b36f72afebe2c31129c373cae081598fc6a96 | Ruby | thooams/ui_bibz | /lib/ui_bibz/ui/core/navigations/breadcrumb.rb | UTF-8 | 3,318 | 2.78125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'ui_bibz/ui/core/navigations/components/breadcrumb_link'
module UiBibz::Ui::Core::Navigations
# Breadcrumb
#
# Indicate the current page's location within a navigational hierarchy.
# Separators are automatically added in CSS through +:before+ and +content+.
#
# This el... | true |
c3925cfeb49e35ac4174fbe6682dce63e6ade333 | Ruby | ihcsim/ruby-tutorial | /src/games/game.rb | UTF-8 | 1,350 | 3.078125 | 3 | [] | no_license | require './invalid_game_error'
require './persistable'
require './emulation'
class Game
include Persistable
include Emulation
def initialize(name, options=[])
raise InvalidGameError unless name
@name = name
@year = options[:year]
@system = options[:system]
@release_date = options[:release_da... | true |
dc50e1c657a0f42ab55e3aecf346e00ddd19e3be | Ruby | simpledotorg/simple-server | /lib/tasks/scripts/get_bsnl_account_balance.rb | UTF-8 | 1,638 | 2.90625 | 3 | [
"MIT"
] | permissive | class GetBsnlAccountBalance
# (15_000 * 3 patients from current experiments + 15_000 patients from stale experiments) * 3 segments per message
# We're unlikely to actually hit this number on any given day, but we'd like to alert early if we're close to the limit
MAX_DAILY_MESSAGE_SEGMENT_COUNT = 50_000 * 3
BALA... | true |
e7b52ac2e73ca624416639af3fe5a8342ddddf50 | Ruby | icarus4/easy_ab | /lib/easy_ab/experiment.rb | UTF-8 | 5,103 | 2.53125 | 3 | [
"MIT"
] | permissive | module EasyAb
class Experiment
attr_reader :name, :variants, :weights, :rules, :winner, :scope
def initialize(name, options = {})
@name = name.to_s
@variants = options[:variants].map(&:to_s)
@weights = options[:weights]
@rules = options[:rules]
@scope = options[:scope... | true |
dcd14795c6f38863793f05748aade04aa7317b86 | Ruby | softprops/yuki | /lib/cast_system.rb | UTF-8 | 935 | 3.015625 | 3 | [
"MIT"
] | permissive | module CastSystem
TO = {
:numeric => lambda { |v| v.to_i },
:float => lambda { |v| v.to_f },
:timestamp => lambda { |v|
unless v.kind_of? Time
Time.at(v.to_i)
else
v
end
},
:boolean => lambda { |v|
case v
when "false" then false
when... | true |
9d9cf351d5842159e0cf91f053f059fc4b7567ad | Ruby | snmgian/translate | /test/lib/test_translator.rb | UTF-8 | 3,497 | 2.59375 | 3 | [] | no_license | require 'lib/translator'
require 'minitest/autorun'
require 'rr'
class TestTranslator < MiniTest::Unit::TestCase
include RR::Adapters::RRMethods
def test_translate
text = 'text'
from = 'fr'
to = 'it'
mock(Translator).get(Translator::TRANSLATE_URI, :query => {:text => text, :sl => from, :tl => to... | true |
bc556d341741299cfb659af5d97f0e8050bda429 | Ruby | at1as/advent-of-code | /2018/day01/part_2.rb | UTF-8 | 248 | 2.9375 | 3 | [] | no_license | data = File.open("./input.txt", "r").readlines()
freqs = []
data.map(&:to_i).cycle.inject(0) do |acc, n|
current_freq = acc + n
if freqs.include? current_freq
puts current_freq
break
end
freqs << current_freq
current_freq
end
| true |
3439cad0317b36512e4b4894df1747060ad3570c | Ruby | sTinGe/RubyTrails | /07_blocks_procs_lambdas.rb | UTF-8 | 1,116 | 4.375 | 4 | [] | no_license | # Usage of yield
def yield_name(name)
puts "In the method! Let's yield."
yield("Kim")
puts "In between the yields!"
yield(name)
puts "Block complete! Back in the method."
end
yield_name("Eric") { |n| puts "My name is #{n}." }
yield_name("Track") { |n| puts "My name is #{n}." }
# Proc Syntax example
group_... | true |
004b450ad48c8db9b2dd1c6691be66886bcecd2b | Ruby | mitsu-sasaki/new-task-list | /app/helpers/sessions_helper.rb | UTF-8 | 622 | 2.53125 | 3 | [] | no_license | module SessionsHelper
def current_user
@current_user ||= User.find_by(id: session[:user_id])
# if @current_user.blank?
# @current_user = User.find_by(id:session[:user_id]) #userを探して@current_userにセットとする
# end
# @current_user
# if # crerrnt_userに中身がある場合
# @current_user #何もしないのでそのまま返す
# e... | true |
b69c5caaa35299094bb7e300dc695cb8b9445574 | Ruby | kwdavidlau/LHL_Programs | /lighthouse-test-oop-electronics_shop_rev1/spec/06_customer_can_add_to_cart.rb | UTF-8 | 1,954 | 3.125 | 3 | [] | no_license | require_relative 'spec_helper'
describe Customer do
describe '#add_to_cart' do
before :each do
# cheap prices cause they are used ;)
@android = Cellphone.new('HTC pos', 400, 'HTC')
@iphone_7s = Cellphone.new('iPhone 7S', 600, 'Apple')
@expensive_tv = Tv.new('54" LG Smart T... | true |
2cc55b682853a8f08b5d2d726aabd6862771f99f | Ruby | sam2500/codesignal-my-solutions | /ruby/Arcade/Intro-43-isBeautifulString/verify.rb | UTF-8 | 429 | 2.734375 | 3 | [] | no_license | load (includefile = 'isBeautifulString.rb')
load ('../../test.rb')
t = Test.new(includefile)
t.test(["bbbaacdafe"],true)
t.test(["aabbb"],false)
t.test(["bbc"],false)
t.test(["bbbaa"],false)
t.test(["abcdefghijklmnopqrstuvwxyzz"],false)
t.test(["abcdefghijklmnopqrstuvwxyz"],true)
t.test(["abcdefghijklmnopqrstuvwxyzqw... | true |
488bbd2046da0ce4c6ae532b114565c2ffa41a05 | Ruby | mcpenchel/batch-513 | /livecodes/food-delivery-day-1/app/controllers/sessions_controller.rb | UTF-8 | 677 | 2.859375 | 3 | [] | no_license | require_relative '../views/sessions_view'
class SessionsController
def initialize(employee_repo)
@employee_repo = employee_repo
@view = SessionsView.new
end
def sign_in
# 1) Pedimos o username (view)
username = @view.ask_for('username')
# 2) Pedimos a senha (view)
password = @view.ask_f... | true |
1f777af64497616b0b56c9d68b55cc558dc97475 | Ruby | Siim/lounasaika | /lib/_amica.rb | UTF-8 | 982 | 2.859375 | 3 | [] | no_license | # encoding: utf-8
class Amica
def self.get_meals(data, meals)
index = 0
days = ["Maanantai", "Tiistai", "Keskiviikko", "Torstai", "Perjantai", "Lauantai", "Sunnuntai"]
data["LunchMenus"].each do |day|
menus = day["SetMenus"]
menus.each do |menu|
if day["DayOfWeek"].present?
... | true |
46810ca406d2b87c34b53c0fc37009f5fee0f7d6 | Ruby | oswen138/tamagotchi | /projectcreator.rb | UTF-8 | 2,989 | 3.125 | 3 | [] | no_license | #!/usr/bin/env ruby
require('Fileutils')
def make_files(class_array, project_name)
class_array.each do |class_name|
File.write("./#{project_name}/lib/#{class_name}.rb", "class #{class_name.capitalize()}\nend")
File.write("./#{project_name}/spec/#{class_name}_spec.rb",
"require('#{class_name}')
describe ('... | true |
44965c9f0a03274f6fc1589fcc191819018b0ad3 | Ruby | shengdzhang/ProjectEuler | /euler160.rb | UTF-8 | 4,396 | 4.3125 | 4 | [] | no_license | # Problem:
#
# For any N, let f(N) be the last five digits before the trailing zeroes in N!.
# For example,
#
# 9! = 362880 so f(9)=36288
# 10! = 3628800 so f(10)=36288
# 20! = 2432902008176640000 so f(20)=17664
#
# Find f(1,000,000,000,000)
def exp(base, exp)
return 1 if exp == 0
return base if... | true |
b4b370c20ddf93a8296174888433a9f5ba09970f | Ruby | collinschaafsma/arena_api | /gems/arena/lib/arena/contest_type/napping.rb | UTF-8 | 578 | 3.28125 | 3 | [
"MIT"
] | permissive | module Arena
module ContestType
class Napping < ContestTypeBase
CONTEST_DESC = 'See who can nap the hardest!'
attr_reader :pets
def initialize(pets)
@pets = pets
super(pets, strategy)
end
def strategy
{
strength: 1, #doesn't matter
spee... | true |
1777ddd3b7ef228582b8db79dfb82ea38ff186e3 | Ruby | sluongo718/ruby-objects-has-many-lab-onl01-seng-pt-081720 | /lib/artist.rb | UTF-8 | 544 | 3.15625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive |
require "pry"
class Artist
attr_accessor :name
def initialize(name)
@name = name
end
def songs
#access the Song class and get all the songs. Find a way to only select those whose artist is the current artist
Song.all.select {|the_song| the_song.artist == self}
end
... | true |
3fdc282edc3848dd4df537170afcd3efd9134306 | Ruby | ggalue/ruby | /all_math.rb | UTF-8 | 567 | 4.75 | 5 | [] | no_license | #question 6 day 5
def math_menu(num1, num2)
puts "------------"
puts "1. Add"
puts "2. Subtract"
puts "3. Multiply"
puts "4. Divide"
choice = gets.chomp.to_i
if choice == 1
puts "Your answer is #{num1 + num2}"
elsif choice == 2
puts "Your answer is #{num1 - num2}"
elsif choice == 3
puts "Your answer i... | true |
0760da1948d4fa93d7bd4a703c6b7614c76a001c | Ruby | metwit/metwit-ruby-sdk | /lib/metwit/metag.rb | UTF-8 | 5,137 | 3 | 3 | [
"MIT"
] | permissive | require 'rgeo'
require 'rgeo-geojson'
require 'httparty'
require 'json'
module Metwit
# Metags are the weather tags
class Metag
include HTTParty
base_uri(BASE_URL+'/metags')
# Mandatory and guaranteed.
# Weather is an Hash with two keys: :status and :details
# Valid :status values are:
# ... | true |
c6f7777e745422547b05a1316716398e65fad785 | Ruby | reidjs/leet | /odd_even_linked_list.rb | UTF-8 | 309 | 3.21875 | 3 | [] | no_license | class LinkedList
attr_reader :head, :tail
def initialize
@head = Node.new
@tail = Node.new
end
def insert(node)
end
end
class Node
attr_accessor :next, :val
@@last_node = 0
def self.assign_val
@@last_node += 1
end
def initialize
@val = Node.assign_val
end
end | true |
de3dd5d8150e1502d843eef87b86754a7b32c5b8 | Ruby | joshmgross/view_components | /lib/primer/forms/dsl/multi_input.rb | UTF-8 | 1,299 | 2.515625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Primer
module Forms
module Dsl
# :nodoc:
class MultiInput < Input
include InputMethods
attr_reader :name, :label
def initialize(name:, label:, **system_arguments)
@name = name
@label = label
super(**system_a... | true |
b5016b35f6f416fefe1f2760449d84e1a73b6695 | Ruby | datafordevelopment/posting-pro | /sinatra/skills_engine.rb | UTF-8 | 1,468 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'rest-client'
require 'json'
# Wrap calls to the SkillsEngine API & handle auth
class SkillsEngine
attr_reader :token_expiry, :has_updated_token
def initialize(access_token, token_expiry)
@access_token = access_token
@token_expiry = token_expiry
@has_updated_token = false
@test_json = Fil... | true |
858f634d071adaa137926594741d7ed510909d56 | Ruby | bellajak/learn-co-sandbox | /practice.rb | UTF-8 | 311 | 3.6875 | 4 | [] | no_license | adef my_method(array)
array.each do |movie|
if movie == "inherent vice"
puts "my favorite movie is #{movie}"
else
puts "one of my favorite movies is #{movie}"
end
end
end
movies_array = ["inherent vice", "the informant", "truman show", "phantom thread"]
my_method(movies_array)
| true |
c7a8905ef08f22b8ddda8a2574db222309af2d12 | Ruby | kkontio/lounaat2 | /lib/scraper/plugins/sello_plugin.rb | UTF-8 | 1,243 | 2.75 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
class SelloPlugin
parse_sello = lambda do |url|
# Result hash where the key is date and value an array of lunch item descriptions as strings.
parsed_results = {}
# Check both the current and next week. Replace <cweek> in url with an actual week number.
urls = []
today = Date.tod... | true |
ca07a4e5f5fcfb239c0a2a5babcdbdcdea200192 | Ruby | brendan-mcgrady/w3_weekend_hw | /models/customer.rb | UTF-8 | 1,116 | 3.1875 | 3 | [] | no_license | require_relative('../db/sqlrunner')
class Customer
attr_accessor :name, :funds
attr_reader :id
def initialize(info)
@id = info['id'].to_i() if info['id']
@name = info['name']
@funds = info['funds'].to_i()
end
def save()
sql = 'INSERT INTO customers (name, funds) VALUES ($1, $2) RETURNING i... | true |
3501b67190155415bac618ea101dcdc3003e29a1 | Ruby | gcrk/seir41-homework | /Andre Anggono/week_04/day_02/mta_lab.rb | UTF-8 | 6,434 | 3.6875 | 4 | [] | no_license | require 'pry'
# Subway layout hash
subway = {
:N => ['Times Square', '34th', '28th', '23rd', 'Union Square', '8th'],
:L => ['8th', '6th', 'Union Square', '3rd', '1st'],
:'6' => ['Grand Central', '33rd', '28th', '23rd', 'Union Square', 'Astor Place']
}
# Planner class to generate a new subway planner. Takes an a... | true |
8d72b8bfe615b371dda02ae8e832904168a74df7 | Ruby | robertexe/cartoon-collections-prework | /cartoon_collections.rb | UTF-8 | 600 | 3.609375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll_call_dwarves(roll_call)
roll_call.each_with_index do |dwarf, i|
puts "#{i+1} #{dwarf}"
end
end
def summon_captain_planet(planeteer_calls)
planeteer_calls.map do |calls|
calls = calls[0].upcase + calls.slice(1..calls.length-1) + "!"
end
end
def long_planeteer_calls(calls)
calls.any? do |word... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.