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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e2211ebec16bf33506232b5f87247ae80b12fb70 | Ruby | aaronwtan/RB101 | /small_problems/easy2/q8.rb | UTF-8 | 1,520 | 4.6875 | 5 | [] | no_license | # Sum or Product of Consecutive Integers
# Write a program that asks the user to enter an integer greater than 0,
# then asks if the user wants to determine the sum or product
# of all numbers between 1 and the entered integer.
# Examples:
# >> Please enter an integer greater than 0:
# 5
# >> Enter 's' to compute the... | true |
11e4a67576cf1b2e51675b2549a914b83d7f904f | Ruby | IrakliZ/webboard | /app/helpers/sessions_helper.rb | UTF-8 | 1,173 | 3.09375 | 3 | [
"MIT"
] | permissive | ##
# Class for making user validation easier
module SessionsHelper
##
# Helper function for signing in an user, creating a cookie on the browser, so that when an user leaves
# without logging off and returns, they will still be logged in.
def sign_in(user)
user_token = User.new_user_token
cookies.permanent[:u... | true |
014b7f2936e2cc3f08c95500f5829dc59e389996 | Ruby | AJ8GH/ruby-udemy | /hashes/each_key_and_each_value_methods.rb | UTF-8 | 470 | 3.734375 | 4 | [] | no_license | salaries = {director: 100_000, producer: 200_000,
ceo: 3_000_000, assistant: 200_000}
salaries.each_key {|position|
puts "Employee Record: -----"
puts "#{position}"}
salaries.each_value {|salary| puts "The next employee earns #{salary}"}
# exercise
def key_arr(hash)
keys = []
hash.each {|k,v| k... | true |
1f4ae5f5c0f6e5e31405c3d1c7778a59ee76c140 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/800/feature_try/method_source/23898.rb | UTF-8 | 272 | 3.265625 | 3 | [] | no_license | def combine_anagrams(words)
hash = Hash.new
words.each do |word|
key = word.downcase.split("").sort.join
hash[key] = Array.new if (hash[key] == nil)
array = hash[key]
array.push(word)
hash[key] = array
array = nil
end
return hash.values
end | true |
1e3fdb52acfbd3b8a4e93cd6ab81eebf74b26e89 | Ruby | diegoa314/artdaq_lme | /artdaq_dune/tools/RunDriver.rb | UTF-8 | 5,047 | 2.859375 | 3 | [] | no_license | #!/usr/bin/env ruby
# JCF, 2-11-14
# This script is meant to provide a very simple example of how one
# might control an artdaq-based program from the command line. The
# idea is that this script uses its command line arguments to generate
# a FHiCL document which in turn is passed to the artdaq-demo's
# "driver" pro... | true |
522e75101f729e6c2854833886eb021ab6651325 | Ruby | uohull/hull-history-centre | /lib/import/ead/piece.rb | UTF-8 | 834 | 2.5625 | 3 | [] | no_license | require_relative 'item'
module Ead
class Piece < Item
class << self
def root_xpath
'c[@otherlevel = "Piece"]'
end
# The xpath to the parent Item that the Piece belongs to
# (relative path from the Piece node)
def item_xpath
"ancestor::#{Ead::Item.root_xpath}[1]"
... | true |
a85a84beab387ad351ddb692898d96fc8a874f1a | Ruby | dmullek/dominion | /app/cards/forge.rb | UTF-8 | 1,827 | 2.734375 | 3 | [] | no_license | class Forge < Card
def starting_count(game)
10
end
def cost(game, turn)
{
coin: 7
}
end
def type
[:action]
end
def play(game, clone=false)
@play_thread = Thread.new {
ActiveRecord::Base.connection_pool.with_connection do
action = TurnActionHandler.send_choose_ca... | true |
add6f98c2d9a40d77240c698ab4198a61e98042a | Ruby | LafayetteCollegeLibraries/webvtt-converter | /lib/webvtt/cue.rb | UTF-8 | 3,699 | 3.140625 | 3 | [] | no_license | # frozen_string_literal: true
module WebVTT
# Small wrapper class for captions. When a caption has a speaker, their name
# is put into a +<v>+ tag to identify them.
class Caption
attr_reader :speaker, :text
# @param [Hash] options
# @option [String] speaker
# @option [String] text
def initia... | true |
2d9ccd52ea50be81f61dd268bd22772e4ef9e34a | Ruby | UjwalBattar/leet-code | /ruby/plus_one.rb | UTF-8 | 718 | 4.09375 | 4 | [] | no_license | # Given a non-empty array of digits representing a non-negative
# integer, plus one to the integer.
#
# The digits are stored such that the most significant digit is at
# the head of the list, and each element in the array contain a
# single digit.
#
# You may assume the integer does not contain any leading zero, excep... | true |
df9f34ff369043b070fefadf2d8a61f4ead5041e | Ruby | tekt8tket2/primary_interview | /album.rb | UTF-8 | 364 | 3.34375 | 3 | [] | no_license | class Album
attr_reader :played, :artist
def initialize(title, artist)
@title = title
@artist = artist
@played = false
end
def play
@played = true
end
def listing_string
"\"#{@title}\" by #{@artist} (#{played_string})"
end
private
def played_string
if @played
'played'
... | true |
8dddbe7708b0fb783edc99471e66a8b2797e05bd | Ruby | jschanker/ruby-text2code-old | /variables.rb | UTF-8 | 6,319 | 3.203125 | 3 | [] | no_license | require './instruction.rb'
class Variables
def self.set(inst)
# arg[0] = var name, arg[1] = "to", arg[2] = value
instance_variable_set "@#{inst.variable}", inst.values[0]
self.send(:attr_accessor, "#{inst.variable}")
return instance_variable_get "@#{inst.variable}"
#MutableNum.send(:set, args)
end
... | true |
0eaab6331781e99a88ed65aad3d64361a719fe34 | Ruby | ruby-git/ruby-git | /lib/git/diff.rb | UTF-8 | 3,656 | 2.71875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Git
# object that holds the last X commits on given branch
class Diff
include Enumerable
def initialize(base, from = nil, to = nil)
@base = base
@from = from && from.to_s
@to = to && to.to_s
@path = nil
@full_diff = nil
@full_diff_files = nil
@stats = nil
... | true |
f67a7c9fda8febf2aedca47218ba50242e444306 | Ruby | jinxue447461686/docs.snap-ci.com | /lib/helpers/as_array_helper.rb | UTF-8 | 299 | 2.890625 | 3 | [] | no_license | module AsArrayHelper
def monospaced_array_to_sentence_string(input)
as_array(input).collect {|i| "`#{i}`" }.join(', ')
end
def monospaced_array_to_bullet_list(input)
as_array(input).collect {|i| "* `#{i}`" }.join("\n")
end
private
def as_array(input)
input || []
end
end
| true |
fd49ce6a87c9bde8bbf810f51e2c0b38a71d63f9 | Ruby | Tricktionary/FakeBookGraphQL | /app/graphql/resolvers/search_song_by_page.rb | UTF-8 | 1,014 | 2.65625 | 3 | [] | no_license | # frozen_string_literal: true
module Resolvers
class SearchSongByPage < Resolvers::BaseResolver
type Types::SongType.connection_type, null: false
argument :title, String, required: true
argument :page_number, Integer, required: true
def resolve(title:, page_number:)
if title.present?
... | true |
e8b867d4551498c9156cbd05693ecfa3eabbbc70 | Ruby | james-wallace-nz/ls_rb109 | /lesson_3/medium_1.rb | UTF-8 | 6,804 | 4.53125 | 5 | [] | no_license | # 1
# Let's do some "ASCII Art" (a stone-age form of nerd artwork from back in the days before computers had video screens).
# For this practice problem, write a one-line program that creates the following output 10 times, with the subsequent line indented 1 space to the right:
# The Flintstones Rock!
# The Flintst... | true |
18a6c5ade8028df68b7f50ae3ccb0e55f577e62b | Ruby | qtlove/Tools | /lib/new_main.rb | UTF-8 | 965 | 2.53125 | 3 | [] | no_license | sk = "新闻 行业 资讯,http://www.51hejia.com/xinwen/;" +
"卖场,http://www.51hejia.com/maichang/;" +
"博客,http://blog.51hejia.com/;"
hk = {}
a1 = sk.split(";")
0.upto(a1.size-1) do |i|
a2 = a1[i].split(",")[0].split(" ")
0.upto(a2.size-1) do |j|
k = a2[j]
v = a1[i].split(",")[1]
hk[k] = v
end
end
p hk["新闻"]
... | true |
426d90872985e3e04d0d4787b9da24d149ef7b5f | Ruby | javierrcc522/prime_numbers | /lib/prime_numbers.rb | UTF-8 | 212 | 3.296875 | 3 | [] | no_license | #! usr/bin/env ruby
class Primes
def magic(num)
array = (2..num).to_a
i = 2
while (i < Math.sqrt(num)) do
array.reject! { |r| r % i === 0 && r != i }
i += 1
end
array
end
end
| true |
e0330a56f493a220d7c3703f6bb625733e79c1c7 | Ruby | pwinning1991/testingruby | /files.rb | UTF-8 | 917 | 3.40625 | 3 | [] | no_license | #working with files
File.open("/Users/pwinnington/ruby/teams.txt", 'w+'){|f| f.write("Twins,Mets,Yankees")}
# r - reading
# a - appending to a file
# w - just writing
# w+ - reading and writing
# a+ - open a file for reading and appending
# r+ - opening a file for updating both readng and writing
file_to_save = File... | true |
43bce6ec4fb39923d53941c99d160f3ed0ea2280 | Ruby | eripheebs/learn_to_program | /ch14-blocks-and-procs/program_logger.rb | UTF-8 | 286 | 3.359375 | 3 | [] | no_license | def program_log desc, &block
puts "Beginning #{desc.inspect}..."
result = block.call
puts "...#{desc.inspect} finished, returning: #{result}"
end
program_log "outer block" do
program_log "inner block" do
"Hello"
end
program_log "second inner block" do
"Bye"
end
true
end | true |
3c9f25cc5844162fa40110c7f8c0bc9aac5ee18d | Ruby | drish/rioter | /lib/rioter/v4/leagues.rb | UTF-8 | 2,714 | 2.59375 | 3 | [
"MIT"
] | permissive | require "rioter/requester"
require "rioter/v4/league_entry"
module Rioter
module V4
class Leagues < Rioter::Requester
def initialize(api_key, region)
super(api_key, region)
end
# GET_getLeagueEntries
def by_queue_tier_division(queue:, tier:, division:, page:)
url = "#{ba... | true |
5fc603e1c61527c23c145c2d574514c3b6d9aff2 | Ruby | c0ded0g/RPi_GPIO_via_web | /RPi_GPIO_via_web.rb | UTF-8 | 19,088 | 3.03125 | 3 | [] | no_license | #################################################################################
# #
# FILE: RPi_GPIO_via_web.rb #
# #
# USAGE: sudo ruby RPi_GPIO_via_web.rb #
# #
# DESCRIPTION: Access and control RPi GPIO via the web. #
# My first attempt at this (Ruby, Sinatra), so... | true |
9ce3a90910a1f9fe06b4960231654392d69589a3 | Ruby | Cobmart199/CIS282_HomeWorkLectures | /acronym_Balonwu.rb | UTF-8 | 575 | 3.671875 | 4 | [] | no_license | ############################################################
# Name : Cyril O. Balonwu
# Assignment: Extra Credit Acronym
# Date: 26/11/2018
# Class: CIS 282
# Description: Extra Credit Acronym
############################################################
puts "Please Enter a complete English ... | true |
5de3be1a4701db78b8cd7d7f4fa8a585f44ad7a8 | Ruby | dqmrf/dive-in-ruby | /tasks/catch_and_ignore_specific_exception/bootstrap2.rb | UTF-8 | 816 | 3.078125 | 3 | [] | no_license | require 'pry'
require_relative 'my_error'
require_relative 'stripe_error'
class SubscriptionsHelper
attr_reader :error
def charge
# raise StripeError.new('Error in :charge method!')
update_subscription
# raise StripeError.new('Error 2 in :charge method!')
puts '>> :charge CODE EXECUTED!'
true
... | true |
7078354572cbae2aedf4e5dd12cfa8a60704f9d2 | Ruby | morganric/embedtree_old | /app/models/ability.rb | UTF-8 | 2,202 | 2.53125 | 3 | [] | no_license | class Ability
include CanCan::Ability
attr_accessor :user
def initialize(user)
alias_action :show, :update, :index, :to => :change
@user = user || User.new
determine_ability
end
private
def determine_ability
if user.has_role? :admin
can :manage, :all
elsif user.has_role? :us... | true |
cf03eeaf3867eb35f79aff90bc52da77bcb27bcd | Ruby | CocoaPods/CocoaPods | /lib/cocoapods/sandbox/headers_store.rb | UTF-8 | 5,775 | 2.734375 | 3 | [
"MIT"
] | permissive | module Pod
class Sandbox
# Provides support for managing a header directory. It also keeps track of
# the header search paths.
#
class HeadersStore
SEARCH_PATHS_KEY = Struct.new(:platform_name, :target_name, :use_modular_headers)
# @return [Pathname] the absolute path of this header direc... | true |
991ea9f1b1a2475a68c814978db4ef2ccff0e980 | Ruby | osmondvail81/geekmap | /app/models/linkable.rb | UTF-8 | 2,223 | 2.515625 | 3 | [] | no_license | module Linkable
##################################
### INSTANCE METHODS
##################################
#----------------------------------
# INTERFACE: Badges
#----------------------------------
#User.first.links << Link.create(:website => Website.find_or_create_by_uri(:uri => "google.co.uk"), :l... | true |
ef1c6178af5def03d957e4807859e7a4c08bc0b7 | Ruby | DougieDev/war_or_peace | /lib/game.rb | UTF-8 | 1,522 | 3.9375 | 4 | [] | no_license | require './lib/card'
require './lib/deck'
require './lib/player'
require './lib/turn'
class Game
attr_reader :player1,
:player2,
:turn_count
def initialize(player1, player2)
@player1 = player1
@player2 = player2
@turn_count = 1
end
def welcome
p "Welcome to War! (o... | true |
11c8ca06c7aafaca272fea6c674e8c6a7bde9b04 | Ruby | sean-yeoh/pairbnb | /spec/models/user_spec.rb | UTF-8 | 2,984 | 2.65625 | 3 | [] | no_license | require "rails_helper"
RSpec.describe User, :type => :model do
let(:name) { "sean" }
let(:email) { "sean@hotmail.com" }
let(:password) { "12345678" }
let(:sean) { User.new(name: name, email: email, password: password) }
context "valid input" do
describe "can be created when all attributes are pres... | true |
0d44819fd66efced93f71bd6904ad37a1b9aa8f8 | Ruby | smallm/RubyQuiz | /7-Countdown/spec/expression_spec.rb | UTF-8 | 1,712 | 3.09375 | 3 | [] | no_license | require 'expression.rb'
describe Expression do
it "can get its constituent base numbers" do
basenode = Expression.new(522,
Operation.new(
Expression.new(500,
Operation.new(
Expression.new(100, nil), 'x', Expression.new(5, nil)
... | true |
c49fd7d31c1c2d9de247fa329e4d61e16976c0fc | Ruby | arthurstomp/PSO | /lib/pso_binary.rb | UTF-8 | 1,021 | 2.875 | 3 | [] | no_license | require File.join(File.dirname(__FILE__),'pso')
class PSOBinary < PSO
def s_function(velocity_i)
1/(1+Math.exp(-velocity_i))
end
def new_position(position_i, velocity_i)
s = s_function(velocity_i)
if rand < s
return 1
else
return 0
end
end
def random_position(n_dimensions)... | true |
b880cf925ee96f55670e3da9e57c665065d5f6e9 | Ruby | keme787/API-Helper-files | /sms/sending/enqueing/ruby.rb | UTF-8 | 827 | 2.640625 | 3 | [] | no_license | require './AfricasTalkingGateway'
username = "MyAfricasTalkingUsername";
apikey = "MyAfricasTalkingAPIKey";
to = "+254711XXXYYY,+254733YYYZZZ";
message = "I'm a lumberjack and it's ok, I sleep all night and I work all day"
sender = nil # sender = "shortCode or sender id"
bulkSMSMode = 1 # This should alw... | true |
2d2e426d19fa228e91d9ef79ad778ad2fcbcbb2e | Ruby | JJavier98/Support | /2º/FIS/practicas/practica 5/decine_ruby/decine/lib/premio.rb | UTF-8 | 654 | 2.65625 | 3 | [] | no_license | # encoding: UTF-8
#
# Fundamentos de Ingenieria del Software
# Grado en Ingeniería Informática
#
# 2014 © Copyleft - All Wrongs Reserved
#
# Ernesto Serrano <erseco@correo.ugr.es>
# Carlos Garrancho
# Pablo Martinez
#
module Decine
class Premio
def initialize(premio, categoria, año)
@premio =... | true |
0b36a6b6f0d92079261e5b13954862ec28595a95 | Ruby | learn-co-students/chi01-seng-ft-051120 | /week_2_code_along/run_file.rb | UTF-8 | 1,238 | 3.234375 | 3 | [] | no_license | require 'bundler'
Bundler.setup
require_relative 'dragon.rb'
require_relative 'rider.rb'
require_relative 'saddle.rb'
require 'pry'
### Dragon Instances ###
carl = Dragon.new("Carl", "grey", "male", false)
steph = Dragon.new("Steph", "yellow", "female", true)
jeff = Dragon.new("Jeff", "green", "male", true)
jasimine... | true |
10cefb4e483e4f9df2e5d229ee7350943f980c90 | Ruby | mavenlink/brainstem | /lib/brainstem/cli.rb | UTF-8 | 3,395 | 2.890625 | 3 | [
"MIT"
] | permissive | # Require all CLI commands.
Dir.glob(File.expand_path('../cli/**/*.rb', __FILE__)).each { |f| require f }
require 'brainstem/concerns/optional'
#
# General manager for CLI requests. Takes incoming user input and routes to a
# subcommand.
module Brainstem
class Cli
include Concerns::Optional
EXECUTABLE_NAME ... | true |
3503a9dc5c13984934df07184a72e17ed9442b2c | Ruby | chadjs/precourse | /Chapter 5/number.rb | UTF-8 | 191 | 3.84375 | 4 | [] | no_license | puts 'What is your favorite number?'
u_number = gets.chomp.to_i
n_number = u_number + 1
puts 'That\'s ok I guess.'
puts 'But, ' + n_number.to_s + ' would be a bigger, better favorite number!' | true |
2d946ab4169999e1a62dc767b2b7d0026308f269 | Ruby | sh6khan/ruby-algo | /graphs/kruskal/edge.rb | UTF-8 | 154 | 2.90625 | 3 | [] | no_license | class Edge
attr_accessor :start_node, :end_node
def initialize(start_node, end_node)
@start_node = start_node
@end_node = end_node
end
end
| true |
9190f0fd45b1fb9f3c5b4dc43e51a57b8e67496a | Ruby | realdev22/hackerrank-ruby | /lib/algorithms/implementation/caesar-cipher-1.rb | UTF-8 | 271 | 3.625 | 4 | [] | no_license | gets
n = gets
k = gets.to_i
def rotate(c, ref, k)
((c.ord - ref.ord + k) % 26 + ref.ord).chr
end
n.chars.each_with_index do |c, idx|
if c >= 'a' && c <= 'z'
n[idx] = rotate(c, 'a', k)
elsif c >= 'A' && c <= 'Z'
n[idx] = rotate(c, 'A', k)
end
end
puts n
| true |
bcfc89ad66fb4aa99029244a9a501a6e8fa3d5ac | Ruby | colin3131/SchoolProjects | /RubyRush/rubyist.rb | UTF-8 | 595 | 3.484375 | 3 | [] | no_license | # Rubyist Class, storing methods / details on rubyists
class Rubyist
def initialize(id)
@id = id
@real_ruby_count = 0
@fake_ruby_count = 0
@days = 0
end
# Reader for accessing Rubyist instance variables
attr_reader :id, :real_ruby_count, :fake_ruby_count, :days
# Increments days spent prospe... | true |
e12b120750ceb1b3ee29ef0ed4663dc86b40d3f4 | Ruby | burtlo/Frogger | /models/frog.rb | UTF-8 | 655 | 2.796875 | 3 | [] | no_license | class Frog < Metro::Model
property :position
property :angle
property :image, path: "80sFrogger.png"
event :on_down, KbLeft do
self.x -= horizonal_step
end
event :on_down, KbRight do
self.x += horizonal_step
end
event :on_down, KbDown do
self.y += veritical_step
end
event :on_down, ... | true |
a4d8e216e857a675c4e5c9752d4eba514f0910a5 | Ruby | nilesr/wg-scraper | /wg-scraper.rb | UTF-8 | 3,510 | 2.859375 | 3 | [] | no_license | require 'net/http'
require 'open-uri'
require 'digest'
require 'json'
if not (ARGV.length == 1 or ARGV.length == 2) then
puts "Usage: ruby wg2.rb <imagedir> [database]"
fail
end
puts "Grabbing thread index"
imagesdir = ARGV[0]
database = "db.json"
if ARGV.length == 2 then
database = ARGV[1]
end
catalog = JSON.parse(... | true |
468545729a4a17e9a4d220eb61c17bfb05b2155b | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/30728693cc60440892eafa199ab3d5e2.rb | UTF-8 | 334 | 3.53125 | 4 | [] | no_license | class Bob
def hey(stating_something)
if stating_something.to_s.strip == ""
response = "Fine. Be that way!"
elsif stating_something == stating_something.upcase
response = "Woah, chill out!"
elsif stating_something[-1,1] == "?"
response = "Sure."
elsif
response = "Whatever."
end
return response... | true |
dec8424ad687b45b8b4dc0e9ceea2c63f5f2a4e0 | Ruby | jentrim/course_101 | /lesson_5/ex15R2.rb | UTF-8 | 166 | 2.78125 | 3 | [] | no_license | arr = [{a: [1, 2, 3]}, {b: [2, 4, 6], c: [3, 6], d: [4]}, {e: [8], f: [6, 10]}]
arr.select do |h|
h.values.map.all? do |v|
v.all?{|int| int.even?}
end
end
| true |
f5e09f1c2999d34c0cf87127e39a520ed4002925 | Ruby | jblosch/ruby-exercises | /04_pig_latin/pig_latin.rb | UTF-8 | 461 | 3.546875 | 4 | [] | no_license | def translate(string)
transformed = []
suffix = "ay"
words = string.split(' ')
words.each do |x|
vowel_num = x =~ /[aeiou]/
if x[vowel_num] == 'u' && x[vowel_num - 1] == 'q'
cut = x.slice!(0..vowel_num)
transformed << x + cut + suffix
else
... | true |
dd485778af6d60357f4eda1125697430254658c6 | Ruby | Kouch-Sato/AtCoderProblems | /ABC/084/084C.rb | UTF-8 | 43 | 2.515625 | 3 | [] | no_license | if ("1" =~ /^[0-9]+$/)
p 1
else
p 0
end | true |
d2b82b9fde1fbefc97af6c9780c56fcfcb752af1 | Ruby | magdabm/ruby-exercises | /03_homework/00_prime_numbers.rb | UTF-8 | 830 | 4.09375 | 4 | [] | no_license | # Napisz program wyszukujący wszystkie liczby pierwsze z zadanego przedziału jako argumenty wywołania metodą Sita Eratostenesa
# $ ruby sieve_of_eratosthenes.rb 1 10
# Prime numbers: 2, 3, 5, 7
def prime_numbers(range)
ar = range.to_a
ar2 = []
if ar.min == 1
ar.delete(1)
else ar.min > 2
ar2 = ... | true |
b64ae89a032d2953f3a40f082293ad74081b4789 | Ruby | spaek14/sinatra | /app.rb | UTF-8 | 221 | 2.75 | 3 | [] | no_license | require 'sinatra'
get '/' do
'Hello World! how are you'
end
get '/named-cat' do
p params
@name = params[:name]
erb :index
end
get '/random-cat' do
@name = ["Amigo", "Misty", "Almond"].sample
erb :index
end
| true |
6b7520d66f4d4cec592687e06ba5bc0f1e242fef | Ruby | Nicolas-Reyland/metalang | /out/euler22.rb | UTF-8 | 391 | 2.890625 | 3 | [] | no_license | require "scanf.rb"
def score( )
scanf("%*\n")
len = scanf("%d")[0]
scanf("%*\n")
sum = 0
for i in (1 .. len) do
c = scanf("%c")[0]
sum += c.ord - "A".ord + 1
# print c print " " print sum print " "
end
return sum
end
sum = 0
n = scanf("%d")[0]
for i in (1 .. n... | true |
1b498558574c8c09dfeaf2862ee797ff4c388d70 | Ruby | jucdn/athome-startup | /app/helpers/peoples_helper.rb | UTF-8 | 247 | 2.515625 | 3 | [
"MIT"
] | permissive | module PeoplesHelper
def national_phone(phone)
national_phone = Phonelib.parse(phone)
return national_phone.national
end
def international_phone(phone)
local_phone = Phonelib.parse(phone)
return local_phone.e164
end
end
| true |
dfbdc9a51741f5598ec60691cd31b5a2a79ef0e0 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/ea00823ecadc4c348361b58a89552a25.rb | UTF-8 | 504 | 3.6875 | 4 | [] | no_license | class Bob
def hey msg
reply msg
end
def reply message
msg = Message.new message
if msg.silence?
'Fine. Be that way!'
elsif msg.yelling?
'Woah, chill out!'
elsif msg.asking?
'Sure.'
else
'Whatever.'
end
end
end
class Message
def initialize msg
@msg =... | true |
43c64f0bc1836c6f4763f5fb92b50f75a8652779 | Ruby | Brendaneus/the_odin_project | /ruby_programming/merge_sort.rb | UTF-8 | 550 | 3.75 | 4 | [] | no_license | def merge_sort arr
return arr unless arr.length > 1
arr_A = merge_sort arr[0...(arr.length / 2)]
arr_B = merge_sort arr[(arr.length / 2)..(-1)]
arr_C = []
until arr_A.empty? and arr_B.empty?
if arr_A.empty?
arr_C.push arr_B.shift
elsif arr_B.empty?
arr_C.push arr_A.shift
elsif arr_A.first < arr_B.fi... | true |
28ba0aa86e4ac07adc65ffbab848f773b266e6df | Ruby | iBryan6/G5-Automation-Tests-A-Team | /Main/PageObjects/Common/Auth.rb | UTF-8 | 607 | 2.734375 | 3 | [
"MIT"
] | permissive | require "rubygems"
require "webdrivers"
class LoginPage
def initialize(driver)
@driver = driver
end
def goToPage(url)
return @driver.navigate.to url
end
#ADD YOUR G5 EMAIL
def typeEmail
puts "***\nType your G5 email:"
email = gets
return @driver.find_el... | true |
ca0a50e0d537da248c9b8992f74cb19da4007e7f | Ruby | sourlows/352phish | /src/facebookAPI.rb | UTF-8 | 3,258 | 2.71875 | 3 | [] | no_license | #githubAPI.rb
#author: djw223 (Dustin Walker)
#email: djw223@mail.usask.ca
#ruby version: 1.9.3p448
#library version: 1.9.1
require 'koala'
require_relative "abstractAPI"
require 'pp'
class FacebookAPI < AbstractAPI
def initialize
@supported = [:name, :music, :email, :politician, :book, :author, :software]
#@p... | true |
a0369a6d37ae3d20247095d6c63991e617df7c53 | Ruby | diegopiccinini/docrails | /activerecord/lib/active_record/relation/predicate_builder.rb | UTF-8 | 4,653 | 2.59375 | 3 | [
"MIT",
"Ruby"
] | permissive | module ActiveRecord
class PredicateBuilder # :nodoc:
require 'active_record/relation/predicate_builder/array_handler'
require 'active_record/relation/predicate_builder/association_query_handler'
require 'active_record/relation/predicate_builder/base_handler'
require 'active_record/relation/predicate_b... | true |
db567aaf4c65e0bd04222808c795de0623de76e1 | Ruby | nwise/activeforecast | /spec/activeforecast_spec.rb | UTF-8 | 1,210 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "ActiveForecast" do
it "should initialize with no arguments" do
ActiveForecast::Forecast.new.should_not be nil
end
it "should initialize with one string argument" do
ActiveForecast::Forecast.new("KCAK").should_not be nil
end
... | true |
6500fc142e621b50fc797f950e8aa69bdddee988 | Ruby | MadBomber/lib_ruby | /rangify.rb | UTF-8 | 1,351 | 3.40625 | 3 | [] | no_license | # lib_ruby/rangify.rb
# convert and array of integers into an array of ranges.
def rangify(an_array)
result = []
list = an_array.sort.uniq
prev = list[0]
result = list.slice_before { |e|
prev, prev2 = e, prev
prev2 + 1 != e
}.map{|b,*,c| c ? (b..c) : b }
return result
end
def unrangify(an_arra... | true |
00cba55dec29972d35b8b5fb8b458693e94a50ab | Ruby | leo-holanda/learn_ruby | /06_timer/timer.rb | UTF-8 | 642 | 3.5625 | 4 | [] | no_license | def setTime(seconds)
minutes = seconds/60
seconds = seconds%60
hours = minutes/60
minutes = minutes%60
formatted = []
if hours < 10
formatted.push("0")
end
formatted.push(hours.to_s)
formatted.push(":")
if minutes < 10
formatted.push("0")
end
formatte... | true |
5e7f4fb40cb5098f8aef927f78e83b21c9458682 | Ruby | dmullek/dominion | /app/cards/council_room.rb | UTF-8 | 455 | 2.65625 | 3 | [] | no_license | class CouncilRoom < Card
def starting_count(game)
10
end
def cost(game, turn)
{
coin: 5
}
end
def type
[:action]
end
def play(game, clone=false)
@card_drawer = CardDrawer.new(game.current_player)
@card_drawer.draw(4)
game.current_turn.add_buys(1)
game.game_player... | true |
9032a0a32c125327ecc7ff438aec40c9ef3c27fe | Ruby | ChristopherDurand/Exercises | /ruby/oop/oo_basics_4/access_denied.rb | UTF-8 | 270 | 3.34375 | 3 | [
"MIT"
] | permissive | class Person
attr_reader :phone_number
def initialize(number)
self.phone_number = number
end
private
attr_writer :phone_number
end
person1 = Person.new(1234567899)
puts person1.phone_number
#person1.phone_number = 9987654321
puts person1.phone_number | true |
32800827083bb8f4154e2a577ae24218b499a3cb | Ruby | pramnora/ruby | /language/output/hw/hw03.rb | UTF-8 | 125 | 3.53125 | 4 | [] | no_license | # Variable declaration...
text="Hello, world!"
# Print variable to output screen...
puts text
# Output...
# Hello, world!
| true |
d8f69be69c2d077ecc841701870cce957cbed900 | Ruby | dlewiski/Leetspeak | /lib/leetspeak.rb | UTF-8 | 845 | 3.421875 | 3 | [] | no_license | class String
def leetspeak()
leet_array = []
new_words_array = []
words_array = self.split()
words_array.each do |word|
letters_array = word.split('')
letters_array.each do |letter|
if letter == "e"
letter = 3
new_words_array.push(letter)
elsif letter ==... | true |
5010b8ab2584af96249097e48337ad82987f7025 | Ruby | alec-horwitz/oo-email-parser-web-022018 | /lib/email_parser.rb | UTF-8 | 474 | 3.609375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Build a class EmailParser that accepts a string of unformatted
# emails. The parse method on the class should separate them into
# unique email addresses. The delimiters to support are commas (',')
# or whitespace (' ').
class EmailParser
attr_accessor :all
def initialize(emails)
self.all = emails
end
def... | true |
c644a01734c48e60cda676c9dcdd44f6cdb41377 | Ruby | sho-kasama/Todo-rails | /bin/scrape_navbar.rb | UTF-8 | 622 | 2.875 | 3 | [] | no_license | require 'open-uri'
require 'nokogiri'
# スクレイピング先のURL
url = 'http://matome.naver.jp/tech'
charset = nil
html = open(url) do |f|
charset = f.charset # 文字種別を取得
f.read # htmlを読み込んで変数htmlに渡す
end
# htmlをパース(解析)してオブジェクトを作成
doc = Nokogiri::HTML.parse(html, nil, charset)
doc.xpath('//li[@class="mdTopMTMList01Item"]').ea... | true |
af5237c1db579daf8d6dc479f9bff849a16875fe | Ruby | avonderluft/radiant-banner_rotator-extension | /lib/banner_rotator/tags.rb | UTF-8 | 2,509 | 2.546875 | 3 | [] | no_license | module BannerRotator::Tags
include Radiant::Taggable
desc %{
Selects a banner from the rotating banners available to this page.
If no banner is found for this page and banners are enabled, the page
will inherit from its parent. If no banners are found, or they are disabled for this page,
then the ... | true |
d00954737fbd5f1d47546e9af779c5c16c72f344 | Ruby | darthmacdougal/GARGoyle | /spec/GARGoyle_spec.rb | UTF-8 | 1,163 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'GARGoyle.rb'
RSpec.describe GARGoyle do
before(:each) do
@sequencer = GARGoyle::JobSequencer.new
end
it 'is an empty sequence' do
expect(@sequencer.process({})).to eq([])
end
it 'has a sequence of one job' do
expect(@sequencer.process(a: '')).to eq(['a'])
end
it 'has a sequence of... | true |
616e257d36a8b8972168cffe16b9ada73fd8bf4e | Ruby | barsoom/prawn_cocktail | /spec/recursive_closed_struct_spec.rb | UTF-8 | 1,085 | 2.765625 | 3 | [
"MIT"
] | permissive | require_relative "spec_helper"
require_relative "../lib/prawn_cocktail/utils/recursive_closed_struct"
describe RecursiveClosedStruct do
it "provides readers from a hash" do
subject = RecursiveClosedStruct.new(key: "value")
assert_equal "value", subject.key
end
it "raises when there's no such key" do
... | true |
72f9bcc8d2a8267aa071d0d5e2323d3fe4b26836 | Ruby | airhorns/acm | /lib/electric_fence_solver.rb | UTF-8 | 595 | 3.5 | 4 | [] | no_license | class ElectricFenceSolver
def initialize(exit)
@exit = exit.to_i
end
def solve
self.find_routes(0, 0) + 1
end
def find_routes(x, y)
count = 0
both_options = true
if self.valid_move?(x+1, y)
count += self.find_routes(x+1, y)
else
both_options = false
end
if se... | true |
4bc2151e58b64bfcc312b65f88d1a4f5b9b78831 | Ruby | SebastianN97/first-ruby | /flow_control.rb | UTF-8 | 135 | 3.296875 | 3 | [] | no_license |
if 2 + 2 == 4
puts "Correct!"
else
puts "Uh oh, something very wrong."
end
#Class
class House
end
house = House.new
end
| true |
484d79f5777de4678ac1972e6dae770bca30fdb2 | Ruby | oolzpishere/qy_jiudian_customer | /components/admin/lib/admin/processed_order.rb | UTF-8 | 2,418 | 2.734375 | 3 | [
"MIT"
] | permissive | require_relative 'processed_payment'
module Admin
class ProcessedOrder
attr_reader :order, :nothing_obj, :room_type_eng_name, :hotel, :room_type, :hotel_room_type, :processed_payment
def initialize(order)
@order = order
@room_type_eng_name = order.room_type
@hotel = order.hotel
@roo... | true |
97693831b827fd05945025ec88b0feaa340c81b6 | Ruby | rhoen/rails_lite | /lib/phase5/params.rb | UTF-8 | 1,671 | 3.203125 | 3 | [] | no_license | require 'uri'
module Phase5
class Params
# use your initialize to merge params from
# 1. query string
# 2. post body
# 3. route params
#
# You haven't done routing yet; but assume route params will be
# passed in as a hash to `Params.new` as below:
attr_accessor :params
def initi... | true |
3359b42860ae76dfb46b5f2d435bac96e76674d7 | Ruby | ThoughtGang/BGO | /lib/bgo/address.rb | UTF-8 | 9,145 | 2.984375 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env ruby
# :title: Bgo::Address
=begin rdoc
BGO Address object
Copyright 2013 Thoughtgang <http://www.thoughtgang.org>
An address can contain structured data, an instruction, or raw bytes.
=end
require 'bgo/image'
require 'bgo/instruction'
require 'bgo/model_item'
module Bgo
=begin rdoc
A definition of ... | true |
1a0f4bc660626eac8951befebc6233949e6e742b | Ruby | phddoom/scripts | /mympd.rb | UTF-8 | 653 | 3.140625 | 3 | [] | no_license | require 'socket'
require 'io/wait'
class MPD
attr_reader :socket
def initialize
@socket = TCPSocket::new "localhost", 6600
@socket.sync = true
puts @socket.gets
end
def send_command command
@socket.puts command
status = nil
response = ""
until status
while @socket.ready?
... | true |
89395c64f871df4fcc68b9793d29287fc2b663f7 | Ruby | Lyforth/Some-ruby-projects | /project-09/project-09.ruby | UTF-8 | 501 | 3.671875 | 4 | [] | no_license | #Importamos as gems necessárias para o nosso projeto
require 'cpf_cnpj'
require 'rainbow'
#Pedimos que o usuário informe seu CPF
print 'Digite seu CPF: '
cpf = gets.chomp.to_i
#Criamos um método para verificar se o CPF é válido ou não
def verify_cpf(cpf)
if CPF.valid?(cpf)
puts "-" * 15 + "\nCPF: " + Rain... | true |
b153a01043dac6f65d8d5d645f055396197720b8 | Ruby | timcharper/misc-tools | /bin/git-treesame-commit | UTF-8 | 612 | 2.625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require "misc-tools/treesame_commit.rb"
args = []
merge = false
force = false
usage = "usage: git-treesame-commit [--merge, --force] <ref>
given a ref, git-treesame-commit <ref> will create a new merge commit that has
the exact same treehash as the given ref on your current branch. if --merge is
p... | true |
dd6a110edbab76012b537c26616bc8bc64e84e58 | Ruby | Pratt0923/data_verification_tool | /app/models/QA_LIST.rb | UTF-8 | 3,267 | 2.53125 | 3 | [] | no_license | class QA_LIST
attr_accessor :programming_grid, :qa_list_headers, :qa_list, :correct_row
def initialize(programming_grid)
@programming_grid = programming_grid
end
def sanitize_qa_list
qa_row = self.qa_list_headers
qa_data = self.correct_row
mv_keep = [
"CUST_NO",
"FIRST_NAME",
... | true |
411c0a17d5d0cf566088f23574e775115d3dee24 | Ruby | srijangarg24398/shopping-website | /app/models/cart.rb | UTF-8 | 593 | 2.78125 | 3 | [] | no_license | class Cart < ActiveRecord::Base
belongs_to :user
has_many :cart_items
def self.calculate_sub_total_price cart_id
new_sub_total_price=0
# byebug
cart=Cart.find(cart_id)
cart.cart_items.each do |cart_item|
puts "khd"
new_sub_total_price=new_sub_total_price+cart_item.total_price_item
end
r... | true |
826fc39182c4c596aaec5f9077a378ccb233166a | Ruby | ashfurrow/buggy | /slack-buggybot/commands/points.rb | UTF-8 | 903 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'slack-buggybot/models/event'
require 'slack-buggybot/models/bug'
module SlackBuggybot
module Commands
class Points < SlackRubyBot::Commands::Base
def self.call(client, data, _match)
user = client.users[data[:user]]
event = Event.user_current_event(us... | true |
5f181b8153aa89494f91cef8bfb7196d46ea0333 | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz84_sols/solutions/Mustafa Yilmaz/pp_pascal.rb | UTF-8 | 2,147 | 3.578125 | 4 | [
"MIT"
] | permissive | # Pascal's Triangle (Ruby Quiz #84)
# by Mustafa Yilmaz
#
# This is the second Ruby program I've ever written and it's not optimized (and probably not
# leveraging the power of Ruby), so don't expect to much ;-) The code should be self-explanatory,
# if you have any questions though don't hesitate to ask me.
#
# My app... | true |
ab637587f58261e554ea7ad394aaff318ed3fa95 | Ruby | NStephenson/sinatra-mvc-lab-v-000 | /models/piglatinizer.rb | UTF-8 | 525 | 3.484375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class PigLatinizer
def piglatinize(word)
if word[0][/[aeiouAEIOU]/] && word.length > 2
if word[/[aeiou]\z/]
word[/[aeiou]\z/] + word = word
word[0, word.length - 1] + "ay"
else
word + "ay"
end
elsif word.length > 2
word[/[aeiou]\w*\b/] + word[/\A[^aeiou]{1,2}/... | true |
c0b60df28850eb5677cf417b4934e377ea82b41f | Ruby | pombreda/hn-scraper | /lib/hn_scraper.rb | UTF-8 | 2,462 | 2.546875 | 3 | [
"MIT"
] | permissive | require "hn_scraper/version"
require 'nokogiri'
require 'rest-client'
require 'open-uri'
module HNScraper
class << self
def get_submit_fnid cookie
headers = { "Cookie" => "user=#{cookie}" }
doc = Nokogiri::HTML(RestClient.get("https://news.ycombinator.com/submit", headers))
fnid = doc.css("inpu... | true |
b014607cb57f9215731ece0c16e01ee01f1adae1 | Ruby | ruby-fatecsp/scripts-uteis | /verifica_notas.rb | ISO-8859-1 | 2,398 | 3 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: iso-8859-1
require 'rubygems'
require 'mechanize'
require 'highline/import'
require 'htmlentities'
CONF_ARQ = __FILE__ + '-config.txt'
# Mtodo para pedir as credenciais do usurio
def get_credentials
user = ask('matricula: ')
pass = ask("senha: " ) { |c| c.echo = "*" }
exit 1 if ... | true |
ccd7fae58e5f500d57032a8e3e3dbc06b88e5351 | Ruby | 3vcloud/linodeapi | /lib/linodeapi/errors.rb | UTF-8 | 1,091 | 2.953125 | 3 | [
"MIT"
] | permissive | module LinodeAPI
##
# A standard HTTP error with an embedded error code
class HTTPError < StandardError
attr_reader :code
def initialize(code, msg = 'HTTP Error encountered')
@code = code
super(msg)
end
end
##
# A retryable error that has exceeded its max retries
class RetriedHTT... | true |
93ebb7ca91152b1a33f42032fc9b61739943a6bd | Ruby | jeevansrivastava/pusher-whos-in-gem | /lib/whos_in.rb | UTF-8 | 1,095 | 2.609375 | 3 | [
"MIT"
] | permissive | require_relative "whos_in/version"
require 'rufus-scheduler'
module WhosIn
class Application
def self.launch_heroku_deploy
puts "Launching deployment setup on Heroku... \n\n Input a name for your app (e.g. office_whos_in) then click the 'Deploy For Free' button. \n\nWhen you're done run 'pusher-whos-in run *... | true |
4007a77b2a93a2868889dff3e8c0abe0251c5a49 | Ruby | mikaa123/trifling-whims | /source_file.rb | UTF-8 | 1,206 | 2.515625 | 3 | [] | no_license | class SourceFile
attr_accessor :content
attr_accessor :metadata
attr_accessor :outline
def self.archive_list
@archive_list ||= Dir.glob("posts/*.{markdown,md}").sort.reverse.collect do |filename|
content = File.read(filename)
content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
title = YAML.load(... | true |
7b55475c82a653b13d0ec2282f24af4c5677dc6a | Ruby | alloy-d/mimi | /qt/image_preview.rb | UTF-8 | 1,489 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'Qt4'
class ImagePreview < Qt::GraphicsWidget
@@max_width = 200
def initialize(path)
super()
@bg_color = Qt::Color.new(rand(255), rand(255), rand(255))
image = Qt::Image.new(path)
@preview = image.scaled(@@max_width,
@@max_width * 3/4,
... | true |
d78fdefbd193f8791be5f56cf7736299b97afc28 | Ruby | ajfigueroa/pug-bot | /lib/pug/list_action.rb | UTF-8 | 771 | 2.71875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Pug
# Lists all the user defined actions
class ListAction < Interfaces::Action
# @param actions [Array<Interfaces::Action>]
# user provided actions
def initialize(actions)
@actions = actions
@enumerator = Action::Enumerator.new
end
# Action ov... | true |
f3d3ba7a2bedcb8e09d9d2dc3d433acab18c5396 | Ruby | njgheorghita/sorting_suite | /bubble_sort.rb | UTF-8 | 444 | 3.953125 | 4 | [] | no_license | class BubbleSort
def sort(array)
# high-level looping
high_level_count = 0
while high_level_count < array.length
# low-level looping
count = 0
array.drop(1).each do |e|
if e < array[count]
array[count], array[count+1] = array[count+1], array[count]
count+=1
end
... | true |
5bc117f70d2764d9bc996c441d850e01ffc35ca6 | Ruby | nomod/energy | /app/helpers/baskets_helper.rb | UTF-8 | 3,114 | 2.765625 | 3 | [] | no_license | module BasketsHelper
#смотрим сколько у текущего пользователя товаров в корзине
def numbers_in_basket
if !current_user.nil?
#смотрим заказ текущего пользователя в статусе оформляется
@order = Order.find_by(user_id: current_user.id, order_status_id: 1)
#если у пользователя есть заказ в стат... | true |
5b24da5e3f9f4812ad191f13c2535c6fe2b30793 | Ruby | iExperience/fizzbuzz | /fizzbuzz.rb | UTF-8 | 759 | 4.1875 | 4 | [] | no_license |
# while the count is not yet 100
1.upto(100) do |number|
#result = ""
#result += "fizz" if (number % 3 == 0)
#result += "buzz" if (number % 5 == 0)
result = "#{"fizz" if (number % 3 == 0)}#{"buzz" if (number % 5 == 0)}"
puts result == "" ? number : result
# if result == ""
# puts number
# else
#... | true |
86a4f169f309bf341129e1c3b196cc64220cd413 | Ruby | yrmallu/bank-app | /app/services/transactions/perform.rb | UTF-8 | 1,496 | 2.65625 | 3 | [] | no_license | module Transactions
class Perform
def initialize(amount, transaction_type, bank_account_id, recipient_id)
@amount = amount.try(:to_f)
@transaction_type = transaction_type
@bank_account_id = bank_account_id
@recipient_id = recipient_id
@bank_account = BankAccount.where(id: bank_accoun... | true |
789bd9dac499f14cb49fa10872cd17f388846bf0 | Ruby | steph-meyering/aa_classwork | /w5d3/AA_Questions/user.rb | UTF-8 | 820 | 3.03125 | 3 | [] | no_license | require_relative 'question_database'
require_relative 'question'
class User
attr_accessor :id, :fname, :lname
def self.find_by_id(id)
hash_id = QuestionDatabase.instance.execute(<<-SQL, id)
SELECT
*
FROM
users
WHERE
id = ?
SQL
User.new(hash_id)
end
def ... | true |
5b1393ac01950e18128c3b7d3332788e6e137939 | Ruby | rshiva/MyDocuments | /01-notes-programming /04-ruby+rails/ruby1.9/samples/slshellwords_1.rb | UTF-8 | 628 | 3.15625 | 3 | [] | no_license | #---
# Excerpted from "Programming Ruby",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit http://www... | true |
7ed72e669b7e3a30b1e2d7c6ef0fbf10f51bab88 | Ruby | mur-wtag/toy-robot-simulator | /lib/toy/robot/simulator/mount.rb | UTF-8 | 1,528 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'toy/robot/simulator/commands'
module Toy
module Robot
module Simulator
class Mount
include Simulator::Commands
attr_reader :table_size
def initialize(table_size=5, output=STDOUT)
@table_size = table_size
@output=output
end
def start(comm... | true |
4c80bf50fd90e63d1934c7976f8af46e30ae9153 | Ruby | Kirill-Petrovskiy/courses_ROR | /lesson_3_4_5_6/route.rb | UTF-8 | 466 | 3.03125 | 3 | [] | no_license | class Route
include InstanceCounter
include ValidateStation
attr_reader :stations
def initialize(first_station, last_station)
validate_count_station!
@stations = {}
@stations[first_station.name] = first_station
@stations[last_station.name] = last_station
register_instance
end
def add_... | true |
3b24b41c537e8609ff73610c0a788f12f14434ef | Ruby | lovenic/vaverka_db | /lib/db/insert.rb | UTF-8 | 2,554 | 2.921875 | 3 | [] | no_license | module DB
class Insert
def self.call(key: nil, value: nil)
new.insert(key: key, value: value)
end
def insert(key:, value:)
return unless input_valid?(key: key, value: value)
payload_to_write = payload(key: key, value: value)
file_to_write = locate_file(payload: payload_to_write)
... | true |
ce716e2ac92bb8d194ca2db25001544417a47865 | Ruby | sendhil/wordpress-github-alfred-workflow | /autocomplete.rb | UTF-8 | 2,081 | 3 | 3 | [
"MIT"
] | permissive | require 'net/http'
require 'json'
require 'nokogiri'
require 'fileutils'
require 'date'
def cache_data(data)
FileUtils.mkdir_p "cached_data"
File.write("./cached_data/github_repos", JSON.dump(data))
end
def retrieve_cached_data
return nil unless File.exist?("./cached_data/github_repos")
data = File.read("./ca... | true |
11fe4cdac10525f436dae2e39bdde466f346557b | Ruby | olook/olook | /app/presenters/showroom_presenter.rb | UTF-8 | 1,750 | 2.59375 | 3 | [] | no_license | class ShowroomPresenter
CATEGORIES_FOR_SHOWROOM = [
Category::CLOTH,
Category::SHOE,
Category::BAG,
Category::ACCESSORY
]
WHITELISTED_BRANDS = [
"OLOOK ESSENTIAL",
"Olook Concept",
"Olook"
]
def initialize(args={})
@recommendation = args[:recommendation]
@products_limit =... | true |
5d4ce1ec9a545e9122ed9e4a88074da672aa961d | Ruby | jimlindstrom/InteractiveMidiImproviser | /music/lib/note_queue_meter_detection.rb | UTF-8 | 5,637 | 2.59375 | 3 | [] | no_license | #!/usr/bin/env ruby
# assumes it is included in NoteQueue
module CanDetectMeter
attr_accessor :tempo, :meter
def detect_meter
bsm = Music::BeatSimilarityMatrix.new(self.beat_array)
bsm_diags = (1..20).map{ |i| { :subbeat=>i, :score=>bsm.geometric_mean_of_diag(i) } }.sort{ |x,y| y[:score] <=> x[:score] }
... | true |
f4ad85ba9be0471b40202737ec788dbbc879b334 | Ruby | ben20262/cli-project | /lib/command_line_interface.rb | UTF-8 | 4,313 | 3.65625 | 4 | [
"MIT"
] | permissive | class CommandLineInterface
def run # directs the program
puts "Please enter the url(s) that you want processed."
puts "If entering multiple please seperate them with a comma and a space."
puts "Enter exit at any time to exit the application."
input = gets.strip
array = input.split(", ")
if i... | true |
01478a84cbd1e114a6b16f08e90a13d73e3bb19e | Ruby | iambanklee/vending_machine | /lib/inventory.rb | UTF-8 | 482 | 3.09375 | 3 | [] | no_license | # frozen_string_literal: true
class Inventory
attr_reader :items
def initialize
@items = {}
end
def increase(name:, stock:)
items[name] ||= 0
items[name] += stock
end
def decrease(name:, stock:)
items[name] ||= 0
items[name] -= stock
end
def stock_of(name)
items[name]
end
... | true |
698ad94f9664e032a1fb81d7b3f64de5a29bf6f6 | Ruby | dexterfgo/foosball | /app/models/player_result.rb | UTF-8 | 1,179 | 2.546875 | 3 | [] | no_license | class PlayerResult < ApplicationRecord
belongs_to :player, class_name: "Player", foreign_key: "playerid"
belongs_to :game, class_name: "Game", foreign_key: "gameid"
belongs_to :teammate, class_name: "Player", foreign_key: "teammate", optional: true
belongs_to :opponent, class_name: "Player", foreign_key: "opponent... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.