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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
447f6d0ec04a06619887ae476e19b4bd9bdcef35 | Ruby | freebz/Ruby-Under-a-Microscope | /ch12/ex12-6.rb | UTF-8 | 285 | 2.515625 | 3 | [] | no_license | # coding: utf-8
# 목록 12-6: 완전 가비지 컬렉션 시작하기
def display_count
data = ObjectSpace.count_objects
puts "Total: #{data[:TOTAL]} Free: #{data[:FREE]} Object: #{data[:T_OBJECT]}"
end
30.times do
obj = Object.new
display_count
end
GC.start
display_count
| true |
ac408716feb95ffece438d0a8b5b09bfbcb27d92 | Ruby | gibsonbriann/kwk-l1-user-input-mini-lab-teachers-l1 | /trip.rb | UTF-8 | 517 | 3.96875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | puts "Lets plan a Trip! Where would you like to stay?"
city=gets.chomp
city.capitalize!
puts "What sites would you like to vist?"
sites= gets.chomp
sites.capitalize!
puts "What type of food do you want to eat?"
eat= gets.chomp
eat.capitalize!
puts "How long do you want to stay?"
stay=gets.chomp
stay.capitalize!
puts "G... | true |
95430f3d6e400784766a276d1b67a07ad18c1997 | Ruby | jwworth/exercism | /ruby/armstrong-numbers/armstrong_numbers.rb | UTF-8 | 234 | 3.140625 | 3 | [] | no_license | module ArmstrongNumbers
extend self
def include?(candidate)
digits = candidate.to_s.chars
raised_sum = digits.reduce(0) do |acc, digit|
acc + digit.to_i**digits.length
end
raised_sum == candidate
end
end
| true |
584788fa248e8855d1cac92a0f205a9ce9c6c8c0 | Ruby | dhercher/cosc480 | /sanity_specs/part7_spec.rb | UTF-8 | 660 | 3.984375 | 4 | [] | no_license | # describe "CartesianProduct" do
# it "should exist" do
# lambda { CartesianProduct.new() }.should_not raise_error(::NoMethodError)
# end
# end
class CartesianProduct
include Enumerable
# your code here
def initialize(a, b)
# YOUR CODE HERE
@a = a
@b = b
end
def each
@a.each do |i|
... | true |
4e67e8b437c329b5249fe03fd683b9be9c0cb9ae | Ruby | gemini2gemini/ruby_study | /answer1/06/q4.rb | UTF-8 | 805 | 4.03125 | 4 | [] | no_license | # -*- encoding : utf-8 -*-
#
Te = ['グー','チョキ','パー']
Guu = 0
Choki = 1
Pa = 2
def judge(a, b)
if (a == b)
"引き分け"
elsif (a == Guu && b == Choki ||
a == Choki && b == Pa ||
a == Pa && b == Guu)
"コンピュータの勝ち"
else
"あなたの勝ち"
end
end
def get_te
while (true)
print "#{Te[0]}は0, #{Te[... | true |
be489717a222ac907f7812f24d68dad9a3a29e78 | Ruby | renae-stl/oystercard | /oystercard/lib/oystercard.rb | UTF-8 | 1,092 | 3.203125 | 3 | [] | no_license | require_relative 'journey'
class Oystercard
BALANCE_LIMIT = 90
BALANCE_MINIMUM = 1
MINIMUM_FARE = 1.50
PENALTY_FARE = 3
attr_reader :balance, :journey_history, :journey
def initialize
@balance = 0
@journey_history = []
@journey = nil
end
def top_up(amount)
... | true |
e37296c1d2d78859d0274552710a346ef066cd46 | Ruby | gwlee1991/crackingcodinginterview | /arraysAndStrings/1.8.rb | UTF-8 | 1,719 | 3.9375 | 4 | [] | no_license | # Zero Matrix: Write an algorithm such that if an
# element in an MxN matrix is 0, its entire row
# and column are set to 0.
# brute force solution
# record the row and column where 0 was found.
# iterate through the positions and reassign 0.
# it would take O(mn) + O(mn) + O(mn^2) total
# which would be O(m(n^2)) tim... | true |
0fb5ab3ab4d2c54e02ef45c040b9a0282c546675 | Ruby | namely/ruby-client | /lib/namely/configuration.rb | UTF-8 | 1,600 | 3.015625 | 3 | [
"MIT"
] | permissive | module Namely
class Configuration
# The http codes that should be retried if a request fails while returning
# a page in paged results. Number of times to retry specified in {#retries}.
# Defaults to an empty Array.
#
# @see #retries
# @return [Array<Integer>] the http codes to retry for a fa... | true |
ee0a80bf5da809a3f9b36986235f39140cb3b82a | Ruby | kaiinui/frasco | /lib/frasco/simulator.rb | UTF-8 | 1,362 | 2.984375 | 3 | [
"MIT"
] | permissive | require "thor"
require "frasco/error"
module Frasco
class Simulator
@@SIMULATOR_PATH = "/Applications/Xcode.app/Contents/Applications/iPhone Simulator.app"
def run
raise FrascoError.new("Simulator not installed at '#{path}'") \
unless File.exists?(@@SIMULATOR_PATH)
`open "#{@@SIMULAT... | true |
49156843f59096f2f20d7aff71027b535829c650 | Ruby | ManageIQ/manageiq-smartstate | /lib/fs/ext3/ex_attrib_name.rb | UTF-8 | 849 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | module Ext3
# ////////////////////////////////////////////////////////////////////////////
# // Data definitions.
EX_ATTRIB_NAME = [
'C', 'name_len', # Length of name
'C', 'type', # Type of attribute, see AT_ below.
'S', 'offset_to_val', # Offset to value.
'L', 'blk_loc', ... | true |
47c93c96fa37199641f1c9c050b982d884ace72a | Ruby | kailaisi/android-29-framwork | /rs/script_api/rs_math.spec | UTF-8 | 61,639 | 3.078125 | 3 | [] | no_license | #
# Copyright (C) 2014 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | true |
076068bcee680ab470b708e8f2866f97e130e6be | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/simple-linked-list/a752f8a6c1b54402a1552dd7389a85a0.rb | UTF-8 | 507 | 3.328125 | 3 | [] | no_license | class Element
attr_reader :datum, :next
def initialize(datum, next_element)
@datum, @next = datum, next_element
end
def to_a
[datum].push *self.next.to_a
end
def reverse
self.class.create_multiple(to_a)
end
class << self
def to_a(element)
element.to_a
end
def from_a(l... | true |
d30a4eedf27227763f984a363c74e4f68ec4f1d5 | Ruby | barrels-o-fun/not_rogue_doom | /build_things.rb | UTF-8 | 3,895 | 3.078125 | 3 | [] | no_license | #
# Beginnings of the module, one function so far
#
module BuildThings
# Generates a building and populates static_ x/y arrays
def BuildThings.build_house ( pos_x, pos_y, color="green", house="default", width=80, height=160 )
# Check if x and y match up to grid
build_err_x=0
build_err_y... | true |
62e363fc8ded61097469340f70b4bbdfbdadf43a | Ruby | RHINDI/mini-sed | /mini-sed/lib/mini-sed/mini-sed.rb | UTF-8 | 525 | 2.546875 | 3 | [] | no_license | module MiniSed
def self.delete( quiet, motif, lignes )
# A COMPLETER.
nil
end
def self.print( quiet, motif, lignes )
# A COMPLETER.
nil
end
def self.insert( quiet, motif, lignes )
# A COMPLETER.
nil
end
def self.substitute( quiet, motif, remplacement, global, lignes )
lign... | true |
6b6e59e95beb588608e07cf419d897c4f5dc351b | Ruby | davout/watchy | /lib/watchy/config/gpg_config_builder.rb | UTF-8 | 1,312 | 2.640625 | 3 | [] | no_license | module Watchy
module Config
#
# Handles the GPG related configuration hash
#
class GPGConfigBuilder
def initialize
@verify_sigs_with = []
end
#
# Defines the GPG key to use for signatures
#
# @param k [String] The GPG key identity, usual... | true |
90e4d5bbe1dbaed1a9ac526b69d318760f6d89f5 | Ruby | breakfasting/AAClasswork | /W4D1/knights_travails/knight_pathfinder.rb | UTF-8 | 2,242 | 3.40625 | 3 | [] | no_license | require_relative "00_tree_node"
class KnightPathFinder
attr_reader :considered_positions, :root
def self.is_inbound?(pos)
pos.all? do |i|
i < 8 && i >= 0
end
end
def self.valid_moves(position)
row, col = position
move_hash = {
down_right: [row + 2, col + 1],
down_left: [ro... | true |
e5b073d9b9ad1c7497a850a7666ab0ff4889b48f | Ruby | 31devi/sloving-for-carrots | /carrots.rb | UTF-8 | 45 | 2.875 | 3 | [] | no_license | a,b=gets.chomp.split.map(&:to_i)
puts b;
| true |
57cab4f45b46b9e6a3bd87f3438cb91496f69e85 | Ruby | Nuung/first_git | /bool.rb | UTF-8 | 554 | 2.96875 | 3 | [] | no_license |
puts("HELLO, it's test in git hash for vim and git branch ~ checkout")
<<<<<<< HEAD
puts("Branch check independence!")
puts("What ur name")
=======
puts("change in hot fix")
puts("What is ur name?")
>>>>>>> hotfix
in_name = gets.chomp();
puts("Put ur password!")
in_str = gets.chomp();
if in_str=="1234"
puts("Welcome... | true |
7ea6d3d652dd514236fb4e1818613830f6ce0c8f | Ruby | ShawnAukstak/problems | /cracking-the-coding-interview/is_linked_list_palindrome.rb | UTF-8 | 1,719 | 3.640625 | 4 | [] | no_license | require 'rspec/autorun'
require 'pry'
class Node
attr_accessor :next, :value
def initialize(value)
@value = value
end
end
def is_palindrome_aux?(head)
array = []
until head.nil?
array << head.value
head = head.next
end
mid = (array.length / 2.to_f).ceil - 1
for i in 0..mid
if... | true |
87ce42a6a1e87e3670de227741b998acca359467 | Ruby | JSsquare/AlertsMall | /vendor/bundle/ruby/2.0.0/gems/whois-3.5.4/lib/whois/record/parser/whois.godaddy.com.rb | UTF-8 | 3,180 | 2.65625 | 3 | [
"MIT"
] | permissive | #--
# Ruby Whois
#
# An intelligent pure Ruby WHOIS client and parser.
#
# Copyright (c) 2009-2014 Simone Carletti <weppos@weppos.net>
#++
require 'whois/record/parser/base'
module Whois
class Record
class Parser
# Parser for the whois.godaddy.com server.
#
# @see Whois::Record::Parser::Exa... | true |
981e79dd3eb90c6a7cacb39f8f4bb93e778d832b | Ruby | AJShrivari/Ruby_Assignments | /Study_Drills/Study_Drills-4.rb | UTF-8 | 300 | 4.21875 | 4 | [] | no_license | # Try running ruby from the Terminal as a calculator like you did before, and use variable names to do your calculations. Popular variable names are also i, x, and j.
i = 10
x = 2
j = i + x
puts "The value of i is#{i}"
puts "The value of x is #{x}"
puts "The additon value of i and x is in j #{j}"
| true |
dbea65c2fe4954badee778af4d415b0271932455 | Ruby | collectiveidea/address_book | /address_book.rb | UTF-8 | 846 | 3.546875 | 4 | [] | no_license | require 'csv'
class AddressBook
class InvalidEntry < StandardError
end
def initialize
@entries = []
end
def entries
@entries
end
def add(item)
@entries << item unless @entries.include?(item)
# @entries |= [item]
end
def remove(item)
if @entries.include?(item)
@entries.d... | true |
fde489eec9dfcff06ddec476d8179a0a525c97fb | Ruby | ophelie-gaudin/J7_Exos_Ruby_Peer_Programming | /exo_05.rb | UTF-8 | 137 | 3.25 | 3 | [] | no_license | puts "Donne un nombre"
user_number = gets.chomp
user_number = user_number.to_i
user_number.times do
puts "Salut, ça farte?"
end | true |
21247cd60265fe4cbb7671ceee67562745fb7c82 | Ruby | neddy/Launch-School | /Exercises/120_Object_Oriented_Programing_(Round_2)/2_Medium_1/ex_4.rb | UTF-8 | 968 | 4.0625 | 4 | [] | no_license | # ex_4.rb
class CircularQueue
def initialize(length)
@queue = []
@length = length
end
def enqueue(value)
queue.pop if queue.length >= length
queue.unshift(value)
nil
end
def dequeue
queue.pop
end
private
attr_accessor :queue
attr_reader :length
end
queue = CircularQueue.n... | true |
8230fcf6dc76e548b3fb5c3c03b60e06e6cd27e3 | Ruby | exAspArk/multiple_files_gzip_reader | /lib/multiple_files_gzip_reader.rb | UTF-8 | 713 | 2.859375 | 3 | [
"MIT"
] | permissive | require "zlib"
require "multiple_files_gzip_reader/version"
class MultipleFilesGzipReader < Zlib::GzipReader
include Enumerable
def initialize(io, options = {})
@io = io
@options = options
end
def rewind
io.pos = 0
end
def each(*args, &block)
loop do
gzip_reader = Zlib::GzipReader.... | true |
058c2df59cadb58ba3ca171f8dc126eaf11a9a83 | Ruby | talkable/talkable-ruby | /lib/talkable/configuration.rb | UTF-8 | 1,415 | 2.703125 | 3 | [
"MIT"
] | permissive | module Talkable
class Configuration
DEFAULT_SERVER = 'https://www.talkable.com'.freeze
DEFAULT_TIMEOUT = 5
attr_accessor :site_slug
attr_accessor :api_key
attr_accessor :server
attr_accessor :read_timeout
attr_accessor :open_timeout
attr_accessor :js_integration_library
class Un... | true |
f80e4476cf611d5db66bd03d62f0c96b1cc02cfe | Ruby | mwhanna/housability | /spec/models/schools_model_spec.rb | UTF-8 | 1,793 | 2.765625 | 3 | [] | no_license | require "rails_helper"
RSpec.describe School, :type => :model do
before(:all) do
schools = CSV.read("./datafiles/schools.csv")
schools.shift
numrows = 0
schools.each do |row|
name = row[0]
lat = row[1]
lng = row[2]
addr = row[3]
website = row[4]
School.create(name: name, lat... | true |
8d4a254140a3d05d09a166a4de0f0f87f5435674 | Ruby | jriga/github-collaborators | /lib/github_collaborators/repositories.rb | UTF-8 | 1,735 | 2.515625 | 3 | [
"LicenseRef-scancode-proprietary-license",
"MIT"
] | permissive | class GithubCollaborators
class Repository
attr_reader :data
def initialize(data)
@data = data
end
def id
data.fetch("id")
end
def name
data.fetch("name")
end
def url
data.fetch("url")
end
def locked?
data.fetch("isLocked")
end
def ar... | true |
af16d64dffec9c97f0d206e5cc3c0637e12adaca | Ruby | michelleamazinglin/aA-classworks | /W1D2/Pair/michelle_lin_debugging_exercise_2/lib/problems.rb | UTF-8 | 951 | 3.609375 | 4 | [] | no_license | # Run `bundle exec rspec` and satisy the specs.
# You should implement your methods in this file.
# Feel free to use the debugger when you get stuck.
require "byebug"
def prime?(num)
if num < 2
return false
end
(2...num).each do |factor|
return false if num % factor == 0
end
true
end... | true |
144e8a7b0efec94aeb80146d34148c12a7e92af1 | Ruby | samwoods1/pnsqc_demo_project | /test/pages/registration_page.rb | UTF-8 | 2,597 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | require_relative 'base_page'
require_relative '../data/user'
require_relative 'all_pages'
class RegistrationPage < BasePage
def initialize
@signup_form = DemoElement.new '#signup'
@first_name_text = DemoElement.new "input[name='signup:fname']"
@last_name_text = DemoElement.new "input[name='signup:lname... | true |
2f37271971941413786c6d6e887cfabdb38ee1b6 | Ruby | baschenbrenner/advanced-hashes-hashketball-prework | /hashketball.rb | UTF-8 | 5,526 | 3 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def game_hash
{
:away=>{
:team_name=>"Charlotte Hornets",
:colors=>["Turquoise","Purple"],
:players=>{
"Jeff Adrien" => {
:number => 4,
:shoe => 18,
:points => 10,
:rebounds => 1,
:assists => 1,
:steals => 2,
:blocks => 7,
... | true |
08f2157e6b7080e92c2e3dc0f197bb386beb0174 | Ruby | sendorf/nxn_grid | /Rspec/nxn_dictionary_spec.rb | UTF-8 | 578 | 3.3125 | 3 | [] | no_license | # nxn_dictionary_spec.rb
require_relative '../nxn_dictionary.rb'
describe Nxn_Dictionary, "Generate NxN grid" do
it "Generate an N x N grid, where N can be any number, and randomly populate the grid with letters (A-Z)." do
nxn_dictionary = Nxn_Dictionary.new
dimension = (2..12).to_a.shuffle.first #Ran... | true |
cb7776d949417d4d80b32dc34352dadbda01e378 | Ruby | Cyclid/Cyclid | /app/cyclid/controllers/users/collection.rb | UTF-8 | 4,773 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
# Copyright 2016 Liqwyd Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | true |
0253f65d046b1b70947250a636e537b3ea8c453a | Ruby | jessethebuilder/bca_tree | /lib/bca_tree.rb | UTF-8 | 1,668 | 2.65625 | 3 | [] | no_license | require 'rubygems'
require 'bundler/setup'
Bundler.require
require_relative 'show_page'
require_relative 'wbca_scribe'
class BcaTree
# include Mechanize
def initialize(url)
@started_at = Time.now
@index_url = url
@mech = Mechanize.new
goto_index_page
@title = @mech.page.css('.title').text
... | true |
631d3135e39fa95c07a390863b7ecac202e31514 | Ruby | cultome/data_pipe | /lib/data_pipe/step/error_handler.rb | UTF-8 | 457 | 2.515625 | 3 | [
"MIT"
] | permissive | require "data_pipe/stepable"
module DataPipe::Step
class ErrorHandler
include DataPipe::Stepable
attr_reader :fnc
def step_command
:handle_error
end
def iter
Enumerator.new do |rsp|
it = input.each
loop do
value = it.next
rsp << value
res... | true |
e9359ee15134094e1a0392743dba00ee47b99309 | Ruby | thoswarner/happimetrics | /app/models/metric.rb | UTF-8 | 622 | 2.625 | 3 | [] | no_license | class Metric < ActiveRecord::Base
attr_accessible :description, :title, :metric_type_ids, :metric_format
# enumerables
enumerate :metric_format
# associations
has_and_belongs_to_many :metric_types
has_many :metric_values
#validations
validates :title, :description, :metric_format, :metric_types, :pre... | true |
e2c68a0c1ee0be250a794d347a6a4f6d945b6a38 | Ruby | estum/procodile | /lib/procodile/logger.rb | UTF-8 | 414 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'logger'
module Procodile
def self.mutex
@mutex ||= Mutex.new
end
def self.log(color, name, text)
mutex.synchronize do
text.to_s.lines.map(&:chomp).each do |message|
output = ""
output += "#{Time.now.strftime("%H:%M:%S")} #{name.ljust(18, ' ')} | ".color(color)
out... | true |
5e61ec2de843fa98907efe44f6b0805e5804b0ba | Ruby | BlakeWilliams/prettyrb | /test/prettyrb_test.rb | UTF-8 | 27,579 | 2.515625 | 3 | [
"MIT"
] | permissive | require "test_helper"
class PrettyrbTest < Minitest::Test
def test_that_it_has_a_version_number
refute_nil ::Prettyrb::VERSION
end
def test_long_ternary
source = <<~RUBY
really_really_long_method_call ? true_method_call_that_is_also_really_really_long : else_method_call_that_is_also_really_long
... | true |
18fd1af4d19358a7b94dc6a1ea74abf2b24335ac | Ruby | michaeleconomy/town_generator | /lib/town_generator/simulators/life/death/murder_simulator.rb | UTF-8 | 4,471 | 2.703125 | 3 | [] | no_license | # http://www.fbi.gov/about-us/cjis/ucr/crime-in-the-u.s/2012/crime-in-the-u.s.-2012/offenses-known-to-law-enforcement/expanded-homicide/expanded_homicide_data_table_10_murder_circumstances_by_relationship_2012.xls
#TODOS
# - particular races could have different murder rates...
# - split up causes of murder (disagreem... | true |
bdfd0bd7939b5644d8831c8eeaacb9bccbd1300f | Ruby | Nalipp/launch_school_intro_excercises | /countdown2.rb | UTF-8 | 137 | 3.421875 | 3 | [] | no_license | def countdown_to_zero(num)
if num <= 0
puts num
else
puts num
countdown_to_zero(num - 1)
end
end
countdown_to_zero(9)
| true |
8fc4244dce1f431eee7bd88f88b3485a98083ac2 | Ruby | JennicaStiehl/enigma | /test/enigma_test.rb | UTF-8 | 4,405 | 3.09375 | 3 | [] | no_license | require './test/test_helper'
require 'pry'
require './lib/enigma'
class EnigmaTest < Minitest::Test
def test_it_exists
enigma = Enigma.new
assert_instance_of Enigma, enigma
end
def test_it_can_check_shifts
enigma = Enigma.new
assert_equal [3, 27, 73, 20], enigma.check_shifts("02715", "040895"... | true |
80aff31458dc1d3d0ad4825e0aa573ec1201989f | Ruby | alex-yoon/aether-fe | /app/helpers/campaign_auth_helper.rb | UTF-8 | 1,189 | 2.75 | 3 | [] | no_license | # Methods for restricting access to resources based on user's permissions
# in the related campaign.
module CampaignAuthHelper
def user_is_member(campaign)
!get_membership(campaign).nil?
end
def user_is_admin(campaign)
return false if get_membership(campaign).nil?
@campaign_membership.role == "admin... | true |
5d4b2201f5671e8fdc977247e55978ce4e479814 | Ruby | CallumD/Electune | /spec/models/song_spec.rb | UTF-8 | 631 | 2.625 | 3 | [] | no_license | require 'spec_helper'
describe Song do
let(:song) { FactoryGirl.create(:song) }
it "should allow duplicate name" do
duplicate = FactoryGirl.build(:song)
duplicate.should be_valid
end
it "should not allow empty name" do
song = FactoryGirl.build(:song, name: '')
song.should_not be_valid
end
... | true |
ea40592def056e545a0a89637439f741c80efb3a | Ruby | GabrielXs/ListSmallCaps | /smallcaps/small_caps.rb | UTF-8 | 1,061 | 3 | 3 | [] | no_license |
class SmallCaps
attr_accessor :header, :data
def initialize()
@header = []
@data = []
end
def setHeader(data)
@header << data
end
def getHeader
self.header
end
def headerConcat
head = ''
self.header.each_with_index do |val, idx|
if idx < (self.header.size - 1)
head.concat(val.to_s + ";... | true |
f96999419189053058c2dda29f13f40c1a5e6b53 | Ruby | Lv-612-Ruby/Console_Project | /Tasks/help_the_bookseller.rb | UTF-8 | 1,584 | 3.328125 | 3 | [] | no_license |
def stockList(arr, arr_2)
arr_2_uniq = arr_2.uniq.sort
print "Дано : #{arr}"
new_array = Array.new
for el in arr
firstCharakter = el[0].to_s #search First Letter
lastCharakter = el[/\d+/].to_i # search number
a = [firstCharakter,lastCharakter] #creat array with First Letter and n... | true |
f2a8710ed974d9caa1c730911312bd40456c2be8 | Ruby | Lukis92/ruby_tasks | /7_kyu/vampire_numbers.rb | UTF-8 | 764 | 3.96875 | 4 | [] | no_license | #https://www.codewars.com/kata/vampire-numbers-1/
def vampire_test(a, b)
result = multiply(a, b)
arr = getArrayOfNum(result)
arr_a = getArrayOfNum(a.abs)
arr_b = getArrayOfNum(b.abs)
sum = arr_a + arr_b
if arr.sort == sum.sort && double_negative?(a, b)
return true
else
return false
end
end
# c... | true |
7e973a252fdebd73b11ac8028ccea46aa4b50c58 | Ruby | SeuRAUL/LRTHW | /projects/ex48/tests/test_parser.rb | UTF-8 | 464 | 2.734375 | 3 | [] | no_license | require "./lib/parser.rb"
require "test/unit"
class TestParser < Test::Unit::TestCase
def testSentence
p = parse_sentence([['verb', 'run'], ['direction', 'north']])
s = Sentence.new(['noun', 'player'], ['verb', 'run'], ['direction', 'north'])
assert_equal(p.verb, s.verb)
assert_equal(p.object, s.obje... | true |
76074abe92f84f4be50456b08ebc9281447c1aed | Ruby | quichey/hw-sinatra-saas-hangperson | /lib/hangperson_game.rb | UTF-8 | 2,280 | 3.5625 | 4 | [] | no_license | class HangpersonGame
# add the necessary class methods, attributes, etc. here
# to make the tests in spec/hangperson_game_spec.rb pass.
# Get a word from remote "random word" service
# def initialize()
# end
attr_reader :word
attr_reader :guesses
attr_reader :wrong_guesses
attr_reader :word_with_gu... | true |
08f267df8b9917d9f916648efab74b50a145fcec | Ruby | urizaraj/av-club-parse | /lib/tag.rb | UTF-8 | 401 | 3.421875 | 3 | [
"MIT"
] | permissive | # Class for Article tags
class Tag
attr_accessor :name, :url, :articles, :size
def initialize(name, url)
self.name = name
self.url = url
self.articles = []
self.size = 0
end
def add_article(article)
articles << article
self.size += 1
end
def display
puts url
puts
artic... | true |
bb16ed963a3cdc445d99a025c68447f066754424 | Ruby | aphero/weather_report | /current_condition.rb | UTF-8 | 666 | 2.859375 | 3 | [] | no_license | require 'httparty'
require 'byebug'
require 'json'
class CurrentCondition
def initialize(zip)
@zip = zip
@response = get_response
end
def location
@response["current_observation"]["display_location"]["full"]
end
def temp
@response["current_observation"]["temp_f"]
end
def rel_humidity
... | true |
3b0d71b6c16bcce4628846835e452d8bdc058dbb | Ruby | akmcc/Evented | /ChatServerEventLoop/Client.rb | UTF-8 | 400 | 2.875 | 3 | [] | no_license | class Client
include MockEventsEmitter
def initialize(socket)
@socket = socket
end
def handle_read
message = to_io.read_nonblock(1000)
if message.downcase.match(/\Aexit\!/)
emit(:close, self)
to_io.close
else
emit(:message, [message, self])
end
end
#IO.select... | true |
054a06df3f131869ed97297ac2fdd1091b488732 | Ruby | Aliciawyse/ruby_practice | /object_oriented_programming_with_ruby/classes_and_objects_pt2/exercise1.rb | UTF-8 | 613 | 4.21875 | 4 | [] | no_license | # Add a class method to your MyCar class that calculates the gas mileage of any car.
class MyCar
attr_accessor :color #read and write
attr_reader :year, :model #read only
def initialize(year, color, model)
@year = year
@color = color
@model = model
@current_speed = 0
e... | true |
8c6d4e799cd0475af458a6e73f69b096293e0a1d | Ruby | NOrochena/collections_practice_vol_2-dc-web-051319 | /collections_practice.rb | UTF-8 | 1,402 | 3.46875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # your code goes here
def begins_with_r(arr)
bool = true
arr.each do |val|
if !val.start_with?("r")
bool = false
end
end
bool
end
def contain_a(arr)
arr.keep_if do |val|
val.include? "a"
end
end
def first_wa(arr)
arr.each do |val|
if val.to_s.start_with?("wa")
return val
... | true |
befefd43549ec9b21f9acef9ddcaf498641344c7 | Ruby | baizhenchao/os_statics | /nodeos_speed/lib/nodeos_statics/mysqlfunc.rb | UTF-8 | 2,017 | 2.578125 | 3 | [] | no_license | #! ruby
# 和数据库有关的东西可以封入一个对象,回一下Active Record
$mydb=Db.new $config["db"]
def getrange(hostlist)
range=""
range=hostlist.join(",")
return range
end
def gethostbyOs(os,date,hostlist)
trange=getrange(hostlist)
rslt=$mydb.query("select host from Server_osstatics where os=\"#{os}\" and date=\"#{date}\" and host in ... | true |
6956c6ce4b3e6deeff3d104a12fff87dd3c6b6e4 | Ruby | chrislawrence/pomade | /app/models/no_pomodoro.rb | UTF-8 | 228 | 2.625 | 3 | [] | no_license | class NoPomodoro
def method_missing(*args, &block)
self
end
def destroy
nil
end
def end_time
Time.new(0)
end
def to_s
0
end
def to_i
0
end
def to_date
Date.today
end
end
| true |
639ea0948ee032c005cabeb68ea77887de1b4737 | Ruby | pragdave/record_session | /lib/record_session.rb | UTF-8 | 4,577 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require "optparse"
require "pty"
require "json"
require 'termios'
LFLAG_MASK = ~(Termios::ISIG |
Termios::ICANON |
Termios::IEXTEN |
Termios::ECHO |
Termios::ECHOE |
Termios::ECHOK |
Termios::ECHONL)
IFLAG_MASK = ~(Termio... | true |
d4647c00b33423f0c6dd4be8026d0f5dc112e685 | Ruby | 6568973/lesson2 | /nomer_day.rb | UTF-8 | 435 | 3.796875 | 4 | [] | no_license | puts "Введите день: "
day = gets.chomp.to_i
puts "Введите месяц: "
month = gets.chomp.to_i
puts "Введите год: "
year = gets.chomp.to_i
month_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
month_days[1] = 29 if year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)
sum = 0
for i in 0..month-2
sum += month_d... | true |
bf2e94a079eb3dbd568e9129a8373357e1c24bf5 | Ruby | jlchenwenbo/ufo | /lib/ufo/tasks/builder.rb | UTF-8 | 1,429 | 2.640625 | 3 | [
"MIT"
] | permissive | module Ufo
class Tasks::Builder
# build and registers together
def self.register(task_definition, options)
# task definition and deploy logic are coupled in the Ship class.
# Example: We need to know if the task defintion is a web service to see if we need to
# add the elb target group. The... | true |
cd4712ecc8b218df53bae8157db6da21e39b98f1 | Ruby | akamah/garbanzo | /interpreter.rb | UTF-8 | 2,083 | 2.890625 | 3 | [] | no_license | # coding: utf-8
=begin
幾つかのプロトタイプに共通する事項をまとめる.
* コマンドライン引数の処理
* デバッグ/プロファイリングなどのサポート
=end
require 'optparse'
require 'readline'
require 'stackprof'
require './repr.rb'
require './evaluator.rb'
module Garbanzo
class Interpreter
attr_reader :evaluator, :name
def initialize(name)
@name = name
... | true |
b79d13dbb501253772a729be6da17dc9c1d8efa1 | Ruby | jershmagersh/redditwallgrab | /reddit_wall_grab.rb | UTF-8 | 4,459 | 2.828125 | 3 | [] | no_license | #!/usr/bin/ruby
require 'net/http'
require 'optparse'
require 'json'
@options = {}
OptionParser.new do |opts|
opts.banner = "Usage: reddit_wall_grab.rb [options]"
option_provided = false
opts.on("-v", "Verbose output.") do
@options[:verbose] = true
option_privided = true
end
opts.on("-h", "Dis... | true |
69f89f6292a7d2f78aabe22b8b7966ac6beb822f | Ruby | leoariaspaz/gastos | /lib/src/consultar_movimientos.rb | UTF-8 | 3,583 | 2.59375 | 3 | [] | no_license | require 'pp'
def group_by_usuario
# puts (1..6).group_by {|i| i%3}
empresa_id = Usuario.find(9).empresa_id
movs = Movimiento
.joins(:empresa)
.joins(transaccion: :tipo_transaccion)
.joins(:cuenta)
.select("movimientos.*, transacciones.descripcion AS trx_desc, transacciones.... | true |
8227580624f828dfa8969f31f10e898c13f087c1 | Ruby | ii2q/ruby_design_pattern_sample | /12_builder_sample2.rb | UTF-8 | 1,743 | 3.90625 | 4 | [] | no_license | # -*- coding: utf-8 -*-
# ConcreteBuilder:ビルダーの実装部分
# SaltWater: 塩水クラス
class SaltWater
attr_accessor :water, :salt
def initialize(water, salt)
@water = water
@salt = salt
end
# 塩を加える
def add_material(salt_amount)
@salt += salt_amount
end
end
# ConcreteBuilder:ビルダーの実装部分
# SugarWater: 砂糖水クラス
cl... | true |
60ff93213172ec0b03937e20c3ac0bec64e8f01a | Ruby | AndriyPedan/lesson2 | /pet.rb | UTF-8 | 6,075 | 3.15625 | 3 | [] | no_license | module Actions
attr_reader :name
ATTR_CHNG = 5
def feed
@attr[:health] += ATTR_CHNG
@attr[:fullness] += ATTR_CHNG + rand(ATTR_CHNG)
pass_time
puts "#{@name} поїв."
end
def play
@attr[:health] += ATTR_CHNG + rand(ATTR_CHNG)
@attr[:mood] += ATTR_CHNG + rand(ATTR_CHNG)
@attr[:fullnes... | true |
8df1e7613747136b3e2afd5e06cd6df684cba242 | Ruby | rgonzalez12/reverse-each-word-onl01-seng-pt-100619 | /reverse_each_word.rb | UTF-8 | 189 | 3.75 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(string)
reversed_words = string.split(" ")
reversed_array = []
reversed_array = reversed_words.collect {|word| word.reverse }
reversed_array.join(" ")
end | true |
2cea1e61fc3f48e52a6517c8c90388b534d49933 | Ruby | happyFish/wikipedia-client | /lib/wikia.rb | UTF-8 | 1,544 | 2.578125 | 3 | [
"MIT"
] | permissive | Dir[File.dirname(__FILE__) + '/wikia/**/*.rb'].each { |f| require f }
require 'uri'
module Wikia
# Examples :
# page = Wikia.find('Rails')
# => #<Wikia:0x123102>
# page.content
# => wiki content appears here
# basically just a wrapper for doing
# client = Wikia::Client.new
# client.find('Rails')... | true |
3d3ff99e40ff6be103fe6f8b5c6a51dea774a13c | Ruby | roomorama/concierge | /lib/concierge/suppliers/kigo/booking.rb | UTF-8 | 1,562 | 2.75 | 3 | [] | no_license | module Kigo
# +Kigo::Booking+
#
# This class responsible for creating booking through Kigo's API.
class Booking
include Concierge::JSON
API_METHOD = 'createConfirmedReservation'
attr_reader :credentials, :request_handler
def initialize(credentials, request_handler: nil)
@credentials ... | true |
c1e7e32f77922661a4ba6262a9fac536d0f61a19 | Ruby | krishnakumar6893/Backend-master | /lib/deeptype_util.rb | UTF-8 | 1,474 | 2.53125 | 3 | [] | no_license | require 'net/http'
require 'uri'
module DeeptypeUtil
def self.communicate_deeptype_with(params)
deeptype_url = deeptype_request_url(params)
response = error = ""
retries = 0
begin
url = URI.parse(deeptype_url)
req = Net::HTTP::Get.new(url.to_s)
response = Net::HTTP.start(url.host,... | true |
06839d732e7e57aaea9b164e74852d2505e529fd | Ruby | dvmrmc/Juego_De_La_Wena_vida | /game.rb | UTF-8 | 10,465 | 2.90625 | 3 | [
"MIT"
] | permissive | def start
puts "Bienvenido, acabas de entrar en el... Camino De La Wena Vida"
fase_1
end
def dead (text)
puts text
puts "Te has muerto mamon!!!!!! juajuajuajuajuajuajua (risa de malo estrenio)"
gets
system "clear"
start
end
def make_decision
decision = gets
decision.delete!("\n")
decision
end
def fas... | true |
3bf5ee0a7806ab957763a5ec7b1bb25942ac1c71 | Ruby | AldairMC/exercism--tracks | /ruby/armstrong-numbers/armstrong_numbers.rb | UTF-8 | 264 | 3.390625 | 3 | [] | no_license | # frozen_string_literal: true
# Exercism armstrong number
class ArmstrongNumbers
def self.include?(number)
num_length = number.to_s.length
arm_number = number.to_s.each_char.map { |i| i.to_i.pow(num_length) }.sum
number.to_i == arm_number
end
end
| true |
85b72dfff57c18e4dbffae7401e86971b06c444b | Ruby | poshboytl/public_weixin | /app/services/message_service.rb | UTF-8 | 405 | 2.65625 | 3 | [] | no_license | class MessageService
attr_reader :request, :by_hot, :page
def initialize(request, params)
@request = request
@page = (params[:page] || 1).to_i
@by_hot = !!params[:by_hot]
end
def index
if by_hot
messages = Message.by_vote.page(page)
else
messages = Message.recent.page(page)
... | true |
e0c62277df8ad886b428a537a382e95fa98a9986 | Ruby | arnabc74/arnabc74.github.io | /numana2021/multidiff.rb | UTF-8 | 4,309 | 2.921875 | 3 | [] | no_license | <NOTE>
@{<UPDT>TUE APR 14 IST 2020</UPDT>
<M>\newcommand{\v}{\vec}</M>
<HEAD1>Multivariate differentiation</HEAD1>
<HEAD2>The definition</HEAD2>
Suppose that you have a function <M>f:\rr^n\to\rr^m.</M> Then we
say that it is differentiable at some <M>\v a\in\rr^n</M> if
locally at <M>\v a</M> the function may be "we... | true |
3edf446fe3ae80921e51814d981fd73218eae3d1 | Ruby | loveablelobster/pia | /lib/pia/requestinterval/duration.rb | UTF-8 | 3,218 | 3.59375 | 4 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Pia
# Durations are initialized with a String that specifies a duration in simple
# a simple notation using integers and the tokens +h+ (hours), +m+ (minutes),
# and +s+ (seconds) and can calculate the duration in seconds.
#
# ===== Examples
#
# Duration.in_seconds(... | true |
6c3b5dc753272f7ca9dfc199d6a4cdfa9b2876a8 | Ruby | bjornblomqvist/emailer | /lib/emailer/mail_queue.rb | UTF-8 | 1,151 | 2.90625 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-unknown-license-reference"
] | permissive |
module Emailer
class MailQueue
def initialize(smtp)
@smtp = smtp
@queue = []
end
def empty?
@queue.empty?
end
def length
@queue.length
end
def add(mail, &callback)
mail[:content_type] ||= 'text/plain'
mail[:encoding] ||= 'utf-8'
... | true |
a2dc82ca0e70881f2a87e6fd09c265a1c38e2674 | Ruby | nathanluo915/phase-0 | /week-5/pad-array/testing.rb | UTF-8 | 362 | 3.78125 | 4 | [
"MIT"
] | permissive |
def pad(array, min_size, value = nil) #non-destructive
new_array = array
puts "New array without bracket #{new_array}"
# new_array = array + []
# puts "New array with bracket #{new_array}"
if array.length < min_size
(min_size - array.length).times do new_array.push(value) end
end
return new_array
end... | true |
47db4df0221ff361c926296c8db82b744af6ce83 | Ruby | denkoroku/cath_riddoch_pda | /Static_and_Dynamic_Task_A/card_game_spec.rb | UTF-8 | 807 | 3.25 | 3 | [] | no_license | require ('minitest/autorun')
require ('minitest/rg')
require_relative ('card_game')
require_relative ('card')
class TestCardGame < MiniTest::Test
def setup()
@game1 = CardGame.new(@card1, @card2)
@card1 = Card.new("clubs", 5)
@card2 = Card.new("spades", 1)
@cards = [@card1, @card2]
end
def test... | true |
27c7b5b6d30da41f0000dc1628ba4f41935ea92d | Ruby | connor-t/number2word_test | /num2english.rb | UTF-8 | 119 | 3.0625 | 3 | [] | no_license | require_relative 'lib/mynumber'
number = ARGV.first
mynumber = Mynumber.new(number.to_i)
puts mynumber.number2word
| true |
ca5c0386f1697ef4d56cfc7b11a812b7834a1fb3 | Ruby | LeinbergerDev/bloc-algorithms | /fibonnaci_recursive_spec.rb | UTF-8 | 497 | 2.828125 | 3 | [] | no_license | include RSpec
require_relative 'fibonnaci_recursive'
RSpec.describe Fibonnaci, type: Class do
let(:fibonnaci) { Fibonnaci.new}
describe "fib()" do
it "should return 0 for fib(0)" do
expect(fibonnaci.fib(0)).to eq 0
end
it "should return 1 for fib(1)" do
expect(... | true |
bacf33d048390cc67af82d4233271935f0d89c14 | Ruby | nbuggia/baron-blog-engine-gem | /spec/baron_blog_engine_spec.rb | UTF-8 | 3,659 | 2.625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
###
# Tests Baron::BlogEngine class
#
# This class understands how the blog directory structure works, and is used by the app to access
# all content from the directory structure.
describe "Baron::BlogEngine" do
before :all do
@config = load_config()
@blog_engine = Baron::BlogEngine.ne... | true |
2439d08ce2f7a7a1a9954e8d332b6254ac82787f | Ruby | lhoeg/ooapi.rb | /lib/validation/error_code_checker.rb | UTF-8 | 928 | 3.28125 | 3 | [] | no_license | class ErrorCodeChecker
@@error_codes = ['APP001', 'APP002', 'APP003', 'APP004', 'APP005',
'SRV001', 'SRV002', 'SRV003', 'SRV004', 'SRV005', 'SRV006',
'CAN001', 'CAN002',
'AUTH001', 'AUTH003', 'AUTH004', 'AUTH005', 'AUTH006', 'AUTH007', 'AUTH008', 'AUTH009',
'LOCK001', 'LOCK002', 'LOCK003',
'OCES00... | true |
74fdd51e6f8c6735098bceed68b4b60464a04021 | Ruby | alperenbozkurt/FilmAL | /models/Kullanici.rb | UTF-8 | 1,986 | 2.515625 | 3 | [] | no_license | class Kullanici
attr_accessor :id, :kullanici_adi, :adi, :soyadi,:parola, :resim_url, :admin_mi
def initialize(id,kullanici_adi,adi,soyadi,parola,resim_url,admin_mi)
@id = id
@kullanici_adi = kullanici_adi
@adi = adi
@soyadi = soyadi
@parola = parola
@resim_url = resim_url
@admin_mi = ad... | true |
011426488e830c9676f4c5a2c0d32dea86160502 | Ruby | jennianelson/sinatra-mvc-lab-v-000 | /models/piglatinizer.rb | UTF-8 | 510 | 3.453125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class PigLatinizer
def piglatinize(word)
cons_sound = word.downcase[/\A[^aeiou]+/]
if cons_sound != nil
result = word.gsub(cons_sound, "")
result + cons_sound + "ay"
else
word + "way"
end
end
def to_pig_latin(string)
string.split(" ").map do |word|
cons_sound = word[/... | true |
e8a84b067568c30bb4e43c149f72404257606d1b | Ruby | Meowsers25/codecademyRuby2018 | /controlFlow/script7.rb | UTF-8 | 163 | 3.109375 | 3 | [] | no_license | # Less than: <
# Less than or equal to: <=
# Greater than: >
# Greater than or equal to: >=
test_1 = 17 > 16
test_2 = 21 < 30
test_3 = 9 >= 9
test_4 = -11 <= 4 | true |
0071ebcb7f33a1fb997bf40eb5748a4f9d4e4a67 | Ruby | aavenoso/logorrhea | /test/unit/team_test.rb | UTF-8 | 2,729 | 2.640625 | 3 | [] | no_license | require 'test_helper'
require 'factory_girl'
require 'shoulda'
require 'shoulda/active_record/macros'
require 'faker'
class TeamTest < ActiveSupport::TestCase
Factory.define :team do |t|
t.name "test team"
end
Factory.define :user do |t|
t.username "user"
t.first_name "joe"
t.last_name "smith"
... | true |
0914540087d620a0e1ce75dd020f81ac877107ef | Ruby | hexinpeter/SMD_PROJ3 | /app/controllers/data_controller.rb | UTF-8 | 1,480 | 2.53125 | 3 | [] | no_license | class DataController < ApplicationController
def locations
@date = Date.today
@locations = Location.all
end
def show
@location_id = params["location_id"]
@date = params["date"]
isPostCode = false
PostCode.all.each do |postcode|
if @location_id == postcode.num
isPostCode = ... | true |
2e151c082da32b751e33f57d87fad5b372c947e0 | Ruby | ktrops/food-tracker | /db/seeds.rb | UTF-8 | 3,212 | 2.6875 | 3 | [] | no_license | require 'httparty'
if Rails.env.production? == true
products_uri = "http://foodtrackerapi.herokuapp.com/product/all"
categories_uri = "http://foodtrackerapi.herokuapp.com/category/all"
fridge_uri = "http://foodtrackerapi.herokuapp.com/fridge"
freezer_uri = "http://foodtrackerapi.herokuapp.com/freezer"
pantry... | true |
871df490362b89ebfc6a34a06f75d159e1d27a05 | Ruby | joejknowles/czech_react | /db/seeding/src/vocab_provider.rb | UTF-8 | 205 | 2.5625 | 3 | [] | no_license | class VocabProvider
def initialize csv_provider, parser
@csv_provider = csv_provider
@parser = parser
end
def vocab
contents = @csv_provider.contents
@parser.parse contents
end
end | true |
0d4b799163851642b54d13c3e859840d4d12eef2 | Ruby | omagdiel/BinaryGuessing | /classmates_code.rb | UTF-8 | 1,064 | 4.1875 | 4 | [] | no_license | ==================================CRAIGS CODE============================
system("clear")
puts "Think of a number between 1 and 25 I will figure it out."
sleep(2)
p 'READY'
sleep(1)
p 'SET'
sleep(1)
p 'GO'
sleep(1)
my_arr = [*1..25]
correct = "N"
until correct == "Y" do
guess = my_arr.sample
puts "Is the answer... | true |
bd9bc4a11224ab27f388237c3ff9696478c62ab3 | Ruby | BriKutauskas/ruby_day4 | /Task.rb | UTF-8 | 314 | 3.34375 | 3 | [] | no_license |
class Task
def initialize
@description
@done = "not done"
end
def add_description(description)
@description = description
end
def done
@done = "done"
end
def if_done
@done
end
def to_s
if (Task.new.done == "done")
"#{@description}, #{@done}"
end
end
end
| true |
d0e77b9cd7049a441fdfc48bc27ab8b78650c60b | Ruby | holt-ace/backend_prework | /day_1/ex3calc.rb | UTF-8 | 192 | 3.46875 | 3 | [] | no_license | puts "This is my calculator!"
#this calculator will do simple math equations.
puts "What is 5+4? #{5+4}"
puts "What is 5-4? #{5-4}"
puts "What is 10*4? #{10*4}"
puts "What is 10%4? #{10%4}"
| true |
12c05b3ad7e59853c7f3677af3009e365f6ca317 | Ruby | IonatanMocan/Learn-Ruby-the-hard-way | /ex19.rb | UTF-8 | 263 | 3.578125 | 4 | [] | no_license | def cheese_and_crackers(*args)
cheese, crackers = args
puts "how much cheese?"
cheese = $stdin.gets.chomp
puts "how much crackers?"
crackers = $stdin.gets.chomp
puts "wow, you have #{cheese} cheese and #{crackers} crackers"
end
cheese_and_crackers()
| true |
92d93225c077800f5c4822668c79de8823cdda47 | Ruby | 404pnf/2u4u_dl | /r_rename.rb | UTF-8 | 1,850 | 2.84375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
require 'fileutils'
# usage: script.rb inputfolder outputfolder
$input = File.expand_path(ARGV[0].chomp('/'))
$output = File.expand_path(ARGV[1].chomp('/'))
def sanitize(title)
# 不要替换 / 否则路径分割符号也被替换了
# 因为下面的file是含有路径的
# 也不要替换英文句号,因为作为文件后缀分割符号
# 例子: "source//TLF/PBS自由选择/PBS.自由选择_2_/_PBS... | true |
6aa0486ab017bbc23f284dd7f71bee6b5ba13cad | Ruby | osulp/API | /app/services/api/library_open_hours_json.rb | UTF-8 | 4,963 | 3.203125 | 3 | [] | no_license | # frozen_string_literal: true
# This returns a json object that contains open hours
# Input: Raw JSON from Alma
# output: OSULP JSON with additional fields
module API
# Format raw json hours fetched from Alma and return the expected format ready
# to be rendered.
#
# @param [Hash] raw_hours
# @returns [Strin... | true |
e577e8aa5ee08d5a87db0d7cda5936762c91b276 | Ruby | Caroguti/rubyonrails | /carta.rb | UTF-8 | 370 | 3.40625 | 3 | [] | no_license | class Carta
attr_accessor :numero,
:pinta
def initialize(numero,pinta)
@numero = numero
@pinta = pinta
end
def to_s
puts "número:#{numero}| pinta:#{pinta}|"
end
end
p = ['C','D','E','T']
cartas =[]
5.times do
cartas.push(Carta.new(Rando... | true |
ab0ba9537de15b17f31b3d44967800b303fa3f8d | Ruby | slonia/aoc2020 | /01/star1.rb | UTF-8 | 190 | 3.078125 | 3 | [] | no_license | pairs = []
File.readlines('input.txt').each do |line|
number = line.chomp.to_i
diff = 2020 - number
if pairs.include?(diff)
puts diff * number
else
pairs << number
end
end
| true |
f546b72a71043fc8b684f56e8402ce45395d5250 | Ruby | nikhgupta/Movier | /lib/movier/info.rb | UTF-8 | 1,383 | 3.125 | 3 | [] | no_license | module Movier
# Find and return information about a movie with the given keywords
#
# * *Args* :
# - +keyword+ -> keywords to search for in movie title
# - +options+ -> hash that alters the behavior of the search
# if +:year+ key is specified, restricts search to that year
# ... | true |
2c57322f476cd409f69fb479d33b4d6385b646c0 | Ruby | Frannyontech/patrones_y_ciclos_anidados | /Desktop/Desafio_Latam/ruby/semana2/desafio anidados/patrones.rb | UTF-8 | 2,302 | 3.53125 | 4 | [] | no_license | n = ARGV[0].to_i
# metodo letra_o(n)
def letter_o(n)
n.times do |i|
print '*'
end
print "\n"
(n - 2).times do
print '*'
(n - 2).times do
print " "
end
print '*'
print "\n"
end
n.times do |i|
print '*'
end
print "\n" ... | true |
bd67b0f087b70166dd669d81c31115121f066c60 | Ruby | MNashSparta/sparta-oop-intro | /oop_starter_code/vehicles/bicycle.rb | UTF-8 | 278 | 2.984375 | 3 | [] | no_license | require_relative './bike'
class Bicycle < Bike
def move_forward
super
puts "The bicycle went forward really quickly."
end
def get_engine
puts "This vehicle doesn't have an engine."
end
end
bc = Bicycle.new
bc.move_forward
bc.get_engine
bc.query_wheels
| true |
e654b462d419e60abc98ff6f71e4cdd8af3a3077 | Ruby | javiertoledo/provincias | /lib/provincias.rb | UTF-8 | 2,787 | 2.890625 | 3 | [
"MIT"
] | permissive | # -*- encoding: utf-8 -*-
require "provincias/version"
require 'csv'
require 'i18n'
module Provincias
def self.find(id)
@@provincias[id] || self.find_by_slug(id)
end
def self.find_by_slug(slug)
@@provincias.values.select { |p| p.slug == slug }.first
end
def self.find_by_name(name)
@@provincias... | true |
aa236f7a00bc0d007b88ff4a7d1b5d2dc16c86e0 | Ruby | sydevs/Atlas | /app/helpers/localization_helper.rb | UTF-8 | 1,808 | 2.546875 | 3 | [] | no_license | module LocalizationHelper
I18N_KEYS = {
OfflineEvent => :offline_event,
OnlineEvent => :online_event,
}
def translate_model model, pluralization = :singular, locale: nil
key = pluralization == :plural ? 'plural' : 'single'
i18n_key = I18N_KEYS[model] || model.model_name.i18n_key
result = tra... | true |
677a367daed1e49d3566cadd11f8296b3d3e64da | Ruby | moliver4/getting-remote-data-apis-and-iteration-seattle-web-102819 | /lib/command_line_interface.rb | UTF-8 | 140 | 3.453125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def welcome
puts "Hello!"
end
def get_character_from_user
puts "please enter a character name"
name = gets.chomp
name.downcase
end
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.