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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
b0bdd078e0122f670a6fc9fc4212a3fb75df994b | Ruby | ougarcia/aa_work | /checkers/board.rb | UTF-8 | 1,686 | 3.546875 | 4 | [] | no_license | require 'colorize'
require_relative 'piece'
class Board
def initialize
@grid = Array.new(8) { Array.new(8) { NullPiece.new } }
fill_board
end
def fill_board
0.upto(2) do |i|
0.upto(7) do |j|
pos = [i, j]
self[pos] = Piece.new(self, pos, :top) if (i+j).odd?
end
end
... | true |
4343d8e01c7526f4cfe93a3d38e3985c6e8c89a0 | Ruby | stuartmg/exercism | /ruby/rna-transcription/rna_transcription.rb | UTF-8 | 234 | 2.796875 | 3 | [] | no_license | module BookKeeping
VERSION = 4
end
class Complement
def self.of_dna(strand)
return "" unless valid?(strand)
strand.tr("GCTA", "CGAU")
end
private
def self.valid?(strand)
strand.match /\A[ACTG]+\z/
end
end | true |
8c756b45ee47cf72d1d68dda8050e0d5d46046b8 | Ruby | nodecarter/chrno_audit | /lib/chrno_audit/action_controller_concern.rb | UTF-8 | 2,565 | 2.578125 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
module ChrnoAudit
##
# Расширение для ActionController.
#
module ActionControllerConcern
extend ActiveSupport::Concern
module ClassMethods
##
# Хелпер для установки контекста аудита.
#
# @param [Proc, Symbol] proc_or_symbol
# символ или Proc для генерац... | true |
b0568fcec736c16c40c4a336fc5f065a100f45fc | Ruby | dan-marino/ruby-practice-problems | /ruby_foundations_more_topics/advanced/definition_arity.rb | UTF-8 | 1,811 | 4.5 | 4 | [] | no_license | # # Group 1
# my_proc = proc { |thing| puts "This is a #{thing}." }
# puts my_proc
# puts my_proc.class
# my_proc.call
# my_proc.call('cat')
# Procs are objects that point to a block.
# Procs don't complain when too few or too many arguments get passed into the block.
# This argument behavior is similar to that of a b... | true |
b617f8b377d66d53cf2d7e265c58bd298580568d | Ruby | davidpdrsn/dotfiles | /bin/strip-indent | UTF-8 | 278 | 3.03125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
class Object
def try(method)
send(method)
end
end
class Nil
def try(*)
end
end
class String
def strip_heredoc
indent = scan(/^[ \t]*(?=\S)/).min.try(:size) || 0
gsub(/^[ \t]{#{indent}}/, '')
end
end
puts $stdin.read.strip_heredoc
| true |
ac9f7dcecfb1be02a87b03a1abd8e289847e2a09 | Ruby | loyno-mathcs/diaper | /app/queries/items_by_storage_collection_and_quantity_query.rb | UTF-8 | 1,123 | 2.75 | 3 | [
"MIT"
] | permissive | class ItemsByStorageCollectionAndQuantityQuery
attr_reader :organization, :filter_params, :items_by_storage_collection_and_quantity
def initialize(organization:, filter_params:)
@organization = organization
@filter_params = filter_params
end
def call
@items_by_storage_collection ||= ItemsByStorage... | true |
9353e7ceb91e5c1cf6e0c5c50c8c08df6c76af32 | Ruby | open-telemetry/opentelemetry-ruby | /api/lib/opentelemetry/trace/tracestate.rb | UTF-8 | 5,518 | 3.046875 | 3 | [
"Apache-2.0",
"Ruby",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0
module OpenTelemetry
module Trace
# Tracestate is a part of SpanContext, represented by an immutable list of
# string key/value pairs and formally defined by the W3C Trace Context
# specification ... | true |
6bd66ff535e0207b1eea878dc259f275a065a5d9 | Ruby | jilucev/Rotten_Mangoes_Rails_Tutorial | /app/helpers/movies_helper.rb | UTF-8 | 302 | 2.75 | 3 | [] | no_license | module MoviesHelper
def formatted_date(date)
date.strftime("%b %d, %y")
end
end
#now whrever we display our release_date, we can formit it by replacing the old
#code with: <%= formatted_date(@movie.release_date) %>
# A useful web app for strftime formatting: http://www.foragoodstrftime.com/ | true |
5483d4daa5f2448db013e136a3da8c76f77e22c2 | Ruby | everett1992/course | /org.rb | UTF-8 | 564 | 3.328125 | 3 | [] | no_license | # org.rb
require './course.rb'
class String
def is_numeric?
self.match(/^\d$/)
end
end
class Org
attr_reader :courses
def initialize cources
@courses = Array.new
cources.each do |k, v|
@courses << Course.new(k, v['notes'], v['book'])
end
end
def list
@courses.map(&:title)
end
... | true |
cdde3e4c3dc4de73a52deeceae255ef0b655282b | Ruby | eljoey/learn_ruby | /01_temperature/temperature.rb | UTF-8 | 173 | 3.828125 | 4 | [] | no_license | #write your code here
def ftoc (num)
celcius = (num - 32) * (5 / 9.0)
return celcius
end
def ctof(num)
farenheit = num * (9.0 / 5) + 32
return farenheit
end | true |
cb8b3a5339cf917139e684f7601ee8bdf4e9953f | Ruby | Nakilon/morsify | /spec/telegraph_decode_spec.rb | UTF-8 | 1,339 | 2.921875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'morsify'
describe Morsify do
# Тесты для режима decode
it 'one morse word' do
expect(Morsify.decode('... --- ...')).to eq 'SOS'
end
it 'two morse words' do
expect(Morsify.decode('... --- ... ... --- ...')).to eq 'SOS SOS'
end
it 'morse to russian text... | true |
b038048f18859a278f6c61e1dbf503ec12f2b96b | Ruby | collinksmith/ruby-projects | /connect-4-and-sudoku/connect-4/connect.rb | UTF-8 | 879 | 3.8125 | 4 | [] | no_license | require_relative 'board'
require_relative 'human_player'
require_relative 'array'
class ConnectFour
def initialize(player1, player2)
@board = Board.new
# @players = [player1, player2]
@player1 = player1
@player2 = player2
@current_player = player1
end
def play
until @board.over?
@... | true |
9d02df5a6799d6e686dcd6c837a189a021aede6f | Ruby | bizangles/mlb | /refresh_games.rb | UTF-8 | 181 | 2.59375 | 3 | [] | no_license | require_relative 'game_util'
day = FIRST_DAY
while day <= Date.today
get_games(day).each do |game|
Game.find_or_create_by(game)
end
puts "Done: #{day}"
day += 1
end
| true |
aacbb4addae2bb1e2af949297498eb239584d9bf | Ruby | JIC9893/scicast_position_finder | /trade_analyzer.rb | UTF-8 | 3,284 | 2.703125 | 3 | [] | no_license | require 'JSON'
FILE = 'trades.txt'
class Position
attr_reader :q_id, :q_name, :c_name, :assumption_q_id, :assumption_q_name, :assumption_c_name, :exposure
def initialize(args)
@q_id = args[:q_id]
@q_name = args[:q_name]
@c_name = args[:c_name]
@assumption_q_id = args[:assumption_q_id]
@assumption_q_name = ... | true |
23b2380f6aa40ca404773111b0283f39d444c436 | Ruby | ivanjankovic/ttt-10-current-player-q-000 | /lib/current_player.rb | UTF-8 | 300 | 3.578125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def turn_count(board)
counter = 0
board.each do |board_positions| if board_positions != " "
counter += 1 end
end
return counter
end
def current_player(board)
counter = turn_count(board)
if counter.even?
return "X"
else
return "O"
end
end | true |
0939640696197530125edb6c9f6eccd8504b09b3 | Ruby | Sheep83/homework_all | /week_2/weekend_homework/karaoke/viewer.rb | UTF-8 | 2,025 | 3.46875 | 3 | [] | no_license | require 'pry-byebug'
require_relative('song')
require_relative('room')
require_relative('guest')
require_relative('bar')
class Viewer
attr_reader :bar
def initialize(bar)
@bar = bar
end
def report_guests_in_bar
return bar.guests.size
end
def welcome
system("clear")
print "Loading,"
sl... | true |
c24c3b694b565fb770f1ca4c480215683abc23f2 | Ruby | wimsy/euler | /euler0028.rb | UTF-8 | 271 | 3.109375 | 3 | [] | no_license | spiralSize = 1001
numSpirals = (spiralSize-1)/2
corners = [[1, 1, 1, 1]]
for i in (1..numSpirals)
corners << [corners[i-1][3]+2*i, corners[i-1][3]+4*i, corners[i-1][3]+6*i, corners[i-1][3]+8*i]
end
puts corners.flatten.inject(0) { |sum, item| sum + item } - 3
| true |
6358b6a5bedc6a798941b192cc64e5423af99e39 | Ruby | Rmartinez75/Launch_School | /RB101/Exercises/Easy4/leap_year2.rb | UTF-8 | 370 | 3.421875 | 3 | [] | no_license | def leap_year?(year)
if year >= 1752
if (year % 4).zero? && year % 100 != 0
true
elsif (year % 100).zero? && (year % 400).zero?
true
else
false
end
elsif year < 1752
if (year % 4).zero?
true
else
false
end
end
end
p leap_year?(1752)
p leap_year?(1700)
p l... | true |
922d4caac7e576ccb0d7e4da285664373d8b7ebe | Ruby | richcole/MyBot | /MyBot.rb | UTF-8 | 5,242 | 3.03125 | 3 | [] | no_license | #!/usr/bin/ruby
class Log
def puts(s)
STDOUT.puts("# " + s)
end
end
LOG = Log.new
class Planet
attr_accessor :x, :y, :owner, :num_ships, :growth_rate, :fleets, :benefit, :strength
def initialize(x, y, owner, num_ships, growth_rate)
@x = x
@y = y
@owner = owner
@num_ships = num_ships
... | true |
0df57c370f7f58f850eeb1881a587912d2164531 | Ruby | isabella232/cryo | /lib/cryo/database/redis.rb | UTF-8 | 878 | 2.546875 | 3 | [
"MIT"
] | permissive | class Redis
include Utils
attr_accessor :user, :host, :remote_path, :local_path, :tmp_path
def initialize(opts={})
self.host = opts[:host] || raise('you need to specify a remote host')
self.tmp_path = opts[:tmp_path] || raise('you need to specify a tmp path')
self.remote_path = opts... | true |
27b65a6b7edbdcd004e00632b53e353e220a3c71 | Ruby | lucianot/pacman | /app/writer.rb | UTF-8 | 748 | 3.1875 | 3 | [] | no_license | require 'csv'
class Writer
def self.write_to_csv(transactions, file_name = 'transactions.csv')
Writer.new.write_to_csv(transactions, file_name)
end
def write_to_csv(transactions, file_name)
csv = generate_csv(transactions)
File.open(file_name, 'w') { |file| file.write(csv) }
end
def generate_cs... | true |
0b4bb9beb95cab0a2a81f39f6a16a3b2c76c8a08 | Ruby | HusseinReda/MoneyTest | /lib/money_test.rb | UTF-8 | 3,134 | 3.921875 | 4 | [] | no_license | # This is the main class for saving the monetary value and handling
# different operations
require 'exceptions'
class Money
attr_accessor :amount, :currency
# Setting Euro as the default base currency
@@base_currency = 'EUR'
@@conversion_rates = {}
# Constructor taking the money amount and the currency
def in... | true |
a7f89d981dbf897a4c354f10693f548993ee1c32 | Ruby | RedL0tus/saltedfishBot | /main.rb | UTF-8 | 2,903 | 2.71875 | 3 | [
"WTFPL"
] | permissive | #!/usr/bin/ruby -w
# -*- coding: UTF-8 -*-
# Author: KayMW
# Copyright © 2017 KayMW <RedL0tus@users.noreply.github.com>
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See the LICENSE file for... | true |
6978366b233c3b01acc2fb6f05cc28cac1cadc4f | Ruby | dhalai/p-jira | /accounting/app/services/tasks/finish.rb | UTF-8 | 1,147 | 2.59375 | 3 | [] | no_license | module Tasks
class Finish
class UnexistingTask < StandardError; end
class UnexistingUser < StandardError; end
def initialize(
task_model: Task,
auditlog_creator: Auditlogs::Create,
price_calculator: Auditlogs::CalculatePrice
)
@task_model = task_model
@auditlog_creator =... | true |
88f4ba8b8ac18ea981cde9dcca9edca256d32d6d | Ruby | villins/leetcode | /ruby/assign_cookies.rb | UTF-8 | 326 | 3.34375 | 3 | [] | no_license | def find_content_children(g, s)
g = g.sort
s = s.sort
i = g.size - 1
j = s.size - 1
num = 0
while(i >= 0 && j >= 0) do
if(s[j] >= g[i])
num += 1
i -= 1
j -= 1
else
i -= 1
end
end
num
end
puts find_content_children([1,2], [1,2,3])
puts find_content_children([1,2,3], [... | true |
c24da805f563043a7d52f6198b8273a0b544d79a | Ruby | matoom/frostbite | /scripts/cinder.rb | UTF-8 | 843 | 2.625 | 3 | [
"MIT"
] | permissive | # desc: from tree in swamp to cinder beasts
# requirements: ?
# run: tree in haven swamp
def go(dir)
put dir
match = { :wait => [/\.\.\.wait|you may only type ahead/],
:retreat => [/You'll have better luck if you first retreat|You are engaged/],
:continue => [/Roundtime/] }
res = match_wa... | true |
92f9c65ce6e96a5bc8090f7f5cab493a2ad00d3c | Ruby | gijolopez/night_writer | /lib/writer.rb | UTF-8 | 392 | 2.765625 | 3 | [] | no_license | require_relative 'encoder'
require_relative 'night_write'
class Writer
attr_reader :data, :file
# def default_args
# {
# data: ,
# file: write_file
# }
# end
def initialize(file, *data)
# args = args.merge(default_args)
@data = data
@file = file
end
def write_to_file(dat... | true |
a7c722b9f25a63890f2c561de29f0fca08a43474 | Ruby | dr-dolce14/ruby-oo-relationships-practice-art-gallery-exercise-nyc01-seng-ft-060120 | /app/models/artist.rb | UTF-8 | 1,039 | 3.25 | 3 | [] | no_license | class Artist
attr_reader :name, :years_experience
@@all = []
def initialize(name, years_experience)
@name = name
@years_experience = years_experience
@@all << self
end
def self.all
@@all
end
def paintings
Painting.all.select do |painting|
painting.artist == self
end
en... | true |
9333e2a5f844d6bacfe10d235fdd18539064fd99 | Ruby | colinturner/ruby | /empty_ruby.rb | UTF-8 | 948 | 3.921875 | 4 | [] | no_license | # name = "Colin"
# def upper(string)
# string.upcase
# end
# def lower(string)
# string.downcase
# end
# random_name = ["Colin", "Ollie"].sample
# def random_case(name)
# arr = [name.downcase, name.upcase].sample
# end
# def random_both
# arr = ["Colin".upcase, "Colin".downcase, "Ollie".upcase, "Ollie".downca... | true |
59b70bc0465748f5ec999abaa2c0af8687345eca | Ruby | VivianAllen/gilded_rose_tech_test_ruby | /gilded_rose.rb | UTF-8 | 1,317 | 3.328125 | 3 | [
"MIT"
] | permissive | require_relative 'item_adjustment_handler'
class GildedRose
MIN_QUALITY = 0
MAX_QUALITY = 50
def initialize(items, handler_class=ItemAdjustmentHandler)
@items = items
@handler = handler_class.new end
def update_quality()
@items.each do |item|
adj = @handler.get_adj(item)
... | true |
483fc52ea0608c94123b3e7e936385716f7c7f20 | Ruby | SunnyBIARD/Nurikabe | /GUI/GCaseJouable.rb | UTF-8 | 2,002 | 3 | 3 | [] | no_license | require_relative 'GCase.rb'
require_relative '../Grille/CaseJouable.rb'
module Gui
##
# Widget graphique représentant une CaseJouable.
class GCaseJouable < GCase
##
# Crée un widget graphique représentant une CaseJouable.
#
# Paramètre :
# [+c+] CaseJouable... | true |
ea6c56d52aa19a5cc174c0cad902ec39d7f1227f | Ruby | CiaraMerrins/Assignment4 | /app/models/facade.rb | UTF-8 | 178 | 2.84375 | 3 | [] | no_license | class facade
def initialize(number_products)
@products= []
number_products.times do |i|
product = new_product("Product#{i}")
@products << product
end
end | true |
d12f4632181896ba9062c985fe60e138b94c551d | Ruby | delsaz/github-mirror | /fixes/fix_forks.rb | UTF-8 | 1,669 | 2.609375 | 3 | [
"BSD-2-Clause",
"BSD-3-Clause"
] | permissive | #!/usr/bin/env ruby
require 'ghtorrent'
class GHTFixForks < GHTorrent::Command
include GHTorrent::Settings
include GHTorrent::Retriever
include GHTorrent::Persister
def logger
@ght.logger
end
def persister
@persister ||= connect(:mongo, settings)
@persister
end
def go
@ght ||= GHT... | true |
7cd1b6693dadb618fd1be22e63d0aa8dcd201461 | Ruby | leonimanuel/sinatra-nested-forms-lab-superheros-online-web-sp-000 | /app/models/team.rb | UTF-8 | 117 | 2.8125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Team
attr_accessor :name, :motto
def initialize(attr)
@name = attr[:name]
@motto = attr[:motto]
end
end | true |
4c4ad1dfc5c026e3abce0f46ea15fa09adc89976 | Ruby | espago/issuer_response_codes | /lib/issuer_response_codes/locale_library.rb | UTF-8 | 3,872 | 2.71875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'yaml'
module IssuerResponseCodes
# Stores the translations of codes.
class LocaleLibrary
attr_reader :locale_hash
def initialize
@locale_hash = {}
AVAILABLE_LOCALES.each do |locale|
load_locale(locale)
end
end
# @param path [Strin... | true |
dbb2b3fd95cf36a1cdf98c626319bcc01d354008 | Ruby | trevoroc/homework | /W2D1/lib/simon.rb | UTF-8 | 1,275 | 3.890625 | 4 | [] | no_license | require 'byebug'
class Simon
COLORS = %w(red blue green yellow)
attr_accessor :sequence_length, :game_over, :seq
def initialize
@sequence_length = 1
@game_over = false
@seq = []
end
def play
system("clear")
until game_over
take_turn
end
game_over_message
reset_game
... | true |
924e943331ee5ebccab05fab5a1361eae1d66f89 | Ruby | markpothers/activerecord-validations-lab-houston-web-career-021819 | /app/models/post.rb | UTF-8 | 662 | 2.8125 | 3 | [] | no_license | require 'pry'
class Post < ActiveRecord::Base
validates :title, presence: true
validates :summary, length: {maximum: 250}
validates :content, length: {minimum: 50}
validates :category, inclusion: {in: %w{Fiction Non-Fiction}}
validate :is_click_bait?,
def is_click_bait?
click_bait = ["Won't Believe", ... | true |
648e8c8718f16e5fbe89912e73012aa106298e48 | Ruby | KrisJordan/blackjack | /lib/kris_jordan/blackjack/state/paying.rb | UTF-8 | 916 | 2.84375 | 3 | [
"MIT"
] | permissive | module KrisJordan::Blackjack::State
class Paying
Skip = KrisJordan::Blackjack::Event::Skip
Win = KrisJordan::Blackjack::Event::Win
Lose = KrisJordan::Blackjack::Event::Lose
def self.prompt deck, player, hand, dealer_hand
if player.dealer?
Skip.new
else
if hand.bust?
... | true |
2c2a37800b3dd144e0bfd241922908322ac765a5 | Ruby | kyletolle/color_divider | /spec/color_divider_spec.rb | UTF-8 | 938 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'color_divider'
describe ColorDivider do
let(:expected_start_color) { '#000000' }
let(:expected_end_color) { '#FFFFFF' }
let(:color_divider) do
described_class.new(expected_start_color, expected_end_color)
end
describe "#initialize" do
subject { color_divider }
it "takes two colors" ... | true |
cc1f0a1d786c6e0ab53698f920eedfb7d9d1da64 | Ruby | cooljl31/learn_rspec | /car_project/spec/car_spec.rb | UTF-8 | 1,148 | 3.15625 | 3 | [] | no_license | require 'car'
describe Car do
describe 'attributes' do
it 'allows reading and write for :make' do
car = Car.new
car.make = 'Test'
expect(car.make).to eq 'Test'
end
it 'allows reading and write for :year' do
car = Car.new
car.year = 2017
expect(car.year).to eq 2017
... | true |
4fe8756bd05aa26676cbcdc473cf07d91240a771 | Ruby | almirpask/Ruby | /sn/loops.rb | UTF-8 | 409 | 3.359375 | 3 | [] | no_license | $init = 0;
$max = 10;
=begin
while $init < $max do
puts "iteration #{$init}"
$init += 1
end
=end
=begin
begin
puts "iteration #{$init}"
$init += 1
end while $init < $max
=end
$arr = ['item1', 'item2', 'item3']
#for item in $arr
#for item in (0...$arr.length)
# puts $arr[item]
#end
#$arr.each do ... | true |
4c99dcf4785aefc10ad01d136264c1f34da4a662 | Ruby | pisuke/su2ds | /su2dslib/interface.rb | UTF-8 | 33,699 | 2.875 | 3 | [] | no_license | require "wxSU/lib/Startup"
module SU2DS
class UserDialog
attr_reader :results
def initialize
@prompts = []
@vars = []
@values = []
@choices = []
@isbool = []
@results = []
end
def addOption(prompt, var, choice='')
@prompts.push(prompt... | true |
3dc53936d78f80dae877293d6abbe2b352d36ca2 | Ruby | RobertoBarros/batch_444_snake_game | /snake.rb | UTF-8 | 1,874 | 3.59375 | 4 | [] | no_license | class Snake
MAX_X = 57
MAX_Y = 42
def initialize(size, foods)
@cube = Gosu::Image.new('media/green_cube.png')
@direction = 'right'
@segments = [{ x: 28, y: 21 }]
size.times { self.grow }
@foods = foods
end
def move
case @direction
when 'up' then @segments.unshift({ x: @segment... | true |
5b518698664f3c98edbe3a0f237ca2ab0cdf1826 | Ruby | tyler-rand/console_game | /init.rb | UTF-8 | 1,260 | 2.796875 | 3 | [] | no_license | require 'YAML'
require 'fileutils'
seeds = %w(mobs quests quest_items)
seeds.each { |seed| load "seeds/#{seed}.rb" }
folders = %w(models facades)
folders.each { |folder| Dir[File.join(__dir__, folder, '*.rb')].each { |file| require file } }
###################
# CREATE DB FILES #
###################
FileUtils.mkdir... | true |
b32f15071a172597db657374425451f5aff5fb9a | Ruby | timfjord/aws-srp | /spec/aws_srp/hex_spec.rb | UTF-8 | 3,636 | 3.109375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
RSpec.describe AwsSRP::Hex do
describe '.str' do
it 'return a hex string' do
expect(described_class.str('aa')).to eql ['aa'].pack('H*')
end
end
describe 'initialization' do
it 'raises an error if the given string is not a hex string' do
expect { described_cl... | true |
7dcd088b141417bd53c160f085a785dcc5df5521 | Ruby | cmaxw/tictactoe | /lib/tictactoe/human_player.rb | UTF-8 | 471 | 3.265625 | 3 | [] | no_license | module TicTacToe
class HumanPlayer < Player
def set_marker(marker)
@me = marker
end
def move
@board.display
puts "\nChoose a space:"
begin
@board.move(STDIN.gets.strip, @me)
rescue InvalidSpaceError
puts $!.message
self.move
rescue InvalidMarker... | true |
71f756a28f0e390afad24c2ce637db3b52c684da | Ruby | l-nichols/launch-intro | /Basics/exercise1.rb | UTF-8 | 342 | 4.5625 | 5 | [] | no_license | # Add two strings together that, when concatenated, return your first and
# last name as your full name in one string.
#
# "<Firstname> <Lastname>"
#
# For example, if your name is John Doe, think about how you can put
# "John" and "Doe" together to get "John Doe".
first_name = "Elliot"
last_name = "Nichols"
puts "#{... | true |
f6795526fbbae1622ea4a5cc50b0f9400138ca0a | Ruby | rmulhol/odin_project_exercises | /caesar/spec/lib/caesar_cipher_spec.rb | UTF-8 | 201 | 2.765625 | 3 | [] | no_license | require '../spec_helper'
require './caesar_cipher.rb'
describe "caesar cipher" do
it "modifies a string by an integer" do
expect(caesar_cipher("What a string!", 5)).to eq("Bmfy f xywnsl!")
end
end | true |
d6138e7a4ef528f4d8206c8ee765a541045fc3a5 | Ruby | transcriptic/ups-shipping | /lib/ups_shipping/package.rb | UTF-8 | 910 | 2.59375 | 3 | [] | no_license | require "nokogiri"
module Shipping
class Package
attr_accessor :large, :weight, :description, :monetary_value
def initialize(options={})
@large = options[:large]
@weight = options[:weight]
@description = options[:description]
@monetary_value = options[:monetary_value]
end
de... | true |
cd33e1e01e731b577687a5000c988afc93c3825c | Ruby | stungeye/glutton_ratelimit | /test/testing_module.rb | UTF-8 | 2,253 | 2.9375 | 3 | [
"Unlicense",
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module TestingModule
# This module assumes use as a mixin within
# a test class which defines @testClass.
TIMING_TOLERANCE = 0.995 # Timing can be off by 0.5%
def test_120_tasks_every_second_with_ms_task
min_time = 1
rl = @testClass.new 120, min_time
delta = timed_run(rl) { sleep 0.001 }
# put... | true |
8c03eb65669f51869e60061ac7e9a0eee60a4f3f | Ruby | wasamasa/aoc | /2015/20.rb | UTF-8 | 2,484 | 4.34375 | 4 | [
"Unlicense"
] | permissive | require_relative 'util'
require 'set'
# --- Day 20: Infinite Elves and Infinite Houses ---
# To keep the Elves busy, Santa has them deliver some presents by
# hand, door-to-door. He sends them down a street with infinite houses
# numbered sequentially: 1, 2, 3, 4, 5, and so on.
# Each Elf is assigned a number, too, ... | true |
503977b951486a1f0a8729e28aa0d217098c3585 | Ruby | denio-rus/thinknetica-ruby | /lesson7/message.rb | UTF-8 | 1,552 | 3.109375 | 3 | [] | no_license | module Message
def operation_success_message
puts "Операция выполнена"
end
def operation_rejected_message(e)
puts e.message
puts "Операция не выполнена"
end
def train_created_message(id)
puts "Поезд #{id} создан."
end
def wrong_choise_message
puts "Нет такого варианта"
end
def... | true |
1a3cede5532f0f84a51cd3b5adb8d7a66373a4b4 | Ruby | mbj/substation | /spec/integration/substation/dispatcher/call_spec.rb | UTF-8 | 4,879 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # encoding: utf-8
require 'spec_helper'
module App
class Database
include Equalizer.new(:relations)
def initialize(relations)
@relations = relations
end
def [](relation_name)
Relation.new(relations[relation_name])
end
protected
attr_reader :relations
class Relation
... | true |
4c85f0a3655c5861f571ea02ba7932d91fae1cd9 | Ruby | wlffann/black_thursday | /test/merchants_revenue_analyst_test.rb | UTF-8 | 1,664 | 2.75 | 3 | [] | no_license | require_relative 'test_helper'
require_relative '../lib/merchants_revenue_analyst'
class MerchantsRevenueAnalystTest < Minitest::Test
attr_reader :engine, :analyst
def setup
@engine = SalesEngine.from_csv({:items => './test/assets/test_items.csv',
:merchants => './test/a... | true |
60516126fd627312b60fdfe3ff59ea958cfd3058 | Ruby | dkamioka/validacnpj | /validacnpj.rb | UTF-8 | 943 | 3.25 | 3 | [] | no_license | # valida cnpj
#
# Require das gems
['sinatra','haml'].each { |x| require x }
get '/' do
haml :index
end
post '/valida' do
valida_cnpj(params[:cnpj]) ? (haml :valido) : (haml :invalido)
end
# metodo que valida se um numero passado é um cnpj válido.
def valida_cnpj(x)
if x.to_s.size == 14
cnpj = x.to_s.sp... | true |
6337d1c8fd172c73079b3f64ea66e2dcfd2a6a7b | Ruby | luqui/soylent | /open/transactions/GlutSucksTimer.rb | UTF-8 | 1,162 | 2.796875 | 3 | [] | no_license | class AwakenException < Exception; end
class GlutSucksTimer
include MonitorMixin
def initialize
super
@timers = []
@thread = Thread.new do
begin
run
rescue => x
puts "EXCEPTION: #{x.message} #{x.backtrace.inspect}"
raise
end
end
end
def delay(delta, &code)
synchronize {
target... | true |
b53af16740e03ac29d69dffae0ca62aa284c4503 | Ruby | archivesspace/archivesspace | /common/log.rb | UTF-8 | 1,392 | 2.578125 | 3 | [
"ECL-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | require 'aspace_logger'
# This is a class used for logging in sinatra applications ( backend, indexer
# ). Rails provides its own logging functionality, so its not needed in the
# Frontend or PUI
class Log
# By default start with STDERR, but allow people to change it.
@@logger = ASpaceLogger.new($stderr)
def s... | true |
ea4db36fac877afa4e439c8332aaa846f65956ec | Ruby | QuenMBar/CS-214 | /labs/08/ruby/name.rb | UTF-8 | 447 | 3.640625 | 4 | [] | no_license | # name.rb defines the Name class
#
# Begun by: Dr. Adams, for CS 214 at Calvin College.
# Completed by: Quentin Barnes
# Date: April 13, 2019
####################################################
class Name
def initialize(first, middle, last)
@first, @middle, @last = first, middle, last
end
attr_reader :fir... | true |
76c472c48cd7d3638430434985fd9e1bcaa087c3 | Ruby | townie/L2PDanPickettWork | /happybday.rb | UTF-8 | 839 | 4.0625 | 4 | [] | no_license | # happy bday
def getage
puts "Lets get your birthday? Year first, please"
year = gets.chomp.to_i
while year < 1900
puts "You are not that old try again."
puts " Please enter your Birth YEAR"
year = gets.chomp.to_i
end
puts "Please enter the month you were born"
month = gets.chomp.to_i
while month > 12
... | true |
968acde4d7480b4a7a58a75db97fdc555ca3ca04 | Ruby | IshchenkoAndriy/Olympiad-Programming | /sum/sum.rb | UTF-8 | 3,748 | 3.46875 | 3 | [] | no_license |
def allCombiantionsOfSumForNumber(resultNumber, numberOfVluesToAdd, availableNumbers)
if resultNumber < 0 then
return []
end
if numberOfVluesToAdd == 1 then
return availableNumbers.include?(resultNumber) ? [[resultNumber]] : []
end
allCombiantion = []
availableNumbers = availableNumbers.find_all { |number... | true |
7eaab9ddd62560616d8c7755cbad79028b86aa7e | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/rna-transcription/6846525658f8433280d5d1481dca86cd.rb | UTF-8 | 318 | 3.109375 | 3 | [] | no_license | module Complement
extend self
RNA_TO_DNA = { "G" => "C", "C" => "G", "T" => "A", "A" => "U" }
DNA_TO_RNA = { "G" => "C", "C" => "G", "U" => "A", "A" => "T" }
def of_dna(dna)
dna.each_char.map { |n| RNA_TO_DNA[n] }.join
end
def of_rna(rna)
rna.each_char.map { |n| DNA_TO_RNA[n] }.join
end
end
| true |
a43658c2277fccd306ea275aaac3ac10b4c3c5b0 | Ruby | cherylhughey/text_rank | /lib/text_rank/char_filter/strip_email.rb | UTF-8 | 550 | 3.25 | 3 | [
"MIT"
] | permissive | module TextRank
module CharFilter
##
# Character filter to remove email addresses from text.
#
# = Example
#
# StripEmail.new.filter!("That is a hard question said candide@gmail.com")
# => "That is a hard question said "
##
class StripEmail
# Simple regex to match most ema... | true |
7cd0cc6909a9e423e4b424901c4041f354a97471 | Ruby | asilano/free-dom | /app/lib/game_engine/base_game_v2/militia.rb | UTF-8 | 1,729 | 2.765625 | 3 | [] | no_license | module GameEngine
module BaseGameV2
class Militia < GameEngine::Card
text "+$2",
"Each other player discards down to 3 cards in hand."
action
attack
costs 4
def play(played_by:)
played_by.grant_cash(2)
# Now, attack everyone else
launch_attack(vic... | true |
ac5ca23df1b226b85a978433351ca63a21fc958b | Ruby | tinyspeck/log-courier | /lib/log-courier/server.rb | UTF-8 | 6,448 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | # encoding: utf-8
# Copyright 2014 Jason Woods.
#
# This file is a modification of code from Logstash Forwarder.
# Copyright 2012-2013 Jordan Sissel and contributors.
#
# 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 ... | true |
e979dc803c91cac20875c11061ce7b8e0bef3a02 | Ruby | niro1987/bouncie | /lib/bouncie/entity.rb | UTF-8 | 1,153 | 2.953125 | 3 | [] | no_license | # frozen_string_literal: true
require 'active_support/inflector'
module Bouncie
# Abstract base class for objects returned from API requests. Parses dates, converts keys to underscore.
class Entity
def initialize(data)
transformed = data.transform_keys { |k| k.to_s.underscore.to_sym }
@data = mass... | true |
4a96fc4da7f2db706f948708498e0b2ac907c07d | Ruby | TataSher/student-directory | /directory3.rb | UTF-8 | 1,716 | 4.09375 | 4 | [] | no_license | def print_header
puts "The students of Villains Academy".center(100)
puts "-------------".center(100)
end
def print(students)
students_by_cohorts = {}
students.map do |student|
name = student[:name]
cohort = student[:cohort]
if students_by_cohorts[cohort] == nil
students_by_cohorts[cohort... | true |
816e7af2b51810935719f6b939b58660833a002a | Ruby | bsheehy9/RB101-new | /lesson_4/additional_practice/p_9.rb | UTF-8 | 151 | 3.296875 | 3 | [] | no_license | title = "the flintstones rock"
def titleize(words)
words.split.map { |word| word.capitalize }.join(' ')
end
puts titleize(title)
title.split.shift | true |
5b038a713c90634defe0c7e3ee9ef959426769d3 | Ruby | yusungkim/BioPerlPrograms | /DoublePrimerExtansion/AppRuby/bio/shell/interface.rb | UTF-8 | 4,407 | 2.703125 | 3 | [] | no_license | #
# = bio/shell/interface.rb - core user interface of the BioRuby shell
#
# Copyright:: Copyright (C) 2005
# Toshiaki Katayama <k@bioruby.org>
# License:: Ruby's
#
# $Id: interface.rb,v 1.14 2006/02/27 09:36:35 k Exp $
#
module Bio::Shell
private
### work space
def ls
list = eval("loca... | true |
a7fe6a2c03257411aa93e0d692b9eff2bea28f4b | Ruby | kenn/active_flag | /lib/active_flag/definition.rb | UTF-8 | 1,898 | 2.765625 | 3 | [
"MIT"
] | permissive | module ActiveFlag
class Definition
attr_reader :keys, :maps, :column
def initialize(column, keys, klass)
@column = column
@keys = keys.freeze
@maps = Hash[keys.map.with_index{ |key, i| [key, 2**i] }].freeze
@klass = klass
end
def humans
@humans ||= {}
@humans[I18n... | true |
18efe866fb84fd25fab5ef6fc04f31c7345476a0 | Ruby | msruseva/ruby-retrospective-2015-2 | /solutions/08.rb | UTF-8 | 4,428 | 3.28125 | 3 | [] | no_license | class Spreadsheet
class Error < RuntimeError
end
def initialize(data = '')
@cells = data.strip.split(/\n/).map do |row|
row.strip.split(/\t|\s{2,}/).map(&:strip)
end
@rows = @cells.size
end
def empty?
@cells.empty?
end
def cell_at(index)
cell = Cell.new(index)
assert_cell_... | true |
fbef3461a3721bc14e69a7ec4999b31ce0e9f3d3 | Ruby | dmdinh22/PreCourse | /Exercises.rb | UTF-8 | 3,790 | 4.15625 | 4 | [] | no_license | #1
array = [1,2,3,4,5,6,7,8,9,10]
#one line version
array.each {|x| puts x}
# Tea Leaf multi-line version
array.each do |number|
puts number
end
#2
array.each {|x| puts x if x > 5 }
#Tea Leaf multi-line version
arr.each do |number|
if number > 5
puts number
end
end
#alternate
arr.each do |number|
puts... | true |
5466a4a1906a5cfea35afd8d7bc931ba2067ff28 | Ruby | AnotherMetal99/VS | /3laba/1task.rb | UTF-8 | 969 | 3.171875 | 3 | [] | no_license | def read(name)
file = File.open(name)
page = file.readlines.map(&:chomp)
file.close
puts page
end
while true
students = []
File.open('fio.txt').each_line do |line|
students.push(line.chomp)
end
read('fio.txt')
puts 'Please,enter student(s) age'
age = gets.chomp
page_result = File.open('resu... | true |
9d15379759782ae46a1d7d024541d9aa31e88a74 | Ruby | bryantomoregie/programming-univbasics-nds-nds-to-insight-with-methods-repetition-lab-houston-web-030920 | /lib/nds_extract.rb | UTF-8 | 2,164 | 3.9375 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | $LOAD_PATH.unshift(File.dirname(__FILE__))
require_relative './directors_database'
require 'pry'
def gross_for_director(d)
total = 0
index = 0 #This is the index of the element of the :movie array.
while index < d[:movies].length do
total += d[:movies][index][:worldwide_gross]
index += 1
#This code add... | true |
708e153822cf07625eab74d42056fb601bc2d74f | Ruby | enkessler/cuke_linter | /lib/cuke_linter/linters/test_with_action_step_as_final_step_linter.rb | UTF-8 | 883 | 2.6875 | 3 | [
"MIT"
] | permissive | module CukeLinter
# A linter that detects scenarios and outlines that have an action step as their final step
class TestWithActionStepAsFinalStepLinter < Linter
# Changes the linting settings on the linter using the provided configuration
def configure(options)
@when_keywords = options['When']
e... | true |
05f72ef859da9f8b4e456e2c6f87a2f5eb43c58a | Ruby | bschnitz/odin-chess | /spec/chess_pieces/king_spec.rb | UTF-8 | 3,100 | 2.875 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../../lib/board'
require_relative '../../lib/chess_pieces/rook'
require_relative '../../lib/chess_pieces/king'
describe King do
let(:board) do
instance_double(
Board,
piece_at?: false,
valid_field?: true,
move_piece: nil,
undo_last_mo... | true |
5fdab267e35860a60ebf36f73232c139e38f9b12 | Ruby | Nikoniym/black_jack | /deck_cards.rb | UTF-8 | 975 | 3.1875 | 3 | [] | no_license | class DeckCards
def initialize
@cards = %w(🂡 🂱 🃁 🃑 🂢 🂲 🃂 🃒 🂣 🂳 🃃 🃓 🂤 🂴 🃄 🃔
🂥 🂵 🃅 🃕 🂦 🂶 🃆 🃖 🂧 🂷 🃇 🃗 🂨 🂸 🃈 🃘
🂩 🂹 🃉 🃙 🂪 🂺 🃊 🃚 🂫 🂻 🃋 🃛 🂭 🂽 🃍 🃝
🂮 🂾 🃎 🃞)
@position = 0
create_deck
@deck = @deck.shuffle
end
... | true |
fe7092e6cbece172afca9695214520f8b40e16ec | Ruby | andoshin11/cinelog | /app/values/client_error.rb | UTF-8 | 247 | 2.71875 | 3 | [] | no_license | class ClientError < StandardError
def default_message
nil
end
def message
super == self.class.name ? default_message : super
end
def reason_phrase
self.class.name.demodulize.gsub(/[A-Z]/) { |x| " #{x[0]}" }.strip
end
end
| true |
ce072eeb44209bdc9d12a8aaa94363d9ee6ba095 | Ruby | makandra/query_diet | /lib/query_diet/logger.rb | UTF-8 | 938 | 2.78125 | 3 | [
"MIT"
] | permissive | module QueryDiet
class Logger
DEFAULT_OPTIONS = { :bad_count => 8, :bad_time => 5000 }
class << self
attr_accessor :queries, :paused
def reset
self.queries = []
end
def log(query)
if paused?
yield
else
result = nil
time = Benchma... | true |
2237d99ac211f0fb0e2d3112c7e55e58d3c18ebb | Ruby | ewest17-uncc/ITSC3155_SPRING2019_ewest17 | /ruby_calisthenics2/lib/dessert.rb | UTF-8 | 757 | 3.1875 | 3 | [] | no_license | class Dessert
# add code for setters and getters
def initialize(name, calories)
@name = name
@calories = calories
end
def healthy?
calories < 200
end
def delicious?
@flavor != "licorice"
end
def name #getter method
@name
end
def name=(newName) #setter method
@name = newNam... | true |
3af673080d6dbcee6657afe85d91fe3e3abb46ae | Ruby | easemob/www.easemob.com | /vendor/gems/ruby/2.6.0/gems/adsf-1.2.0/lib/adsf/rack/index_file_finder.rb | UTF-8 | 1,179 | 2.546875 | 3 | [
"MIT"
] | permissive | module Adsf::Rack
class IndexFileFinder
def initialize(app, options)
@app = app
@root = options[:root] or raise ArgumentError, ':root option is required but was not given'
@index_filenames = options[:index_filenames] || [ 'index.html' ]
end
def call(env)
# Get path
path_in... | true |
72fd34bda2234b2116ac000f1db47ab2338f8b52 | Ruby | handlez36/BlackJack | /spec/models/game_spec.rb | UTF-8 | 1,103 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Game, type: :model do
include FactoryGirl::Syntax::Methods
before do
@game = Game.create
@player1 = create(:user, game: @game)
@player2 = create(:user, game: @game)
end
describe "Game players set up correctly" do
it "should setup two players" do
... | true |
7ddc604bd34c66fef0e5a13edc4a591d0ce199e7 | Ruby | wisq/wisq_utils | /bin/x3rename | UTF-8 | 1,759 | 3.125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-public-domain"
] | permissive | #!/usr/bin/ruby
# Quick and dirty script to either create a gap in a series
# of numbered CAT/DAT files, or to collapse said gap(s).
# It's used for modding EgoSoft's X3 games
# (Terran Conflict, Albion Prelude), hence the name.
files = Dir.entries('.').select do |file|
file =~ /^(\d+)\.[cd]at$/
end.sort
numbers = ... | true |
d07e402667a0ea01a71172b86e41ce8ee622409b | Ruby | vkeepe/dynamic-bundle | /best_plan.rb | UTF-8 | 3,829 | 3.171875 | 3 | [] | no_license | # encoding: utf-8
################################################################################
# @file best_plan.rb
# @author Vishal Srivastava <http://vishalthearch.branded.me>
# @brief Find the best plan based on selected items
# @Keywords best plan, pricing
# @Std Ruby 2.0.0
##----------------... | true |
93aa6bc81e4b3b53a125bd3b8f06f115af8c82c5 | Ruby | kpam92/app_academy_coursework | /w1d5/knightpathfinder.rb | UTF-8 | 1,388 | 3.484375 | 3 | [] | no_license | require_relative 'polytreenode'
class KnightPathFinder
attr_reader :visited_positions
ALLOWED_MOVE_DIRECTIONS = [
[1, 2],
[1, -2],
[-1, 2],
[-1, -2],
[2, 1],
[2, -1],
[-2, 1],
[-2, -1]]
def initialize(pos = [0,0])
@board = Array.new(8) {Array.new(8)}
populate_board
@... | true |
85be5012bfb4de5f257adcc9290f5f4b683a32ac | Ruby | sandagolcea/Ruby | /kickstart/session2/challenge/6_array.rb | UTF-8 | 904 | 4.53125 | 5 | [] | no_license | # Write a method named prime_chars? which takes an array of strings
# and returns true if the sum of the number of characters is prime.
#
# Remember that a number is prime if the only integers that can divide it with no remainder are 1 and itself.
#
require 'mathn'
def prime_chars? array_of_chars
sum = 0
ar... | true |
270c905d353736b596a8c99d6d70948f3cd84a95 | Ruby | masanorifunaki/ruby_study | /11_exception/method_exception.rb | UTF-8 | 238 | 3.5625 | 4 | [] | no_license | def foo(x ,y)
result = x + y
return result
rescue => ex
return x, y
ensure
if result
puts "xとyを足した結果は、#{result}でした"
else
puts "xとyは足せませんでした"
end
end
foo(10, 20)
foo(10, "a") | true |
8ec93e270b3593ce362b19e3c0654531047ad874 | Ruby | iMears/ruby_practice | /letter_generator_2.rb | UTF-8 | 229 | 3.046875 | 3 | [] | no_license | require 'csv'
class Letter
# define the class here
def
end
CSV.foreach("birthday.csv", :headers => true) do |row|
letter = Letter.new(row['their name'], row['present'], row['your age'], row['your name'])
letter.print
end
| true |
022152b63ba2572cc84960978ce1b975c56848e3 | Ruby | mikeotoole/data_structures_and_algorithms_in_ruby | /data_structures/node.rb | UTF-8 | 470 | 3.5625 | 4 | [
"MIT"
] | permissive | # Nodes used by the LinkedList, Queue, and Stack data structures.
class Node
attr_accessor :next_node
attr_reader :data
# Recursively call to_a on all connected Nodes and return an Array with their data.
# Time Complexity: O(n)
# Space Complexity: O(n)
def to_a
if next_node
[data].concat(next_nod... | true |
15fda8b5ba0c6ac4d84df48817aab80eb0ea98f9 | Ruby | DianaLuciaRinconBl/Ruby-book-exercises | /ruby_basic_ex/debugging/ex_3.rb | UTF-8 | 547 | 4.78125 | 5 | [] | no_license | # When the user inputs 10, we expect the program to print The result is 50!,
# but that's not the output we see. Why not?
def multiply_by_five(n)
n * 5
end
puts "Hello! Which number would you like to multiply by 5?"
number = gets.chomp #=>this needs .to_i at the end
puts "The result is #{multiply_by_five(number)}!... | true |
46cd7ad8afe1e8ce417fbf94c38a93029e60fa28 | Ruby | itinerary-builder/travellier | /db/seeds.rb | UTF-8 | 38,711 | 2.65625 | 3 | [] | no_license | # # This file should contain all the record creation needed to seed the database with its default values.
# # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
# #
# # Examples:
# #
# # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the R... | true |
3f3cbed724bce2365f8a94f04109bc67cbb17795 | Ruby | yudi-tan/fa17-hw1 | /foobar.rb | UTF-8 | 183 | 3.25 | 3 | [] | no_license | class Foobar
def self.baz(a)
# Class method
# Call with `Foobar.baz`
a.map(&:to_i).map{|e| e + 2}.delete_if{|e| e % 2 != 0}.uniq.delete_if{|e| e > 10}.sum
end
end
| true |
c1b6f5dfd8fd1d789d1ee5f021ce93aaf3d9b37c | Ruby | oloo/oo_bootcamp | /probability/chance_test.rb | UTF-8 | 1,312 | 3 | 3 | [] | no_license | # Copyright 2015 by Fred George. May be copied with this notice, but not used in classroom training.
require 'minitest/autorun'
require_relative './chance'
# Confirms behavior of Chance
class ChanceTest < Minitest::Test
IMPOSSIBLE = 0.chance
UNLIKELY = 0.25.chance
EQUALLY_LIKELY = 0.5.chance
LIKELY = 0.75.ch... | true |
52bd3b941494bb8a96630185578e6569cf11ac9a | Ruby | vishalantony/Quizzup | /app/helpers/quizzes_helper.rb | UTF-8 | 170 | 2.78125 | 3 | [] | no_license | module QuizzesHelper
def self.mapper(durations, questions)
m = durations.zip questions
q_map = {}
m.each do |k, v|
q_map[k] = v
end
return q_map
end
end
| true |
840786a3ca96d6e6eab6a8074715bd187538b77c | Ruby | MirkoMignini/completion-progress | /lib/completion-progress/hint.rb | UTF-8 | 195 | 2.53125 | 3 | [
"MIT"
] | permissive | class Hint
attr_accessor :step, :text, :href, :options
def initialize(step, text, href = '', options = {})
@step = step
@text = text
@href = href
@options = options
end
end | true |
b8533b8e6951bf472796d627eb28c00a46a2460e | Ruby | itggot-max-gustafsson/standard-biblioteket | /lib/square.rb | UTF-8 | 54 | 2.765625 | 3 | [] | no_license | def square(num)
out = num*num
return out
end
| true |
120c29f18420610c436ac0a3205922be35407b79 | Ruby | dbfarms/sinatra-mvc-lab-v-000 | /models/piglatinizer.rb | UTF-8 | 1,996 | 4.15625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class PigLatinizer
attr_reader :text
def initialize #(text)
@text = text
end
def piglatinize(text)
pig_latined = ""
text_array = text.split(" ")
text_array.each do |word|
if word[0].downcase.match(/[aeiou]/) != nil
word += "way"
pig_latined += word + " "
e... | true |
50a363e1d8642365e1b5c5fe17e51eaa8b9c64ba | Ruby | cookpad/grpc_kit | /lib/grpc_kit/calls/client_bidi_streamer.rb | UTF-8 | 1,568 | 2.578125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'grpc_kit/call'
require 'grpc_kit/calls'
module GrpcKit
module Calls::Client
class BidiStreamer < GrpcKit::Call
include Enumerable
alias outgoing_metadata metadata
def initialize(**)
super
@recv_mutex = Mutex.new
@send = false
... | true |
0a94889c6a163ccede2653e3f7e906956997b618 | Ruby | Andyreyesgo/Gen45 | /objetcs/Challenge2/Fallos/Ejercicio1.rb | UTF-8 | 910 | 3.984375 | 4 | [] | no_license | class Persona
def initialize ( first, last, age, type)
@first_name = first
@last_name = last
@age =age
@type =type
end
def birthday
@age +=1
end
def talk
if @type == "Student"
puts "Aquí es la clase de programación d ruby?"
elsif ... | true |
bbe9aa1faafc94a836adc72eeafea34cc92f1ea2 | Ruby | johatfie/scripts | /split_parameters.rb | UTF-8 | 2,012 | 2.90625 | 3 | [] | no_license | require 'tempfile'
require 'fileutils'
path = "#{ ARGV[ 1 ] }"
temp_file = Tempfile.new('foo')
split_size = 50
begin
File.open( path, 'r' ) do |f|
f.each_line do |line|
case ARGV[ 0 ]
when '0'
# line contains a hash key-value pair
if line =~ /\([^)]*=>[^)]*\)/
subline = li... | true |
76b74622c33aba70aea4ec303154f6b79c74a05a | Ruby | gitmamhub/reinforce_ex | /exercise1.rb | UTF-8 | 2,200 | 3.21875 | 3 | [] | no_license |
train_info = [
{train: "72C", frequency_in_minutes: 15, direction: "north"},
{train: "72D", frequency_in_minutes: 15, direction: "south"},
{train: "610", frequency_in_minutes: 5, direction: "north"},
{train: "611", frequency_in_minutes: 5, direction: "south"},
{train: "80A", frequency_in_minutes: 30, direction: "east"... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.