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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
81e0f50f88fbd6b7e0ddf47fbb8ad335f073e18d | Ruby | namusyaka/mandrake | /lib/mandrake/dsl/stringify.rb | UTF-8 | 1,978 | 3.234375 | 3 | [
"MIT"
] | permissive | module Mandrake
module DSL
# A class for building an expression by using the method_missing method
# @example
# Oh = Class.new(Mandrake::DSL::Stringify)
# Oh.stringify.Mikey.hello('boy').to_s #=> "oh.Mikey.hello(\"boy\")"
# Oh.stringify.James.goodbye('man').to_s #=> "oh.James.goodbye(\"man\"... | true |
22ece5b63a7a2e15c8df662ebd10c393f7068a10 | Ruby | learn-co-students/atl-bonus-lectures | /testify-052819/spec/gilded_rose_spec.rb | UTF-8 | 4,153 | 2.921875 | 3 | [] | no_license | require_relative 'spec_helper'
describe "Gilded Rose" do
it "should be able to tick a gilded rose" do
# given a gilded rose
rose = GildedRose.for("example", 20, 30)
# when i tick
rose.tick
# then i expect quality and sell_in to go down by one
expect(rose.sell_in).to eq(19)
expect(rose.qu... | true |
9392672c36c6be328a331b73301b72162a3b1223 | Ruby | tnishi/rdf-config | /bin/rdf-config | UTF-8 | 3,025 | 2.671875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'getoptlong'
require 'rdf-config'
def help
puts DATA.read
exit
end
opts = {
:config_dir => nil,
:mode => nil,
}
args = GetoptLong.new(
[ '--config', '-c', GetoptLong::REQUIRED_ARGUMENT ],
[ '--help', '... | true |
3f674d63b7e56e22080b9acdc71849957b420c49 | Ruby | jgrazulis/1module | /Challenges/mid_mod/spec/term_spec.rb | UTF-8 | 1,298 | 3.171875 | 3 | [] | no_license |
require './lib/course'
require './lib/student'
require './lib/term'
describe 'Term class' do
it 'exists' do
calculus = Course.new("Calculus", 2)
term = Term.new("Winter 2018", [calculus])
expect(term).to be_an_instance_of(Term)
end
it 'has attributes' do
calculus = Course.new("Calculus", 2)
term... | true |
f13ee1d4948e4e15bc9f229a3f9220f63dbb473b | Ruby | wuhuizuo/SCTM | /tech_demos/sf_parser.rb | UTF-8 | 764 | 2.546875 | 3 | [
"MIT"
] | permissive | require_relative 'sf_baidu_parser'
module Sctm
class SfParser
SF_SITES = {
baidu: 'http://rj.baidu.com/'
}
SF_PARSERS = {
baidu: SfBaiduParser
}
# @param [String] sf_center 软件中心类别
def initialize(sf_center = :baidu)
@sf_main_url = SF_SITES[sf_center]
@parser = SF_PARSERS... | true |
ca1a0cd2550e51864aec8fdf493580b1c8c743a6 | Ruby | baggio63446333/mrubyc | /examples/ledswitch/ledswitch.rb | UTF-8 | 258 | 2.640625 | 3 | [
"BSD-3-Clause"
] | permissive | val = 0
portled = 64
portsw = 33
pin_mode(portsw, 0);
while true
if val == 1
val = 0
else
val = 1
end
if digital_read(portsw) == 0
portled += 1
if portled > 67
break
end
end
digital_write(portled, val)
sleep 1
end
| true |
13f868dc9a62b82335f818310bde77e227dc2270 | Ruby | jtblow/oxford-comma-chicago-web-career-040119 | /lib/oxford_comma.rb | UTF-8 | 237 | 3.4375 | 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 ")
elsif array.length === 3
array[0..1].join(", ") + ", and " + array[2]
else
array[0..-2].join(", ") + ", and " + array[-1]
end
end | true |
e9d1f4086f04670e6fc268a8a90938c7b845169e | Ruby | ttt242242/fx | /rubyOkn/EasyGraphMaker.rb | UTF-8 | 1,009 | 2.5625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
$LOAD_PATH.push(File::dirname($0)) ;
require "pry"
require "gnuplot"
Gnuplot.open do |gp|
Gnuplot::Plot.new( gp ) do |plot|
plot.output "test.eps"
plot.set 'terminal postscript 16 eps enhanced color ' #必要epsで保存するには
plot.size "1,0.8"
plot.origin "0.0, 0.0"
plot.gr... | true |
88ee7b0e687ee11fe9db36bd611cad694ff29f2e | Ruby | jdun10/phase-0 | /week-5/die-class/my_solution.rb | UTF-8 | 1,464 | 4.59375 | 5 | [
"MIT"
] | permissive | # Die Class 1: Numeric
# I worked on this challenge by myself.
# I spent [] hours on this challenge.
# 0. Pseudocode
# Input: calling the method
# Output: a number 1-6
# Steps: There will be a function that goes from 1-6 and selects a number.
# A random number will be returned.
# 1. Initial Solution
# class Die
#... | true |
1f6c762f6bed9414e1115d70732b57dfead768de | Ruby | escobara/ro_design_patterns | /strategy_pattern/strategy_v1.rb | UTF-8 | 1,049 | 3.71875 | 4 | [] | no_license | class Formatter
def output_report(title, text)
raise 'Abstract method called'
end
end
class HTMLFormatter < Formatter
def output_report(title, content)
puts('<html>')
puts(' <head>')
puts(" <title> #{title} </title>")
puts(' </head>')
puts(' </body>')
content.each do |line|
puts(" <p>#{lin... | true |
58f12cf64c1adc27327c2b99c035acda9ac9f1de | Ruby | jinhale/viper | /spec/make_bindings_spec.rb | UTF-8 | 3,201 | 2.640625 | 3 | [
"MIT"
] | permissive | # make_bindings_spec.rb - specs for make_bindings
require_relative 'spec_helper'
describe 'make_bindings returns a key inserter proc for letters' do
let(:buf) { Buffer.new '' }
let(:bind) { make_bindings }
let(:prc) { bind[:key_p] }
subject { prc.call(buf); buf.to_s }
specify { subject.must_equal 'p' }
end... | true |
bbf2df7fd953a34af26d3bd6dcf2081f9997dece | Ruby | GaronHock/Homework | /octopus problems/octopus.rb | UTF-8 | 2,094 | 4.3125 | 4 | [] | no_license | # A Very Hungry Octopus wants to eat the longest fish in an array of fish.
# ['fish', 'fiiish', 'fiiiiish', 'fiiiish', 'fffish', 'ffiiiiisshh', 'fsh', 'fiiiissshhhhhh']
# => "fiiiissshhhhhh"
# Sluggish Octopus
# Find the longest fish in O(n^2) time. Do this by comparing all fish lengths to all other fish lengths
d... | true |
0db0691ddf25e2d2defd21cdc610a551066fa4ba | Ruby | nekokat/codewars | /8 kyu_1/grasshopper-make-change.rb | UTF-8 | 184 | 2.90625 | 3 | [
"Unlicense"
] | permissive | #Kata: Grasshopper - Make change
#URL: https://www.codewars.com/kata/560dab9f8b50f89fd6000070
money = 10
candy = 1.42
chips = 2.4
soda = 1
change = money - candy - chips - soda | true |
c34128da13a2d380e31235d24fd7b329eda8608e | Ruby | denisson/BibliaSocial | /config/initializers/integer.rb | UTF-8 | 86 | 2.6875 | 3 | [] | no_license | class Integer
def quantos()
return self.to_s if self > 0
return ""
end
end | true |
2ddeb8f002933e7714a4b2c0a1679aadf627540e | Ruby | DiegoSalazar/template_parsing_challenge | /template_parser.rb | UTF-8 | 1,587 | 3.5 | 4 | [] | no_license | # Given a template and an environment, fill the template with correct values.
class TemplateParser
IF_TAG = ?# # prefix for if tags
UNLESS_TAG = ?^ # prefix for unless tags
NIL_VAR = ''
TAG_CAPTURE = /
{(.+)} # capture an opening tag
(.+) # capture content after opening tag
{(\1)} # capture ta... | true |
d2d00f06487a04f9ba0670fcdddac562085fae68 | Ruby | juanlfr/tests-ruby | /lib/03_basics.rb | UTF-8 | 484 | 3.390625 | 3 | [] | no_license | def who_is_bigger(a,b,c)
if a==nil || b==nil || c==nil then return "nil detected"
elsif a==[a,b,c].max then return("a is bigger")
elsif b==[a,b,c].max then return("b is bigger")
else return("c is bigger")
end
end
def reverse_upcase_noLTA(string)
return string.reverse.upcase.delete 'LTA'
end
def array_42(array... | true |
8c307273ee2e549fec139bae0c9ab6e6bcdf8620 | Ruby | narayana1208/git-review | /lib/git-review/local.rb | UTF-8 | 7,733 | 2.65625 | 3 | [
"MIT"
] | permissive | module GitReview
# The local repository is where the git-review command is being called
# by default. It is (supposedly) able to handle systems other than Github.
# TODO: remove Github-dependency
class Local
include ::GitReview::Internals
attr_accessor :config
# acts like a singleton class but i... | true |
a7bfa377d2cfb9f91d417b9ca3f1e819cfe876ec | Ruby | awesome/coffeelint-ruby | /lib/coffeelint.rb | UTF-8 | 2,640 | 2.640625 | 3 | [
"MIT"
] | permissive | require "coffeelint/version"
require 'execjs'
require 'coffee-script'
require 'json'
module Coffeelint
require 'coffeelint/railtie' if defined?(Rails::Railtie)
def self.path()
@path ||= File.expand_path('../../coffeelint/lib/coffeelint.js', __FILE__)
end
def self.colorize(str, color_code)
"\e[#{color... | true |
effb7076c4fbcdc3d9008231e1b1515d0720ca05 | Ruby | Maikon/learn_ruby_hard_zed | /ex9.rb | UTF-8 | 652 | 4 | 4 | [] | no_license | # Here's some new strange stuff, remember type it exaxctly.
days = "Mon Tue Wed Thu Fri Sat Sun"
months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"
puts "Here are the days: ", days # will print the list of days in a row
puts "Here are the months: ", months # will print the list of months each one on its own line,
... | true |
bc239ddffaa4c0b07f1b9fde83ce53a8e30e0c27 | Ruby | yuta-pharmacy2359/ruby_tutorial | /第6章/Sample6_3_2.rb | UTF-8 | 1,118 | 3.515625 | 4 | [] | no_license | text = <<-TEXT
島原の乱は1637年12月11日に発生し、1638年4月12日に終結しました。
TEXT
p text.scan(/\d+年\d+月\d+日/)
# ["1637年12月11日", "1638年4月12日"]
p text.scan(/(\d+)年(\d+)月(\d+)日/)
# [["1637", "12", "11"], ["1638", "4", "12"]]
text = '本能寺の変は1582年6月21日に発生しました。'
m = /(\d+)年(\d+)月(\d+)日/.match(text)
puts m[0]
# 1582年6月21日
puts m[1]
# 1582
puts... | true |
1ff0aa7efb560a26e4bd3aeb701915f6f27f284d | Ruby | clone18476/ghibli_cli | /lib/api.rb | UTF-8 | 1,237 | 3.5 | 4 | [] | no_license | class API
# NOTE: all of your API methods should be class methods
def self.fetch_films
url = "https://ghibliapi.herokuapp.com/films/"
uri = URI(url)
response = Net::HTTP.get(uri)
films_array = JSON.parse(response)
# each hash represents a film, and we want to initiali... | true |
de2951aac31a02c0994cf3ae0c3c48b1e1669b8f | Ruby | HMJospeh/ruby-gets-input-v-000 | /bin/greeting | UTF-8 | 266 | 3.515625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #!/usr/bin/env ruby
require_relative '../lib/hello_ruby_programmer.rb'
puts "What's happening! Welcome to the wonderful world of Ruby programming."
puts "Let's get this game started!! Type in your name so we can get things going:"
name = gets.strip
greeting(name)
| true |
c6d5d74f9e4289dbaf42af53dbce87f80124107d | Ruby | MattStopa/Coding-Casts-Code | /modules/2_organizing/modules.rb | UTF-8 | 689 | 3.828125 | 4 | [] | no_license | class Loan
attr_accessor :balance_owed, :maturity_months, :interest_rate
def owed_by_month
balance_owed / maturity_months
end
def print_balance
"Your balance is: #{balance_owed}"
end
def years_left_to_maturity
maturity_months / 12
end
def print_estimated_cost_per_day
"The cost per da... | true |
becf18b0371e36657b66589b78d47bb33a8a557b | Ruby | thallam/odin_ruby | /advanced_building_blocks/lib/bubble_sort.rb | UTF-8 | 585 | 3.640625 | 4 | [] | no_license | require 'pry'
def bubble_sort(arr)
binding.pry
arr.length.times do
arr.each_with_index do |item, index|
next_item = arr[index+1]
if next_item < item
temp = item
item = next_item
next_item = temp
# because a,b = b,a doesn't work
end
end
end
end
=begin
... | true |
6157a36f3bbae3622f42217ae9a5909ce5bafb41 | Ruby | justJosh1004/AcademyPGH | /Template Engine/Mad Libs.rb | UTF-8 | 518 | 2.828125 | 3 | [] | no_license | require './lib/template_engine'
#require './Star Wars.txt'
mad_lib = Template_reader.new
mad_lib.set_template(File.read('.\Star Wars.txt'))
get_template = []
user_answers = []
get_template = mad_lib.get_template_fields
i = 0
while i < get_template.length
puts "Type in a #{get_template[i]}: "
user_answers << gets... | true |
1b404bb086eacad4bea7e6eb9915d54c469a4dcf | Ruby | Sancbella/jumpstart-app | /Basics/orangetree.rb | UTF-8 | 1,841 | 4.03125 | 4 | [] | no_license | class OrangeTree
def initialize
@height = 120
@age = 0
@name = 'Mr.Orange'
@orangeProduction = 0
puts 'Mr.Orange is born'
end
def oneYearPasses number
if number <= 0
puts 'no time has passed'
elsif
@age = @age + (1*number)
@height =... | true |
2243b12cf8463297ae639c97f2d7ba15a780e2c3 | Ruby | slague/night_writer | /lib/night_reader.rb | UTF-8 | 1,322 | 3.59375 | 4 | [] | no_license | require_relative 'file_reader'
require_relative 'letters'
require 'pry'
class NightReader
attr_reader :file_reader
def initialize
@reader = FileReader.new
end
def decode_file_to_english
braille = @reader.open_the_file
char_count = braille.chomp.length
braille_out = zip_input(scan_input(s... | true |
e5e0ec2b01e23b428f6b1a809c65374d3d45905f | Ruby | grimesjm/clean_arch_rb | /core/lib/core/gateways/user/fake_user_repository.rb | UTF-8 | 257 | 2.8125 | 3 | [] | no_license | class FakeUserRepository
def initialize
@users = []
end
def save(user)
require 'securerandom'
user.id = SecureRandom.uuid
@users << user
end
def find_by_username(username)
@users.find { |u| u.username == username }
end
end
| true |
699519c3036ec4ba95f88a6dcc4517832a02e5ff | Ruby | access-watch/logstash-filter-accesswatch | /test.rb | UTF-8 | 2,917 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | require "manticore"
require "json"
require "digest"
require "lru_redux"
require 'net/http'
class AccessWatchClient
def initialize(api_key, cache_size=10000)
@client = Manticore::Client.new ssl: {ca_file: "cert.pem"}
@api_key = api_key
if cache_size > 0
@cache = LruRedux::ThreadSafeCache.new(cache_... | true |
a4eccd11808ed943efe5f6a2489d45704adacfde | Ruby | whastings/coding_practice | /problems/exponent_rec.rb | UTF-8 | 251 | 3.375 | 3 | [] | no_license | def exponent_rec(base, power)
return 1 if power == 0
return 1.0 / exponent_rec(base, power * -1) if power < 0
return base * exponent_rec(base, power - 1) if power.odd?
# Power is even.
half = exponent_rec(base, power / 2)
half * half
end
| true |
0bfd318d1bc5197dc4f0dfda4516b70712976cd5 | Ruby | n-flint/brownfield-of-dreams-2 | /app/services/github_api_service.rb | UTF-8 | 721 | 2.6875 | 3 | [] | no_license | class GithubApiService
def initialize(token)
@token = token
end
def user_email(handle)
parsed_response(conn.get("/users/#{handle}"))
end
def followers
parsed_response(conn.get('/user/followers'))
end
def repos(limit = 5)
response = conn.get('/user/repos')
new_response = parsed_respo... | true |
b91b3ee8e6378a51b1618a16a1464d02f62a76f9 | Ruby | fertech/csv_decision | /lib/csv_decision/validate.rb | UTF-8 | 3,100 | 2.90625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# CSV Decision: CSV based Ruby decision tables.
# Created December 2017.
# @author Brett Vickers <brett@phillips-vickers.com>
# See LICENSE and README.md for details.
module CSVDecision
# Parse and validate the column names in the header row.
# These methods are only required at table... | true |
ca5b3e486034511b4a1ef883f7f293755885341a | Ruby | Fabian-tapia7/ruby | /arreglos/sesion_online/aumento_precios.rb | UTF-8 | 177 | 3 | 3 | [] | no_license | def promedio(notas)
n= notas.count
n.times do |i|
if notas[i]=='N.A'
notas[i] = 2
end
end
print notas.sum/notas.count
end
promedio([5, 5, 20])
print "\n"
| true |
a6f2ba7435c679956e4b574d20eccff8ab983fac | Ruby | p/lonely_coder | /lib/lonely_coder/profile.rb | UTF-8 | 7,573 | 2.53125 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
class OKCupid
def profile_for(username)
Profile.by_username(username, @browser)
end
def visitors_for(username, previous_timestamp = 0)
Profile.get_new_visitors(username, previous_timestamp, @browser)
end
def likes_for(username)
Profile.get_new_likes(username, @browser)
end
... | true |
ced90e8a6e3f67406ceab2ebfec2406ab0987fa7 | Ruby | anotherminh/ruby_chess_game | /player.rb | UTF-8 | 2,114 | 3.71875 | 4 | [] | no_license | require_relative 'display'
class HumanPlayer
# Reads keypresses from the user including 2 and 3 escape character sequences.
def self.read_char
STDIN.echo = false
STDIN.raw!
input = STDIN.getc.chr
if input == "\e" then
input << STDIN.read_nonblock(3) rescue nil
input << STDIN.read_nonbl... | true |
a52b6da4d4f5193ea16476b80e088d33588a6e9e | Ruby | tidorisan/ruby | /2-8/2-8.rb | UTF-8 | 1,660 | 4.03125 | 4 | [] | no_license | # puts "aaa"
# input_key = gets
# puts "入力された内容は"+input_key
# puts "hello"
# input_key = gets
# puts "入力された内容は"+input_key
# a=gets.to_i
# b=gets.to_i
# puts "a+b=#{a+b}"
# a=gets.to_i
# b=gets.to_i
# puts "a+b=#{a+b}"
# puts "キーボードで数字「2」と数字「3」を入力してください"
# a=gets.to_i
# b=gets.to_i
# puts "a+b=#{a+b}"
# dice = 0 # ... | true |
85cbd2d91e8e1e56a72765cebb1e897e6e891966 | Ruby | SALIM-UsseF/DEPIC | /back-end/app/controllers/questionchoixes_controller.rb | UTF-8 | 1,972 | 2.90625 | 3 | [] | no_license | ################################
# Question choix Controller
# #############################
#
# Expose des services REST sous format Json:
# - Afficher la liste des questions choix
# - Afficher une question choix par ID
# - Creer une nouvelle question choix
# - Modifier une question choix
# - Supprimer u... | true |
e7c9018c91fd455d3c8b3dcc676535ecd54ee0f0 | Ruby | TwilioDevEd/api-snippets | /quickstart/ruby/autopilot/create-first-task/create_hello_world_task.6.x.rb | UTF-8 | 1,068 | 2.5625 | 3 | [
"MIT"
] | permissive | # Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'
# Your Account Sid and Auth Token from twilio.com/console
# To set up environmental variables, see http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@cl... | true |
dc048a66e078f93adb0e21533d99cb691f8fd371 | Ruby | jordansissel/experiments | /ruby/octokit/migrate-issue.rb | UTF-8 | 3,235 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: utf-8
require "clamp"
require_relative "mixins/github"
require_relative "mixins/logger"
require_relative "mixins/cla"
class GithubIssueMigrator < Clamp::Command
include Mixin::GitHub
include Mixin::Logger
include Mixin::ElasticCLA
parameter "SOURCE", "The github issue to migra... | true |
189706c51143988a519b4b309dd2095bc69fd0ab | Ruby | hirataya/fatechan | /lib/google_calc.rb | UTF-8 | 718 | 2.84375 | 3 | [
"BSD-2-Clause"
] | permissive | require "uri"
require "cgi"
require "open-uri"
require "nokogiri"
module GoogleCalc
def self.calc(expr, &block)
uri = sprintf("http://www.google.com/search?hl=ja&q=%s", CGI.escape(expr))
#p uri
result = nil
open(uri, "r:utf-8", "User-Agent" => "Mozilla/5.0") do |fp|
content = fp.read
#p ... | true |
a20133fe9d6b00be177d6c28e91a9df4606b22ea | Ruby | tcrane20/AdvanceWarsEngine | /Advance Wars Edit/Scripts_Old/[191]Sea.rb | UTF-8 | 485 | 2.5625 | 3 | [] | no_license | class Sea < Tile
def initialize
super
@name = 'sea'
@id = TILE_SEA
end
def move_cost_chart(move_type)
return case move_type
when MOVE_FOOT then return [0]
when MOVE_MECH then return [0]
when MOVE_TIRE then return [0]
when MOVE_TREAD then return [0]
when M... | true |
44fa8a998fd2bedd52a5c0cd2c1433880fee6d78 | Ruby | rubenpazch/ruby-algorithms | /strings/practice.rb | UTF-8 | 1,135 | 3.515625 | 4 | [] | no_license | # p "abcdef" <=> "abcde" #=> 1
# p "abcdef" <=> "abcdef" #=> 0
# p "abcdef" <=> "abcdefg" #=> -1
# p "abcdef" <=> "ABCDEF" #=> 1
# p "abcdef" <=> 1 #=> nil
# str1 = 'aa'
# str2 = 'bb'
# ar1 = str1.squeeze.each_char.to_a
# ar2 = str2.squeeze.each_char.to_a
#
# p ar1 - ar2
# p ar2 - ar1
#
## str1.e... | true |
8ff2fc70915edfa5036c00ea783412436103f2c3 | Ruby | Chrispolanco/debugging-with-pry-online-web-prework | /lib/pry_debugging.rb | UTF-8 | 53 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def plus_two(num)
num + 2
new_total = num + 2
end | true |
c04a746ca13e22a7a5723f1b35cf6d9a68fc2136 | Ruby | vuhailuyen1991/rails | /activesupport/lib/active_support/core_ext/date_and_time/compatibility.rb | UTF-8 | 601 | 2.640625 | 3 | [
"MIT",
"Ruby"
] | permissive | module DateAndTime
module Compatibility
# If true, +to_time+ preserves the the timezone offset.
#
# NOTE: With Ruby 2.4+ the default for +to_time+ changed from
# converting to the local system time to preserving the offset
# of the receiver. For backwards compatibility we're overriding
# this ... | true |
6d99066e7787e4dc54923f4ed69a22b4e6192fc8 | Ruby | sbasnyat/cosi166b | /PA2/MovieData.rb | UTF-8 | 6,995 | 3.359375 | 3 | [] | no_license | class MovieData
# constructor, if one parameter is passed, it takes path to the folder containing the movie data,
# optionally if two arguments are passed, the first is taken as path to folder and second symbol to specify a particular training/test pair
def initialize(*args)
train_test_h = {:u1 => ["u1.base","u1... | true |
784cddaa14b24afa3245d7908e6aaad22e17de9e | Ruby | higepon/misc | /count-and-say.rb | UTF-8 | 507 | 3.609375 | 4 | [] | no_license | # @param {Integer} n
# @return {String}
def count_and_say(n)
if n == 1
return "1"
end
prev = count_and_say(n - 1)
ret = ''
currentVal = 0
num = 0
for i in 0...prev.size
ch = prev[i]
if num == 0
currentVal = ch
num = 1
elsif ch == currentVal
num = num + 1
else
re... | true |
291f200ff99145d88b75bbab9dd6a581f73fed95 | Ruby | sogbdn/ar-exercises | /exercises/exercise_7.rb | UTF-8 | 430 | 3.078125 | 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 "----------"
# Ask the user for a store name (store it in a variable)
puts... | true |
ce0c2d6b1bff6d2d664dfd0a64711a0346788692 | Ruby | gotar/internship_day_V | /lib/model/product.rb | UTF-8 | 239 | 3.046875 | 3 | [] | no_license | module Shop
class Product
attr_reader :id, :name, :price
@@id = 0
def initialize(name, price)
@id = set_id
@name = name
@price = price
end
private
def set_id
@@id += 1
end
end
end
| true |
b0a7fbb32fb5c86b85e032fe4ad5a5022e29ba9d | Ruby | toshichanapp/projecteuler | /1-10/problem5.rb | UTF-8 | 195 | 2.875 | 3 | [] | no_license | require 'prime'
(1..20).map {|num| Prime.prime_division(num)}.flatten.each_slice(2).group_by{|arr| arr[0]}.map do |_, arr|
arr.max_by{|nums| nums[1] }
end.map do |a, b|
a ** b
end.reduce(:*)
| true |
95b00a42ea438f4979db6b3d5da53f7d4a09b10a | Ruby | masayuki038/chienowa | /app/helpers/stars_helper.rb | UTF-8 | 140 | 2.53125 | 3 | [
"MIT"
] | permissive | module StarsHelper
def starred?(stars)
stars.each do |star|
return true if current_user?(star.user)
end
false
end
end
| true |
194a25cbe0080c2db9109579d313ce0fb8f3f7d7 | Ruby | pamungkaski/Malkist-Ruby | /spec/malkist_spec.rb | UTF-8 | 3,166 | 2.59375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
RSpec.describe Malkist do
it 'has a version number' do
expect(Malkist::VERSION).not_to be nil
end
it 'return distance between two coordinate' do
result = Malkist.calculate_distance(%w[40.6655101,-73.89188969999998], %w[40.6905615,-73.9976592])
expect(result[0].distance)... | true |
4ceee98fb56d597ffc2a8385e07adf7f32a2826d | Ruby | kennyfrc/launch_school | /130/anagram.rb | UTF-8 | 1,197 | 4 | 4 | [] | no_license | # 04/23/16 - Challenge: Anagrams
class Anagram
attr_reader :detector
def initialize(detector)
@detector = detector
end
def match(array_of_words)
filtered_words = array_of_words.map(&:downcase).select do |word|
word.chars.all? do |chars|
detector_letters.include?(chars)
end && pass_... | true |
21ef2d477d190f1f0989bcb0d5264d9c5793350e | Ruby | sksamal/omnetpp-5.0 | /samples/FatTree/simulations/createIniBorderExp.rb | UTF-8 | 1,226 | 2.78125 | 3 | [] | no_license | # Generating experiment inis
#Execute with ruby createIniBorderExp.rb
data = File.readlines("inputBorders.ini")
upper = [10, 20, 40, 60, 80, 160]
lower = [5, 10, 20, 30, 40, 80]
lower2 = [3, 5, 10, 15, 20, 40]
repeats = (1..5).to_a
upper.zip(lower).each do |upper, lower|
repeats.each do |i|
data_temp = data.d... | true |
bdd6ee448b1dfae8533e0454f61b12702c51b7b9 | Ruby | kbehnfeldt/RB101 | /rb101-lesson4/Loops1/exercise6.rb | UTF-8 | 76 | 3.140625 | 3 | [] | no_license | number = []
while number.length < 5
number << rand(100)
end
puts number | true |
30b98fcc700dffac0c65bfc92cc84df8af8ad865 | Ruby | ric2b/learning_ruby | /ruby/hamming/hamming.rb | UTF-8 | 194 | 3.546875 | 4 | [] | no_license | class Hamming
def self.compute(string_a, string_b)
raise ArgumentError if string_a.length != string_b.length
string_a.chars.zip(string_b.chars).map{|a, b| a != b ? 1 : 0}.sum
end
end | true |
091d14e988ba41047519cc89e48d9b15b979ea6c | Ruby | btazi/rbnd-toycity-part4 | /lib/analyzable.rb | UTF-8 | 891 | 3.09375 | 3 | [] | no_license | module Analyzable
# Your code goes here!
def average_price(products)
average = products.map(&:price).map(&:to_f).reduce(:+)/products.length
average.round(2)
end
def print_report(products)
report = ""
products.each do |product|
report += "#{product.name}, brand: #{product.brand}, price: #{product.price}... | true |
542558846983f977142894603c5554457c5257e7 | Ruby | roodi/roodi | /lib/roodi/checks/abc_metric_method_check.rb | UTF-8 | 2,015 | 3.140625 | 3 | [
"MIT"
] | permissive | require 'roodi/checks/check'
module Roodi
module Checks
# The ABC metric method check calculates the number of Assignments,
# Branches and Conditionals in your code. It is similar to
# cyclomatic complexity, so the lower the better.
class AbcMetricMethodCheck < Check
ASSIGNMENTS = [:lasgn]
... | true |
c303c31408aa672ed882d6950b428899282d7b93 | Ruby | jcquarto/everything-is-a-object-or-method | /object_test2.rb | UTF-8 | 110 | 3.171875 | 3 | [] | no_license | # works with classes too!
class Cat
end
puts Cat.class
puts Cat.new.class
cato = Cat.new
puts cato.class
| true |
104b1567e4d48ca27aa73a2f6510dd5769ca7fc1 | Ruby | magic8baller/the-bachelor-todo-prework | /lib/bachelor.rb | UTF-8 | 1,482 | 3.828125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #require 'pry'
def get_first_name_of_season_winner(data, season)
data[season].each do |contestant_hash| # {'name'=>'Tessa H'..,}
if contestant_hash['status'] == 'Winner'
return contestant_hash['name'].split.first
#split name into 2 strings, return first name
end
end
end
def get_contestant_nam... | true |
978e0b3723d87a83c9b7357b026b6b9f3e8e3461 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/binary/309c0a008dd847918cd61c14010c5f45.rb | UTF-8 | 357 | 3.8125 | 4 | [] | no_license | class Binary
attr_reader :value
def initialize(value)
@value = value
end
def to_decimal
return 0 unless is_decimal?
chars.each_with_index
.map { |digit, index| digit.to_i * (2 ** index) }
.inject(&:+)
end
private
def chars
value.reverse.each_char
end
def is_decimal?
... | true |
dfa258b68b1e8e530a1b76762c9461b6a435406d | Ruby | ajemobile/big | /lib/bigmagic/database_object.rb | UTF-8 | 634 | 2.859375 | 3 | [] | no_license | module Bigmagic
class DatabaseObject
def eigen_class
class << self
self
end
end
def add_instance_variables(argv)
hash = {}
if argv.kind_of?(Hash)
hash = argv
elsif argv.kind_of?(Array)
argv.map! {|item| item.to_s.to_sym}
hash = Hash[*argv.zi... | true |
3a0ac8d9f7e32e0792c7b6f472ab3c5f24d64040 | Ruby | sans-pulp/ruby-exercises | /ruby_basics/3_conditionals/string_caps.rb | UTF-8 | 332 | 4.40625 | 4 | [
"MIT"
] | permissive | # Write a method that takes a string as an argument and returns a new all caps version of the string only if the string is longer than 10 characters
def upcase_long_string(string)
string.length > 10 ? string.upcase : string
# if string.length > 10
# string.upcase
# end
end
puts upcase_long_string('This is i... | true |
d6a787429ce11e7b7ed18d6ba4a7041600de7109 | Ruby | mkaushish/quizsite | /lib/QuestionGenerator/trig.rb | UTF-8 | 2,422 | 3.21875 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative 'questionbase'
require_relative 'tohtml'
include "Math.rb"
PYTHTRIP=[[3,4,5],[5,12,13],[7,24,25],[8,15,17]]
ORD=["a","o","h"]
PYTH=[[1,1,Math.sqrt(2)], [1,Math.sqrt(3),2]]
TRIGF=["sin", "cos", "tan", "cot", "cosec", "sec"]
TRIGDEF={"sin" => ["o","h"], "cos" => ["a","h"], "tan" => ... | true |
e2772763f491343e97a06dc05dbdb571757704a5 | Ruby | QPC-WORLDWIDE/rubinius | /kernel/common/eval.rb | UTF-8 | 3,392 | 2.765625 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Kernel
# Names of local variables at point of call (including evaled)
#
def local_variables
locals = []
scope = Rubinius::VariableScope.of_sender
# Ascend up through all applicable blocks to get all vars.
while scope
if scope.method.local_names
scope.method.local_names.each... | true |
40f476049ab8f5f902a18876a02c28e6d5b8c9f7 | Ruby | guspowell/Battleships | /spec/board_spec.rb | UTF-8 | 812 | 2.984375 | 3 | [] | no_license | require 'board'
require 'player'
describe Board do
let(:board) { Board.new }
let(:player) { Player.new }
let(:ship) { Ship.new(2) }
it 'should have no ships to start' do
expect(board.ship_count).to eq 0
end
it "should be able to receive ships from the player" do
player.place(board, ship, ['a1','... | true |
e0f1b00bce3e385cb3e04afe1c861a43c92ffd39 | Ruby | filip373/ruby_algorithms | /enumerable.rb | UTF-8 | 1,389 | 3.296875 | 3 | [] | no_license | module Enumerable
def my_each
self.size.times do |time|
yield self.to_a[time]
end
end
def my_each_with_index
self.size.times do |time|
yield self.to_a[time], time
end
end
def my_select
arr = []
self.my_each do |elem|
arr.push elem if yield elem
end
return a... | true |
3c1e17fde955b1619f725c3753be36ad8552f3b8 | Ruby | pedro-ivo-molina/bank-slip-validator | /validator.rb | UTF-8 | 848 | 2.53125 | 3 | [] | no_license | class Validator
attr_reader :body_annotations
def initialize
@header_errors = []
@body_errors = []
@body_annotations = []
@footer_errors = []
end
def validate_header(bank_slip:, rules:)
rules.each do |rule|
rule.validate(bank_slip)
@header_errors << rule.error unless rule.erro... | true |
9a5af248af913ef1d60efd2b8a3ec901ba9cd4ab | Ruby | huyu398/manmenmi | /manmenmi.rb | UTF-8 | 2,833 | 2.53125 | 3 | [] | no_license | require 'capybara'
require 'capybara-webkit'
require 'logger'
require 'yaml'
require_relative 'tag_reader'
require_relative 'errors'
MANMENMI_ROOT = File.expand_path(File.dirname(__FILE__))
AUDIO_PREFIX = "#{MANMENMI_ROOT}/voice"
NFCPY_PREFIX = "#{MANMENMI_ROOT}/nfcpy/0.9"
LOG_PREFIX = "#{MANMENMI_ROOT}/log"
config ... | true |
1b5b5026a1b64b07bdf61d825cfa84fb185f413d | Ruby | CJStadler/state_machine_checker | /lib/state_machine_checker/state_result.rb | UTF-8 | 1,115 | 3.359375 | 3 | [
"MIT"
] | permissive | module StateMachineChecker
# The result of checking whether this state satisfies a formula.
class StateResult
# @param [Boolean] satisfied
# @param [Array<Symbol>] path
def initialize(satisfied, path)
@satisfied = satisfied
@path = path
end
# Whether the formula is satisfied from th... | true |
ee0e187c1f0ab6b5b0b30312ecfcab794440e64b | Ruby | msomji/bowling_kata | /bowl.rb | UTF-8 | 3,918 | 3.484375 | 3 | [
"MIT"
] | permissive | # as a bowler I want to be able to start a new game
# as a bowler I want to be able to bowl
# as a bowler I want to be able to be able to see how many pins I knocked out after each bowl
# as a bowler I want to be able to see if I get a spare or a strike
# as a bowler I want to be able to see my score after every frame
... | true |
502aeccf5aa28e42cc789c26ff40cb8a662e5a13 | Ruby | v9n/proc | /study/interviewcake/matching-parens/spec.rb | UTF-8 | 462 | 2.796875 | 3 | [] | no_license | require_relative 'solution.rb'
require 'minitest/spec'
require 'minitest/autorun'
describe InterviewCake::MatchingParens do
it 'returns correct close posstion' do
s = "Sometimes (when I nest them (my parentheticals) too much (like this (and this))) they get confusing."
solution = InterviewCake::MatchingParen... | true |
2faaea69eca77e2681b2c2e070515301c5110172 | Ruby | StlMaris123/ruby_tutorials | /learn ruby the hard way/ex3.rb | UTF-8 | 1,544 | 4.40625 | 4 | [] | no_license | #mathematics
#use of interpolation is how we insert Ruby computations
#displays the following code
puts "i will now count my hens"
#executes the computations and interpolates it wit Hens and also Roosters
puts "Hens #{25 + 30 / 6}"
puts "Roosters #{100-25*3%4}"
#displays the following code
puts "I will now count my eg... | true |
4fb73857aa983f0cfc10960b91ccfadff7049233 | Ruby | alrawi90/day_name_displayer | /day_name_display.rb | UTF-8 | 1,185 | 3.65625 | 4 | [] | no_license | class Day_name_displayer
def initialize
welcome
menu
end
def welcome
puts ""
puts ""
puts "welcome to ---Day Name Displayer----"
puts ""
end
def msg
puts "Please enter a number from 1-7 OR enter 'exit' to end application ."
end
def menu
msg... | true |
77fc6c7b8fcc52837b08ba5995e88d34e3ec4746 | Ruby | squareben1/review_12_spellcheck | /lib/spellchecker.rb | UTF-8 | 818 | 3.75 | 4 | [] | no_license | class SpellChecker
def initialize(dictionary=[])
@dictionary = homogenise_arr(dictionary)
end
def spellcheck(string)
words = split_string(string)
checked_words = []
words.each do | word |
checked_words.push(word_check(word))
end
checked_words.join(" ")
end
def add_words(... | true |
103902ed24dc2e9570dc384f42565e5dedda3a22 | Ruby | johndierks/ruby-intro | /vehicles.rb | UTF-8 | 306 | 3.609375 | 4 | [] | no_license | class Vehicle
def go
puts "Pressed Gas Pedal"
end
def stop
puts "Pressed Brake Pedal"
end
end
class Convertible < Vehicle
def lower_top
puts "It's a nice day, so I put the top down"
end
def raise_top
puts "Looks like it's going to rain, so I raised the top."
end
end | true |
91f16e625d58019b95a8823cc5b085d82cd43387 | Ruby | Dwein9/ruby-object-initialize-lab-web-1116 | /lib/person.rb | UTF-8 | 73 | 2.765625 | 3 | [] | no_license | class Person
def initialize(the_name)
@name = the_name
end
end
| true |
4733d1c6cfce81aa46248e89b7d5bb74a1f1c54e | Ruby | jordanluce/AdvancedActiveRecord | /has_many_activerecord.rb | UTF-8 | 5,095 | 3.359375 | 3 | [] | no_license | #has_many associations activerecord
class Person < ActiveRecord::Base
belongs_to :location
belongs_to :role
end
class Role < ActiveRecord::Base
has_many :people
end
class Location < ActiveRecord::Base
has_many :people
end
_____________________________________________________________________________________... | true |
3b7653ccbcc67d487eecff3adc342d73d8fcda77 | Ruby | danabo/zhat | /_plugins/jumpto.rb | UTF-8 | 384 | 2.515625 | 3 | [
"MIT"
] | permissive | module Jekyll
class JumpToBlock < Liquid::Block
require "shellwords"
def initialize(tag_name, text, tokens)
super
@text = text.shellsplit
end
def render(context)
contents = super
"<a name='#{@text[0]}'></a>"\
"<span class='jump_to'>#{contents}</span>"
end
end
end... | true |
2063d534906cb9df672fdfa25f7da4e388116b43 | Ruby | stupergenius/Software-Engineering-for-SaaS | /assignment1/part2_spec.rb | UTF-8 | 3,078 | 3.265625 | 3 | [] | no_license | load 'part2.rb'
describe "#rps_game_winner" do
context "fail states" do
it "should raise when number of players is not two" do
expect { rps_game_winner([]) }.to raise_error(WrongNumberOfPlayersError)
expect { rps_game_winner([["Armando", "P"]]) }.to raise_error(WrongNumberOfPlayersE... | true |
8cad1f79ccd8091f0b35197064bfd57ae7652eef | Ruby | shoebham/Ruby_Projects_the_odin_project | /Project_Tic_Tac_Toe/tic_tac_toe.rb | UTF-8 | 3,406 | 3.375 | 3 | [] | no_license | LINES = [[1,2,3],[4,5,6],[7,8,9],[1,5,9],[3,5,7],[1,4,7],[2,5,8],[3,6,9]]
class Game
def initialize(player_1_class,player_2_class)
@board = Array.new(10)
@current_player_id=0
@players = [player_1_class.new(self,"X",1),player_2_class.new(self,"O",... | true |
17a9860a23a7d87cfbb573810d55bf79bf09ccb6 | Ruby | idimitrov07/ruby_ood_book | /chapter_five/duck_overlook.rb | UTF-8 | 437 | 3.15625 | 3 | [] | no_license | # overlooking the duck
class Trip
attr_reader :bicycles, :customers, :vehicle
# this 'mechanic' could be of any class..
def prepare(mechanic)
mechanic.prepare_bicycles(bicycles)
end
# ...
end
# 'Mechanic' class in not referenced anywhere in the class above
class Mechanic
def prepare_bicycles(bicycles... | true |
fd588b4372f00639f2c3222c062f12d7199a4e30 | Ruby | smainar/backend_prework | /day_1/exe3-1.rb | UTF-8 | 296 | 3.578125 | 4 | [] | no_license | puts "I will count my books."
puts "Old text books #{18 - 2 * 3}."
puts "Autobiographies #{3 + 3 % 1}."
puts "Non-fiction #{27 + 14 / 2 - 5}."
puts "Fiction #{56 - 17 % 3}."
# Results:
# I will count my books.
# Old text books 12.
# Autobiographies 3.
# Non-fiction 29.
# Fiction 54.
| true |
9a2605235dfd8be5f55e327771ce6732dd30a5ed | Ruby | goyox86/razer | /lib/razer.rb | UTF-8 | 984 | 3.640625 | 4 | [
"MIT"
] | permissive | require "razer/version"
module Razer
#
# A small utility class which for flattening nested arrays.
#
class Flattener
# Flattens the input +array+ of arrays into a uni-dimensional one
# preserving the relative order of eelements. If an empty array is
# provided then the exact same empty array objevc... | true |
3a371458f69091c787cb7e3bd844db7220ab7ff9 | Ruby | nickfryer21/screw-charlie | /app/models/game_player.rb | UTF-8 | 745 | 2.65625 | 3 | [] | no_license | # == Schema Information
#
# Table name: game_players
#
# id :integer not null, primary key
# game_id :integer
# player_id :integer
# slot_id :integer
#
class GamePlayer < ActiveRecord::Base
belongs_to :game
belongs_to :player
has_one :hand, :dependent => :destroy
has_many :turns, :depen... | true |
9f55d4455b0328267d0dc466c14056b4f7f75add | Ruby | fbenevides/conf-algorithm | /lib/conferences/track.rb | UTF-8 | 904 | 3.265625 | 3 | [] | no_license | module Conferences
class Track
attr_reader :name
def initialize(name, sessions = [Session.new('Morning', 9, 12), Session.new('Afternoon', 13, 17)])
@name = name
@sessions = sessions
end
def duration
@sessions.map(&:duration).reduce(&:+)
end
def distribute(talks)
talk... | true |
babbe9f2186192f1da4a927285d6f42b52e3c223 | Ruby | junyuanxue/learn_to_program | /ch14-blocks-and-procs/better_program_logger.rb | UTF-8 | 448 | 3.4375 | 3 | [] | no_license | $indent = 0
def better_log desc, &block
puts " " * $indent + "Beginning \"#{desc}\"..."
$indent += 1
result = block.call
$indent -= 1
puts " " * $indent + "...\"#{desc}\" finished, returning: #{result.to_s}"
end
better_log "outer block" do
better_log "some little block" do
better_log "teeny-tiny block... | true |
659316aa79719ba729942b2fc657afdaa0fe1e20 | Ruby | CoopTang/module_0_capstone | /day_5/ex39.rb | UTF-8 | 2,297 | 4.4375 | 4 | [] | no_license | # Hashes in 'Learn Ruby the Hard way'
# Create a mapping of states to abbreviation
states = {
'Oregon' => 'OR',
'Florida' => 'FL',
'California' => 'CA',
'New York' => 'NY',
'Michigan' => 'MI'
}
# Creat a basic set of states and some cities in them
cities = {
'CA' => 'San Francisco... | true |
8073b475c3f9cf87336820c2f7437add4a43cc37 | Ruby | arakla/binder-app | /app/helpers/application_helper.rb | UTF-8 | 1,325 | 2.625 | 3 | [] | no_license | module ApplicationHelper
def display_base_errors resource
return '' if (resource.errors.empty?) or (resource.errors[:base].empty?)
messages = resource.errors[:base].map { |msg| content_tag(:p, msg) }.join
html = <<-HTML
<div class="alert alert-error alert-block">
<button type="button" class="clos... | true |
bc69eede1366cf4d862db29f1cbd0d2247f0380f | Ruby | timbeiko/tealeaf-prework | /greetings.rb | UTF-8 | 177 | 3.90625 | 4 | [] | no_license | # greetings.rb
def greetings(name)
puts "Hi there, "+ name
end
name = gets.chomp
greetings(name)
x = 2
puts x = 2
p name="Joe"
four = "four"
print something = "nothing" | true |
cb186eccb2a05d681feeb207b686282f486dd8a7 | Ruby | mdvincen/tts_projects | /unless.rb | UTF-8 | 77 | 3.015625 | 3 | [] | no_license | sum = 50
unless sum ==50
puts 'That is incorrect'
else
puts 'Correct'
end | true |
ab65df6218c1465eb922ba6ed8912f6957a0fbf7 | Ruby | mgdelin/operators-online-web-ft-081219 | /lib/operations.rb | UTF-8 | 182 | 2.96875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def unsafe?(speed)
if speed > 60
return true
elsif speed < 40
return true
else return false
end
end
def not_safe?(speed)
speed > 60 or speed < 40 ? true : false
end
| true |
37823c86fc5e1317850a71e1bd760e3b39919357 | Ruby | bemijonathan/tracker | /app/models/transaction.rb | UTF-8 | 435 | 2.53125 | 3 | [] | no_license | require "securerandom"
class Transaction < ApplicationRecord
belongs_to :user
before_save :getvalue
def encode (uuid)
return [uuid.tr('-', '').scan(/../).map(&:hex).pack('c*')].pack('m*').tr('+/', '-_').slice(0..21)
end
def getvalue()
... | true |
03a5d9fdb45dbf687cc69a94a7e49a58dfbab955 | Ruby | learn-co-students/houston-web-062419 | /07-CLI-Application/lib/app.rb | UTF-8 | 564 | 3.03125 | 3 | [] | no_license | $prompt = TTY::Prompt.new
def start
puts 'Welcome to my APP!'
name
end
def name
name = $prompt.ask('What is your name?')
puts name
p = password
puts "Your password is: #{p}"
choices = %w(milk coffee tea orageJuice)
$prompt.multi_select("Select drinks?", choices)
end
# name = prompt.a... | true |
d360de954a635d4546e2ffc30ece84f0a3b1c210 | Ruby | 1powechri2/BikeShare | /app/models/cart.rb | UTF-8 | 764 | 3.25 | 3 | [] | no_license | class Cart
attr_reader :contents
def initialize(initial_content)
@contents = initial_content || Hash.new(0)
end
def total_count
@contents.values.sum
end
def add_accessory(accessory_id)
@contents[accessory_id.to_s] ||= 0
@contents[accessory_id.to_s] += 1
end
def accessory_quantity(acc... | true |
c9ab308c2df9f5af1df9e8f4bf2d5985e8660b52 | Ruby | s6ruby/universum | /universum-contracts/tokens/token_test.rb | UTF-8 | 1,957 | 2.96875 | 3 | [
"CC0-1.0"
] | permissive | # to test the contract script run:
# $ ruby tokens/token_test.rb
require 'minitest/autorun'
require_relative 'token'
class TestToken < Minitest::Test
def setup
@token = Token.new(
name: 'Your Crypto Token',
symbol: 'YOU',
decimals: 8,
initial_... | true |
4275ab528d5840b3c7bc3a859b31bb1482410d28 | Ruby | JDAVEHACKER/RubyLearning | /comparacion_combinado.rb | UTF-8 | 430 | 4.40625 | 4 | [] | no_license | puts "Operador de comparación combinada"
#Devuelve 0 si el primero y el segundo son iguales
#Devuelve 1 si el primero es mayor que el segundo
#Devuelve -1 si el primero es menor que el segundo
puts "ingrese dos número"
num1 = gets.chomp.to_i
num2 = gets.chomp.to_i
res= num1 <=> num2
if res == 0
puts "son iguales"
... | true |
f031dba05393c7aa815b60f135c0b7dea604ec81 | Ruby | paulalexrees/learn_to_program | /ch14-blocks-and-procs/grandfather_clock.rb | UTF-8 | 249 | 3.296875 | 3 | [] | no_license | def grandfather_clock &block
hours = if Time.new.hour > 12
Time.new.hour - 12
else
Time.new.hour
end
hours.times{
yield
}
end
dong = Proc.new {
puts "DONG!"
}
grandfather_clock &dong
| true |
55fbbd4186f48f53254d844caa13709ebe04e92e | Ruby | octosteve/hangman | /lib/hangman/boundary/game_server.rb | UTF-8 | 1,351 | 2.75 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Boundary
class GameServer
attr_reader :name
def initialize(name:)
@name = name
@ractor = create_ractor
end
def make_guess(guess)
ractor.send([:make_guess, guess])
end
def won?
ractor.send([:won?, Ractor.current])
Ractor.rec... | true |
6e1dfe76b3dca4517b9f9f5de59425ebc36d097f | Ruby | klavinslab/ProtocolsForReview | /illumina_ngs/protocol/dilute_total_rna/protocol.rb | UTF-8 | 5,823 | 2.515625 | 3 | [] | no_license | # By Eriberto Lopez
# elopez3@uw.edu
# Production 10/05/18
# C µl
needs "RNA/RNA_ExtractionPrep"
needs "Illumina NGS Libs/RNASeq_PrepHelper"
needs "Illumina NGS Libs/TruSeqStrandedTotalRNAKit"
class Protocol
include RNA_ExtractionPrep
include RNASeq_PrepHelper
include TruSeqStrandedTotalRNAK... | true |
36c02a112f3c9408455458dbce25c4c33f317c90 | Ruby | Mew-Traveler/mew-api | /lib/airbnb_api.rb | UTF-8 | 659 | 2.609375 | 3 | [] | no_license | require 'http'
module Airbnb
# Service for all Airbnb API calls
class AirbnbApi
#Setting the URL and parameters
Airbnb_URL = 'https://api.airbnb.com/'
API_VER = 'v2'
Airbnb_API_URL = URI.join(Airbnb_URL, "#{API_VER}/")
Search_URL = URI.join(Airbnb_API_URL, "search_results")
# attr_reader :a... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.