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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
26c19e96427e2e79e35c5a50d9868cab95ae1e99 | Ruby | nlicalzi/ruby_exercises | /small_problems/easy_2/when_will_i_retire.rb | UTF-8 | 2,113 | 4.3125 | 4 | [] | no_license | # Source: https://launchschool.com/exercises/d28a76d4
# Q: Build a program that displays when the user will retire and how many years
# she has to work till retirement.
CURRENT_YEAR = Time.now.year
def prompt(message)
puts "=> #{message}"
end
loop do
current_age = ''
target_age = ''
loop do
prompt('... | true |
732902293fdc308325722cc1f00a5b2c86f79a31 | Ruby | Team-Aqua/Multi-ConnectAll | /lib/multi-connectall/lib/client/models/player.rb | UTF-8 | 811 | 2.859375 | 3 | [] | no_license | module Models
class Player
##
# Model for player
include AbstractInterface
attr_accessor :player_num, :player_color, :player_type, :score, :set_move, :make_move, :name, :ai
def initialize(player_num, player_color, name)
@player_num = player_num
@player_color = player_color
@n... | true |
5fe8933eb524fc693fb2bfa1158ad23c672889eb | Ruby | PhalanXware/pomo | /lib/pomo/github_task.rb | UTF-8 | 2,054 | 2.78125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # This is to make sure Faraday doesn't warn the user about the `system_timer` gem missing in Ruby 1.8
old_warn, $-w = $-w, nil
begin
require 'faraday'
ensure
$-w = old_warn
end
require 'octokit'
module Pomo
class GithubTask < Task
##
# Username.
attr_accessor :username
##
# Project name.
... | true |
b0994096cad0c7b9e7ac392df7e8b5c359489ea2 | Ruby | MiltonStanley/AdventOfCode2020 | /Day1/day1.rb | UTF-8 | 2,425 | 3.671875 | 4 | [] | no_license | require 'minitest/autorun'
class DataLoader
def self.load(file)
data = []
File.open(file).each do |number|
data << number.to_i
end
data
end
end
class Calculator
def initialize(data, goal_sum)
@data = data
@goal_sum = goal_sum
end
def calculate
sum = find... | true |
4d99c8a1604289dda40b12cd56928800e42f0773 | Ruby | tibbsa/launchschool | /RB101-109-Exercises/medium_2/tri-angles.rb | UTF-8 | 1,361 | 4.375 | 4 | [] | no_license | # RB101-109 Small Problems
# Medium Problems 2, Question 6 - Tri-Angles
# https://launchschool.com/exercises/1d04b607
#
# A triangle is classified as follows:
#
# - right: One angle of the triangle is a right angle (90 degrees)
# - acute: All 3 angles of the triangle are less than 90 degrees
# - obtuse: One angle is gr... | true |
23fb8f3057183c821c1bab3c878705ff0f87dccd | Ruby | christianstanfield/ruby-blackjack | /source/view.rb | UTF-8 | 2,142 | 3.453125 | 3 | [
"MIT"
] | permissive | class View
def welcome_screen cards
reset_with_header
puts 'Welcome to Ruby Blackjack'
draw_cards_on_screen cards
puts "What's your name, playa?"
end
def deal_round? player
puts ''
puts "You have $#{player.cash} #{player.name}."
puts ""
puts 'Deal the next round?'
end
def de... | true |
e062121efbac68f41b21025033ab14b773c23b4a | Ruby | espezua/phase-0 | /week-4/variables-methods.rb | UTF-8 | 2,133 | 4.5 | 4 | [
"MIT"
] | permissive | #Full Name Greeting Challenge
puts "Hello, what is your first name?"
first_name = gets.chomp
puts "Thanks! What's your middle name?"
middle_name = gets.chomp
puts "Great. What's your last name?"
last_name = gets.chomp
puts "Nice to meet you #{first_name} #{middle_name} #{last_name}!"
#Bigger, Better Favorite Number... | true |
c532e44914bd38e75244d125c1963309967381c4 | Ruby | othiym23/ingestion-tools | /lib/disc.rb | UTF-8 | 266 | 2.96875 | 3 | [] | no_license | class Disc
attr_accessor :album, :number, :tracks, :number_of_tracks
def initialize
@tracks = []
end
def number_of_tracks_loaded
tracks.nitems
end
def tracks_sorted
return tracks.compact.sort {|l,r| l.sequence <=> r.sequence}
end
end | true |
deeef042746ca5af68234a9e21337d8c9c47f7b4 | Ruby | bookmate/epubinfo | /lib/epubinfo/models/person.rb | UTF-8 | 981 | 2.953125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module EPUBInfo
module Models
class Person
# Name ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.6 EPUB2 reference})
# @return [String]
attr_accessor :name
# File as ({http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.6 EPUB2 reference})
# @return [String]
... | true |
b3e5f25473654d06d15a5982f1c912446693a3f9 | Ruby | itacademy-ruby/Verbovsky-muzbox | /muzbox.rb | UTF-8 | 3,185 | 3.828125 | 4 | [] | no_license | # encoding: UTF-8
# без наследования
class Musicbox
def initialize song_cost
@songs = ["Californication", "Dreams", "Not affraid"]
@song_cost = 10
@song_name = ''
@current_song = ''
@turned_on = false
@song_founded = false
@songammount = ''
end
def turn_on
unless @turned_on
@turned_on = true
puts "B... | true |
867f3cc40c28282e86b5b14fded35c78fbb9ceb7 | Ruby | kenton/katas | /ruby/euler/004.rb | UTF-8 | 626 | 3.984375 | 4 | [] | no_license | def palindrome(number_of_digits)
a = []
min = []
number_of_digits.times { a << 9 }
max_number = a.join.to_i
first = max_number
second = max_number
floor_value = (number_of_digits - 1).times { min << 0}
min_number = min.join.to_i
max = 0
first.downto(min_number) do |f|
second.downto(min_num... | true |
1caffe6eb4661f7d06bd80c7331a8e1f68c5a636 | Ruby | philm1873/Homework_Week03_Weekend | /models/customer.rb | UTF-8 | 1,991 | 2.953125 | 3 | [] | no_license | require('pg')
require_relative('../db/sql_runner.rb')
require_relative('ticket.rb')
class Customer
attr_reader :id, :name, :funds
def initialize(input)
@id = input['id'].to_i if input['id']
@name = input['name']
@funds = input['funds']
end
def save
sql = "INSERT INTO customers(name, funds)
... | true |
0100ba457199d10a0474a79a2acdbd9700e40f10 | Ruby | hildebrandosegundo/exercicio2 | /questao11.rb | UTF-8 | 166 | 3.71875 | 4 | [] | no_license | exit = false
while exit==false do
num = gets.chomp.to_i
if (num>=0 &&num<=10)
puts "Valor válido!"
exit=true
else
puts "Valor invalido!"
end
end | true |
452e07a4841d810b3269e94d1502549c01bb4029 | Ruby | TannerDale/exercism | /ruby/ocr-numbers/ocr_numbers.rb | UTF-8 | 1,268 | 3.765625 | 4 | [] | no_license | =begin
Write your code for the 'Ocr Numbers' exercise in this file. Make the tests in
`ocr_numbers_test.rb` pass.
To get started with TDD, see the `README.md` file in your
`ruby/ocr-numbers` directory.
=end
module OcrNumbers
extend self
NUMBERS_USING_INDEX = {
0 => {
" " => [1, 4],
" _ " => [0, ... | true |
75dda7c4f780046d2202c9a78b24de00971d9578 | Ruby | lambardi/serenitizer | /app/models/snippet.rb | UTF-8 | 3,213 | 3.015625 | 3 | [] | no_license | class Snippet
require 'active_model'
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
def initialize(attributes = {})
attributes.each do |name, value|
send("#{name}=", value)
end
end
def persisted?
false
end
@text
def text
@text
... | true |
95650fc5df658f3686608e67c17350863a48fa23 | Ruby | maikeru/vending_machine | /test/vending_machine_test.rb | UTF-8 | 1,350 | 3.21875 | 3 | [] | no_license | require 'minitest/autorun'
require_relative '../lib/vending_machine'
DENOMINATIONS = [10, 50, 100, 500, 1000]
describe VendingMachine do
describe "when individual coins/notes inserted" do
DENOMINATIONS.each do |denomination|
machine = VendingMachine.new
describe "when #{denomination} is inserted" do
... | true |
d00367b10d2dc3b9ed6c01eeef521cf591463736 | Ruby | hturnbull93/oystercard | /lib/journey_list.rb | UTF-8 | 646 | 3.28125 | 3 | [] | no_license | require_relative 'journey'
class JourneyList
attr_reader :journey_history, :current_journey
def initialize(journey_class = Journey)
@journey_history = []
@current_journey = journey_class.new
@journey_class = journey_class
@in_journey = false
end
def start_journey(station)
@current_journey... | true |
3dfe0e4958252dd9ad11d30c97a391cee75dd4a2 | Ruby | Estudanteseg/regex | /executandoRegex/UsandoRuby.rb | UTF-8 | 1,163 | 4.125 | 4 | [] | no_license | texto = '0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f'
puts '***************** Metodos da RegExp *****************'
regexNove = Regexp::new('9')
puts 'Exemplo1:'
puts regexNove.match(texto)
=begin
Exemplo1:
9
=end
puts 'Exemplo2:'
puts regexNove =~'831594'
=begin
Exemplo2:
4
Retornou o índice da busca
=end
puts 'Exemplo... | true |
07f47054b2ce42573a3afbc6bde11ca6f1dcd3ff | Ruby | ddiaz810/David_Diaz_LaunchSchool | /basics4dd.rb | UTF-8 | 178 | 3.53125 | 4 | [] | no_license | #Use the dates from the previous example and store them in an array.
#make your program output the same thing as exercise 3.
a = [1995, 2002, 1998]
puts a[2], a[0], a[1] | true |
49a49077ce8ec6d7169b12c2611a90311713c4c8 | Ruby | DaniyarKulmanov/ruby_full | /Lesson_10/wagon.rb | UTF-8 | 595 | 2.625 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'instance_counter'
require_relative 'manufacturer'
require_relative 'validation'
class Wagon
include InstanceCounter
include Manufacturer
include Validation
MADE_IN = /^(standard|cargo|passenger)/i.freeze
attr_reader :open_locks, :model
validate :type, :fo... | true |
d4b10271c9b506d89e42b40b4ebc8f49501e4dbc | Ruby | Alux77/Ruby-2 | /1_pseudocodigo.rb | UTF-8 | 1,111 | 4 | 4 | [] | no_license | students = [[["Eliezer", 7], ["Mariam", 7], ["Deborah", 10], ["Harley", 7]],
[["D'angelo", 10], ["Brittany", 8], ["Hubert", 7], ["Erling", 9]],
[["Bradford", 7], ["Theodora", 10], ["Casandra", 9], ["Lindsay", 8]],
[["Hilma", 10], ["Lina", 10], ["Isabell", 8], ["Urban", 9]]]
def best_students(students)
best_stud... | true |
86eb3c08961239fb1f65607635913409072beed6 | Ruby | jmb521/grocery_list-cli-gem | /lib/grocery_list/cli.rb | UTF-8 | 2,327 | 3.28125 | 3 | [
"MIT"
] | permissive | require 'pry'
class GroceryList::CLI
def call
store_list
menu
end
# input = nil
# while input != "exit"
# input = gets.strip
#
# puts "Gain with FreshLock Island Fresh Dryer Sheets 120 ct - $2.50"
# puts "$2.00/1 – Gain Liquid Laundry Detergent 40 oz, Fabric Enhancer 52 load or Dryer She... | true |
f880398877604a0d0e6cb6a3edc499be2463f78b | Ruby | phemmer/ruby-corosync | /spec/corosync/cpg/member.rb | UTF-8 | 922 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Corosync::CPG::Member do
before(:all) do
@member1 = Corosync::CPG::Member.new(1001,20001)
@member2 = Corosync::CPG::Member.new(1001,20002)
end
it 'checks equality' do
member = Corosync::CPG::Member.new(1001,20001)
expect(member).to eq(@member1)
expect(member).not_to eq(@me... | true |
52e4ab0f3a1381271c212cb2783cfe6a6615080e | Ruby | smthom05/apollo_14 | /spec/models/astronaut_spec.rb | UTF-8 | 722 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
describe Astronaut, type: :model do
describe 'Validations' do
it { should validate_presence_of :name }
it { should validate_presence_of :age }
it { should validate_presence_of :job }
end
describe 'Relationships' do
it { should have_many :astronaut_missions}
it { should... | true |
05311252734b57644b0c989ed6980ba09a9fba2a | Ruby | veralizeth/interviews_practice | /dinamic_prog.rb | UTF-8 | 1,549 | 4.46875 | 4 | [] | no_license | def fibonacci(n)
if n == 0 || n == 1
return n
end
return fibonacci(n-1) + fibonacci(n-2)
end
# fibonacci(n - 1) + fibonacci(n - 2)
# fib(2) + fib(1) = 1 + 1 = 2
# fib(1) = 1
# fib(3) + fib(2) = 1 + 0 = 1
# fib(2) + fib(1) = 1 + 0 = 1
# fib(1) + fib(0) = 1 + 0 = 1
# def fib(n)
# array_n = Array.new(n)... | true |
847d7dbe8e6666f761e116932784fba430a035ab | Ruby | sajadtorkamani/ruby-katas | /spec/negation_value_spec.rb | UTF-8 | 413 | 2.609375 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../src/negation_value'
describe 'negation_value' do
it 'applies the list of negations to the given value' do
expect(negation_value('!', false)).to be true
expect(negation_value('!', true)).to be false
expect(negation_value('!!!', [])).to be false
expe... | true |
07b9eee95e92932100851bf15beceb236782d155 | Ruby | ryanliang/lotus | /lib/hanami/application/routes_helper.rb | UTF-8 | 888 | 2.546875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Hanami
class Application
# Hanami application routes helpers
#
# An instance of this class gets registered in the container
# (`routes_helper` key) once the Hanami application is booted. You can use
# it to get the route helpers for your application.
#
... | true |
e0d35b57646f7a0cb5f50639072d79a09cc8bbfc | Ruby | ready4god2513/pm | /app/models/state_manager.rb | UTF-8 | 287 | 2.515625 | 3 | [] | no_license | class StateManager
def initialize(team)
@team = team
end
def initialze_defaults
%w(unstarted rejected started finished accepted delivered).each_with_index do |type, index|
@team.states.create(
sort_order: index,
name: type
)
end
end
end | true |
0238c0d064d64f7444b406bd3f7aca17bbf93da0 | Ruby | ashleylaswell/mastermind | /lib/mastermind/board.rb | UTF-8 | 621 | 3.4375 | 3 | [] | no_license | module Mastermind
class Board
attr_reader :grid
def initialize(input = {})
@grid = input.fetch(:grid, default_grid)
end
def get_cell(x, y)
grid[x][y]
end
def set_cell(x, y, value)
get_cell(x, y).value = value
end
def game_over
return :winner if winner?
return :out_of_turns if out_of_t... | true |
c61eb6ac437ef63fb8d390c19a34ce4b5a66a3d1 | Ruby | Salsa-Dude/review-flatiron | /Mod-1/Variables-Methods/ruby-basic-review.rb | UTF-8 | 622 | 4.34375 | 4 | [] | no_license |
# given two numbers returns quotient of the first number divided by the second number
def divided(num1, num2)
num1 / num2
end
# should take an argument of a persons name and assign it to a variable name
def my_name(value)
name = value
end
# should add an argument to the method argue
def argue(argument)
argumen... | true |
ea70442e4208058057f2d2f4d69f684695068fdf | Ruby | TheEnder42/CS340 | /MiniVM/MiniVM-master/Assembler.rb | UTF-8 | 4,841 | 2.671875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #! /usr/bin/ruby
# MiniVM - Copyright (c) 2012-2015 David H. Hovemeyer
# Free software - see LICENSE.txt for license terms
# MiniVM assembler
require 'BinaryFile'
require 'ExeFile'
require 'Opcode'
require 'Syscall'
require 'Constant'
class Assembler
def initialize(f)
@f = f
@exe = ExeFile.new()
@labels = {}... | true |
ee279650bf9142ce88f3a83db800da9c320a3d42 | Ruby | maxamg/vcloud-walker | /lib/walk/catalog.rb | UTF-8 | 543 | 2.609375 | 3 | [] | no_license | module Walk
class Catalog < Entity
attr_accessor :id, :name, :description, :items
def initialize(catalog)
self.id = catalog.id
self.name = catalog.name
self.description = catalog.description
self.items = CatalogItems.new(catalog.catalog_items.all(false))
end
end
class Catalo... | true |
83f6243add93980f3e6c35ca7f3209ec9600419b | Ruby | raheebwa/ruby-enumerables | /src/enumerable.rb | UTF-8 | 2,668 | 3.125 | 3 | [] | no_license | # frozen_string_literal: true
module Enumerable
def my_each
return to_enum unless block_given?
i = 0
while i < length
yield(self[i])
i += 1
end
self
end
def my_each_with_index
return to_enum unless block_given?
i = 0
while i < length
yield(self[i], i)
i ... | true |
d2fe367e04bb6c896c246b458a704bf2ac461cce | Ruby | sunny-b/hangman | /lib/board.rb | UTF-8 | 1,472 | 3.21875 | 3 | [] | no_license | # Boardgame class
class Board
BODY_PARTS = ['O', '|', '/', '\\', '/', '\\'].freeze
WORDS = %w(GENETIC BOOGIE SQUASH QUARTER HANGMAN CONTRADICTION FRIEND EMPLOYEE
CHERRY ANNUAL FAVORABLE SENSATIONAL MOTHER BUFFET BUFFER STUDIO
PERFUME FRAGRANT FRAGILE ACCOMPANY GOSSIP INSPIRE MOTIVE).freeze... | true |
795dcf1760345d6b16e0127ef5f5a03d8b0af13d | Ruby | NicolasDontigny/rails-longest-word-game | /test/system/games_test.rb | UTF-8 | 1,088 | 2.578125 | 3 | [] | no_license | require "application_system_test_case"
require 'pry-byebug'
class GamesTest < ApplicationSystemTestCase
test "Going to /new gives us a new random grid to play with" do
visit new_url
assert test: "New Game"
assert_selector "li", count: 10
end
test "submitting the form with random word that's not in t... | true |
822e468fea9e38e7e0cd6833d7e76f8284e6b34a | Ruby | linyows/trellohub | /lib/trellohub/list.rb | UTF-8 | 1,046 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'ostruct'
require 'trellohub/board'
module Trellohub
class List < OpenStruct
def id
@id ||= find_id
end
def find_id
current_list = self.class.find_by(name: name)
list = case
when current_list && current_list.closed
Trell.update_list(current_list.id, closed: f... | true |
e8d16690e1b890a2b3fc324255a5c3f5052922cd | Ruby | mfcworks/progladder | /src/test.rb | UTF-8 | 195 | 2.65625 | 3 | [
"MIT"
] | permissive | require_relative 'Lexer'
require_relative 'Parser'
src = <<EOF
a & {
b -> c
d -> e
f -> g
}
EOF
lexer = Lexer.new(src)
tokens = lexer.lex
parser = Parser.new(tokens)
p parser.parse
| true |
4c5e31a4e0d7b2873bd986c559830816273d1cf3 | Ruby | hharper/project1_personal_finance_manager | /archived_files/UPDATED_personal_finance_methods.rb | UTF-8 | 6,019 | 3.78125 | 4 | [] | no_license |
#PSEUDO CODE#
#update_balance: for each transaction, if the transaction is a credit (+), add its amount to the current account balance
#else, if the transaction is NOT a credit (-), subtract its amount from the current account balance
def update_balance(transaction_id)
transaction = Transaction.find(transaction_id)... | true |
d46ede0f3970c203ca46379aa863de28b187ff2a | Ruby | victor1cs/programacao-ruby | /conceitos/12-construtores.rb | UTF-8 | 531 | 3.9375 | 4 | [] | no_license | class Pessoa
attr_accessor :nome
attr_accessor :idade
def initialize(nome, idade)
@nome = nome
@idade = idade
end
def gritar(texto = "GRRRRHHHH!")
"Gritando..... #{texto}"
end
def agradecer(texto = "Obrigado!")
texto
end
end
###############################################
pessoa1 = Pessoa.new("Vi... | true |
090807861e8c0bbac24d852ea09c5c5be4722734 | Ruby | hadriagh/loom | /lib/loom.rb | UTF-8 | 306 | 2.609375 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
require 'pp'
class Loom
def self.weave(html)
textile = ''
html_doc = Nokogiri::HTML.fragment(html)
html_doc.children.each do |node|
tag = Tag.new(node)
textile += tag.process
end
return textile
end
end
require 'loom/tag' | true |
2ecdcac1dbcf80373337838c036477188510fd29 | Ruby | PetraStill/RoR-Classes | /q.rb | UTF-8 | 792 | 3.5 | 4 | [] | no_license | class User
attr_accessor :first_name, :last_name, :year, :country, :city, :street, :house_number
def initialize(options)
self.first_name = options.fetch(:first_name)
self.last_name = options.fetch(:last_name)
self.year = options.fetch(:year)
self.country = options.fetch(:country)
self.city = opt... | true |
8e3512b0315bad4ac2b39b0d87857ad6464ac8b2 | Ruby | Karin-Zuniga/introduccion_ruby | /ejercicio1_if/ejercicio_nivel2.rb | UTF-8 | 553 | 3.828125 | 4 | [] | no_license | puts "Ingresa tu nombre, edad, nivel"
persona = gets.chomp
puts persona
nombre = persona.split(%r{,\s*})[0].to_s
edad = persona.split(%r{,\s*})[1].to_s
nivel = persona.split(%r{,\s*})[2].to_s
if nivel == "basico"
puts "Hola, me llamo " + nombre + " y tengo " + edad + " años mi nivel es *"
elsif nivel == "inter... | true |
03f50207098c4f3154faa3b2540171eb80f6dde5 | Ruby | m-gb/rubytapas | /episode188_fail_and_raise.rb | UTF-8 | 842 | 3.5625 | 4 | [] | no_license | # At this point, most of the Ruby world has embraced #raise over #fail.
# use raise when re-raising an exception.
# That way, the choice of raise instead of fail provides an extra cue to the reader that something out of the ordinary is going on.
['--require', '-r MODULE',
"Require MODULE before executing rakefile.",
... | true |
3b33161fc702644da9b2c15d0924aece53c7622b | Ruby | emanon001/atcoder-ruby | /lib/warshal_floyd.rb | UTF-8 | 225 | 3.0625 | 3 | [] | no_license | def warshal_floyd(d)
v = d.size
v.times do |k|
v.times do |i|
v.times do |j|
cost = d[i][j]
new_cost = d[i][k] + d[k][j]
d[i][j] = new_cost if new_cost < cost
end
end
end
end | true |
25e65765150c4cd77b449ba7e929960b610bb1af | Ruby | heydabop/silverfish | /commands/source.rb | UTF-8 | 705 | 2.640625 | 3 | [
"BSD-2-Clause-Views"
] | permissive | def Commands.source(socket, nick, channel, args)
if args.empty?
tsputs "SEND: PRIVMSG #{channel} :https://github.com/heydabop/silverfish"
socket.puts "PRIVMSG #{channel} :https://github.com/heydabop/silverfish"
else
file = args[0]
if Commands.respond_to? file
tsputs "SEND: PRIVMSG #{channel} :... | true |
18581af2260f0f7ee01b5d7444bf3420d24fe9f1 | Ruby | tamu222i/ruby01 | /tech-book/2/2-25.rb | UTF-8 | 185 | 2.890625 | 3 | [] | no_license | # RDocの記述例
# = Hogeを表現するクラス
# 説明用のクラス定義です
#
class Hoge
# == テスト用メソッド
# 返り値:: 常に1
def test
1
end
end
| true |
ee23d60bfdaf9be2b7ed3544ac2f00a084c0c042 | Ruby | alialkaheli/aA-homeworks | /W1D5/map.rb | UTF-8 | 485 | 3.296875 | 3 | [] | no_license | class Map
attr_reader :map_arr
def initialize
@map_arr = []
end
def set(key,value)
arr_idx = map_arr.index { |arr| arr[0] == key}
if arr_idx != nil
map_arr[arr_idx][1] = value
else
map_arr << [key,value]
end
value
end
def get(key)
map_arr.each{ |arr| return arr[1] ... | true |
07f5c600bd99e19412fcc5892f9c925b60595f5e | Ruby | goyalankit/themeanbot | /bin/process_tweet.rb | UTF-8 | 1,597 | 3 | 3 | [] | no_license | require 'wordnik'
class ProcessTweet
class << self
Wordnik.configure do |config|
config.api_key = ENV['API_KEY']
end
def get_me_definition keyword
results = Wordnik.word.get_definitions(keyword, :use_canonical => true, :limit => 4, :source_dictionaries => 'all').collect{|i| i["text"] if i["... | true |
077ffe4f472abe322a38327028eb143f91ae2908 | Ruby | DragonRuby/dragonruby-game-toolkit-contrib | /samples/04_physics_and_collisions/09_arbitrary_collision/app/blocks.rb | UTF-8 | 25,466 | 2.703125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | MAX_COUNT=100
def universalUpdateOne args, shape
didHit = false
hitters = []
#puts shape.to_s
toCollide = nil
for b in args.state.balls
if [b.x, b.y, b.width, b.height].intersect_rect?(shape.bold)
didSquare = false
for s in shape.squareColliders
if (s.collision?(args, b))
di... | true |
f135c19ebba6790a03a0d1cd02789adef90676ae | Ruby | sparkapps/polonius-1 | /bard.rb | UTF-8 | 85 | 3.328125 | 3 | [] | no_license | puts "what is your name"
name = gets.chomp
puts "alas poor #{name} I knew him well"
| true |
c1300f6eb771bd593d49e4e8ab7c61c5d6c51a38 | Ruby | jasonchilcott/oo-tic-tac-toe-ruby-intro-000 | /lib/tic_tac_toe.rb | UTF-8 | 1,632 | 3.703125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class TicTacToe
def initialize
@board = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
end
WIN_COMBINATIONS = [
[0,1,2], # Top row
[3,4,5], # Middle row
[6,7,8], # Bottom row
[0,3,6], # Left column
[1,4,7], # Middle column
[2,5,8], # Right column
[0,4,8], # TL to BR diagonal
[2,4,6], # TR to B... | true |
a30a4a3606c233861fd97d8cbd9c2c0707aafc7e | Ruby | durrantm/r_p_s_run_rspec_tests | /game.rb | UTF-8 | 505 | 3.65625 | 4 | [] | no_license | class Game
Winners = {paper: :rock, rock: :scissors, scissors: :paper}
def play
my_guess = Winners.keys[rand(3)]
your_guess = Winners.keys[rand(3)]
p "You guessed #{your_guess} and I guessed #{my_guess}"
determine_winner(my_guess, your_guess)
end
def determine_winner(my_guess, your_guess)
if ... | true |
aa10ad86d3ee5343dbf0bc324652fa911356d490 | Ruby | conf/to_slug_param | /lib/to_slug_param/string.rb | UTF-8 | 2,432 | 2.78125 | 3 | [
"MIT"
] | permissive | class String
def to_slug_param opts = {}
self.class.to_smart_slug_param(self, opts)
end
def to_slug_param_base opts = {}
self.class.to_slug_param_base(self, opts)
end
def slugged_filename opts = {}
self.class.slugged_filename(self, opts)
end
def slugged_filepath opts = {}
self.class.slu... | true |
f3a26b3e24034fd36d05adf0e48922b5fa07a36f | Ruby | landoan/ticketcode | /app/models/order.rb | UTF-8 | 362 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | class Order < ActiveRecord::Base
belongs_to :user
has_many :tickets
accepts_nested_attributes_for :tickets
validate :at_least_one_ticket
def at_least_one_ticket
if self.tickets.size < 1
errors.add(:tickets, 'cannot be empty')
elsif self.tickets.map(&:quantity).sum < 1
errors.add(:tickets,... | true |
c9fc433d3bb154ed934bfd19e85e9fd5932eb4b3 | Ruby | bycdiaz/well_grounded_rubyist | /ch5_default_object_scope_visibility/5.2.4_scope_and_resolution_constants.rb | UTF-8 | 670 | 3.421875 | 3 | [] | no_license | # module M
# class C
# class D
# module N
# X = 1
# end
# end
# end
# end
# puts M::C::D::N::X
# module M
# class C
# class D
# module N
# X = 1
# end
# end
# puts D::N::X
# end
# end
# Forcing an absolute constant path
class Violin
class String... | true |
1fde394e77044fab6a2a7aca033877ab864f60c0 | Ruby | stevejackson/priphea | /app/services/audio_player.rb | UTF-8 | 2,359 | 3.1875 | 3 | [] | no_license | class AudioPlayer
attr_accessor :song_queue
attr_accessor :active_song
def initialize
@song_queue ||= []
end
def play
@active_song = @song_queue.first
if @active_song
cli_command = %Q{ cmus-remote --file "#{@active_song.full_path}" }
system(cli_command)
end
end
# is the cur... | true |
25a43d1f21bec4292f1cea981683c128b11c39d3 | Ruby | nohemirojas/hackerrank | /the-time-in-words.rb | UTF-8 | 1,180 | 3.90625 | 4 | [] | no_license | #!/bin/ruby
#https://www.hackerrank.com/challenges/the-time-in-words/problem
def the_time_in_words(h,m)
arr = ["o' clock",'one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','quarter','sixteen','seventeen','eighteen','nineteen',
'twenty','twenty one','twenty ... | true |
e2ce682824374189a6746e7e2f4f7793a546ba0e | Ruby | BaobabHealthTrust/dde-server | /script/duplicate_cleaner_version2.rb | UTF-8 | 2,811 | 2.75 | 3 | [] | no_license | LogErr = Logger.new(Rails.root.join("log","duplicates_error.txt"))
LogSuc = Logger.new(Rails.root.join("log","success.txt"))
class DuplicateCleaner < ActiveRecord::Migration
def self.duplicate_national_ids
national_id_values = NationalPatientIdentifier.select("value, count(value) as idcount").
... | true |
ee8d2f68f797d65ffc9a598577160dff0311c20f | Ruby | smithWEBtek/ttt-with-ai-project-v-000 | /notes.rb | UTF-8 | 7,176 | 2.859375 | 3 | [] | no_license |
##########################################
######### THE WALL solution!! #################
def turn
choice = current_player.move(board)
if board.valid_move?(choice)
board.update(choice, current_player)
else
turn
end
end
##########################################
def pl... | true |
6ffbce1ebcc558e8c4a7675355c46b9406631111 | Ruby | jbcool17/MyHandyScripts | /Ruby/other/getAllBrewOptions.rb | UTF-8 | 914 | 3.203125 | 3 | [] | no_license | #Script by JB
#============
# ruby getAllBrewOptions.rb {program}
#============
require 'colorize'
puts "Message==>Starting...".green
puts " "
#Settings Up Variables
program = ARGV[0]
text_file_name = "temp_text.txt"
options_array = []
#Running command to get options
print "Message==> Getting options...".green
puts... | true |
ba7d9623c3480f4696ed52fdc9cc12a5d1647461 | Ruby | masahino/mruby-mrbmacs-base | /test/mode_ruby.rb | UTF-8 | 2,373 | 2.546875 | 3 | [
"MIT"
] | permissive | assert('get_candidates 1') do
mode = Mrbmacs::RubyMode.new
assert_equal(['and'], mode.get_candidates_a("and"))
end
assert('get_candidates String') do
mode = Mrbmacs::RubyMode.new
assert_equal(['"test".chomp', '"test".chomp!'], mode.get_candidates_a('"test".chom'))
end
assert('get_candidates Regexp') do
mode... | true |
a2f5efcce2d1a2487f7148a7494d3d256066951a | Ruby | markus1189/trivia | /ruby/lib/ugly_trivia/board.rb | UTF-8 | 1,448 | 3.375 | 3 | [] | no_license | module UglyTrivia
class Field
attr_reader :category
%w[Pop Sport Rock Science].each do |category|
define_method("#{category.downcase}?") do # def sport?
self.category == category # self.category == 'Sport'
end ... | true |
b1f420313d527335fcc4b5dd1ce311b3ab641ba9 | Ruby | taylormcdowell/dice_roll | /roll_dice.rb | UTF-8 | 1,308 | 3.46875 | 3 | [] | no_license | #TEXT-STYLE IMAGE draw
die_image = []
die_image.push("___________\n| |\n| |\n| O |\n| |\n| |\n-----------")
die_image.push("___________\n| O |\n| |\n| |\n| |\n| O |\n-----------")
die_image.push("___________\n| O |\n| |\n| O |... | true |
d77e81c0552ab08bb4b298b00f087ee190fcee31 | Ruby | KIMJUNGKWON/ProgrammingRuby | /ch1/method.rb | UTF-8 | 1,167 | 4.71875 | 5 | [] | no_license | # [함수]
# 루비에서의 함수는 { } 와 같은 중괄호가 없으며 def ~ end 로 표현될 수 있다
def say_goodnitght(name)
result = "Good night, " + name
return result
end
# 통상적으로 함수의 인자를 감싸는 괄호 ( )도 생략이 가능하다
# 다만 가독을 위해서 넣어 주는 것을 습관으로 들이자
puts say_goodnitght("john") # => Good night, john
puts (say_goodnitght("john")) # => Good night, john
# [' ' vs " ... | true |
a1bcf1469e886ce886de02b421885c6b5a2053c7 | Ruby | richardrguez/exercises | /coderbyte/easy/ExOh.rb | UTF-8 | 849 | 4.09375 | 4 | [] | no_license | # Using the Ruby language, have the function ExOh(str) take the str parameter being passed and
# return the string true if there is an equal number of x's and o's, otherwise return the string
# false. Only these two letters will be entered in the string, no punctuation or numbers.
# For example: if str is "xooxxxxoox... | true |
5412e8c7c2574d795cdedfcf347b9fc63ddd9a37 | Ruby | jcurhan/tic_tac_toe_cli_game | /computer.rb | UTF-8 | 212 | 3.046875 | 3 | [] | no_license | class Computer
attr_accessor :game_symbol, :board, :game
def initialize(board, game)
@board = board
@game = game
end
def make_move
@game.current_player = self
move = rand(1..9)
end
end | true |
2a75de7883a7576d752203904e2fdc16770754cb | Ruby | secretbookclub/backend_module_0_capstone | /day_4/exercises/say.rb | UTF-8 | 499 | 4.15625 | 4 | [] | no_license | puts "hello"
puts "hi"
puts "how are you"
puts "I'm fine"
def say(words='hello') # parameter in parentheses - a "meaningful and explicit name"
puts words + '.' # you cannot reference this local variable outside of the say method definition
end
say()
say # works the same as the above line - but can get confusing
say... | true |
cad0d9d66f6866ef199d51a37e59a20814901e87 | Ruby | mrj9235/PersonalSWEN | /DietManager/FoodDB.rb | UTF-8 | 1,308 | 3.9375 | 4 | [] | no_license | require_relative 'Recipe'
require_relative 'BasicFood'
class FoodDB
##initializes a new FoodDB
def initialize()
@base = Hash.new()
end
attr_reader :base
##prints every food in the database
def printAll()
@base.each_value {|food| puts food.to_s()}
end
##goes through each food and if the food s... | true |
19b2f94378ae22512ad1165ce523822d45be0553 | Ruby | svo/role-based-access-control | /lib/repository/user_repository.rb | UTF-8 | 391 | 2.8125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
class UserRepository
def initialize(user = [])
@user = user
end
def retrieve_all
@user.clone
end
def retrieve(id)
@user.find { |item| item.id == id }
end
def retrieve_with_role(role)
@user.select { |item| role.include? item.role }
end
def delete_all
... | true |
851216204f52d8101d38fe1d864866830506e6e7 | Ruby | lucademontis/rails-stupid-coaching | /app/controllers/questions_controller.rb | UTF-8 | 491 | 2.625 | 3 | [] | no_license | class QuestionsController < ApplicationController
def ask
end
def answer
# params[question] comes from HTML form found in ask.html.erb
@question = params[:question]
if @question == "I am going to work"
@answer = "Great!"
# [-1, 1] --> last entry of string
elsif @question[-1, 1] == "?... | true |
cb97aa6e4d949ce19d8ab58dd8cf2912873728a2 | Ruby | pointerish/Enumerable | /enumerable_blocks.rb | UTF-8 | 4,245 | 3.234375 | 3 | [
"MIT"
] | permissive | # rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/PerceivedComplexity
# rubocop:disable Metrics/ModuleLength
module Enumerable
# my_each
def my_each
return to_enum(:my_each) unless block_given?
element = if instance_of?(Array)
self
else
... | true |
0dca58c7dd7c183c3e6cf613c816a653c4000f44 | Ruby | ZijianLiang2000/COM2025_Project | /app/models/game.rb | UTF-8 | 1,840 | 2.546875 | 3 | [] | no_license | class Game < ApplicationRecord
# Game model
# |_ id (Generated and Validates defaultly)
# |_ homeTeamName (Must exist, Validates names)
# |_ awayTeamName (Must exist, Validates names)
# |_ homeTeamScore (Can be nil, due to a game can be scheduled, but not yet played)
# |_ awayTeamScore (Can be ... | true |
029c0e2a961e3782c7a038965bddf34cfcbe142f | Ruby | vnegrisolo/guide-algorithms | /monk.rb | UTF-8 | 247 | 2.5625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Monk
def find_it(obj, method)
klass = obj.is_a?(Class) ? obj : obj.class
(klass.superclass && find_it(klass.superclass, method)) ||
(klass.instance_methods.include?(method) && klass)
end
end
| true |
3ee9c1940a05eaff2bd7a14e37e256dc8af9450a | Ruby | inocr8/homeworkwkend2 | /rates.rb | UTF-8 | 405 | 2.859375 | 3 | [] | no_license | class Rates < Hotel
attr_reader :name, :type, :rate, :category
def initialize(options = {})
@name = options[:name]
@type = options[:type]
@rate = options[:rate]
@category = options[:category]
end
# printing out reports for the class
def report_lister
"Name: #{@name}\nType: #{@type}\nRate:... | true |
46dcb7654f88900bf6201c176fa7ec9376799308 | Ruby | gingerhendrix/json_proxy | /test/features/step_definitions/test_service.rb | UTF-8 | 720 | 2.546875 | 3 | [] | no_license | include Server::DSL
# Not needed but the test should be a little more robust this way
class EchoResponse
attr_accessor :message
def initialize(msg)
@message = msg
end
end
np_namespace "echo" do |ns|
ns.route 'echo', [:message] do |message|
EchoResponse.new message
end
ns.route 'exception... | true |
9efa3bf0493ce5925de795fd7b537abc7d54c267 | Ruby | s-davies/aA_Classwork | /W4D4/Poker/spec/hand_spec.rb | UTF-8 | 952 | 2.828125 | 3 | [] | no_license | require_relative "hand.rb"
describe Hand do
# let(:js) {double("js", :get_val => 10, :get_suit => "♤")}
# let(:js) {double("js")}
# let(:js) {double("js")}
# let(:js) {double("js")}
# let(:js) {double("js")}
subject(:hand) {Hand.new([:js,])}
describe "#find_hand_value" do
high_card_hand = Hand.new([:... | true |
a2e67e5933e71d8ad570f53499e35af9f2babff7 | Ruby | fargelus/ruby-examples | /network/http/lib/calc_price.rb | UTF-8 | 1,056 | 2.828125 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../formats/csv_format'
class CalcPrice
extend CSVFormat
private_methods :new
def initialize(params)
@params = params
end
def self.call(params)
@@prices ||= parse_prices
new(params).call
end
def call
prepare_params
@params.keys.inject... | true |
96ba967ace0fd29c97b39feae022b32edd21362c | Ruby | jagiweb/programming-univbasics-3-build-a-calculator-lab-london-web-120919 | /lib/math.rb | UTF-8 | 365 | 3.328125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def addition(num1, num2)
sum = num1 + num2
sum
end
def subtraction(num1, num2)
subtracts = num1 - num2
subtracts
end
def division(num1, num2)
divides = num1/num2
divides
end
def multiplication(num1, num2)
mult = num1 * num2
mult
end
def modulo(num1, num2)
mod = num1%num2
mod
end
def square_root... | true |
9c0c75a5fdfc191857a490be4bc4092f5694fff5 | Ruby | thealice/key-for-min-value-uci-online-web9-pt-093019 | /key_for_min.rb | UTF-8 | 511 | 3.71875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
require 'pry'
def key_for_min_value(hash)
# min_value = 10000
min_value = nil
min_key = nil
hash.each do |key, value|
if min_value == nil || value < min_value
min_value = valu... | true |
ac95eb1c632f6066c8546d0fe89f736cdf41858c | Ruby | williscool/passport-api | /app/models/boat.rb | UTF-8 | 360 | 2.578125 | 3 | [] | no_license | class Boat < ActiveRecord::Base
has_many :assignments
has_many :timeslots, through: :assignments
has_many :bookings
#name and capacity come from db
def availability_by_timeslot(ts)
self.capacity - self.bookings_total_by_timeslot(ts)
end
def bookings_total_by_timeslot(ts)
Booking.where(timeslo... | true |
2237bb866fb4354ab34cb7860252e93e11c53c7c | Ruby | cindy/collections_practice-v-000 | /collections_practice.rb | UTF-8 | 647 | 3.828125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(arr)
arr.sort
end
def sort_array_desc(arr)
arr.sort{|a,b| b <=>a }
end
def sort_array_char_count(arr)
arr.sort{|a,b| a.length <=> b.length}
end
def swap_elements(arr)
arr[1], arr[2] = arr[2], arr[1]
arr
end
def swap_elements_from_to(arr, n, m)
arr[n], arr[m] = arr[m], arr[n]
arr
end... | true |
d1cbf327ca4f1918a496955820b5a5409ed768e5 | Ruby | grahammitchell/music-ripping-tools | /find_superfluous_oggs.rb | UTF-8 | 463 | 2.53125 | 3 | [] | no_license | #!/usr/bin/ruby -w
# 2006-06-26
# List all ogg files that have an identically-named flac in the same directory.
require 'find'
require 'fileutils.rb'
# find them
filenames = []
Find.find('.') do |path|
next unless FileTest.file?(path)
next unless ( File.extname(path)=='.ogg' )
next unless FileTest.readable?(path... | true |
7591de3df28b2d7a3598967ebd825a6b71005ac7 | Ruby | whatalnk/cpsubmissions | /atcoder/ruby/arc039/arc039_a/477762.rb | UTF-8 | 715 | 3.140625 | 3 | [] | no_license | # Contest ID: arc039
# Problem ID: arc039_a ( https://atcoder.jp/contests/arc039/tasks/arc039_a )
# Title: A. A - B problem
# Language: Ruby (2.1.5p273)
# Submitted: 2015-08-26 10:37:57 +0000 UTC ( https://atcoder.jp/contests/arc039/submissions/477762 )
a, b = gets.chomp.split(" ").map(&:to_i)
as = []
bs = []
(0..2)... | true |
5db7510df0f9cbb880c60f1f442b94c04bd497b1 | Ruby | RostomH/scrappeur_fou | /lib/scrapping_crypto.rb | UTF-8 | 954 | 2.78125 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
require 'pry'
require 'rspec'
require 'rubocop'
def name_crypto_in_array
doc = Nokogiri::HTML(open("https://coinmarketcap.com/all/views/all/"))
crypto_name_array = []
doc.xpath('//*[@id="__next"]/div/div[2]/div[1]/div[2]/div/div[2]/div[3]/div/table/tbody/tr/td[3]/div').each ... | true |
540384cb7e721340212e95e40f195bd3075e92c3 | Ruby | mjrkmail/payroll-in-ruby | /payday.rb | UTF-8 | 587 | 2.953125 | 3 | [] | no_license | require_relative "paycheck"
class Payday
def initialize(pay_date, database)
@pay_date = pay_date
@database = database
@paychecks = {}
end
def execute
empIds = @database.get_all_employee_ids
empIds.each do |empId|
employee = @database.get_employee(empId)
if (employee.pay_date?(@pa... | true |
1bfa7c2959a7b24ab71f32b95cbaa3e1e6780b52 | Ruby | antropova/tictactoe | /tictactoe.rb | UTF-8 | 5,751 | 4.65625 | 5 | [] | no_license | # 2 players, 1 board (9 cells - 3 rows, 3 columns)
# create the board with a hash to store the cells' information
# identify method to display the board on the screen with puts
# create 2 classes Board and Player to work with separately
# ask for players' input with gets.chomp and assign the marks X / O
# display... | true |
2b5dc50e5e584e20697e1ed86dea1229f15df13e | Ruby | fursich/hack_jack_compiler | /lib/transformer/nodes/base.rb | UTF-8 | 744 | 2.640625 | 3 | [] | no_license | module JackCompiler
module Transformer
module Node
class Base
# extend Forwardable
# def_delegators :@children, :slice!
attr_accessor :parent, :scope
attr_accessor :children
attr_reader :kind
def initialize(kind, *children)
@children = children
... | true |
390c3c0765a378d0b02dceb2870efe194556b0a1 | Ruby | angeloxenakis/oo-relationships-practice-houston-web-030920 | /app/Imdb/character.rb | UTF-8 | 795 | 3.359375 | 3 | [] | no_license | class Character
@@all = []
attr_accessor :name, :actor
def initialize(options)
@name = options[:name]
@actor = options[:actor]
@@all.push(self)
end
def movies()
Movie.all.select {|movie| movie.characters.include?(self)}
end
def shows()
Show.all... | true |
a787fc29aa86678e1b256e825a8273525e4f0e64 | Ruby | kenhufford/aA-projects | /W4D2/chess/queen.rb | UTF-8 | 184 | 2.96875 | 3 | [] | no_license | require_relative "piece.rb"
class Queen < Piece
attr_reader :symbol
def initialize(color, board, pos)
super
@symbol = :Q
end
def move_dirs
[:hor, :diag]
end
end | true |
7b9e9e9212345aef3e19beb86d4fe1ce4e460975 | Ruby | brysgo-forks/semr | /lib/semr/translation.rb | UTF-8 | 282 | 2.578125 | 3 | [
"MIT"
] | permissive | module Semr
class Translation
def [] arg
context[arg]
end
def context
@context ||= Hash.new()
end
def phrases_translated
@phrases_translated ||= []
end
def translated?
!phrases_translated.empty?
end
end
end
| true |
ef93daa20c68f1c5f2b796a84e56770dee9c9c23 | Ruby | AdedayoOpeyemi/Ruby-capstone-project | /lib/zero_unit.rb | UTF-8 | 243 | 2.828125 | 3 | [] | no_license | require 'colorize'
module ZeroUnit
def zero_unit_check(line, index)
matching_condition = /[\:\s]+0{1}+\w/
return unless matching_condition =~ line
"Unit assigned to Zero value on line #{index + 1}".colorize(:magenta)
end
end
| true |
954005238a0b70b575d815dbbf2cd10926e21d4c | Ruby | sarumathiap/Estimation | /app/models/info.rb | UTF-8 | 921 | 3 | 3 | [] | no_license | require 'base64'
require 'digest'
require 'openssl'
class Info < ApplicationRecord
before_save :password_encryption
private
def password_encryption
rand_iv = (0...8).map { (65 + rand(26)).chr }.join
rand_key = (0...8).map { (65 + rand(26)).chr }.join
iv = Digest::SHA256.hexdigest(rand_iv)[0..15]
k... | true |
0ee2c8edc934da44a4c31f4c544fa4db01d3c55e | Ruby | code-lever/brigade-monitor-gem | /lib/brigade/monitor/monitor.rb | UTF-8 | 2,172 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'json'
module Brigade
module Monitor
class Monitor
def initialize(key, miners, logger)
@key = key
@miners = miners.map do |m|
fetcher = Brigade::Monitor::Fetcher.new(m[:client], m[:name], logger)
{ fetcher: fetcher }.merge(m)
end
@log = logger
... | true |
df1c4e7c900a0bc39a32fa36b8f5b0169491f215 | Ruby | Koolmeester/Cursus | /Store/happyCats.rb | UTF-8 | 800 | 3.234375 | 3 | [] | no_license | require 'colorize'
require "./product"
require "./tins"
require "./store"
happyCat = Store.new
tin1=Tins.new()
tin1.id = 1
tin1.name = "happyTins Tuna"
tin1.unit = "Tray of 10"
tin1.price = 10.00
happyCat.add_catg tin1
tin2=Tins.new()
tin2.id = 2
tin2.name = "happyTins Turkey"
tin2.unit = "Tray of 10"
tin2.price = 10.... | true |
fbe62f4527f14c9000d5f079ee61db13ebb296ee | Ruby | twill14/launchschool-practice-exercises | /exercise_seven/exercise_seven.rb | UTF-8 | 1,419 | 4.25 | 4 | [] | no_license | ############################## Number 1 #####################################
arr = [1, 3, 5, 7, 9, 11]
number = 3
if arr.include?(number)
puts "Yes, this array contains the number #{number}"
else
puts "No, this array does not contain this number"
end
############################## Number 2 #####################... | true |
69fca6791cea9a451dbfa5d614dacb1b5521af7a | Ruby | srikarZ/bakerySite | /bakeryItems.rb | UTF-8 | 1,934 | 3.4375 | 3 | [] | no_license | class Cake
attr_accessor :description, :price
def initialize(description, price)
@description = description
@price = price
end
end
class Cookie
attr_reader :description, :price
def initialize(description, price)
@description = description
@price = price
end
end
class Muffin
attr_reader :... | true |
418f9236ed8c176f0c3d1ba7747f076d129f7e02 | Ruby | Kouch-Sato/AtCoderProblems | /ABC/128/128B.rb | UTF-8 | 285 | 3.046875 | 3 | [] | no_license | n = gets.to_i
array = []
n.times do |i|
s, p = gets.split
p = p.to_i
array << [i, s, p]
end
array = array.sort_by { |x| x[1] }
array = array.group_by { |x| x[1] }
array.each do |x|
x = x[1]
x = x.sort_by { |value| -1 * value[2] }
x.each do |z|
puts z[0] + 1
end
end | true |
23c272b193a71a92bbc3edc3d9543db837d991bc | Ruby | rudietuesdays/dojo_ruby | /first_vagrant_box/rails_mvc/rails_TDD/spec/models/user_spec.rb | UTF-8 | 1,433 | 2.609375 | 3 | [] | no_license | # set up testing env by telling rails to import file '/spec/rails_helper.rb'
require 'rails_helper'
# tells rails thats you are going to be describing a set of tests that you want to run
RSpec.describe User, type: :model do
# pending "add some examples to (or delete) #{__FILE__}" # this test is created with the file... | true |
4571798b13178cf8bfadf7d5914ba24f27d0ee16 | Ruby | wdrexler/SIPtreadmill | /app/services/rtcp_parser.rb | UTF-8 | 379 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'json'
class RtcpParser
def initialize(data, test_run_instance)
@data, @test_run = data, test_run_instance
end
def run
@data.each do |d|
data = symbolize d
data[:test_run] = @test_run
RtcpData.create data
end
end
def symbolize(h)
sym_hash = {}
h.each do |k,v|
... | true |
c05dc052fc2ba991aec52730c3fb3c0a51a8e0d7 | Ruby | eps0003/KartDrifter | /replay.rb | UTF-8 | 2,853 | 3.1875 | 3 | [
"MIT"
] | permissive | class Replay
attr_accessor :data, :index, :duration
def initialize()
@data = Array.new()
@index = -1
@duration = 0
end
end
def add_replay_data(replay, data)
# Convert to data to integers
i = 0
while (i < data.size)
data[i] = data[i] ? 1 : 0
i += 1
end
# Check if data is the same a... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.