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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
66018c49fafd5450d62fbc31d2647838aeb404ab | Ruby | fma2/colocated-charters-nyc-script | /all-colocated-script.rb | UTF-8 | 345 | 3 | 3 | [
"MIT"
] | permissive | def create_csv_with_same_address_schools(schools, csv)
schools.each do |school|
address = school.Primary_Address
matched_item = schools.find { | item | item.Primary_Address == address && item.ATS_System_Code != school.ATS_System_Code }
school.Same_Address_As_Another_School = true;
if matched_item != nil
csv... | true |
29f0b7b8fbf68ab940a4de3bf9fd43ce70783542 | Ruby | IIIIIIIIll/RubyQuizess | /Quiz17/question7.rb | UTF-8 | 202 | 2.8125 | 3 | [] | no_license | first = 'speed'
second = 'racer'
p binding.local_variables
p TOPLEVEL_BINDING.local_variables
#class Motivation
def speak
eval('"Go #{first} #{second}!!!"', TOPLEVEL_BINDING)
end
#end
p speak
| true |
a61950de28a279ffd69dbc0f571f9192784e49a9 | Ruby | yehudamakarov/inspiration-please | /lib/inspiration_please/cli.rb | UTF-8 | 2,225 | 3.71875 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class InspirationPlease::CLI
attr_reader :date_page
def initialize
@date_page = InspirationPlease::DatePage.new
end
def call
list_date
menu
end
def menu
puts ''
input = nil
begin
while input != 'exit'
puts ''
puts " > Enter '1' for today's day in Je... | true |
074b3532665e100d8909ed869968112d08cc804d | Ruby | rorysaur/chess | /king.rb | UTF-8 | 272 | 3.1875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
require_relative './stepping_piece.rb'
class King < SteppingPiece
DELTAS = [
[-1, -1],
[-1, 0],
[-1, 1],
[0, 1],
[0, -1],
[1, -1],
[1, 0],
[1, -1]
]
def to_s
@color == :white ? "♚ " : "♔ "
end
end | true |
65b3df2c33f1cecfd4e1886e35089863367e4f68 | Ruby | leungwensen/70-math-quizs-for-programmers | /zh_CN/q61_02.rb | UTF-8 | 1,268 | 3.390625 | 3 | [
"MIT"
] | permissive | # 设置方格点数目
W, H = 5, 4
# 移动方向
@move = [[0, 1], [0, -1], [1, 0], [-1, 0]]
@log = {}
# 递归遍历
def search(x, y, depth)
return 0 if x < 0 || W <= x || y < 0 || H <= y
return 0 if @log.has_key?(x + y * W)
return 1 if depth == W * H
# 遍历到一半,检查剩下的点是否连结
if depth == W * H / 2 then
remain = (0..(W*H-1)).... | true |
8b3e2b5106434db4afebc68e239ef7ce85def51f | Ruby | jalapl/state_machine | /lib/state_machine/base.rb | UTF-8 | 1,747 | 2.703125 | 3 | [
"MIT"
] | permissive | module StateMachine
module Base
module ClassMethods
extend Forwardable
def_delegators :@state_collection, :states, :initial_state
attr_accessor :options
def whiny_transitions?
options[:whiny_transitions] == true
end
def state_collection
@state_collection ||=... | true |
3291bd0b7949fee92265970c2999aaff988648aa | Ruby | JackBracken/Connect4 | /lib/board.rb | UTF-8 | 937 | 3.65625 | 4 | [] | no_license | module Connect4
class Board
attr_reader :board
ROWS = 5
COLS = 7
EMPTY_SPACE = 'o'
def initialize
# 5 rows, 7 columns
@board = Array.new(COLS){ Array.new(ROWS, EMPTY_SPACE) }
@veto = -1
end
def to_s
#@board.reverse.each { |x| print "#{x} #{x.size}\n" }
(R... | true |
88adf3a65d1f8737ac279364e2b6242d003d4f53 | Ruby | morsedigital/morse_controller_helpers | /spec/morse_controller_helpers_spec.rb | UTF-8 | 2,304 | 2.546875 | 3 | [
"MIT"
] | permissive | require "spec_helper"
class GenericController < ActionController::Base
include MorseControllerHelpers
end
class Thing; end
class ThingStuff; end
RSpec.describe MorseControllerHelpers, type: :controller do
let(:controller) { GenericController.new }
describe 'klass' do
it 'should constantize the klass_camel... | true |
3c8e3c948795877aaa0111c002e2ac8b343bcf47 | Ruby | AlexHg/Teoria-Computacional | /Practica3.Automatas.Finitos.Deterministas/autom.rb | UTF-8 | 4,093 | 3.25 | 3 | [] | no_license | class AFD
attr_accessor :hash
def initialize hash, fin, expresion
@hash = hash
@fin = fin
@is = false
@expresion = expresion
puts "Se ha creado un nuevo AFD"
puts "\nEspresión regular: "+@expresion+"\n"
end
def is_number? string
true if Float(string) rescue false
end
def verificar_01 word
puts ... | true |
e8d88a93dafd8d78fd3d4493c424c9225548cd5d | Ruby | Samy-Amar/gosu_smb | /lib/characters/mario.rb | UTF-8 | 1,137 | 2.828125 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'base_character'
require_relative '../assets/mario/repository'
module Characters
# Manages the mario character -
# Mario-specific movement and actions, as well as assets
class Mario < Characters::BaseCharacter
def initial_position
{
x: 0,
... | true |
025ce6049262ddb9a095f9e39c7cc90ee0600717 | Ruby | rcjara/project-euler | /85-Problem/ruby/solve.rb | UTF-8 | 724 | 3.625 | 4 | [] | no_license | def num_rectangles(h, w)
(1..w).inject(0) do |sum, width|
(1..h).inject(0) do |s, height|
s + (h - height + 1) * (w - width + 1)
end + sum
end
end
h = 1
w = 1
h += 1 while num_rectangles(h, w) < 2_000_000
max_h = h
max_w = max_h / 2
nearest = (2_000_000 - num_rectangles(h, w) ).abs
nearest_area = ... | true |
c406291082aee90b088881b72bc2f0864f6c4550 | Ruby | MikeWestHub/tic_tac_toe | /lib/game.rb | UTF-8 | 839 | 3.953125 | 4 | [] | no_license | require_relative 'player'
require_relative 'board'
require "pry"
class Game
attr_reader :board
def initialize
@board = Board.new
end
def create_player
puts "Player 1, you will be X. Please enter your name."
@player_1 = Player.new(gets.chomp, "x")
puts "Player 2, you will be O. Please enter you... | true |
bb881cfcbd326ecdc941b0b4afa13290f3369918 | Ruby | kotobuki562/Ruby | /drill_12.rb | UTF-8 | 366 | 3.859375 | 4 | [] | no_license | class Fruits
@@sum = 0
def self.get_sum
puts "合計の価格は#{@@sum}円です"
end
def initialize(name, price)
@name = name
@price = price
@@sum = @@sum + price
end
end
apple = Fruits.new("リンゴ", 120)
orange = Fruits.new("オレンジ", 200)
strawberry = Fruits.new("イチゴ", 60)
Fruits... | true |
8d0b2837fe45260bed2d8d6cc2966fb86de72d74 | Ruby | samesystem/social_security_number | /lib/social_security_number/country/ca.rb | UTF-8 | 1,306 | 3.125 | 3 | [
"MIT"
] | permissive | module SocialSecurityNumber
# SocialSecurityNumber::Ca validates Canadian Social Insurance Numbers (SINs)
# The Social Insurance Number (SIN) is a 9-digit identifier issued to
# individuals for various government programs. SINs that begin with a 9 are
# issued to temporary workers who are neither Canadian citiz... | true |
047dfe3dbd529e660ba7dd36020a2fdfe09bba47 | Ruby | nate-hunter/deli-counter-dumbo-web-career-010719 | /deli_counter.rb | UTF-8 | 1,416 | 4.03125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def line (deli_line)
if deli_line.count == 0
puts "The line is currently empty."
else
current_line = "The line is currently:"
deli_line.each.with_index(1) do |name, position|
current_line << " #{position}. #{name}"
#current_line.push(" #{position}. #{name}")
end
... | true |
510bfe8fdb77578596d4d19f678da365c85c6c6d | Ruby | alrawi90/ruby-objects-has-many-lab-re-coded-000 | /lib/artist.rb | UTF-8 | 381 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Artist
attr_accessor :name
@@song_count=0
def initialize(name)
@name=name
@songs=[]
end
def songs
return @songs
end
def add_song(song)
song.artist=self
@songs.push(song)
@@song_count +=1
end
def add_song_by_name(song_name)
song=Song.new(song_name)
song.artist=self
@songs.push(song)
@@song_cou... | true |
8384c52e7da683b33182acf2c7e0279b8f060a73 | Ruby | Jandrocks/POO_RUBY | /cuenta_bancaria.rb | UTF-8 | 814 | 3.6875 | 4 | [] | no_license | class CuentaBancaria
attr_accessor :nombre_de_usuario, :nuemero_de_cuenta, :tipo
def initialize(nombre_de_usuario, nuemero_de_cuenta, tipo = 0)
@nombre_de_usuario = nombre_de_usuario
@nuemero_de_cuenta = nuemero_de_cuenta
@tipo = tipo
raise RangeError, 'Cuenta debe tener... | true |
31270459299c1094b8cae28a625d4a36d98c7b2d | Ruby | sooo-s/AtCoder | /abc214/c/main.rb | UTF-8 | 403 | 3.109375 | 3 | [] | no_license | N = gets.to_i # 10
S = gets.chomp.split.map(&:to_i) # n = 10, m = 20
T = gets.chomp.split.map(&:to_i) # n = 10, m = 20
t_first = T.find_index(T.min)
s = [S[t_first..], S[...t_first]].flatten
t = [T[t_first..], T[...t_first]].flatten
dp = Array.new(N) { 0 }
dp[0] = t[0]
(1...N).each do |n|
dp[n] = [t[n], dp[n - 1]... | true |
7059e2955239f896b7d753c4bd2b5bdd48b8a982 | Ruby | wili3/banker | /app/services/transaction_agent.rb | UTF-8 | 1,145 | 2.9375 | 3 | [] | no_license | class TransactionAgent
def initialize(transaction, same_bank)
@transaction = transaction
@same_bank = same_bank
end
# send money is triggered at the end of the TransactionCreator in order to deliver the money
def send_money
if @transaction.status == "Succeed"
@money = @transaction.money
remove_money
... | true |
bc871d7a968dcd0438f684b707c6d97212f56caf | Ruby | lishulongVI/leetcode | /ruby/115.Distinct Subsequences(不同的子序列).rb | UTF-8 | 4,364 | 3.796875 | 4 | [
"MIT"
] | permissive | =begin
<p>Given a string <strong>S</strong> and a string <strong>T</strong>, count the number of distinct subsequences of <strong>S</strong> which equals <strong>T</strong>.</p>
<p>A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters withou... | true |
f8ebbba9efdc4564b08cf4a403a9f966043f2a12 | Ruby | bogdan/accept_values_for | /lib/accept_values_for/matcher.rb | UTF-8 | 2,124 | 2.640625 | 3 | [
"MIT"
] | permissive | require "active_model"
module AcceptValuesFor
class Matcher
def initialize(attribute, *values)
@attribute = attribute
@values = values
@failed_values = {}
end
def matches?(model)
base_matches?(model) do |value|
unless model.errors[@attribute].to_a.empty?
@failed... | true |
9cf08dad1561706930c14fcdd16821fcb93eba20 | Ruby | rocky/rb8-trepanning | /processor/command-ruby-debug/catchpoint.rb | UTF-8 | 1,517 | 2.8125 | 3 | [] | no_license | module Trepan
class CatchCommand < OldCommand # :nodoc:
self.allow_in_control = true
def regexp
/^\s* cat(?:ch)?
(?:\s+ (\S+))?
(?:\s+ (off))? \s* $/ix
end
def execute
excn = @match[1]
if not excn
# No args given.
info_catch
elsif not ... | true |
4a732c16a9a7fa455cf6f4d6399f68dae4f07b82 | Ruby | shlima/translate_enum | /lib/translate_enum/builder.rb | UTF-8 | 1,466 | 2.578125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module TranslateEnum
class Builder
attr_accessor :i18n_scope
attr_accessor :i18n_key
attr_accessor :enum_instance_method_name
attr_accessor :enum_klass_method_name
attr_accessor :method_name_singular
attr_accessor :method_name_plural
attr_reader :model, :a... | true |
1c63a5023eceaa5f72ee2f769fb5792f5356762f | Ruby | corbinsykes/Calculator | /calculator.rb | UTF-8 | 3,893 | 3.75 | 4 | [] | no_license | def get_two_numbers
puts "What's the first number?"
first = gets.chomp.to_f
puts "What's the second number?"
second = gets.chomp.to_f
return first, second
end
def add(x,y)
return x+y
end
def subtract(x,y)
return x-y
end
def multiply(x,y)
return x*y
end
def divide_decimal(x,y)
return x/y
end
d... | true |
43522f3884e6f14dc803db3255e978ba24cbd6e6 | Ruby | jackaquigley/testingtask | /specs/card_spec.rb | UTF-8 | 917 | 3.109375 | 3 | [] | no_license | require("minitest/autorun")
require('minitest/reporters')
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
require_relative("../card_game.rb")
require_relative("../card.rb")
class CardTest < Minitest::Test
def setup
@card1 = Card.new("Clubs", 8)
@card2 = Card.new("Spades", 1)
@card3 = Car... | true |
39046a045d422ff21d9aac15338b44522fc6fc93 | Ruby | nc-trevorb/rbon | /spec/rbon_value_spec.rb | UTF-8 | 4,438 | 2.640625 | 3 | [] | no_license | require 'spec_helper'
describe RbonValue do
{
RbonBool => false,
RbonNumber => 3,
RbonString => 'asdf',
RbonObject => {},
RbonArray => [],
}.each do |rbon_type, value|
context "for any type (#{rbon_type})" do
describe '#to_json_schema' do
let(:json_schema) { RbonValue.create(v... | true |
f793de86a3d590d3ec9350bd8bea14b79f701a74 | Ruby | crowdcompass/middleman-breadcrumbs | /spec/breadcrumbs_helper_spec.rb | UTF-8 | 3,031 | 2.640625 | 3 | [
"MIT"
] | permissive | require_relative './spec_helper'
require 'ostruct'
require 'middleman-breadcrumbs/breadcrumbs_helper'
describe BreadcrumbsHelper do
before do
@helper = Object.new
@helper_class = @helper.singleton_class
end
describe '.included' do
describe 'link_to is defined' do
it 'does not include Padrino::... | true |
b60acee7865574316f694ed83d87cb7d93326d7c | Ruby | Fem-Fem/my_anime_list | /lib/my_anime_list/anime.rb | UTF-8 | 765 | 3.03125 | 3 | [
"MIT"
] | permissive | class MyAnimeList::Anime
@@all = []
attr_accessor :name, :show_length, :time_aired, :members_watched, :url, :description, :genres
def initialize(name=nil, show_length=nil, time_aired=nil, members_watched=nil, url=nil)
@name = name
@show_length = show_length
@time_aired = time_aired
@members_wat... | true |
4bdced0090589d95acda907f310c152c3aad2eb0 | Ruby | Mehwisha/ttt-10-current-player-v-000 | /lib/current_player.rb | UTF-8 | 304 | 3.59375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def turn_count(board)
counter = 0
board.each do |space|
if space == "X" || space == "O"
counter += 1
end
end
return counter
end
def current_player(board)
if turn_count(board) == 0 || turn_count(board).even?
return "X"
elsif turn_count(board).odd?
return "O"
end
end
| true |
dd6ecbd3cb60678cbcf742460ff06c2447984840 | Ruby | b-ggs/indinero-circleci-slack-build-alerts | /helpers/slack_helper.rb | UTF-8 | 2,065 | 2.828125 | 3 | [] | no_license | require 'httparty'
module SlackHelper
SLACK_API_POST_MESSAGE_URL = 'https://slack.com/api/chat.postMessage'
SUCCESS_COLOR = '#41AA58'
FAIL_COLOR = '#D10C20'
RUNNING_COLOR = '#66D3E4'
SUCCESS_MESSAGE = 'Your build passed!'
NON_SUCCESS_MESSAGE = 'There was a problem with your build.'
def is_slack_user?(re... | true |
544cdcf9cd2b80921d3fa928753279812c161caa | Ruby | cocupu/mjg_twitter | /lib/runners/url_dataset_reducer_runner.rb | UTF-8 | 2,996 | 2.671875 | 3 | [] | no_license | require 'fileutils'
require 'date'
class UrlDatasetReducerRunner < BaseRunner
attr_accessor :message, :dataset_path, :dat_repository
def initialize(opts={})
@start_date = opts[:start_date].kind_of?(DateTime) ? opts[:start_date] : DateTime.strptime(opts[:start_date], "%Y%m%d")
@end_date = opts[:end_date]... | true |
8da54882aa1745ababfe07abb612f5d699e54d5a | Ruby | nosyjoe/codejam | /2013/round1c/a/a.rb | UTF-8 | 2,919 | 3.21875 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby -wKU
def write_output_line(i, data)
"Case ##{i}: #{data}"
end
def write_output_file(filename, data)
i = 1
File.open(filename, 'w') do |file|
data.each do |a_case|
file.puts(write_output_line(i, a_case))
i += 1
end
end
end
def read_input_file(filename)
i = 1
cases =... | true |
89664bfdcf3edc2d44e27240360ace8ec0178cb5 | Ruby | talgoldfus/Tic-Tac | /lib/opponent.rb | UTF-8 | 218 | 3.375 | 3 | [] | no_license | class Opponent
attr_accessor :mark ,:score
attr_reader :name
def initialize(mark)
@mark=mark
@score=0
@name="Computer"
end
def turn
puts "Computer is choosing his next move"
choice = rand(1..9)
end
end | true |
d94e3f5f03dc4ff1fc7c1e7a8a527f899b1eabaa | Ruby | nishimura121/oyou10 | /config/schedule.rb | UTF-8 | 963 | 2.65625 | 3 | [] | no_license | # Use this file to easily define all of your cron jobs.
#
# It's helpful, but not entirely necessary to understand cron before proceeding.
# http://en.wikipedia.org/wiki/Cron
env :PATH, ENV['PATH'] # 絶対パスから相対パス指定
set :output, 'log/cron.log' # ログの出力先ファイルを設定
set :environment, :development # 環境を設定
every 1.minutes do
... | true |
74d65ec7290cdd9f7316c0d62516508cb1c89644 | Ruby | intuit-archive/s3cmd-cookbook | /libraries/download.rb | UTF-8 | 331 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | class Download
def command(args)
bucket = args[:bucket]
object_name = args[:object_name]
file_name = args[:file_name]
force = args[:force] ? '--force' : ''
object_url = "s3://#{File.join bucket, object_name}"
cmd = "s3cmd #{force} "
cmd << "get #{object_url} #{file_name}"
... | true |
9a92cdac8e12bbedbb2f98eb6eb43d67088e7f4c | Ruby | hatuyo/kadai | /pico.rb | UTF-8 | 3,152 | 3.75 | 4 | [] | no_license | # coding: utf-8
require 'minitest/autorun'
# ピコ太郎を表すクラス
# @author Kento Matsumoto
# @attr [String] name 人の名前
# @attr [String] right 右手の物
# @attr [String] left 左手の物
# @attr [String] result1 合わされた物1
# @attr [String] result2 合わされた物2
class Pico
attr_accessor :name, :right, :left, :ummm
# コンストラクタ
# @param name [Stri... | true |
fd5e40770be027061279c668bbd239874489d6cc | Ruby | camerican/wdi-sep-2017 | /week5/lunch.rb | UTF-8 | 202 | 3.359375 | 3 | [] | no_license | # take an array of menu options
# then pick a random lunch item
options = ["Thai Sliders","Bon Chon","Jubiliee"]
def lunch( menu )
#menu[rand(menu.length)]
menu.sample
end
puts lunch( options )
| true |
b76faff0816231503b6154ce29e8ee0fc9a67936 | Ruby | xpmethod/torn-apart | /ruby/article-grabber.rb | UTF-8 | 890 | 2.796875 | 3 | [] | no_license | require "csv"
require "httparty"
# articles = CSV.read(File.join("data", "state-articles.csv"), headers: true)
articles = CSV.read(File.join("..", "data", "everything-articles.csv"), headers: true)
articles.to_a.shuffle.each_with_index do |row, i|
# filename = "#{row[0]}-#{row[2]}-#{i}.html"
filename = "#{row[0]}-... | true |
512cc9f4d04a669d918cd4e3b5c6d4a2b765f442 | Ruby | eliastre100/Advent-of-Code-2020 | /day 15/day_15.rb | UTF-8 | 509 | 3.625 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require_relative 'count_table'
if ARGV.size != 2
warn 'Usage: ./day_15.rb [input file] [target]'
exit 1
end
input = File.read(ARGV.first).chomp
target = ARGV[1].to_i
count_table = CountTable.new(input)
puts "Playing the game until the turn #{target}. It might take a while depending on your ... | true |
e654b233ec500e4484c93bf7811717481ce7d866 | Ruby | digitalh2o2/project-euler-multiples-3-5-q-000 | /lib/oo_multiples.rb | UTF-8 | 425 | 3.84375 | 4 | [] | no_license | # Enter your object-oriented solution here!
class Multiples
def initialize(limit)
@limit = limit
end
def limit
@limit
end
def collect_multiples
numbers = []
(1...limit).each do |num|
if num % 3 == 0 || num % 5 == 0
numbers << num
end
end
numbers
end
def sum_mu... | true |
06fc963f723eb2d71a5bb48c00e0b21c5a6ab34b | Ruby | onorton/gottree | /characterAdder.rb | UTF-8 | 3,549 | 3.734375 | 4 | [] | no_license | #!/usr/bin/env ruby
def createCharacter
puts "Creating character...\n\n"
total_string = ""
total_string += (IO.readlines('characters.txt').last.split(" ")[0].to_i+1).to_s + "\t"
puts "Please enter the character's name:\n"
total_string += gets.chomp + "\t"
puts "Please e... | true |
5cbee6ae55d0312a6695f0adf7fca6ccc9922929 | Ruby | tblanchard01/oyster_card | /lib/Oystercard.rb | UTF-8 | 922 | 3.671875 | 4 | [] | no_license | # boots up new Oyster
class Oystercard
MIN_BALANCE = 1
attr_reader :balance
attr_accessor :in_journey, :entry_station, :exit_station, :list_of_journeys
def initialize(monies = 0)
@balance = monies
@in_journey = false
@entry_station = nil
@exit_station = nil
@list_of_journeys = []
end... | true |
6124a0d68f1c7e19b7012c8f9f4d45c5f928da84 | Ruby | russellkoons/learning-ruby | /module_6/01strings.rb | UTF-8 | 169 | 4.03125 | 4 | [] | no_license | puts "I am a string"
puts "I can also include characters and \nnumbers: # $ ! 5 9"
name = "Russell"
puts name.length
puts name.class
p 5.to_s # Makes 5 into a string | true |
52e31c969a3d0634fdcb1dd5471b462fb18b8a4e | Ruby | qubis741/ruby-interview | /checkout.rb | UTF-8 | 1,725 | 3.140625 | 3 | [] | no_license | require './promotional_rule_factory'
require './promotional_rule'
class Checkout
attr_accessor :promotional_rules, :total, :items, :total_percentage_discount
def initialize(promotional_rules)
@promotional_rules = promotional_rules.map do |pr|
PromotionalRuleFactory.build(
id: pr[:id],
... | true |
b0c8ad6511a4130bc04342151cd5d98c9c5ec539 | Ruby | CepCap/intern | /work/bisrch/bisrch.rb | UTF-8 | 625 | 3.34375 | 3 | [] | no_license | def bisrch(arr, find_value)
arr.sort!
loop do
mid = arr.length/2
break if mid.zero?
if arr.length == 2
if arr[0] == find_value
break true
elsif arr[1] == find_value
break true
else
break false
end
end
mid_el = arr[mid]
if mid_el == find_value
... | true |
555bf0f7270492d553ef7813c6639b9c66fe0b57 | Ruby | nomlab/swimmy | /lib/swimmy/resource/event.rb | UTF-8 | 604 | 2.578125 | 3 | [
"MIT"
] | permissive | # coding: utf-8
require 'pp'
require 'date'
require 'fileutils'
require 'active_support/time'
module Swimmy
module Resource
class Event
attr_reader :start,:summary,:calendar_name
def initialize(start, summary, calendar_name)
@start = DateTime.parse(start)
@summary = summary... | true |
f05c37e8fba245635f834ebae5fc89b6eeb26955 | Ruby | ctrhansen/OO-Art-Gallery-houston-web-career-021819 | /tools/console.rb | UTF-8 | 398 | 2.65625 | 3 | [] | no_license | require_relative '../config/environment.rb'
painting1 = Painting.new("A Happy Landscape", 3000, "Bob Ross", "Houston Art Gallery")
painting2 = Painting.new("A Sad Landscape", 1000, "Bob Ross", "New York Art Gallery")
painting3 = Painting.new("A Moody Landscape", 3000, "Bob Ross", "San Francisco Art Gallery")
gallery... | true |
7033b2b2529d7a484715c6364421686b7066fd92 | Ruby | Jordan-1996/Arrays | /aumento_precios.rb | UTF-8 | 425 | 3.328125 | 3 | [] | no_license | prices = [200, 3000, 5000]
# multiplicador = rand(3)
# def augment(prices, multiplicador)
# resolve = []
# prices.count.times do |i|
# prices[i] *= multiplicador
# resolve.append(prices[i])
# end
# return resolve
# end
# print augment(prices, multiplicador)
prices = ARGV
def augm... | true |
4b7723c89f56db382d4e30b4237d4533971d9155 | Ruby | alexnvb/Ruby | /Old study/Lesson 14/class_plane.rb | UTF-8 | 825 | 3.125 | 3 | [] | no_license | class Airplane
attr_reader :model
attr_reader :alt
attr_reader :speed
def initialize(model)
@model=model
@alt=0
@speed=0
end
def fly
@speed=800
@alt=10000
end
def land
@speed=0
@alt=0
end
def moving?
return @speed>0
end
end
plane1=Airplane.new("SuperJet")
puts ... | true |
57ed198a4e486ef413dc8ad68b9c55a639f6fb31 | Ruby | jeffrafter/gemstalker | /bin/gemstalk | UTF-8 | 1,663 | 2.859375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env ruby
$LOAD_PATH.unshift(File.dirname(__FILE__), '..', 'lib')
require 'gem_stalker'
def usage
puts ""
puts "Usage:"
puts ""
puts " #{File.basename $0} <username> <repository> [version] [--install]"
puts ""
puts "Begins stalking a gem at the specified location. Example:"
puts ""
puts " ... | true |
ca9277cf241a85dcc0860d550d321c49d95d363f | Ruby | ktlacaelel/abstract_command | /lib/abstract_command.rb | UTF-8 | 2,064 | 3.375 | 3 | [
"MIT"
] | permissive | require 'open3'
require 'shellwords'
# Shell Command Abstraction.
#
# Hides away all the details to generate a command.
# And provides an easy interface to interact with shell commands as if
# they were objects.
#
# This is good for the following reasons:
#
# - Enforces standardization.
# - Enforces separation of comm... | true |
d894d9b38090607137b0052450f8dd0a72430e04 | Ruby | mkroman/mumble | /library/mumble/connection.rb | UTF-8 | 2,346 | 2.609375 | 3 | [] | no_license | # encoding: utf-8
module Mumble
class Connection < EM::Connection
HeaderSize = 6 # The header is 6 bytes.
HeaderFormat = 'nN' # The type is 2 bytes, and the length value is 4 bytes def initialize client = nil
# Create a new server connection.
#
# @param [Server] server The server reference.
... | true |
dfd5cf3d0df6ce397b96e70055c4ab5fe3be3d1a | Ruby | nickzaf95/project-euler-largest-prime-factor-london-web-021720 | /lib/oo_largest_prime_factor.rb | UTF-8 | 598 | 3.625 | 4 | [] | no_license | # Enter your object-oriented solution here!
class LargestPrimeFactor
attr_accessor :limit
def initialize(limit)
@limit = limit
end
def number
n = @limit
test = 1
while test % 2 == 0 do
test = n / 2
end
if test == 2
return 2
... | true |
633d9e46ca98219cc08cad58d30a411aba5d736c | Ruby | TPei/faas_orchestrator | /lib/post_function.rb | UTF-8 | 466 | 2.59375 | 3 | [
"MIT"
] | permissive | class PostFunction < Function
def execute(data)
header = {'Content-Type': 'text/json'}
# Create the HTTP objects
http = Net::HTTP.new(@uri.host, @uri.port)
request = Net::HTTP::Post.new(@uri.request_uri, header)
request.body = data.to_json
# Send the request
res = http.request(request)
... | true |
ea5ab26d473a062c802932256c7774c411d76381 | Ruby | schlos/OpenAidRegister | /app/models/project_sector.rb | UTF-8 | 2,730 | 2.59375 | 3 | [] | no_license | class ProjectSector
# find Project Sector by id
#----------------------------------------------------------------------
def self.find(id)
sql = 'select cartodb_id, project_id, sector_id, the_geom_str
FROM project_sectors WHERE cartodb_id = ?'
result = Oar::execute_query(sql, id)
result.r... | true |
cc1d97ecc9edcbb11103543bf3fb15ff59207d42 | Ruby | m-negishi/ruby_training | /TeachYourselfRuby/section8/8_check.5.rb | UTF-8 | 520 | 3.71875 | 4 | [] | no_license | # 何乗するかを保持する場合
def make_gs_gen(ft, cr)
ans = 0
count = 0
lambda do
ans = ft * (cr ** count)
count += 1
ans
end
end
# 今の解答を保持する場合
# def make_gs_gen(ft, cr)
# ans = 0
# lambda do
# if ans != 0
# ans *= cr
# else
# ans = ft
# end
# end
# end
gen1 = make_gs_gen(1, 2) # 初項... | true |
a0819edd3758f28b0b01a3c3ac0a37322003a306 | Ruby | ricamarena/Code-KIEI925 | /final/db/seeds.rb | UTF-8 | 2,062 | 2.5625 | 3 | [] | no_license | puts "Deleting..."
Project.delete_all
User.delete_all
Owner.delete_all
Investment.delete_all
puts "Creating Owners..."
altaventures = Owner.create(name: "Alta Ventures", summary:"alta ventures is a firm", rating: 4)
fivere = Owner.create(name: "5 RE", summary:"5re is a firm", rating: 5)
lp = Owner.create(name: "Leisur... | true |
6de9ac27caf61952ae36fa4fae604d4b80e25a34 | Ruby | Smorenor91/Battleship | /game.rb | UTF-8 | 2,367 | 3.671875 | 4 | [] | no_license | #!/usr/bin/ruby
require 'matrix'
class Matrix
def to_readable
i = 0
self.each do |number|
print number.to_s + " "
i+= 1
if i == self.column_size
print "\n"
i = 0
end
end
end
def []= (row, column, value)
@rows[row][column] = value
end
end
class Board
def... | true |
801b6d2209fa25352afbeb8fd38c3d835f94dacf | Ruby | UC10D/RubyDemo | /ruby_lang/error.rb | UTF-8 | 159 | 2.953125 | 3 | [] | no_license | # 异常捕获
puts '===================Error==================';
(-10 .. 10).each { |a|
begin
puts 100/ a
rescue Exception => e
p e.to_s
end
} | true |
acca2fcdd4d437daf1f4f6f6b8e295a55d62b310 | Ruby | rudyoyen/starSearch | /rubySolution/movies.rb | UTF-8 | 729 | 3.234375 | 3 | [] | no_license | require "./utils/MovieDatabase"
require "./utils/Output"
first_arg, second_arg = ARGV
first_name = first_arg || ''
last_name = second_arg || ''
full_name = last_name == '' ? first_name : first_name + ' ' + last_name
if full_name == ''
puts "Please provide a star's name to search"
exit(true)
end
#Define meta dat... | true |
33e027fca5ec611de7a9cfc2087509b9974603ee | Ruby | itsolutionscorp/AutoStyle-Clustering | /assignments/ruby/hamming/src/218.rb | UTF-8 | 205 | 3.109375 | 3 | [] | no_license | def compute(s1, s2)
i = 0
n = s1.length
n_differences = 0
while (i < n)
if (s1[i] != s2[i])
n_differences += 1
end
i += 1
end
return n_differences
end | true |
67673b3201224a2df867afb6b79e16916cd58fff | Ruby | h4hany/yeet-the-leet | /algorithms/Easy/1260.shift-2d-grid.rb | UTF-8 | 1,249 | 3.609375 | 4 | [] | no_license | #
# @lc app=leetcode id=1260 lang=ruby
#
# [1260] Shift 2D Grid
#
# https://leetcode.com/problems/shift-2d-grid/description/
#
# algorithms
# Easy (61.37%)
# Total Accepted: 18.8K
# Total Submissions: 30.6K
# Testcase Example: '[[1,2,3],[4,5,6],[7,8,9]]\n1'
#
# Given a 2D grid of size m x n and an integer k. You ne... | true |
7a61294abf6b05bd32da34fbef0418288cd76a8c | Ruby | rralcala/pyeduca-infra | /mothership/puppet/puppetcontent/configs/check_nodes/check_nodes.rb | UTF-8 | 2,187 | 3.1875 | 3 | [] | no_license | #!/usr/bin/ruby
#
# Get the list of nodes from a conf file and loop
# forever checking status (via tcp ping) and update
# their status via ActiveResource
#
require File.join(File.dirname(__FILE__), 'node.rb')
require 'ping'
require "socket"
class NetworkNode
def initialize(node_id, ip_address)
@node_id = n... | true |
183afee58e54bff7f1b88d4648225c41147cae21 | Ruby | cdalbergue/drivy-backend-challenge | /backend/level4/commission.rb | UTF-8 | 856 | 3.1875 | 3 | [] | no_license | class Commission
COMMISSION_PERCENTAGE = 0.3
INSURANCE_COMMISSION = 0.5
ROADSIDE_ASSISTANCE_COMMISSION = 100
attr_reader :price, :duration, :total_commission
def initialize(rental)
@price = rental.price
@duration = rental.duration
@total_commission = total_commission
end
def value
{
... | true |
e0f78302c0e0fdc0941994e5000bb7f8af5a014d | Ruby | isabella232/puppet-adopt | /lib/puppet_x/adopter/util.rb | UTF-8 | 345 | 2.53125 | 3 | [] | no_license | module PuppetX::Adopter::Util
def self.run_with_spinner(timeout = 30, &block)
spin_thread = Thread.new do
loop do
['|','/','-','\\'].each { |c| print c; sleep 0.1; print "\b" }
end
end
Timeout::timeout(timeout) do
return block.call
end
ensure
spin_thread.terminate
... | true |
f404427c6d08c53b364de294e6f0d1d34a60264e | Ruby | rickpeyton/learntoprogram_chris_pine | /chapter11archive.rb | UTF-8 | 4,396 | 3.515625 | 4 | [] | no_license | require 'yaml'
test_array = [
['Rick','Brady'],
['Rebecca','Kaarin'],
['Abe','Richard'],
]
test_string = test_array.to_yaml
filename = 'rick_test.txt'
File.open filename, 'w' do |f|
f.write test_string
end
read_string = File.read(filename)
read_array = YAML::load read_string
puts(read_string == test_string)
pu... | true |
9f082ac7511fbf3e0a97c2a0aa01a2a3f128783c | Ruby | lbvf50mobile/til | /20221230_Friday/20221230.rb | UTF-8 | 856 | 3.421875 | 3 | [] | no_license | # Leetcode: 797. All Paths From Source to Target.
# https://leetcode.com/problems/all-paths-from-source-to-target/
# = = = = = = = = = = = = = =
# Accepted.
# Thanks God, Jesus Christ!
# = = = = = = = = = = = = = =
# Runtime: 156 ms, faster than 84.62% of Ruby online submissions for All Paths From Source to Target.
# M... | true |
3e6ca67fea90c56899821b5fba9c14a403f4e8e0 | Ruby | adilgondal1/sinatra-mvc-lab-yale-web-yss-052520 | /models/piglatinizer.rb | UTF-8 | 565 | 3.75 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class PigLatinizer
def initialize()
end
def piglatinize(str)
str.split(" ").map {|word| piglatinize_word(word)}.join(" ")
end
def piglatinize_word(str)
vowels = ['a' , 'e' , 'i' , 'o' ,'u']
ary = str.split(//)
index = ary.find_index {|c| vowels.includ... | true |
4c2d1e8208acca562a26723d46b8dd0b8450047d | Ruby | MattKwong/myssp-cedar | /spec/models/program_spec.rb | UTF-8 | 4,870 | 2.65625 | 3 | [] | no_license | require 'spec_helper'
# == Schema Information
#
# Table name: programs
#
# id :integer not null, primary key
# active :boolean
# created_at :timestamp
# end_date :date
# name :varchar(255)
# program_type_id :integer
# short_name :varchar(255)
# site_id... | true |
d3551b12cc69d2e2085b87985441d943ae6cc56f | Ruby | michaelhayman/dogood-api | /test/unit/models/user_test.rb | UTF-8 | 1,784 | 2.578125 | 3 | [] | no_license | class UserTest < DoGood::TestCase
def setup
super
@user = FactoryGirl.create(:user)
end
test "has a valid name" do
assert @user.valid?, "Should be valid"
end
test "should be valid with all default values" do
assert FactoryGirl.build(:user).valid?
end
test "should have an email address" ... | true |
c6fd893aa29583730991835824f19c3fba3d0e41 | Ruby | achalaggarwal/myimdb | /lib/myimdb/scraper/base.rb | UTF-8 | 2,006 | 2.796875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class UnformattedHtml < Exception; end
class DocumentNotFound < Exception; end
class ScraperNotFound < Exception; end
module Myimdb
module HandleExceptions
EXCEPTIONS_ENABLED = true
def self.included(base)
base.send(:include, InstanceMethods)
base.send(:extend, ClassMethods)
end
module... | true |
b0ade60d330c4ac575f874b17557ac9b76659b48 | Ruby | panesofglass/RubyOnMonads | /lib/identity.rb | UTF-8 | 179 | 3.03125 | 3 | [] | no_license | class Identity
attr_reader :value
def initialize( value )
@value = value
end
def bind
yield @value
end
def map
Identity.new( yield @value )
end
end | true |
55c5fc3e81fcf1e2b6899616f0cb42b587705e22 | Ruby | sg552/bubu | /app/models/category.rb | UTF-8 | 1,055 | 2.609375 | 3 | [] | no_license | class Category < ActiveRecord::Base
PRINCIPLE_BY_USAGE = "by_usage"
PRINCIPLE_BY_SHAPE= "by_shape"
PRINCIPLE_BY_AGE = "by_age"
AGE_SCOPES_FOR_SEARCH = ["0-3", "4-6", "7-9", "10-14"]
# define scope
# :by_usage
# :by_shape
# :by_age
[PRINCIPLE_BY_AGE, PRINCIPLE_BY_USAGE, PRINCIPLE_BY_SHAPE].each do |by... | true |
b2df29218e85de0a601efc6e4d486a5119ce3f58 | Ruby | mrdougal/textmate2-rubocop | /Support/vendor/gems/rubocop-0.18.1/spec/rubocop/cop/style/favor_sprintf_spec.rb | UTF-8 | 1,309 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # encoding: utf-8
require 'spec_helper'
describe Rubocop::Cop::Style::FavorSprintf do
subject(:cop) { described_class.new }
it 'registers an offence for a string followed by something' do
inspect_source(cop,
['puts "%d" % 10'])
expect(cop.offences.size).to eq(1)
expect(cop.messages... | true |
b0168ae84797cde3f0ba8b94057cd9be6c1e5aa3 | Ruby | EDalSanto/OperatingSystems | /processes/unix_processrb/pipes_spawning.rb | UTF-8 | 256 | 3.09375 | 3 | [] | no_license | # UNIX pipes in pure ruby
puts IO.popen("ls").read
# an IO object is passed into black
# in this case we open the stream for writing,
# so the stream is set to the STDIN of the spawned process
IO.popen("less", "w") { |stream|
stream.puts "some\ndata"
}
| true |
2fd687cc21c3044fd432106df47b71e928637e73 | Ruby | bdarfler/CodeKata | /ruby/05/KataFiveTest.rb | UTF-8 | 812 | 3.140625 | 3 | [] | no_license | require 'test/unit'
require 'KataFive'
class KataFiveTest < Test::Unit::TestCase
@@spell_checker = BloomFilter.new('/usr/share/dict/words')
def test_contains
word = 'hello'
bloom_filter = BloomFilter.new()
bloom_filter.insert(word)
assert(bloom_filter.contains(word), "filter should contain #{word}... | true |
177f91cf899f65042725999bdd5553235baa1081 | Ruby | swethagnath/ruby-programs | /arrayornot.rb | UTF-8 | 326 | 4.5 | 4 | [] | no_license | #Write a Ruby method to check whether an `input` is an array or not.
# e.g. - check_is_array(10)
# => false
# check_is_array([10,20,30])
# => true
def check_is_array(number)
if number.class == Array
return true
else
return false
end
end
puts check_is_array(10)
puts check_is_array([10,2... | true |
a7ed8f161c53042f52d220fdba5d954c60a52396 | Ruby | alu0100600810/LPP_T_03 | /lib/examen/exam.rb | UTF-8 | 569 | 3.3125 | 3 | [
"MIT"
] | permissive | # coding: utf-8
require "lista"
# Clase gestora de examenes con preguntas
class Exam
attr_accessor :list
# Crea una instancia de la clase Exam , a partir de una pregunta.
def initialize(p)
@list = Lista.new(p)
end
# Definición del Metotodo to_s, para la clase Exam.
def to_s
"#{@list}"
end
# Sobr... | true |
ec620e40e248b1abe2a224de5ff0bc6f39b166fc | Ruby | Duncan-Britt/Launch-School-Prep-Exercises | /Loops_and_Iterators/3.rb | UTF-8 | 91 | 2.984375 | 3 | [] | no_license | def count_down(num=10)
return if num == 0
puts num
count_down(num-1)
end
count_down
| true |
101ec27b77c1112d1756c51e9bc5cb1db304c8b7 | Ruby | turingschool-examples/vehicle_boolean | /lib/vehicle_analysis.rb | UTF-8 | 794 | 3.390625 | 3 | [] | no_license | # vehicle_analysis.rb
class VehicleAnalysis
def analyze(vehicle)
if vehicle.car?
if vehicle.four_wheel_drive? || !vehicle.four_wheel_drive?
puts "Vehicle has four wheels "
if vehicle.four_wheel_drive?
puts "with four wheel drive"
else
puts "with two wheel drive"... | true |
6d08298cbf1ffbf03ead789b53302a166296125e | Ruby | imurchie/chess | /lib/chess.rb | UTF-8 | 1,572 | 3.765625 | 4 | [
"Apache-2.0"
] | permissive | require_relative './board'
require_relative './human_player'
module Chess
class Game
GRID_MAP = { "h" => 7, "g" => 6, "f" => 5, "e" => 4,
"d" => 3, "c" => 2, "b" => 1, "a" => 0,
"1" => 7, "2" => 6, "3" => 5, "4" => 4,
"5" => 3, "6" => 2, "7" => 1, "8" => 0 }... | true |
c8d4e255c67eca46cf5c28c161d217feb9e4fd2f | Ruby | andeeisaacs/prework_backend | /db/notseeds2.rb | UTF-8 | 14,112 | 3.296875 | 3 | [] | no_license | # Parent classes
topics = [{
# Topic id 1
title: 'Html'
},
{
# Topic id 2
title: 'JavaScript'
},
{
# Topic id 3
title: 'CSS'
}]
# Creates Topic for seed file
topics.each do |v|
Topic.create v
end
# START OF HTML
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Code Modules but in this case L... | true |
6dd6ce7161f3b674ea34b94350be38b65e2c6e60 | Ruby | lenertzdiane/api-muncher | /lib/muncher_api_wrapper.rb | UTF-8 | 1,469 | 3.03125 | 3 | [] | no_license | require "httparty"
# require 'pry'
class MuncherApiWrapper
BASE_URL = "https://api.edamam.com/"
KEY = ENV["EDAMAM_KEY"]
ID = ENV["EDAMAM_ID"]
class ApiError < StandardError
end
def self.search(search_term, from = 0)
url = BASE_URL + "search?q=" + search_term + "&app_id=#{ID}" + "&app_key=#{KEY}" + "&... | true |
52a7134c10cdbc5571ab10c4d5a8c1d22a1cced0 | Ruby | shysteph/vagrant-port | /lib/vagrant-port/command.rb | UTF-8 | 1,072 | 2.515625 | 3 | [] | no_license | module VagrantPort
class Command < Vagrant.plugin("2", :command)
Settings = Struct.new(:machines)
def execute
require "optparse"
settings = Settings.new
settings.machines = []
options = OptionParser.new do |o|
o.banner = "Query which host port is mapped to the given guest port.... | true |
300375e1c114ea0efe693f187ac6872747e98381 | Ruby | fapapa/ar-exercises | /lib/store.rb | UTF-8 | 722 | 2.578125 | 3 | [] | no_license | # frozen_string_literal: true
class Store < ActiveRecord::Base
validates :name, length: { minimum: 3 }
validates :annual_revenue,
numericality: {
greater_than: 0,
only_integer: true
}
validate :mens_apparel_or_womens_apparel_must_be_true
has_many :employees
... | true |
49e3f168637996452eaae9497652963f07a0a7a1 | Ruby | Gabbendorf/martian_robots | /spec/movements_spec.rb | UTF-8 | 1,630 | 3.296875 | 3 | [] | no_license | require_relative '../lib/movements'
RSpec.describe Movements do
let (:movements) {Movements.new}
describe "Robot turns clockwise" do
it "returns E if robot's initial orientation is N" do
expect(movements.change_orientation_clockwise("N")).to eq("E")
end
it "returns W if robot's initial orienta... | true |
5c7cd56bcc75fe12ff7418237474876954edcba7 | Ruby | tKeitttt/furima-34165 | /spec/models/item_spec.rb | UTF-8 | 4,579 | 2.609375 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Item, type: :model do
before do
@item = FactoryBot.build(:item)
end
describe '商品情報の保存' do
context '商品が登録できる場合' do
it '商品名、商品説明、商品画像、カテゴリ、状態、配送料、発送元、発送までの日数、価格の入力があれば投稿できる' do
@item
expect(@item).to be_valid
end
end
context '商品が登録で... | true |
4421f45dce8d0d6f0a0e0c55c58b67040577e173 | Ruby | NLanese/ttt-with-ai-project-online-web-sp-000 | /lib/players/computer.rb | UTF-8 | 1,880 | 3.40625 | 3 | [] | no_license | require 'pry'
module Players
class Computer < Player
WIN_COMBINATIONS = [
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[0, 3, 6],
[1, 4, 7],
[2, 5, 8],
[0, 4, 8],
[6, 4, 2]
]
def move(inputBoard)
if self != "X"
opp = "O"
else
opp = "X"
... | true |
cb9f8b3f1cbccf61d2e4058d16519a572d1f2970 | Ruby | colbySherwood/Boolean-Gurus | /Project1/userTurn.rb | UTF-8 | 2,417 | 3.5625 | 4 | [] | no_license | require "./noSetsOption.rb"
require "./setsOnTable.rb"
# divided into small parts in case we want to change behavior of some of them
# designed so we call turn in a loop, puts current table, then updates score and table
def validIn? (inStr)
if inStr.to_i == 0
puts "Invalid input!"
return false
end
return... | true |
bb11240e11dc1eaa1731f7097f28d384f7cd4df3 | Ruby | sugamasao/kirico | /lib/kirico/validators/space_divider_validator.rb | UTF-8 | 1,565 | 2.609375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'active_model'
require 'active_model/validator'
require 'active_model/validations/format'
# 文字種別を検証する
#
# 設定例:
# validate :name, space_divider: { space: :full_width }
# validate :name_yomi, space_divider: { space: :half_width }
# validate :name, space_divider: { space: :b... | true |
1ac49f9275f28b790b50499cc89b7f5a09543f26 | Ruby | joemcbride/frostbite | /scripts/disarm.rb | UTF-8 | 5,003 | 3.09375 | 3 | [
"MIT"
] | permissive | # desc: Disarm boxes you have in open containers or holding in your right hand,
# harvest only on quick and blind disarms.
# requirements: -
# run: anywhere
@harvest = true
if $args.join(" ").include? "noh"
@harvest = false;
end
def ident(box)
put "disarm my #{box} ident"
match = { :wait => [/\.\.wait/]... | true |
8d23d0ee7a8b22c5839b128ada7eeb0052f4a62f | Ruby | alarryant/jungle-rails | /spec/models/user_spec.rb | UTF-8 | 2,673 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
subject {
User.new(first_name: "Angela", last_name: "Larryant", email: "angela@example.com", password: 'pass1234', password_confirmation: 'pass1234')
}
describe 'Validations' do
it 'is valid with valid attributes' do
expect(subject).to be... | true |
456d0b9892fd459a4a91616d36121bd19552a43e | Ruby | cprasarn/furniture-store | /plugins/store/Bookcase.rb | UTF-8 | 4,516 | 3.25 | 3 | [] | no_license | class Bookcase
def initialize(spaces, width, depth)
@spaces = spaces - 1
@width = width
@depth = depth
@thickness = 1
case spaces
when 2
@height = 29.25
when 3
@height = 41
when 4
@height = 52.75
... | true |
21c14d4c747650e06baed4601c440c4d3d376233 | Ruby | cicloid/pingpong-master | /app/models/game.rb | UTF-8 | 2,294 | 2.890625 | 3 | [] | no_license | class Game < ApplicationRecord
belongs_to :player_one, class_name: 'User', foreign_key: 'player_one_id'
belongs_to :player_two, class_name: 'User', foreign_key: 'player_two_id'
validates :player_one_score,
numericality: {
only_integer: true,
greater_than_or_equal_to: 0,
less_than_or_equal_to: 21
... | true |
819e68151b884db7aa878678ae49e8600818ab2d | Ruby | karottenreibe/dome | /test/css/parser_tests.rb | UTF-8 | 12,724 | 2.546875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'test/unit'
require 'dome/css'
class CSSParserTests < Test::Unit::TestCase
include Dome
include Selectors
def testElement
p = CSSParser.new CSSLexer.new("batman")
f = p.next
assert_kind_of Token, f
assert_equal :element, f.type
assert_equ... | true |
810977b314e1891fe282e61304b3d3728f4c08d5 | Ruby | gscho/inspec-osquery | /libraries/osquery.rb | UTF-8 | 1,130 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | require 'inspec/utils/object_traversal'
require 'json'
class OSQuery < Inspec.resource(1)
name 'osquery'
desc '
run osquery via InSpec.
'
example "
describe osquery('SELECT * FROM users;') do
its('length') { should_not eq 0 }
end
"
attr_reader :params
include ObjectTraverser
def i... | true |
7dfdfba1cc45d9ac86d10bad0a3c2db009b2328a | Ruby | lfborjas/estructuras_de_datos | /stack_queue.rb | UTF-8 | 2,348 | 3.984375 | 4 | [] | no_license | #Estamos "editando" la clase Array para que tenga algunos métodos que una list
#debería tener. En ruby podemos agregar o sobreescribir métodos de
#una clase en tiempo de ejecución
class Array
alias :get_at :[]
def get_first
self.index self.first or 0
end
def end
self.index(self.last) +... | true |
8f516fc5867846554f5bc7a193bba43d8b1a6835 | Ruby | idit/instituto-gabi | /app/models/data_file.rb | UTF-8 | 2,026 | 2.75 | 3 | [] | no_license | # == Schema Information
#
# Table name: data_files
#
# id :integer not null, primary key
# name :string(255)
# path :string(255)
# file_type :integer
# created_at :datetime not null
# updated_at :datetime not null
# mime_type :string(255)
# description :string(... | true |
cd0f289e8b1ade7a5a7a97a98102e2b4669f5e1f | Ruby | syborg/mme_tools | /lib/mme_tools/args_proc.rb | UTF-8 | 710 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # NamedArgs
# Marcel Massana 13-Sep-2011
#
# Extends Hash with methods based on ideas from
# http://saaientist.blogspot.com/2007/11/named-arguments-in-ruby.html
# Also thanks to ActiveSupport from Rails
module MMETools
extend self
module ArgsProc
# Tests if +options+ includes only valid keys. Raises an erro... | true |
8b02fd8657b4e3b67bbda6f4ec76394baf1930ad | Ruby | rosette-proj/rosette-core | /lib/rosette/core/extractor/repo_config.rb | UTF-8 | 13,935 | 2.859375 | 3 | [] | no_license | # encoding: UTF-8
module Rosette
module Core
# Configuration for a single repository. Instances of {RepoConfig} can
# be configured to:
#
# * Extract phrases (via {#add_extractor}). Phrase extraction means
# certain files (that you specify) will be monitored for changes and
# processed. ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.