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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
56f1a74c06962422c303c49356a672c6477ba200 | Ruby | davinaSanders/classes-objects | /homework/specs/student_spec.rb | UTF-8 | 774 | 3.34375 | 3 | [] | no_license | require ("minitest/autorun")
require ("minitest/rg")
require_relative ("../student.rb")
class StudentTest < MiniTest::Test
def setup
@student = Student.new("Ian", 21)
end
def test_student_name
assert_equal("Ian", @student.get_name())
end
def test_cohort
assert_equal(21, @student.get_cohort())
... | true |
78fb8b19e67e991e6edc2782546f39abd15817ee | Ruby | skomer/friends_hashes_TDD | /friends.rb | UTF-8 | 2,538 | 3.765625 | 4 | [] | no_license | require 'pry-byebug'
# 1. For a given person, return their favourite tv show
def tv_show(person)
return person[:favourites][:tv_show]
end
# 2. For a given person, check if they like a particular food
def favourite_foods(person, food)
return person[:favourites][:things_to_eat].include?(food)
end
# 3. Allow a... | true |
c1e776658f0a3125c13a6596bb7522df5708a21e | Ruby | sravanpsk/mysql | /Ruby/fizbuzz.rb | UTF-8 | 250 | 3.921875 | 4 | [] | no_license | def fizzBuzz(number)
i = 1
while i <= number
a = i%3 == 0
b = i%5 == 0
if (a && b)
puts "#{i} is fizzBuzz"
elsif a
puts "#{i} is fizz"
elsif b
puts "#{i} is buzz"
end
i += 1
end
end
fizzBuzz(25)
| true |
8e25d0e9af9ff8517e498a9688db0d9860c03847 | Ruby | reneclavijo/introduccion_ruby | /ejercicio5_clases/generador_clientes.rb | UTF-8 | 636 | 2.640625 | 3 | [] | no_license | require_relative 'cliente'
class GeneradorClientes
def self.generar_sin_mascotas(cantidad_clientes)
lista_de_cliente = []
for i in 0..cantidad_clientes
cliente = Cliente.new
cliente.nombre = Faker::Name.name
cliente.correo = Faker::Internet.email(
... | true |
1d2bafe56c2c78a6cc250b50b000c06bbd54864d | Ruby | Michael3434/fullstack-challenges | /01-Ruby/03-Iterators-Blocks/03-Splitter/lib/splitter.rb | UTF-8 | 782 | 3.671875 | 4 | [] | no_license | def size_splitter(array, size)
array.sort!
p array.partition { |beatle| beatle.length == size }
# TODO: Return an array of two arrays, the first containing
# words of length `size`, the second containing all the other words
# In addition to this split, each array should be *sorted*.
end
size_spli... | true |
d2a7a31fd55bd6d106e44b96ed1c3bf36fdc3122 | Ruby | cc256/ls_ruby | /RB120 - Object Oriented Programming/3 OO Basics Inheritance/3.rb | UTF-8 | 477 | 3.828125 | 4 | [] | no_license | class Vehicle
attr_reader :year
def initialize(year)
@year = year
end
end
class Truck < Vehicle
attr_reader :bed_type # add getter and setter methods
def initialize(year, bed_type) # add add bed_type param
super(year) # add
@bed_type = bed_type ... | true |
6f797a74b2cd55c34752b223ffccaf0a8df832fd | Ruby | grant-mc/LaunchSchool-RB101-Programming-Foundations | /Exercises/Easy_1/RepeatYourself.rb | UTF-8 | 75 | 3.109375 | 3 | [] | no_license | def repeat(word, num)
num.times { |n| p word }
end
repeat('Fuck Off', 4) | true |
49ff75fb643ea14e594e7973b4a9bd33ac2d2050 | Ruby | AlbatrossAutomated/blue_collar_gdax | /app/models/sentinel.rb | UTF-8 | 5,562 | 2.53125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
class Sentinel
class << self
def sync_executed_sells
Bot.log('Checking if any sells executed')
exchange_sell_orders = RequestUsher.execute('open_orders').select { |ord| ord['side'] == 'sell' }
sold_ids = find_executed_sells(exchange_sell_orders)
return Bot.l... | true |
8cc73d182cbf69e3eb97c3665fe8cbbf507fb525 | Ruby | kwin555/ruby-code-and-algorithm-practice | /find_the_missing_letter.rb | UTF-8 | 293 | 3.65625 | 4 | [] | no_license | def find_missing_letter(arr)
first = arr.first
last = arr.last
all_letters_array = []
first.upto(last) { |char| all_letters_array << char }
# (all_letters_array - arr).join('')
(all_letters_array - arr)[0]
end
array = ["a","b","c","d","f"]
puts find_missing_letter(array).inspect | true |
0931f8635806b3742617a2859f68432cb9bad46a | Ruby | lexruee/backend-basics | /platforms/ruby/basics/write-file.rb | UTF-8 | 161 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env ruby
#encoding: utf-8
File.open('new.txt', 'w+') do |f|
f.puts "x\tx**2"
(0..100).each do |x|
f.puts "#{x}\t#{x**2}"
end
end
| true |
f054a50cc85c10b4d981143bdeec261d0c70e8ad | Ruby | edlu77/Chess | /pieces/slideable.rb | UTF-8 | 853 | 3.265625 | 3 | [] | no_license | require 'byebug'
module Slideable
def horizontal_dirs
HORIZONTALDIRS
end
def diagonal_dirs
DIAGONALDIRS
end
def moves
all_moves = []
move_dirs.each do |dir|
all_moves += grow_unblocked_moves_in_dir(dir[0], dir[1])
end
all_moves
end
private
DIAGONALDIRS = [[1, 1], [-1,... | true |
5a7c53ac4c85b0d4167053437b3eba578b74d13b | Ruby | jamst/mongo_image_demo | /lib/wh_utils.rb | UTF-8 | 2,575 | 2.609375 | 3 | [] | no_license | class WhUtils
class << self
def split_id(id,with_id = true)
t = ("%08d" % id.to_i).scan(/(\d{2})/).flatten
t = t[0,3]
t << id if with_id
t.join('/')
end
ALL_CHARS = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
LETTERS = ("a".."z").to_a + ("A".."Z").to_a
NUMBERS = ("0... | true |
6b563e19e2de5fc9414c384fcdd1736cef98b0fa | Ruby | dsci/bishl | /lib/params_builder.rb | UTF-8 | 461 | 2.515625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Bishl
class ParamsBuilder
class << self
def build_link(options={})
raise OptionsNotMetError, "season missing" unless options.has_key?(:season)
raise OptionsNotMetError, "league missing" unless options.has_key?(:cs)
url = "?season=#{options[:season]}&cs=#{options[:cs]}"
... | true |
91f30b96f3222690bbe033d3d586375a0a5c7359 | Ruby | matass/business-period | /lib/business_period/base.rb | UTF-8 | 1,209 | 2.890625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module BusinessPeriod
class Base
SEPARATOR = '_'
def config
@config ||= Config
end
def calculate_period(to_date, options = nil)
magic_number = 15 - config.work_days.size
days_to_add = days_to_seconds(to_date * magic_number)
start_date = options[... | true |
22722d6e68d3a2875bd3ce7c3011e65bc2fdb82b | Ruby | nicholasblock78/phase-0-tracks | /ruby/secret_agents.rb | UTF-8 | 1,099 | 4.25 | 4 | [] | no_license | # encrypt method will advance each index/letter in string forward by 1 letter
#two options:
#iterate through each letter in the string
#split string and iterate over each letter
#use .next method to push each letter forward 1
####NOTES
#Very confused/stuck how to do this without each loops. I was able to do it w... | true |
473632ba76d9eb3a392a3e2d034b5eb99a71df28 | Ruby | smanolloff/svg_drawer | /lib/svg_drawer/image.rb | UTF-8 | 1,067 | 2.578125 | 3 | [
"MIT"
] | permissive | module SvgDrawer
class Image < Base
# Required since there is no known way to calculate them
requires :width
requires :height
# Retranslate ensures the parent element can correctly draw borders
defaults scale: [1, 1],
overflow: true,
retranslate: false # true not suppo... | true |
12405a94d86f330d127485042bcc22b5e17b124f | Ruby | drobazko/modifier | /spec/rules_spec.rb | UTF-8 | 728 | 2.578125 | 3 | [] | no_license | Dir['./lib/float.rb', './lib/string.rb', './lib/rules/*.rb'].each {|f| require f }
rules = [
{ rule: ValueWinRule.new, in: [1, 2], expected: 2 },
{ rule: RealWinRule.new, in: [nil, 0, '0', '', 1, 2], expected: 2 },
{ rule: IntRule.new, in: [1, 2], expected: '1' },
{ rule: FloatRule.new, in: ['1.2', '1.3'], exp... | true |
6e14f536a81dfc335ee65faeb0ccd28f84f07348 | Ruby | annamgithub/phase-0-tracks | /ruby/iteration.rb | UTF-8 | 1,566 | 4.09375 | 4 | [] | no_license | # Release 0
def print_name
name1 = "Anna"
name2 = "Kanan"
puts "Hello teammates"
yield [name1, name2]
end
print_name {|name1, name2| puts "Good teamwork, #{name1} and #{name2}!"}
# Release 1
student_name = ["Jim", "Jack", "Joe"]
p student_name
student_name.map! do |name1|
puts name1
name1.length
end
p ... | true |
b971a7f42c34843a95271ed2105787e9897ca11a | Ruby | mas2311/TDD-Katas | /supermarket-pricing/tests.rb | UTF-8 | 2,458 | 3.046875 | 3 | [] | no_license | #!/usr/bin/env ruby
require "./supermarket"
require "test/unit"
class TC_Supermarket < Test::Unit::TestCase
Offer = Struct.new(:product, :quantity, :price)
def catalog
{'Loaf of Bread' => 1, 'Noodles' => 0.5, 'Soup cans' => 2}
end
def test_empty_cart
price = Supermarket.price(catalog, {}, {}, {})
a... | true |
e0cb6b80e9d9d7eba9a185103f664908fd5a0a48 | Ruby | Aliya-cmuq/MobilePhone | /features/step_definitions/customer_steps.rb | UTF-8 | 4,523 | 2.515625 | 3 | [] | no_license | require 'factory_girl'
Given /^I created a customer, phone and order$/ do
@asma = FactoryGirl.create(:customer, :firstName => "Asma", :lastName => "Al-kubaisi")
@iphone = FactoryGirl.create(:phone, :brand => "Apple", :name => "iphone")
@order = FactoryGirl.create(:order, :phone => @iphone)
end
Given /^I am in th... | true |
72dfd3f5e90ea9ddd61a5d7eb2c1d90dedc0744e | Ruby | shelling/weekly-hours | /test/basic_test.rb | UTF-8 | 609 | 2.640625 | 3 | [] | no_license | require_relative "test_helper"
describe WeeklyHours do
it "can parse single day with time" do
expect(WeeklyHours::Parser.new.parse("Mon 10 am - 5 pm").tokenize).must_equal [[1], [10*3600, 17*3600]]
end
it "can parse single day with time containing minutes in start time" do
expect(WeeklyHours::Parser.new... | true |
790f4b7c69c1395b4a56c4851fc33c8cc68e64b4 | Ruby | dkaushal99352/devbootcamp | /rubyprogs/assesment.rb | UTF-8 | 4,691 | 4 | 4 | [] | no_license |
EXERCISE # 1
first_name = "Dinesh"
last_name = "Kaushal"
EXERCISE # 2
def calculate_product(array)
if !array.empty?
product = 1
array.each {|num| product *= num }
return product
else
return nil
end
end
EXERCISE # 3
def calculate_product_odd(array)
first_flag = false
product = 0
array.e... | true |
e64dec3e6e3264e5a2b6bd2477ae0703b02dbc76 | Ruby | toolkitsof/sofkit | /nelder-mead-optimization/services/downhill-simplex.rb | UTF-8 | 2,045 | 2.875 | 3 | [] | no_license | class Array
def mplus (arg)
if self[0].is_a? Numeric
self.each_with_index.map{|v, i| v + arg[i]}
else
self.each_with_index.map{|v, i|v.mplus(arg[i])}
end
end
def *(arg)
if arg.is_a? Numeric
self.map{|v| v * arg}
else
if arg[0].is_a? Numeric
if self[0].is_a? Numeri... | true |
f9a866821bc154698d09e516ad061bbd6d0dc21a | Ruby | recrudescence/elevator | /person.rb | UTF-8 | 161 | 3.09375 | 3 | [] | no_license | class Person
attr_reader :destination
def initialize floor
@destination = floor
end
def clock_tick
end
def to_s
print "(#{destination})"
end
end | true |
76c50a50b5360fcd98ac139dbac8b0d85d778411 | Ruby | austinthecoder/adventofcode2019 | /lib/adventofcode2019/fuel_calculator.rb | UTF-8 | 249 | 2.625 | 3 | [] | no_license | # frozen_string_literal: true
module Adventofcode2019
FuelCalculator = Ivo.new(:fuel_calculator) do
def calculate(value)
fuel = fuel_calculator.calculate(value)
return 0 if fuel < 1
fuel + calculate(fuel)
end
end
end
| true |
62c8dc5e22f8a3e59db65f2c309746391e8f0325 | Ruby | YoshiMejia/ruby-oo-object-relationships-collaborating-objects-lab | /lib/mp3_importer.rb | UTF-8 | 269 | 2.921875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class MP3Importer
attr_accessor :path
def initialize(path)
@path = path
end
def files
files = Dir.entries(path)
files.select {|i| i.include?(".mp3")}
end
def import
files.each{|i| Song.new_by_filename(i)}
#binding.pry
end
end | true |
9d4c6d303e797043391d48252c4be420488605b1 | Ruby | isanberg/rampup | /weektwo.rb | UTF-8 | 338 | 3.421875 | 3 | [] | no_license | def weektwo
random = rand(100)
idx = 1
while idx < 6
puts "Choose a number"
number = gets.chomp
if number = random
puts "You are a winner!!!!"
else
if number > random
puts "Too high. Try again"
else
if number < random
puts "Too Low. Try again"
end
idx = idx + 1
puts "There are #{6-idx} turnss left"... | true |
b33a1b06e5ba8e26ef1afaabdc55620e8e2c80c2 | Ruby | nikhil-shrestha/apple_epf | /lib/apple_epf/main.rb | UTF-8 | 3,397 | 2.625 | 3 | [
"MIT"
] | permissive | require 'nokogiri'
module AppleEpf
class Main
attr_reader :downloader, :filedate, :files_matrix
attr_accessor :store_dir, :keep_tbz_after_extract
def initialize(filedate, files_matrix = nil, store_dir = nil, keep_tbz_after_extract = nil)
@filedate = filedate
@files_matrix = files_matrix || A... | true |
731b02cc86a8569ffb91690a7cae9179e9c1a5c9 | Ruby | snikolau/prime-numbers-rb | /spec/cli_spec.rb | UTF-8 | 1,919 | 2.9375 | 3 | [] | no_license | require_relative '../lib/primer_task/cli'
RSpec.describe PrimerTask::Cli do
let(:args) { [] }
subject { described_class.start(args) }
context 'when no arguments are provided' do
let(:expected_output) { "No value provided for required options '--count'\n" }
it 'outputs valid help text and exits' do
... | true |
9eedbb6266887ada914a285644fc3383c66aaec7 | Ruby | jkvyff/count-elements-seattle-web-career-042219 | /count_elements.rb | UTF-8 | 181 | 3.1875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def count_elements(array)
# code goes here
new_hash = {}
array.each do |anim|
new_hash[anim] ? new_hash[anim] += 1 : new_hash[anim] = 1
end
new_hash
end
| true |
0c705773a7f2844c3d335f17cb5dfb45069377be | Ruby | isukeaima/2.2practice | /greeting.rb | UTF-8 | 94 | 3.109375 | 3 | [] | no_license | def greeting(name)
return"Hello,#{name}!"
"Good mornig,#{name}"
end
puts greeting("john")
| true |
c4a2a342d3a373b98f55563521e6cfde36113a9a | Ruby | assafshomer/calc | /Helpers/btc_view_helper.rb | UTF-8 | 900 | 2.71875 | 3 | [] | no_license | module BtcViewHelper
def prepare_parray(p_min=0.5,granularity=10)
return [p_min] if granularity<1
p_array=[]
(0..granularity).each {|x| p_array<<p_min+x.fdiv((1/(1-p_min))*granularity)}
result=p_array.map {|x| x.round(5)}
return result
end
def prepare_qarray(q_min=0,q_max=1,granularity=10)
return [q_mi... | true |
a14a6a1b7551a2213affd0d4718930b213c4cfca | Ruby | pshushereba/intro-to-programming | /variables-exercises.rb | UTF-8 | 218 | 3.125 | 3 | [] | no_license | # 5. The first program prints 3 to the screen. The second program
# gives an error.
# 6. The error comes up because we haven't defined the variable, or someone
# was trying to access the variable outside of the scope. | true |
19e9ef1d61d7087da56230b6124f4bab22e6a58a | Ruby | danko-master/clockwork-1 | /test/clockwork_test.rb | UTF-8 | 1,626 | 2.515625 | 3 | [
"MIT"
] | permissive | require File.expand_path('../../lib/clockwork', __FILE__)
require 'contest'
require 'timeout'
class ClockworkTest < Test::Unit::TestCase
teardown do
Clockwork.clear!
end
def set_string_io_logger
string_io = StringIO.new
Clockwork.configure do |config|
config[:logger] = Logger.new(string_io)
... | true |
11d043a0e2568020278126bc5a423ea7cdc227e5 | Ruby | airbnb/nerve | /lib/nerve/utils.rb | UTF-8 | 416 | 2.890625 | 3 | [
"MIT"
] | permissive | module Nerve
module Utils
def safe_run(command)
res = `#{command}`.chomp
raise "command '#{command}' failed to run:\n#{res}" unless $?.success?
end
def responsive_sleep(seconds, tick=1, &should_exit)
nap_time = seconds
while nap_time > 0
break if (should_exit && should_exi... | true |
b4bd7030f47d4bade316c65861d40c56fa457d43 | Ruby | sparkland/codeClan | /week_8/application.rb | UTF-8 | 856 | 3.453125 | 3 | [] | no_license | require_relative("./functions/functions.rb")
require_relative("./data/data.rb")
class Main
@datause = DATA
puts "\n\rUser Appliction Manager\n\r"
while true
puts "\n\rOptions:"
puts "\n\r1. Get Username By Name"
puts "\n\r2. Get Which Applications Are Installed By Username"
puts "q. Quit Applc... | true |
fb3b63113f1ca7bb8465146c7381f3f90b2dff68 | Ruby | ender672/hash_translation | /test/test_hash_reader.rb | UTF-8 | 1,078 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'test/unit'
#require 'test/preload'
require 'hash_translation'
class TestHashReader < Test::Unit::TestCase
COMPLEX_HASH = {
:hi => %w{silly buns button lungs},
:some => {
:time => 'ago',
:we => {
:stood => nil,
:on => {
:top => {
:of => {
... | true |
e4aac2ab197c42b187ac64d0775420492877fe88 | Ruby | s-shimko/ruby_learn2 | /lesson15_api_tw_notepad/task15_2_city_game/main.rb | UTF-8 | 1,191 | 3.40625 | 3 | [] | no_license | #-------using mechanize--------
# require 'mechanize'
# require 'launchy'
# require 'json'
#
# agent = Mechanize.new()
#
# chosen = false
#
#
# get_city = agent.get("https://api.vk.com/method/database.getCities?country_id=1&q=Москва&count=1")
#
# json_string = get_city.body.chomp
#
# city_hash = JSON.parse(json_string)... | true |
8baf7677d7bb2166ce857a11d1c09baf9fa24670 | Ruby | MMcClure11/learn-co-sandbox | /oo_private_methods.rb | UTF-8 | 782 | 3.671875 | 4 | [] | no_license | class Bartender
attr_accessor :name
BARTENDERS = []
def initialize(name)
@name = name
BARTENDERS << self
end
def self.all
BARTENDERS
end
def intro
"Hello, my name is #{name}!"
end
def make_drink
@cocktail_ingredients = []
choose_liquor
choose_mixer
choose_garn... | true |
9173e757338d3b083cda3087e3d6bc8e730c96b5 | Ruby | JaneHope607/weekend_homework_karaoke | /specs/rooms_spec.rb | UTF-8 | 2,117 | 2.8125 | 3 | [] | no_license | require("minitest/autorun")
require('minitest/reporters')
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
require_relative("../rooms")
require_relative("../guests")
require_relative("../songs")
class RoomsTest < MiniTest::Test
def setup
@room1 = Rooms.new("Superstar", 15, 2, @song_list, @g... | true |
1754bae66c74c3fa8fa85e4212e33921a6843fbf | Ruby | bkerley/archaeopteryx | /lib/metacircular_evaluator.rb | UTF-8 | 1,596 | 2.78125 | 3 | [] | no_license | module Archaeopteryx
class MetacircularEvaluator
def initialize(file)
@file = file
reload
end
def reload
eval(File.read(@file))
puts "hey"
end
def notes(beat)
[]
end
def mutate(measure)
reload
end
end
end
# This class is not a real metacircular ev... | true |
1c99d1165dfa8970bc9814ccf845cdb076ffa103 | Ruby | tim-friedrich/group-discussion-services | /vendor/bundle/ruby/2.2.0/gems/g-1.7.2/spec/g_spec.rb | UTF-8 | 724 | 2.609375 | 3 | [
"MIT"
] | permissive | $:.unshift File.dirname(__FILE__) + '/../lib'
require 'g'
describe 'g' do
it 'calls with a arg' do
GNTP.should_receive(:notify).with(:app_name => $0, :title => "g", :text => "foo")
g('foo').should == 'foo'
end
it 'calls with args' do
GNTP.should_receive(:notify).exactly(2).times
g('foo', 1).shou... | true |
83c02e1e2be678382167d7c8ebdd1e13f56cd7d2 | Ruby | GoetheProductions/bmi-ruby | /bmi-calculator/methods/calculate_bmi.rb | UTF-8 | 232 | 3.34375 | 3 | [] | no_license |
def ask_for_input(string)
puts "Whats your #{string.downcase}? ";
input = gets;
return input.to_f;
end
# called on calculate bmi command
def calculate(height, weight)
bmi = (weight / height) / height.to_f;
end | true |
536e1b70d2417a60dd3ccb19dc4d0a41f7014cd0 | Ruby | ayellapragada/root | /lib/root/factions/racoons/quest_deck.rb | UTF-8 | 1,775 | 2.8125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Root
module Factions
module Racoons
# module for catable methods
# probably just color tbh
class QuestDeck < Decks::Base
DECK_SIZE = 15
def generate_deck
list_of_cards!
deck.shuffle!
end
def list_of_cards... | true |
bd3451ef47b1d47d185a860dfe47622519c7f376 | Ruby | machida15/Good_Life | /app/models/tweet.rb | UTF-8 | 2,004 | 2.515625 | 3 | [] | no_license | class Tweet < ApplicationRecord
belongs_to :user
attachment :image
has_many :tweet_comments, dependent: :destroy
has_many :notifications, dependent: :destroy
has_many :favorites, dependent: :destroy
validates :body, presence: true
# いいね機能
def favorited_by?(user)
favorites.where(user_id: user.id).e... | true |
cdaff10a1a8a42c0d690df2bd5a0d353271ca8cb | Ruby | jesuslg123/xsimulator | /lib/xsimulator/position.rb | UTF-8 | 305 | 2.6875 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'coordinate'
# Represent an item position in a plane with orientation and coordinates
class Position
attr_accessor :coordinate, :orientation
def initialize(coordinate, orientation)
@coordinate = coordinate
@orientation = orientation
end
end
| true |
20faebf6ee3bce17b257086a3a90aa241b463d5d | Ruby | Romu-Muroga/dic-my-task | /spec/features/task.spec.rb | UTF-8 | 8,551 | 2.515625 | 3 | [] | no_license | # requireで、Capybaraなどの、Feature Specに必要な機能を使用可能な状態にしている。
require "rails_helper"
# RSpec.featureの右側に、「タスク管理機能」のように、テスト項目の名称を書きます(do ~ endでグループ化されています)
RSpec.feature "タスク管理機能", type: :feature do
# ユーザー
user1 = FactoryBot.create(:user)
user2 = FactoryBot.create(:second_user)
# タスク
task1 = FactoryBot.create(:task... | true |
811bc46433725fcc903b6161facdebbdcf169ea4 | Ruby | kvuvalentin/androidImageTool | /androidImageTool | UTF-8 | 2,991 | 2.765625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
require 'RMagick'
require 'fileutils'
require 'pathname'
include Magick
dpi_hash = {"drawable-ldpi"=>24, "drawable-mdpi"=>32,"drawable-hdpi"=>64, "drawable-xhdpi"=>128}
opts_hash = {}
optparse = OptionParser.new do|opts|
opts.banner = "Usage: androidImageTool path filename res... | true |
5a50a0c74e7be5c756f325fd18a7b0028665470c | Ruby | madis/dros | /spec/services/response_store_spec.rb | UTF-8 | 1,283 | 2.59375 | 3 | [] | no_license | require 'spec_helper'
require 'services/response_store'
require 'tmpdir'
describe ResponseStore do
def store_test_hash(hash)
described_class.store(data: hash, args: 'greeting')
end
describe '.store' do
it 'saves to disk' do
Dir.mktmpdir do |tmpdir|
allow(described_class).to receive(:tmp_pa... | true |
276150399f3848fdcc3c26f72e7367de87ca3ee3 | Ruby | coderchandu/coding_interview | /ruby/src/sort/floor_ceil.rb | UTF-8 | 1,050 | 3.953125 | 4 | [] | no_license | #Floor and ceil of sorted array for a given element
# Floor of 5 in 1,2,7 is 2 (highest elemen smaller than or equal to given number)
def floor(a, num)
low = 0
high = a.size-1
while (low <= high)
mid = (low + high)/2
return a[mid] if a[mid] == num
if (a[mid] < num)
return a[mid] if mid==a.size-1... | true |
f885bd6ce8b00444b3d8c104eba3d8fbd3506140 | Ruby | deniselaw/ruby-challenges | /test.rb | UTF-8 | 1,920 | 4.625 | 5 | [] | no_license | #Then, determine the birth path number inside a method. The method should take the birthdate as an argument.
#The return value of the method should be the birth path number.
def birth_path_number(birthdate)
number = birthdate[0].to_i + birthdate[1].to_i + birthdate[2].to_i + birthdate[3].to_i + birthdate[4].to_i + bir... | true |
a2fccd12ee4c4a462f41f374aee330aa496c03b6 | Ruby | ogom/my_gems | /spec/my_gems_spec.rb | UTF-8 | 924 | 3.109375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
RSpec.describe MyGems do
describe MyGems::FizzBuzz do
describe '#say' do
let(:fizz_buzz) { described_class.new(number) }
subject { fizz_buzz.say }
context '3で割り切れる場合' do
let(:number) { 3 }
example 'Fizz という' do
expect(subject).to eq 'Fizz'
... | true |
7426e8de81c68321b6e5d8d093a33a8105b81e23 | Ruby | rikur/ramaze | /lib/ramaze/store/default.rb | UTF-8 | 1,938 | 3.0625 | 3 | [
"Ruby"
] | permissive | # Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the Ruby license.
require 'yaml/store'
module Ramaze
# Namespace for Stores in Ramaze
module Store
# A simple wrapper around YAML::Store
class Default
include Enumer... | true |
c5342ac54a2af8ee222659ae9a9cd957a770de58 | Ruby | ngocson2vn/StudyRuby | /workspace/ruby_core/fork.rb | UTF-8 | 284 | 2.609375 | 3 | [] | no_license | #!/usr/bin/ruby
child_pid = fork do
puts "[child] child_pid: #{child_pid}"
puts "[child] Process ID: #{Process.pid}"
puts "[child] Parent Process ID: #{Process.ppid}"
end
Process.wait(child_pid)
puts "[parent] child_pid: #{child_pid}"
puts "[parent] Process ID: #{Process.pid}"
| true |
d66183c3c31800a5b9320fb68b7c80e6ba9c3808 | Ruby | anais277792/ruby_file_builder | /ruby_file_builder.rb | UTF-8 | 1,428 | 3 | 3 | [] | no_license | require 'pry'
#créationd d'un dossier qui porte le nom de l'argv
def create_folder(file_name)
system("mkdir #{file_name}")
system("cd #{file_name}")
end
#vérification du nom
def check_if_user_gave_input
abort("erreur: nom_du_dossier") if ARGV.empty? || ARGV.length > 1
end
#Création du Gemfile avec l... | true |
8d1c04dab899a2a8bb1e740bb3331a236b2e5581 | Ruby | deppfx/automation-scripts | /checkmongoempty.rb | UTF-8 | 1,095 | 2.65625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
require 'mongo'
Mongo::Logger.logger.level = ::Logger::FATAL
#auth = db.authenticate(tps, password) unless (db.user.nil? || db.user.blank?)
#
##auth = client.authenticate(tps, password)
#
#put " This is the #{auth}."
#
#client.collections.each { |coll| puts coll.name }
#
#client.close
client_host = ... | true |
f1bce2c80cf4e4646b883c133febe616217437b6 | Ruby | spectre6000/console_chess | /spec/console_chess/pawn_spec.rb | UTF-8 | 1,215 | 2.953125 | 3 | [] | no_license | require "spec_helper.rb"
module ConsoleChess
describe Pawn do
pieces_setup_array = [[:wpawn, "h", "2", "White"], [:bpawn, "a", "7", "Black"]]
let (:fake_board) {Board.new}
pieces_setup_array.each {|x, y, z, a| let (x) {Pawn.new(y, z, a, fake_board)}}
it "initializes with the correct 'color'" do... | true |
2d901d8582a22dbf0c776b641c6e8df847e3b891 | Ruby | djhart/ruby_recursion | /fibonacci.rb | UTF-8 | 242 | 3.828125 | 4 | [] | no_license | def fibs(n)
a = 1
b = 0
n.times do
puts a
c = a
a += b
b = c
end
return a
end
def fibs_rec(n)
return n if (0..1).include? n
fibs_rec(n-1) + fibs_rec(n-2) if n > 1
end
puts "how many"
n = gets.chomp.to_i
puts fibs_rec(n) | true |
33671f4ae627eac75d9c191a2ee8c7d19188f26c | Ruby | brhoades/euler | /1x/18/18.rb | UTF-8 | 2,349 | 3.875 | 4 | [] | no_license | require 'awesome_print'
# https://projecteuler.net/problem=18
class Node
attr_accessor :parents
def initialize(data, parents)
@parents = parents
@data = data
end
def to_str
@data.to_s
end
def to_int
@data.to_i
end
end
class Tree
attr_accessor :root, :lastnodes
def initialize(file... | true |
6311f0f6e0dcc671df15ec7c76537b28b00543cf | Ruby | JPuchalla/market_2001 | /lib/market.rb | UTF-8 | 771 | 3.765625 | 4 | [] | no_license | class Market
attr_reader :name, :vendors
def initialize(name)
@name = name
@vendors = []
end
def add_vendor(vendor)
@vendors << vendor
end
def vendor_names
@vendors.map {|vendor| vendor.name}
end
def vendors_that_sell(item)
vendors_with_item = []
@vendors.each do |vendor|
... | true |
0c0c50fb2259bbfec88370ed4d5fe54e3d8dfd08 | Ruby | alexbujenita/looping-times-london-web-career-012819 | /times.rb | UTF-8 | 132 | 2.953125 | 3 | [] | no_license | $num = 7 # Just trying out global variables
def using_times
$num.times do
puts "Wingardium Leviosa"
end
end
| true |
bebfa6a5e79048991d59c5a4d2ae93b3e81ffefb | Ruby | cmhollen/bubble_sort | /bubble-sort.rb | UTF-8 | 537 | 3.765625 | 4 | [] | no_license |
def bubble_sort(arr)
(arr.length - 1).times do
for i in 0...arr.length - 1
if arr[i] > arr[i + 1]
arr[i], arr[i + 1] = arr[i + 1], arr[i]
end
end
end
arr
end
puts bubble_sort([4,3,78,2,0,2])
def bubble_sort_by(arr)
(arr.length - 1).times do
for i in 0...arr.length - 1
... | true |
99f7303c68e8eb9ee5deb9122cbab596113aa91f | Ruby | tradegecko/magentor | /lib/magento/invoice.rb | UTF-8 | 2,585 | 2.546875 | 3 | [
"MIT"
] | permissive | module MagentoAPI
# http://www.magentocommerce.com/wiki/doc/webservices-api/api/sales_order_invoice
# 100 Requested shipment does not exists.
# 101 Invalid filters given. Details in error message.
# 102 Invalid data given. Details in error message.
# 103 Requested order does not exists
# 104 Invoice st... | true |
16c852fac65c2bba20759b51c8e860d178c17d4b | Ruby | doahuang/misc | /hackerrank/linked_lists/findMergeNode.rb | UTF-8 | 226 | 3.1875 | 3 | [] | no_license | def findMergeNode(head1, head2)
seen = {}
node = head1
while node
seen[node] = true
node = node.next
end
node = head2
while node
return node.data if seen[node]
node = node.next
end
nil
end | true |
041f9ac979ff15bc7fccf182ab9c36f39b971a7c | Ruby | jazminmatos/cli_project | /lib/pokemon.rb | UTF-8 | 330 | 2.953125 | 3 | [
"MIT"
] | permissive | #keep track of our pokemon
#turns our responses into objects
#saves all pokemon created
class Pokemon
attr_accessor :name, :url, :abilities
@@all = []
def initialize(name:, url:)
@name = name
@url = url
@abilities = []
@@all << self
end
def self.all
@@all
... | true |
eb180d1461c93b14d6564fe54b8e2552a874e052 | Ruby | OrientalSiru/hw-ruby-intro | /lib/ruby_intro.rb | UTF-8 | 1,640 | 4.0625 | 4 | [] | no_license | # When done, submit this entire file to the autograder.
# Siru Li homework 1 Final
# Part 1
def sum arr
arraySum = 0
arr.each{|i|arraySum+=i}
return arraySum
end
def max_2_sum arr
if arr.size == 0
return 0
elsif arr.size == 1
return arr[0]
else
sum = 0
arr.sort!
arr.reverse!
sum = ar... | true |
065eefa542cf99540b93e3cb7060e452f1e0586d | Ruby | tomdalling/racky | /test/lib/def_deps_test.rb | UTF-8 | 1,313 | 2.765625 | 3 | [] | no_license | require 'unit_test'
require 'def_deps'
class DefDepsTest < UnitTest
class Farm
include DefDeps[:cat, 'dog', rabbit: 'animal.rabbit']
end
class OldMcDonaldsFarm < Farm
include DefDeps[:eieio, rabbit: 'bugsbunny']
end
def test_declared_dependencies
expect(Farm::DECLARED_DEPENDENCIES) == {
c... | true |
1d6a65a313e69e1daf5220914504ab173d83df9d | Ruby | calderete/exercism | /ruby/hamming/hamming.rb | UTF-8 | 266 | 3.65625 | 4 | [] | no_license |
class Hamming
VERSION = 1
def Hamming.compute(a ,b)
if a.length != b.length
raise ArgumentError
end
first = a.chars
second = b.chars
counter = 0
first.each_index do |x|
if second[x] != first[x]
counter += 1
end
end
counter
end
end | true |
a6e8ffab63abb3e27b195c926e096fb6bf67b82d | Ruby | workshare/swaggable | /spec/swaggable/schema_definition_spec.rb | UTF-8 | 1,271 | 2.5625 | 3 | [
"MIT"
] | permissive | require_relative '../spec_helper'
RSpec.describe 'Swaggable::SchemaDefinition' do
subject { subject_instance }
let(:subject_instance) { subject_class.new }
let(:subject_class) { Swaggable::SchemaDefinition }
it 'has a name' do
subject.name 'My Schema'
expect(subject.name).to eq 'My Schema'
end
it... | true |
5b14292f9e559924c15773c70823ce22a0f0988d | Ruby | wordtreefoundation/heatmap | /heatmap.rb | UTF-8 | 1,853 | 3.078125 | 3 | [] | no_license | require 'json'
def make_chart(
title: "Chart", subtitle: nil,
xtitle: nil, ytitle: nil,
placeholder: 'PLACEHOLDER', height: 400)
tooltip_formatter = "function() { return '' + this.point.count + ' occurrences / ' + this.point.total + ' total words' }"
xlabels, ylabels, data = [], [], []
for x in 1.... | true |
26eb99067fea312c48605e692cf81dba384b165e | Ruby | MaligneCanyon/nwa | /lesson3/my_framework/web_frame.rb | UTF-8 | 695 | 2.71875 | 3 | [] | no_license | # web_frame.rb
private
# encapsulate the creation and organization of the response
def response(status, headers, body = '')
body = yield if block_given?
[status, headers, [body]]
end
# def response(status, headers, body = [])
# body = [yield if block_given?]
# [status, headers, body]
# end
# create an all-te... | true |
3d6181dfc6715084bf8be67b167750035cc09581 | Ruby | ijikeman/Study | /RUBY/OOP/Deligation/sample1.rb | UTF-8 | 523 | 3.671875 | 4 | [] | no_license | class Echo
def english_message
p "Hello"
end
def japanese_message
p "こんにちは"
end
def suwahiri_message
p "Jumbo"
end
end
class PlusFrenchEcho < Echo
# 元のクラスに処理を追加
def french_message
p "Melce"
end
# 元のクラスをオーバーライド
def japanese_message
p "今日は"
end
end
f = PlusFrenchEcho.new
... | true |
eba4a2b53dc11a5e70b635fc2dfd8c7b02f499f0 | Ruby | jr1412594/ruby-check | /shorthand_syntax_for_array_of_strings.rb | UTF-8 | 152 | 2.90625 | 3 | [] | no_license | names = %w[Jack Jill John James]
states = %w[Alabama Alaska Arizona Arkansas California Colorado Conneticuit]
# states[0] = "New York"
p states
# p names | true |
9455514458fb435d3bc64996f9c1e0115a3e3621 | Ruby | glebtv/fancygrid | /lib/fancygrid/grid.rb | UTF-8 | 14,034 | 2.65625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require "active_support/hash_with_indifferent_access"
module Fancygrid#:nodoc:
class Grid < Fancygrid::Node
# Collection of all fancygrid leafs. These are instances of Fancygrid::Node
# and define the columns of a table. They may refer to an attribute or a
# method or a renderable cell of a model... | true |
c7851d88c2cca3ea7dfc6141f9c7bdf05e74390b | Ruby | M-Burr/dynamic-programming | /lib/newman_conway.rb | UTF-8 | 625 | 3.546875 | 4 | [
"MIT"
] | permissive |
# Time complexity: O(1)
# Space Complexity: O(n)
def newman_helper(num, newman_hash)
if newman_hash[num]
return newman_hash[num]
end
if num == 1 || num == 2
return 1
else
newman_hash[num] = newman_helper(newman_helper(num - 1, newman_hash), newman_hash) +
newman_helper(num - newman_helpe... | true |
eac4f3ba8484cbe9f723d6df3a26eb73a4e9189b | Ruby | woodsy88/myrecipes | /test/models/member_test.rb | UTF-8 | 1,980 | 2.90625 | 3 | [] | no_license | require 'test_helper'
class MemberTest < ActiveSupport::TestCase
def setup
@member = Member.new(membername: "andrew", email: "andrew@gmail.com",
password: "password", password_confirmation: "password")
end
test "should be valid" do
assert @member.valid?
end
test "nam... | true |
fb326ff93fec056ad38fbb9e19c650708ac08189 | Ruby | CodingDojoDallas/ruby_oct_2017 | /Alyssa_McKee/oop/human.rb | UTF-8 | 838 | 4 | 4 | [] | no_license | class Human
attr_reader :strength, :intelligence, :stealth, :health
def initialize strength: 3, stealth: 3, intelligence: 3, health: 100
@strength = strength
@stealth = stealth
@intelligence = intelligence
@health = health
end
def attack target
if target.class <= Human #if target's class is a subclass or ... | true |
75e25ed72e636fe373af5a4f5823bff79644f05f | Ruby | ThunderKey/dirwatch | /lib/dirwatch/string_extensions.rb | UTF-8 | 258 | 2.84375 | 3 | [
"MIT"
] | permissive | class String
RESET_KEY = "\033[0m".freeze
{
bold: "\033[1m",
green: "\033[32m",
red: "\033[31m",
yellow: "\033[33m",
}.each do |name, color_key|
define_method(name) do
"#{color_key}#{self}#{RESET_KEY}"
end
end
end
| true |
b75c01946cc18ff3dcb99ba0c68b6ff36652572b | Ruby | Gurenax/ruby-codewars | /counting_duplicates.rb | UTF-8 | 784 | 3.953125 | 4 | [] | no_license | def duplicate_count(text)
char_occurrences = {}
text.chars.map { |c|
if char_occurrences.has_key? c.to_s.downcase.to_sym
char_occurrences[c.to_s.downcase.to_sym] += 1
else
char_occurrences[c.to_s.downcase.to_sym] = 1
end
}
char_occurrences.select{|k,v| v >... | true |
66d2c07a767b60e48be06b869bb675d5fb4aab09 | Ruby | ikemo3/serverless-slack-bot-example | /callback.rb | UTF-8 | 1,946 | 2.625 | 3 | [] | no_license | require 'json'
require 'aws-sdk'
require 'net/https'
TOKEN_ENDPOINT = "https://slack.com/api/oauth.access"
DENIED_URL = ENV['DENIED_URL']
REGISTERED_URL = ENV['REGISTERED_URL']
CLIENT_ID = ENV['CLIENT_ID']
CLIENT_SECRET = ENV['CLIENT_SECRET']
REDIRECT_URI = ENV['REDIRECT_URI']
DYNAMODB_TABLE_NAME = ENV['DYNAMODB_TAB... | true |
2ed874f24fb80f1286563d44a57913855c1a22cc | Ruby | PaHenriquez/Memory_Matching_Game | /Memory Puzzle/Board.rb | UTF-8 | 1,032 | 3.4375 | 3 | [] | no_license | require_relative "Card"
class Board
attr_accessor :display_grid
def initialize(size = 4)
@size = size
@grid = Array.new(size){Array.new(size)}
@display_grid = Array.new(size){Array.new(size," ")}
populate
end
def [](row,column)
@grid[row][column]
end
... | true |
2286a203273baf66428fff404f44faf9d5263b36 | Ruby | zentrification/monitor-brightness-learner | /lib/monitor.rb | UTF-8 | 583 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | class Monitor
def initialize(identifier)
@device = find_device(identifier)
end
def get_brightness
`sudo ddccontrol dev:/dev/i2c-#{@device} -r 0x10 2>&1 | grep -i brightness`.split('/')[1]
end
def set_brightness(brightness)
brightness = get_brightness.to_i + brightness.to_i if %w(+ -).include?(br... | true |
284d95bc466b2f2058950e1b466cac4ba31a75b0 | Ruby | mohammeduk/LearnRubyTheHardWay | /Exercises/Challenges/rockPaperScissors.rb | UTF-8 | 4,238 | 4.1875 | 4 | [] | no_license | puts """
Welcome to the awesome game of Rock Paper Scissors!!
You will be playing against Hal - the computer!
˚˚˚˚ ROCK PAPER SCISSORS - GAME RULES ˚˚˚˚
1 -> Rock
2 -> Paper
3 -> Scissors
Lets gets started! Best out of 3!
"""
@rock = "Rock"
@paper = "Paper"
@scissors = "Scissors"
@hand_array = ["Rock", "Paper", "Sc... | true |
7cb7398687ad6808dd0ccaf03bf2476a1c623759 | Ruby | EmeraldCityProgrammingGroup/RubyBasicsExamples | /ex2.rb | UTF-8 | 79 | 3.140625 | 3 | [] | no_license | def multiply_by_three(num)
return num * 3
end
puts multiply_by_three(10)
| true |
1db2b0dd46eaee46e3ab988d375280df637c5bd9 | Ruby | mendozacm/countdown-to-midnight-onl01-seng-pt-100619 | /countdown.rb | UTF-8 | 227 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
def countdown (counter)
counter = 10
while counter > 0
puts "#{counter} SECOND(S)!"
counter -= 1
end
"HAPPY NEW YEAR!"
end
def countdown_with_sleep (sleep)
sleep (5)
end
| true |
33a28ad7c6019bed67a48d2922034e72b9cbe741 | Ruby | bblkmn5/tic-tac-toe-rb-v-000 | /lib/tic_tac_toe.rb | UTF-8 | 3,752 | 4.21875 | 4 | [] | no_license | #create variable to hold all possible win combinations (all caps for use in all functions)
WIN_COMBINATIONS = [
[0,1,2], [3,4,5], [6,7,8],
[0,3,6], [1,4,7], [2,5,8],
[0,4,8], [2,4,6]
]
#declare #display_board, with board location array
def display_board(board)
puts " #{board[0]} | #{board[1]} | #{board[2]} "
... | true |
27e86f88d3bc71d61bdd99f63949037a04bd8de8 | Ruby | mskubenich/medical_tests | /app/models/category.rb | UTF-8 | 895 | 2.703125 | 3 | [] | no_license | class Category < ActiveRecord::Base
has_many :questions, dependent: :destroy
serialize :session
def generate_state
self.points ||= 0 unless self.points
self.session = [] unless self.session
end
def answered_questions_count
self.session ? self.session.count : 0
end
def state
self.gene... | true |
869b55bd97a2404022df9f4d85b38d1a5b436e40 | Ruby | jamiew/boring-crypto-trader | /limit_order.rb | UTF-8 | 1,836 | 2.78125 | 3 | [
"MIT"
] | permissive | class LimitOrder
attr_accessor :client, :amount,
:order_id, :order_bid_price, :order_bid_amount
def initialize(_client, _amount)
self.client = _client
pp _amount
if _amount =~ /^\$/ || _amount =~ /USD$/
dollars = _amount.gsub(/^\$/,'').gsub(/USD$/,'').to_f
self.amount = ("%... | true |
ff960a53c169e97d2b3fed5be48a0ccb3d8c2103 | Ruby | davidedelerma/bill_sky | /spec/main_spec.rb | UTF-8 | 3,865 | 2.546875 | 3 | [] | no_license | ENV['RACK_ENV'] = 'test'
require_relative '../main.rb'
require 'test/unit'
require 'rack/test'
require_relative '../db/get_bill_data'
require_relative '../models/bill'
class SkyBillTest < Test::Unit::TestCase
include Rack::Test::Methods
def app
Sinatra::Application
end
def setup
data = Get_bill_da... | true |
cefb1491706c4dbc6fdcf92a56201b19818452cf | Ruby | drinkbeer/DesignPattern | /CompositePattern/composite_pattern.rb | UTF-8 | 1,265 | 3.875 | 4 | [] | no_license | class Task
attr_reader :name
def initialize(name)
@name = name
end
def get_time_required
0.0 #do nothting
end
end
class AddDryIngredientsTask < Task
def initialize
super('Add dry ingredients')
end
def get_time_required
1.0 #1 minute to... | true |
1e3f2b6558881af898a46a3c467b3a7b5cd7498d | Ruby | hideto1993/furima-32082 | /spec/models/user_spec.rb | UTF-8 | 6,934 | 2.65625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
describe '#create' do
before do
@user = FactoryBot.build(:user)
end
context '新規登録がうまくいくとき' do
it "正常型" do
expect(@user).to be_valid
end
end
context '新規登録がうまくいかないとき' do
it "nicknameが空では登録できないこと" do
... | true |
e218f968f05b5c7838b8d35b304067eda8803e2a | Ruby | kitanaisia/ASRScript | /addYomi.rb | UTF-8 | 1,654 | 3.09375 | 3 | [] | no_license | #!/usr/bin/ruby
$KCODE="utf-8"
require "MeCab"
require "nkf"
#=============================================================
# カタカナをひらがなに直す関数
# [入力]:カタカナ文字列str
# [出力]:strをひらがなに直した文字列
#=============================================================
def kanaFilter(str)
return (str == nil ) ? str : NKF.nkf("-w --hiragana"... | true |
424bcaf5d91ddf9906ba6088b8e2d6e0f9089f20 | Ruby | DainisL/i18n_translation_dashboard | /spec/lib/i18n_translation_dashboard/translations_spec.rb | UTF-8 | 1,228 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe I18nTranslationDashboard::Translations do
describe '#keys_by_locale' do
it "get keys hash by locale" do
keys = described_class.new.keys_by_locale(:en)
expect(keys).to be_a_kind_of(Hash)
end
end
describe "#keys_by_locale_and_group" do
context "group nil" d... | true |
2a67c49132775a08894731a5fb3c6aa05b603477 | Ruby | jas0nmjames/jas0nmjames.github.io | /vendor/bundle/ruby/3.2.0/gems/hashery-2.1.2/test/case_key_hash.rb | UTF-8 | 3,184 | 3.09375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause"
] | permissive | require 'helper'
testcase KeyHash do
class_method :[] do
test 'creates new KeyHash' do
s = KeyHash[]
KeyHash.assert === s
end
test 'pre-assigns values' do
s = KeyHash[:a=>1, :b=>2]
s[:a].assert == 1
s[:b].assert == 2
end
end
method :[] do
test 'instance level ... | true |
163820cd1c4640f5df2e5c003b3dc1c0acaa4ed5 | Ruby | caioertai/food-delivery-347 | /app/views/sessions_view.rb | UTF-8 | 268 | 2.859375 | 3 | [] | no_license | class SessionsView
def ask_for(label)
puts "#{label}?"
print '> '
gets.chomp
end
def greet(user)
puts "Welcome #{user.role} #{user.username}!"
end
def wrong_credentials
puts "Wrong username or password."
puts "Try again:"
end
end
| true |
71a8130806c5fda315b8b35a5190c40d766977e4 | Ruby | cloudfoundry/buildpacks-ci | /tasks/create-new-version-line-story/create-new-version-line-story.rb | UTF-8 | 2,090 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby
require 'fileutils'
require 'json'
require 'yaml'
require_relative './dispatch.rb'
class SemanticVersion
attr_reader :major
attr_reader :minor
attr_reader :patch
def initialize(original)
@original = original
m = @original.match /^v?(\d+)\.(\d+)(\.(\d+))?(.+)?/
if m
@major... | true |
d809db99c40f84269dfcb200bc987f91c799e320 | Ruby | eronisko/sciencetoolbox | /repo_health.rb | UTF-8 | 1,525 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'rest_client'
require 'json'
def check_health(contents, path_key)
readme = false
license = false
virtualization = false
ci = false
test = false
contents.each do |content|
print "#{content}\n"
contentname = content[path_key].chomp(File.extname(content[path_key])).downcase
if readme == fa... | true |
f18c64c1da4b2767481e74b19095fbe487252b8c | Ruby | furyfire/codingtests | /ProjectEuler/020/solve.rb | UTF-8 | 223 | 3.96875 | 4 | [] | no_license | FACTORIAL = 100
def factorial(num)
if(num == 0)
return 1
else
return num * factorial(num - 1)
end
end
number = factorial(FACTORIAL)
sum = 0
number.to_s.each_char do |c|
sum += c.to_i
end
puts sum | true |
8cd3644f1ac5c92dd86870400fbd8a4f738b26ad | Ruby | k28/ruby_math_puzzle | /first_time/q68_01.rb | UTF-8 | 656 | 3.59375 | 4 | [] | no_license | #!/usr/bin/env ruby
# -*- coding: utf-8 -*-
N = 6
FREE, USED, WALL = 0, 1, 9
# 版兵として両端と真ん中に壁をセット
@seat = [WALL] + [FREE] * N + [WALL] + [FREE] * N + [WALL]
def search(person)
count = 0
@seat.size.times{|i|
if @seat[i] == FREE
if @seat[i - 1] != USED && @seat[i + 1] != USED
@seat[i] = USED
... | true |
ec17f20ca7180da17fb187124d293a4747c754ad | Ruby | jdejesu2/com331_bookrepo1 | /chapter4/variable.rb | UTF-8 | 832 | 4.46875 | 4 | [] | no_license |
my_string = '...you can say that again...'
puts my_string
puts my_string
##OUTPUT
##...you can say that again...
##...you can say that again...
name = 'Anya Christina Emmanuella Jenkins Harris'
puts 'My name is ' + name + '.'
puts 'Wow! ' + name
puts 'is a really long name!'
##OUTPUT
##My name is Anya Christina Emm... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.