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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
3f99e48e04b2f70b5486082b3f680c22adc9d430 | Ruby | stefanosu/OO-mini-project-dumbo-web-051319 | /app/models/RecipeCard.rb | UTF-8 | 238 | 2.734375 | 3 | [] | no_license |
class RecipeCard
attr_accessor :user, :recipe, :date, :rating
def initialize(user, date, recipe, rating)
@user = user
@date = date
@recipe = recipe
@rating = rating
end
end
| true |
1faa6fc53e74ea7255fbf761d6560ed98c57ae3c | Ruby | fleurhim/tests-ruby | /lib/03_basics.rb | UTF-8 | 492 | 3.5625 | 4 | [] | no_license | def who_is_bigger(a,b,c)
if a == nil || b== nil ||c== nil
return "nil detected"
else
array = ["a", "b", "c"]
array_2 = [a, b, c]
hash = array.zip(array_2).to_h
return "#{hash.key(hash.values.max)} is bigger"
end
end
def reverse_upcase_noLTA(string)
string.reverse.upcase.delete("LTA")
end
def array_42(ar... | true |
fb12e15d0673844ae15dd90c8844b11a3ff8ff28 | Ruby | Madh93/codewars_rb | /spec/lib/kata/kyu7/categorize_new_member_spec.rb | UTF-8 | 582 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Kata::Kyu7 do
it 'Return open and senior members' do
Kata::Kyu7.categorize_new_member([[45, 12],[55,21],[19, -2],[104, 20]]).must_equal(['Open', 'Senior', 'Open', 'Senior'])
Kata::Kyu7.categorize_new_member([[3, 12],[55,1],[91, -2],[54, 23]]).must_equal(['Open', 'Open', 'Open',... | true |
f30b5f59bdcf194bc081b3966344f0ec8deaedf4 | Ruby | jibarra/advent-of-code | /2019/day4/solution.rb | UTF-8 | 3,035 | 4 | 4 | [
"MIT"
] | permissive | # TODO: not the best method name
def digits_never_decrease(number)
i = 0
digits = number.digits.reverse
digits.all? do |digit|
i += 1
if i >= digits.size
true
else
digit <= digits[i]
end
end
end
def has_adjacent_same_digit(number)
i = 0
digits = number.digits
digits.any? do |d... | true |
e2e492672b8c86831256f7abd77dd5bd6d91b906 | Ruby | ailadson/ghost | /ai_player.rb | UTF-8 | 1,868 | 3.546875 | 4 | [] | no_license | require './game_node.rb'
class AI_Player
attr_accessor :name, :round_dictionary, :losses
ALPH = ("a".."z").to_a
def initialize(number_of_players)
@name = "Hal"
@losses = 0
@number_of_players = number_of_players
end
def guess(fragment)
puts "The current word fragment is #{fragment}"
pu... | true |
16e0aff6853ef65e1a067dc24a5bd1654ac27d17 | Ruby | gboydhub/MM_Kata_TDD | /test_kata.rb | UTF-8 | 1,488 | 3.078125 | 3 | [] | no_license | require "test/unit"
require "./kata.rb"
class Test_kata < Test::Unit::TestCase
def test_ensure
assert_true(true)
end
def test_kata_func
assert_equal(get_kata(1), 1)
assert_equal(get_kata(2), 2)
end
def test_kata_replace
assert_equal(get_kata(3), "mined")
as... | true |
701988d6a063adf953a8d47ff1e054e9741b5ded | Ruby | regru/reg_api2-ruby | /lib/reg_api2/user.rb | UTF-8 | 3,014 | 2.59375 | 3 | [
"MIT"
] | permissive | # -*- encoding : utf-8 -*-
require 'reg_api2/entity/user'
module RegApi2
# REG.API user category
module User
include RegApi2::Builder
category :user
# @!method nop
# @param None
# Accessibility testing.
# @return [void] Nothing.
define :nop
# @!method create(opts = {})
# @p... | true |
197ba77ce0ff07cb43f82e4f263cc1dbaae3e935 | Ruby | Joe11000/play_around_with_rspec | /lib/person.rb | UTF-8 | 1,091 | 3.875 | 4 | [] | no_license | class Person
attr_reader :name
def initialize name=('a'..'z').to_a.sample(5).join
@name = name
end
def to_s
"what's up, #{@name}?"
end
end
class Partier < Person
attr_reader :alive
def initialize name=('a'..'z').to_a.sample(5).join
super name
@drank = 0
@alive = true
end
def t... | true |
9254b74eb2c342e9e0262056950c928021888231 | Ruby | rengotaku/lens-manage | /app/services/concerns/base_service.rb | UTF-8 | 1,446 | 2.703125 | 3 | [
"MIT"
] | permissive | # 各サービスの基底モジュール
module BaseService extend self
# TODO: pidの制御をしようとしたが志半ばで諦めた
LOCKFILE = "#{Rails.root}#{Rails.application.config.common.pid[:lock_file]}".freeze
# プロセス実行時
def begin_ps(shell_str)
# ファイルチェック
if File.exist?(LOCKFILE)
# pidのチェック
pid = 0
File.open(LOCKFILE, "r") do |f|
... | true |
3db555f03f08fbb59767dd9b40802b1030b4b795 | Ruby | minkeesung/phase-0-tracks | /databases/to_do_list.rb | UTF-8 | 488 | 2.6875 | 3 | [] | no_license | require 'sqlite3'
db = SQLite3::Database.new("to_do_list.db")
db.results_as_hash = true
create_table_list = <<-SQL
CREATE TABLE IF NOT EXISTS list(
id INTEGER PRIMARY KEY,
things_to_do VARCHAR(255),
is_done VARCHAR(255)
)
SQL
db.execute(create_table_list)
def create_list(db, things_to... | true |
81f141d7d9f80b37a1830cb99ca2f461e359cd8f | Ruby | apeiros/teaching_rpg | /lib/screens/battle.rb | UTF-8 | 783 | 3.15625 | 3 | [] | no_license | # encoding: utf-8
require 'screen'
module Screens
class Battle < Screen
LogSize = ScreenHeight-3
def initialize(hero, enemy)
@hero = hero
@enemy = enemy
@log = ["You encounter a #{@enemy.name}"]
end
def report(event)
@log << event
end
def rendered
unit_... | true |
95cc8adec0b5b5c4615be658d5ca8157e1cc208e | Ruby | britton-jb/programming_problems | /project_euler/special_pythagorean_triplet.rb | UTF-8 | 157 | 3.125 | 3 | [] | no_license | (1..500).each do |a|
(1..500).each do |b|
c = Math.sqrt(a ** 2 + b ** 2)
if a + b + c == 1000
puts a * b * c
break
end
end
end
| true |
bb1836618280fd4676b57e19d458d108bfc81460 | Ruby | botrethewey/BankAccounts | /specs/account_spec.rb | UTF-8 | 12,903 | 3 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/reporters'
require 'minitest/skip_dsl'
require_relative '../lib/account'
require_relative '../lib/owner'
describe "Wave 1" do
describe "Account#initialize" do
# Checks for instance variables
it "Takes an ID and an initial balance" do
id = 1337
balance ... | true |
e9eaef95187b45528ab676ddec2461237f7b583d | Ruby | trentkjackson/dtp-package-manager | /src/lib/util/array/sort.rb | UTF-8 | 947 | 3.546875 | 4 | [
"Apache-2.0"
] | permissive | def filter_two_arrays(this, arr, should_include)
filterd = []
i = 0
this.each do |x|
checkpoint_cleared = true
# For each element in argument's array.
arr.each do |m|
# Checkpoint passed
if should_include
if x.include? m
next
else
# Checkpoint failed
checkpoint_cleared = false
... | true |
d329a13de0cc718f11f95db6d747f28727611e57 | Ruby | akshedu/hello_app | /exp4.rb | UTF-8 | 66 | 2.8125 | 3 | [] | no_license | num = 10001
4.times do
puts "#{num.class}: #{num}"
num *= num
end
| true |
bb81d57638d65999f36dffef8c6d872b2185f3ad | Ruby | mlee1974/sea-c17-ruby | /class2/6_bigger_better_favorite_number.rb | UTF-8 | 401 | 4.0625 | 4 | [] | no_license | # Section 5.6 on page 25
# 4 points
#
# Write a program that asks for a person’s favorite number. Have your program
# add 1 to the number, and then suggest the result as a bigger and better
# favorite number. (Do be tactful about it, though.)
puts "What's your favorite number?"
number_input = gets.chomp
number_input =... | true |
709fea616ae2668f3336fc3f6e24b9752a982c96 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/ce21de0a49b840ba9fed68b25f1fd6f3.rb | UTF-8 | 195 | 3.453125 | 3 | [] | no_license | class Hamming
def self.compute a, b
length = [a.length, b.length].min
distance = 0;
length.times do |i|
distance += 1 if a[i] != b[i]
end
return distance;
end
end
| true |
63e6ef9b480eac650929726b879f79a38073de36 | Ruby | superpower1/pacman | /app/game_controller.rb | UTF-8 | 1,423 | 3.484375 | 3 | [
"MIT"
] | permissive | require_relative 'pacman'
class GameController
attr_accessor :width, :height, :pacman
def initialize(size)
@width = size[:width]
@height = size[:height]
@pacman = Pacman.new
@face_angle_hash = {
"EAST": 0,
"NORTH": 90,
"WEST": 180,
"SOUTH": 270
}
end
def angle_to_f... | true |
1678680790888dafa5ca82a6563ab2d3e03a4e9e | Ruby | justinwang11/AppAcademy | /w1d2-master/sudoku.rb | UTF-8 | 2,805 | 3.90625 | 4 | [] | no_license | require 'colorize'
require 'byebug'
class Tile
attr_reader :given
attr_accessor :value
def initialize(value)
@value = value
@given = value != "0"
end
def check_given
@given
end
def to_s
check_given ? value.colorize(:blue) : value
end
end
class Board
attr_accessor :grid
def initi... | true |
25c2b5e4df9b97a61805c864a80afa3b89a9f202 | Ruby | kimjaneclark/homework_20190128 | /models/game.rb | UTF-8 | 759 | 3.53125 | 4 | [] | no_license | class Game
def initialize (hand1, hand2)
@hand1 = hand1
@hand2 = hand2
end
def play
if @hand1 =="rock" && @hand2 =="sissors"
return "Rock won"
elsif @hand1 =="sissors" && @hand2 == "rock"
return "Rock won"
elsif @hand1 =="rock" && @hand2 == "paper"
return "Paper won"
el... | true |
43504f452d84ab74caa5d4512a134fbe831d666d | Ruby | emilyjspencer/The_Book_Lounge | /lib/book.rb | UTF-8 | 1,888 | 3.203125 | 3 | [] | no_license | require_relative 'database_connection'
require_relative 'review'
class Book
attr_reader :title, :author, :genre, :isbn, :id
def initialize(title:, author:, genre:, isbn:, id:)
@title = title
@author = author
@genre = genre
@isbn = isbn
@id = id
end
def self.create_entry(title:, autho... | true |
7c9c147a83871059876a0f96005f503ee109708d | Ruby | artfuldodger/School | /TCC/Ruby/Lab5/Tut.rb | UTF-8 | 1,412 | 3.90625 | 4 | [] | no_license | class Tut
alpha_lower = ('a'..'z')
alpha_upper = ('A'..'Z')
vowels = %w{a e i o u A E I O U}
ConsonantsLower = alpha_lower.reject { |v| vowels.include? v }
ConsonantsUpper = alpha_upper.reject { |v| vowels.include? v }
# Have to convert ranges to arrays to combine as far as I can tell
Consonants = Consona... | true |
27b6bd4078affbff076a0d734ffed71ba20894d4 | Ruby | mrflip/lorkbong | /vendor/wukong/lib/wukong/store/conditional_store.rb | UTF-8 | 1,534 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | module Monkeyshines
module Store
class ConditionalStore < Monkeyshines::Store::Base
attr_accessor :options, :cache, :store, :misses
DEFAULT_OPTIONS = {
:cache => { :type => :tyrant_rdb_key_store },
:store => { :type => :chunked_flat_file_store },
}
#
#
# +c... | true |
5a08d46e11f4a716008e8c0426e0babf372b5446 | Ruby | Crysicia/THP_S6 | /THP-Ruby-Day05/weight_watcher.rb | UTF-8 | 1,014 | 3.296875 | 3 | [] | no_license | WELSH = Hash.new
WELSH["Lipides"] = 38.4
WELSH["Glucides"] = 18.3
WELSH["Protéines"] = 36.3
CALORIES = Hash.new
CALORIES["Lipides"] = 9
CALORIES["Glucides"] = 4
CALORIES["Protéines"] = 4
FRITES = Hash.new
FRITES["Lipides"] = 15
FRITES["Glucides"] = 41
FRITES["Protéines"] = 3.4
BIERE = Hash.new
BIERE["Lipides"] = 0
B... | true |
fa950a07c62c77c5d928a842ee287c024df5982b | Ruby | nickcharlton/web_log_parser | /lib/web_log_parser.rb | UTF-8 | 3,160 | 2.9375 | 3 | [
"MIT"
] | permissive | require 'web_log_parser/version'
class WebLogParser
COMMON_LOG_FORMAT = '%h %l %u %t \"%r\" %>s %b'
COMMON_LOG_FORMAT_VIRTUAL_HOST = '%v %h %l %u %t \"%r\" %>s %b'
COMBINED = '%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"'
COMBINED_VIRTUAL_HOST = '%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \... | true |
66688d5765dd8e8fb64ccfc8f202fcfd8baea5e4 | Ruby | njenga-kariuki/the-bachelor-todo-seattle-web-career-021819 | /lib/bachelor.rb | UTF-8 | 1,095 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'json'
require 'pry'
def get_first_name_of_season_winner(data, season)
data[season].each do |k|
#binding.pry
if k["status"] == "Winner"
return k["name"].split(" ")[0]
end
end
end
def get_contestant_name(data,occupancy)
data.each do |season, season_data|
season_data.each do |values|... | true |
e727c1754f34fc67afd71e651b3250e3759c704e | Ruby | piyushranjan/Newmail | /webapp/app/helpers/mailboxes_helper.rb | UTF-8 | 1,965 | 2.515625 | 3 | [] | no_license | module MailboxesHelper
def writeFroms(ticket)
if ticket and ticket.mail_tickets_count>1
if ticket.mail_tickets_count==2
if ticket.mails.first.froms[0] == ticket.mails.last.froms.first
truncate(ticket.mails.last.froms.first.person.name, :limit => 20)
else
trunca... | true |
28318b486ada9b9841624e0a661e7a07e0180ccb | Ruby | ewhitebloom/Katas | /pandigital_prime/pandigital.rb | UTF-8 | 327 | 3.484375 | 3 | [] | no_license | def pandigital
i = 999999999
primes = []
while primes.empty?
prime = true
(2...i/2).to_a.each do |num|
if i % num == 0
prime = false
break
end
end
if prime == true && i.to_s.split('').uniq.size == 9
primes << i
end
i -= 1
end
primes[0]
end
puts pand... | true |
1a23e02d951bea1fd657fdf3948fa857def27ae9 | Ruby | Mackaber/startupbus-na-2014-game | /lib/account_checker.rb | UTF-8 | 1,834 | 2.890625 | 3 | [] | no_license | require 'net/http'
require 'net/https'
require 'json'
module AccountChecker
module Type
BUSPRENEURS = "buspreneurs"
CONDUCTORS = "conductors"
end
extend self
def knows_about?(email, type = Type::BUSPRENEURS)
!!info_for(email, type)
end
def info_for(email, type = Type::BUSPRENEURS)
return ... | true |
12198cfe5e808db3d30cda5a53ba7bda73481c6c | Ruby | ECE421W17/Project5 | /model/virtual_player.rb | UTF-8 | 1,878 | 3.296875 | 3 | [] | no_license | require 'test/unit/assertions'
require_relative 'player'
require_relative 'board'
include Test::Unit::Assertions
class VirtualPlayer
##Algorithm for computerized player
def self.makemove(board, players, cPlayerNumber)
validColumn = board.valid_columns
if(validColumn.length == 0)
puts "no mor... | true |
3a5136d304fe080c69be1301875459e6700ee962 | Ruby | weirdpercent/oversetter | /lib/oversetter/cli/yandex.rb | UTF-8 | 1,408 | 2.609375 | 3 | [
"MIT"
] | permissive | desc 'Yandex operations'
command :ya do |dex|
dex.desc 'Lists supported languages'
#dex.arg_name 'word'
dex.command :li do |list|
list.flag :ui, :default_value => nil, :arg_name => 'string', :desc => '2-letter ISO 639-1 language code. If set, the response will contain a list of supported language codes and corresp... | true |
1b8bc5967ab4a86d0563ccabd2b14da44dff3229 | Ruby | scrollytelling/export | /lib/scrollytelling/export/screenshot.rb | UTF-8 | 2,615 | 2.609375 | 3 | [
"ISC"
] | permissive | require 'fileutils'
require 'ferrum'
module Scrollytelling
module Export
# Document an entire Scrollytelling by way of screenshots.
class Screenshot
attr_accessor :paths
attr_reader :story, :browser
def initialize(story)
@story = story
@browser = Ferrum::Browser.new(
... | true |
d223653a24c7c00446b745ad4df6ec0adad0cf66 | Ruby | neidiom/sortiranje_i_pretrazivanje_podataka_ruby | /konstantna_slozenost.rb | UTF-8 | 457 | 2.890625 | 3 | [] | no_license | #!/usr/bin/env rvm-auto-ruby
require 'benchmark'
# Primjer gdje pristupamo prvom članu postojećeg niza .
# Možemo primjetiti da ma koliko je veliki niz vrijeme koje je potrebno
# da se pristupi prvom članu postojećeg niza je uvijek isti.
mali_niz = [1, 2, 3, 4, 5]
veliki_niz = (1..9_000_000).to_a
Benchmark.bm(10) d... | true |
4a59651c1746bf12f68cfa507a1359fe44b2cb8a | Ruby | fazaton/learn_ruby | /02_calculator/calculator.rb | UTF-8 | 507 | 3.671875 | 4 | [] | no_license | #write your code here
def add(a, b)
return a + b
end
def subtract(a, b)
return a - b
end
def sum(a)
k = 0
a.each do |iterator|
k += iterator
end
return k
end
def multiply(a)
k = 1
a.each do |iterator|
k *= iterator
end
return k
end
def power(a)
i = 0
a.each do |iterator|
i = iterator ** iterator
... | true |
6740a0773f9bcc78829b0f700c3fc36c2e06274e | Ruby | Archyfly/less2 | /less24_glasnie.rb | UTF-8 | 192 | 3.171875 | 3 | [] | no_license | string_az = ("a".."z").to_a #заполняем массив
vowels = ["a","e","i","o","u"]
string_az.each.with_index(1) { |value, index | puts "#{index}: #{value}" if vowels.include?(value)}
| true |
1ff8317cca12af8d5b084b5f32b395ff55128d73 | Ruby | lesochodec/coding-examples | /ruby/homework01/cube.rb | UTF-8 | 510 | 2.625 | 3 | [] | no_license | size 400,400
background 105, 120, 16
def pravouhly (x,y)
# PRAVOUHLY trojuholnik
line x+0,y+0, x+100,y+0
line x+100,y+0, x+0,y+100
line x+0,y+100, x+0,y+0
end
def stvorec (x,y)
# stvorec
line x+0,y+0, x+100,y+0
line x+100,y+0, x+100,y+100
line x+100,y+100, x+0,y+100
line x+0,y+100, x+0,y+0... | true |
22a53b2913fc15a669faf3e560e4ff9a0d806795 | Ruby | smoip/crawler | /spec/lib/crawler/room_spec.rb | UTF-8 | 1,129 | 2.5625 | 3 | [] | no_license | require 'spec_helper'
RSpec.describe Crawler::Room do
subject { described_class }
let(:room) { subject.new }
describe ".new" do
it "assigns default attributes" do
expect(room.name).to eq("Room")
end
context "with attributes passed in" do
let(:room) {
subject.new({
nam... | true |
96087b345c13dda45a23b16de7874b2b7ab2d94b | Ruby | JustinData/GA-WDI-Work | /w02/d03/Ann/morn_ex.rb | UTF-8 | 987 | 4.1875 | 4 | [] | no_license | random_animals = ["porpoise", "camel", "lobster", "kangaroo", "wombat", "chameleon"]
# Print out a plural version of each animal on a new line(ie porpoises, camels, etc)
random_animals.map {|x| x + "s \n"}
# Return an array of the animals sorted alphabetically
random_animals.sort
# Return an array of the animals so... | true |
153a9e0acc87db46f5c20f5981d950125706adcb | Ruby | demileee/reinforcement_programming | /exercise3.rb | UTF-8 | 581 | 3.65625 | 4 | [] | no_license | def options
all = [
[nil, "Pumpkin", nil, nil],
["Socks", nil, "Mimi", nil],
["Gismo", "Shadow", nil, nil],
["Smokey","Toast","Pacha","Mau"]
]
puts "Welcome to class."
all.each_with_index do |row, index1|
row.each_with_index do |seat, index|
if seat == nil
puts "Row #{index1+... | true |
9788a4e7ba87aaa08f1b12296c963ab300d60d6f | Ruby | shukerski/ruby-retrospective-4 | /solutions/04.rb | UTF-8 | 654 | 3.015625 | 3 | [] | no_license | module UI
class TextScreen
def self.draw(&block)
UI::TextScreen.new.draw(&block)
end
def initialize
@contents = ""
end
def draw(&block)
instance_eval(&block)
@contents
end
def vertical(&block)
@add_new_line = true
instance_eval(&block)
end
def horizontal(&... | true |
5b935aff3a3caaa267552337f2c76b9579578baa | Ruby | avni510/projecteuler | /lib/problem_seven.rb | UTF-8 | 248 | 2.625 | 3 | [] | no_license | $LOAD_PATH << '.'
require "problem_three"
module ProblemSeven
def ProblemSeven.nth_prime(n)
return 2 if n == 1
i, count = 3, 2
until count == n do
i += 2
count +=1 if ProblemThree.is_prime(i)
end
i
end
end
| true |
4552bef2095e2aa06407227abd8382399aa5c327 | Ruby | rodolfobandeira/ruby-studies | /procs.rb | UTF-8 | 358 | 3.75 | 4 | [] | no_license | multiples_of_3 = Proc.new do |n|
n % 3 == 0
end
(1..100).to_a.select(&multiples_of_3)
# (1..100) iterate from 1 to 100. Using ... would iterate between 2 and 99
# .to_a converts to array
# .select iterate on every element with the proc selected between parentesis ()
# procs are a way to make a block a kind of obje... | true |
5cc9d69a883db638cef32c3d726e56c6c2376cc8 | Ruby | gocoog/ruby-oo-object-relationships-collaborating-objects-lab-hou01-seng-ft-071320 | /lib/mp3_importer.rb | UTF-8 | 344 | 3.078125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class MP3Importer
attr_accessor :file
attr_reader :path
def initialize(path)
@path = path
end
def files
@file = Dir::entries(@path)
@file.shift(2)
@file
end
def import
self.files.each do |index|
Song.new_by_filename(index)... | true |
65645f5700a2e47e0e8cbfea95ca73ad55b6b84a | Ruby | benfalk/ruby_intro | /projects/02/math.rb | UTF-8 | 913 | 4.5625 | 5 | [
"MIT"
] | permissive | # Ruby can do Math like a champ! Lets explore some of the things it can do
# Addition, with Integers
puts 1 + 1 # => 2
# Addition, with Floats
puts 1.0 + 1.0 # => 2.0
# Addition, with a mix of Floats and Integers
puts 1.0 + 1 # => 2.0
# Integer Division
puts 4 / 3 # => 1
# Multiplication, as you would e... | true |
733fd95758078843f94b1a839628ca2ab4472883 | Ruby | cattywampus/chef-nexus3 | /libraries/api.rb | UTF-8 | 1,012 | 2.59375 | 3 | [
"MIT"
] | permissive | module Nexus3
# Interact with the Nexus3 API
class Api
require 'json'
def initialize(base_url, user, password)
@http_client = HTTPClient.new(base_url: base_url).tap do |client|
# Authentication
client.set_auth(base_url, user, password)
client.force_basic_auth = true
# ... | true |
e51f4162db8d2158b7d496400d6752ab0e2fc901 | Ruby | massierc/game-of-life | /app/life.rb | UTF-8 | 1,548 | 3.328125 | 3 | [] | no_license | require './app/cell'
class Life
attr_accessor :world, :previous_world, :original_world
def initialize(width, height, live_cells)
flat_world = Array.new(width * height).map { |cell| cell = Cell.new(value: 0) }
live_cells.times { |i| flat_world[i].value = 1 }
@world = flat_world.shuffle.each_slice(width... | true |
8911f7d06822774f5f9efcf7d80580290b94fb0e | Ruby | duke-libraries/dul-hydra | /app/services/inspect_nested_folder_ingest.rb | UTF-8 | 1,430 | 2.6875 | 3 | [
"BSD-2-Clause"
] | permissive | class InspectNestedFolderIngest
attr_accessor :results
attr_reader :scanner_config, :filepath
Results = Struct.new(:file_count, :exclusions, :content_model_stats, :filesystem)
def initialize(filepath, scanner_config={})
@scanner_config = scanner_config
@filepath = filepath
@results = Results.new
... | true |
441f99e0167e4c70455a6d0f1340a1a489e76c70 | Ruby | phss/playground | /exercises/skiena/chapter_five/data_structure/src/bfs.rb | UTF-8 | 1,636 | 3.34375 | 3 | [] | no_license | # BFS logic
class BreadthFirstSearch
def initialize(graph, visitor_actions)
do_nothing = lambda { |*anything| }
@graph = graph
@actions = { :on_node_entry => do_nothing, :on_node_exit => do_nothing,
:on_any_edge => do_nothing, :on_unique_edge => do_nothing }.merge(visitor_actions)
@... | true |
5c7ca16c230c439de519eaef757bec10d047c0c7 | Ruby | wf1101/encode_repeating | /lib/encode_repeating.rb | UTF-8 | 893 | 3.78125 | 4 | [] | no_license | # A method that updates the string by replacing consecutive repeating characters
# with a number representing the frequency. The replacement is done only if the
# string length will get reduced by this process.
def encode_repeating(my_string)
return nil if my_string.nil?
return my_string if my_string.length <= 1
... | true |
c9b78a4b33693c37dfd39568ff63291865be5535 | Ruby | sobrinho/range_sentence_parser | /lib/range_sentence_parser.rb | UTF-8 | 1,814 | 3.328125 | 3 | [
"MIT"
] | permissive | require 'range_sentence_parser/invalid_sentence_error'
require 'range_sentence_validator' if defined? ActiveModel
class RangeSentenceParser
# Parse the sentence and return a collection of numbers and/or ranges
#
# Usage:
#
# RangeSentenceParser.parse!('') # => []
# RangeSentencePar... | true |
f55810027ce4f0c302f0d6fc2f3a6af07d7afcf5 | Ruby | dragonmaus/home-old-2017-05-21 | /src/bin/namechange/namechange.rb | UTF-8 | 370 | 2.75 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env ruby
# frozen_string_literal: true
require 'clipboard'
require 'derpi'
def clean(string)
string.downcase.sub(/^artist:/)
end
def format(name)
Derpi.link("artist:#{name}")
end
old = clean(ARGV[0])
new = clean(ARGV[0])
puts Clipboard.copy(format('"DA":http://%s.deviantart.com/ %s -> %s',
... | true |
21054f34703bec32ea340c12b2124f91da76b742 | Ruby | aimiyuki/opac | /models.rb | UTF-8 | 2,205 | 2.71875 | 3 | [] | no_license | require 'active_record'
# reverse mapping for the roles assigned in create_database.rb
ROLES = {
'editor' => '編著',
'director' => '監修',
'author' => '著',
'translator' => '訳',
'illustrator' => '絵',
}
class HoldingLocation < ActiveRecord::Base
has_many :books
end
class Book < ActiveRecord::Base
has_many :book_... | true |
e6f35c4d744954f64d25b9dc649180499c378a25 | Ruby | dlaststark/machine-learning-projects | /Programming Language Detection/Experiment-2/Dataset/Train/Ruby/text-processing-1-1.rb | UTF-8 | 1,347 | 3.046875 | 3 | [] | no_license | filename = "readings.txt"
total = { "num_readings" => 0, "num_good_readings" => 0, "sum_readings" => 0.0 }
invalid_count = 0
max_invalid_count = 0
invalid_run_end = ""
File.new(filename).each do |line|
num_readings = 0
num_good_readings = 0
sum_readings = 0.0
fields = line.split
fields[1..-1].each_slice(2) ... | true |
30531347ffb4344359802fb18efc03d5792b49b1 | Ruby | adedayoominiyi/aws-doc-sdk-examples | /ruby/example_code/s3/s3_ruby_bucket_cors.rb | UTF-8 | 4,176 | 2.65625 | 3 | [
"Apache-2.0",
"CC-BY-NC-SA-4.0"
] | permissive | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX - License - Identifier: Apache - 2.0
# Purpose
# This code example demonstrates how to add a cross-origin resource sharing (CORS)
# configuration containing a single rule to an Amazon Simple Storage Service (Amazon S3) bucket.
# snippe... | true |
772ed1d29316b0018d696df051e1ecf865d5ccae | Ruby | tinbka/rmtools | /lib/rmtools/rand/string.rb | UTF-8 | 2,920 | 3.015625 | 3 | [
"Ruby",
"MIT"
] | permissive | # encoding: utf-8
RMTools::require 'lang/ansi'
module RMTools
begin
require 'securerandom'
SecureRandom.random_bytes
Urandom = true
rescue
Urandom = false
end
Numbers = '0123456789'
Chars = 'abcdefghijklmnopqrstuvwxyz'
Alphanum = Chars + Chars.upcase + Numbers
ASCII_readable = '!"#$%&\'()... | true |
0fa266728a35d69c03a02967a8bee25cb319700c | Ruby | mikewang333/fa16-hw1 | /hw1.rb | UTF-8 | 455 | 3.140625 | 3 | [] | no_license | def squared_sum(a, b)
# Q1 CODE HERE
x = (a + b)
return x ** 2
end
def sort_array_plus_one(a)
# Q2 CODE HERE
a.sort!
a.map! { |x| x+1 }
a
end
def combine_name(first_name, last_name)
first_name + " " + last_name
end
def blockin_time(a)
# DO NOT EDIT THIS CODE BELOW
require './foobar'
Foobar.ba... | true |
0fafaa70dd6738fd21a5aed204cc75ed1e4ead9f | Ruby | drugpl/TypingHero | /lib/typing_hero/typing_hero.rb | UTF-8 | 1,696 | 3.34375 | 3 | [
"MIT"
] | permissive | module TypingHero
class TypingHero
attr_reader :visible_words, :available_words, :players
def initialize(available_words)
@available_words = available_words
@visible_words = [available_words.shift]
@players = []
@units_elapsed = 0
end
def start
end
def new_player_jo... | true |
5207911ddbca95928764de186c8647a9e0337ca5 | Ruby | rahulpatel2/exercism | /ruby/sieve/sieve.rb | UTF-8 | 257 | 3.109375 | 3 | [] | no_license | require 'prime'
# Program to generate List of prime no
class Sieve
def initialize(num)
@num = num
end
def primes
list_of_primes = []
(2..@num).each do |i|
list_of_primes << i if Prime.prime?(i)
end
list_of_primes
end
end
| true |
282a279d96ee84eddeabc89eb51e0651b217de12 | Ruby | JohnGeigerWS/regroup-online | /db/sessions.rb | UTF-8 | 7,196 | 2.859375 | 3 | [] | no_license | {
title: "Navigating Culture",
description: "Welcome to <%= ENV['SITE_NAME'] %> 15! Be sure to tune in to our very first session with our lead pastor, Andy Stanley. And join in on the conversation by following @DriveOnline15 on Twitter.",
permalink: "navigating-culture",
timeslot: 1,
type: "main",
finished:... | true |
3ef110fab7eb84138c25596bda161f6a082afaca | Ruby | silviofmv/resp-ruby-exercicio07 | /resposta-07.rb | UTF-8 | 1,108 | 3.46875 | 3 | [] | no_license | class Tamagushi
def initialize(nome, fome, saude, idade)
@nome = nome
@fome = fome
@saude = saude
@idade = idade
end
def alterarNome(nome)
@nome = nome
end
def alterarFome(fome)
@fome = fome
end
def alterarSaude(saude)
@saude = saude
end
def alterarIdade(idade)
@id... | true |
df2d396d96cd859ed9e36fb09d81f3c31d8666ac | Ruby | claudioveiga/Autom-SauceDemo | /spec/pages/_Item_page.rb | UTF-8 | 1,127 | 2.65625 | 3 | [] | no_license | require_relative('./_Base_page.rb')
class ItemPage < BasePage
attr_accessor :driver
def initialize(webDriver)
@driver = webDriver
end
# Mapeamento
# Mapeando itens
def text_nameItem
driver.find_element(:css, '#inventory_item_container > div > div > div > d... | true |
9b5eedcbd1d926b94f4f2a47c9e42fcacd025e31 | Ruby | tylermzeller/magic-cube | /src/CubeInstructions.rb | UTF-8 | 1,402 | 3.125 | 3 | [] | no_license | # Created October 20th, 2015
# Last modified October 21st, 2015
class CubeInstructions
def initialize(cube)
@cube = cube
end
private def execute(token)
case token
when "F"
@cube.F
when "F'"
@cube.FPrime
when "F2"
@cube.F2
... | true |
f5b77be5699fcf40b9af02fc4788797621c50525 | Ruby | lifecoderua/daily-status | /model/slack.rb | UTF-8 | 764 | 2.578125 | 3 | [] | no_license | require 'net/http'
class Slack
API_URL = 'https://slack.com/api/'
def initialize
@token = ENV['BOT_TOKEN']
end
def post(channel, text, attachments=[])
run 'chat.postMessage', {
channel: channel, # 'updates' || 'C492503HT' || 'U.....'
text: text,
attachments: attachments,
as_us... | true |
02e5d9d3c49106c3a35e92526ba3a0ec9ef8bdfd | Ruby | pshussain/Backup | /histogram.rb | UTF-8 | 839 | 3.09375 | 3 | [] | no_license | class Hash
define_method('histogram') do
res=count(self.values)
end
define_method('sort') do |result|
result.sort{|x,y| y[1] <=> x[1]}
end
def count(values)
all_values=values
compact_values=values.uniq
... | true |
f0764a066e002f411a12b2dd1889cef4b99e788f | Ruby | nysol/doc | /olddoc/mcmd/jp/examples/mkeybreak.rb | UTF-8 | 804 | 2.765625 | 3 | [] | no_license | #!/usr/bin/env ruby
# coding: utf-8
require "./mkTex.rb"
File.open("dat1.csv","w"){|fpw| fpw.write(
<<'EOF'
id,k1,k2,val
1,A,a,1
2,A,b,2
3,A,b,3
4,B,a,4
5,B,a,5
EOF
)}
############## 例1
title="基本例"
comment=<<'EOF'
\verb|k1|項目で並べ替えた後、\verb|k1|キー項目の先頭(\verb|top|項目)と終端(\verb|bottom|項目)に印(\verb|1|)をつける。
EOF
scp=<<'EOF'
m... | true |
d772bc8f75adfd0dfa840676f97e2ded9c6c58c2 | Ruby | stormbrew/channel9 | /environments/ruby/simple_tests/019.super.rb | UTF-8 | 231 | 3.734375 | 4 | [
"MIT"
] | permissive | class A
def blah(a, b)
puts "hi, #{a} and #{b}!"
end
end
A.new.blah(1, 2)
class B < A
def blah
super("what", "stuff")
end
end
B.new.blah
class C < A
def blah(a, b)
super
end
end
C.new.blah("woop", "zoop") | true |
72c98718ab2b1864286c75598b11e25251be4b91 | Ruby | nilesmc/coderbyte_ruby | /firstfactorial.rb | UTF-8 | 155 | 3.390625 | 3 | [] | no_license | def FirstFactorial(num)
count = 0
product = 1
num.times do
count += 1
product *= count
end
return product
end | true |
80333584ad3c20751012c91f0c9c26848d2c0b68 | Ruby | brupm/elasticsearch_ruby | /nested_filter_or_and.rb | UTF-8 | 686 | 2.515625 | 3 | [] | no_license | require 'tire'
require 'debugger'
Tire.configure { logger STDERR }
klass = Tire.index 'search' do
delete
store last: "ju", first: 'Kimberly', score: 10
store last: "ju", first: 'Maria', score: 45
store last: "ju", first: 'Beth', score: 88
store last: "ju", first: 'Carla', score: 95
refresh
end
s = Tire... | true |
c2b39614782f9db1f4f830033c39dc26351ae717 | Ruby | chemistrytocode/Makers-Academy | /Misc_Problems/Encapsulation/Calculator/spec/calculator_spec.rb | UTF-8 | 324 | 2.515625 | 3 | [] | no_license | require 'calculator'
describe Calculator do
describe '#add' do
it 'returns 10 when :add(5, 5) when is called' do
expect(subject.add(5, 5)).to eq 10
end
end
describe '#subtract' do
it 'returns 0 when :subtract(5, 5) is called' do
expect(subject.subtract(5, 5)).to eq 0
end
end
... | true |
c05cd77d7192d32a7ea3a488e79d684d4aaf6fbb | Ruby | AdanML/LPP_P7 | /lib/Fraccion.rb | UTF-8 | 451 | 3.78125 | 4 | [] | no_license |
class Fraccion
attr_reader :num, :denom
include Comparable
def mcd(x,y)
y == 0 ? x: mcd(y, x%y)
end
def mcm(x,y)
z = x / mcd(x,y) * y
end
def initialize(num, denom)
raise TypeError, "El denominador no puede ser cero" if denom.eql? 0
d = mcd(num, denom)
@... | true |
4c0fe776419f1b5d74483118a53532f5d3afb609 | Ruby | kerglis/scrabble.lv | /app/models/move.rb | UTF-8 | 944 | 2.71875 | 3 | [] | no_license | class Move < ActiveRecord::Base
belongs_to :game
belongs_to :player
has_many :game_chars
has_many :cells, through: :game_chars
acts_as_list scope: :game
include AASM
aasm(:state) do
state :new, initial: true
state :finished
event :finish, after: :finish_move do
transitions to: :f... | true |
7ae6edc411993cc15e22d1d138bdaa6f6b6fedf5 | Ruby | cloudycua/ttt-with-ai-project-v-000 | /bin/tictactoe_choose_token | UTF-8 | 3,287 | 3.75 | 4 | [] | no_license | #!/usr/bin/env ruby
require_relative '../config/environment'
# Greetings and Number of Players
puts "Welcome to Tic-Tac-Toe! What's your name?"
name = gets.strip
puts "Hello, #{name}! How many players will be playing Tic-Tac-Toe?"
number_of_players = gets.chomp.to_i
valid_number_of_players = [0, 1, 2]
while !valid_nu... | true |
1c547e1dff7cfbcf114004bf0d72701ccb3d620d | Ruby | Aram-Anderson/sorting_suite | /insertion/test/insertion_sort_test.rb | UTF-8 | 632 | 3.0625 | 3 | [] | no_license | require 'minitest'
require 'minitest/autorun'
require 'minitest/emoji'
require './lib/insertion_sort'
class InsertionSortTest < Minitest::Test
def test_it_exists
sorter = InsertionSort.new
assert_instance_of InsertionSort, sorter
end
def test_it_can_sort_letters
sorter = InsertionSort.new
inpu... | true |
a403119f1d47699d919417e6f67bc8f666a1174d | Ruby | prakashdwd/simple_calc | /main.rb | UTF-8 | 243 | 2.53125 | 3 | [] | no_license | require_relative 'calculator'
require_relative 'router'
require_relative 'parser'
calc = Calculator.new
while true
arg=String.new("")
arg=gets
parser = Parser.new(arg)
router = Router.new(parser.parse)
router.route(calc)
end
| true |
db8edb3076150a645ad862d5db1197555a5578dd | Ruby | kagamirr0r/Ruby | /at_coder/Substring.rb | UTF-8 | 195 | 3.0625 | 3 | [] | no_license | s = gets.chomp
t = gets.chomp
min = t.length
0.upto(s.length-t.length) do |i|
count = 0
t.length.times do |j|
count += 1 if s[i+j] != t[j]
end
min = count if count < min
end
puts min | true |
2de922d75d45e76bf96289ca659e328686c8ed7e | Ruby | aslakhellesoy/activerecord-sqlserver-adapter | /lib/dbi/row.rb | UTF-8 | 6,763 | 3.703125 | 4 | [] | no_license | require "delegate"
# The DBI::Row class is a delegate of Array, rather than a subclass, because
# there are times when it should act like an Array, and others when it should
# act like a Hash (and still others where it should act like String, Regexp,
# etc). It also needs to store metadata about the row, such as
# co... | true |
f230f73c6f493e09bf1c8e097dc11af8260f20f9 | Ruby | dcow/rpg | /Player.rb | UTF-8 | 912 | 3.234375 | 3 | [] | no_license | # Copyleft Alexander Marrs, marrsale@live.com
# website: http://marrsale.herokuapp.com
# Github: github.com/marrsale
require 'rubygems'
require 'gosu'
require './Gvals'
#Player is meant to be an non-directly interactable scoreboard
#Direct control of the game is relegated to activity types, e.g. Battle, Overworld
c... | true |
3549fb87e4af03710dd7a1b3dba93e5b616ce9af | Ruby | PhillipDMorrisJr/babble | /tile_group.rb | UTF-8 | 357 | 3.578125 | 4 | [] | no_license | class TileGroup
attr_accessor :tiles
def initialize()
@tiles = Array.new
end
def append(tile)
@tiles.push(tile)
end
def remove(tile)
tileIndex = @tiles.index(tile)
@tiles.delete_at(tileIndex)
end
def hand()
tileString=""
@tiles.each {|tile| tileString+= tile.to_s}
return tileString
end
def... | true |
2c81d300cc2a5640d029b79a57bcca96e8734c30 | Ruby | Enceradeira/FoodHeroWeb | /app/lib/search/domain/google_restaurant_search.rb | UTF-8 | 1,847 | 2.9375 | 3 | [] | no_license | module Search
module Domain
class GoogleRestaurantSearch
class << self
def google_max_search_radius
50000
end
def google_max_search_results
200
end
def google_price_level_min
0
end
def google_price_level_max
4
... | true |
669eb34f4c98ce40c9e87d2f8c00074973dda169 | Ruby | haanhduclinh/hell-stock | /lib/hell_stock/command/system.rb | UTF-8 | 1,089 | 2.734375 | 3 | [
"MIT"
] | permissive | module HellStock
module Command
class System
LIST_COMMANDS = Dir[::Settings.system_commands_path]
def initialize(command)
@command = command
yield(self) if block_given?
end
def run!
main_command = @command[1..-1]
command_type = []
LIST_COMMANDS.ea... | true |
b355f5a6e08f0d9d2ea68db8091f3c3f1d0d7863 | Ruby | HenryXV/exercism_ruby | /conditionals/assembly-line/assembly_line.rb | UTF-8 | 429 | 3.234375 | 3 | [] | no_license | class AssemblyLine
def initialize(speed)
@speed = speed
end
def production_rate_per_hour
production_rate = 221 * @speed
if @speed >= 5 and @speed <= 8
production_rate * 0.9
elsif @speed == 9
production_rate * 0.8
elsif @speed == 10
production_rate * 0.77
else
produ... | true |
851867b34ce68a0a19d21657bf477d7dc56c0e7d | Ruby | istewart13/homeworkw3d3 | /models/pet_shop.rb | UTF-8 | 1,413 | 2.984375 | 3 | [] | no_license | require('pg')
require_relative('pet')
require('pry-byebug')
class PetShop
attr_reader :name, :stock_type, :address, :pet_id
def initialize(options, runner)
@name = options["name"]
@address = options["address"]
@stock_type = options["stock_type"]
@runner = runner
@pet_id = options["pet_id"]
e... | true |
bd9dca0957f11fd9be30cd6cb14dfdf7aa21decf | Ruby | MastersAcademy/ruby-course-2020 | /olexandr.vakulinskiy/HW1/Task2/hash.rb | UTF-8 | 406 | 3.109375 | 3 | [] | no_license | p hash = {
'Yes' => 23,
'b' => 'travel',
'yesterday' => 34,
5 => '234',
yesss: :fg,
try: 30,
key: 'some value',
' yesterday1 '=> 34,
' yesteryear '=> 2014
}
keys = hash.transform_keys(&:to_s).keys
puts "Amount of ke... | true |
2bfe83db5832812b31f67868cb3100676cb4193d | Ruby | taylorthurlow/advent-of-code-2018 | /day5/part2.rb | UTF-8 | 497 | 3.359375 | 3 | [] | no_license | #!/usr/bin/env ruby
data = File.read('data.txt').chomp.chars
def react(chars)
loop do
result = chars.find_index.with_index { |c, i| c == chars[i + 1]&.swapcase }
if result
chars.delete_at(result)
chars.delete_at(result)
else
break
end
end
return chars.count
end
results = {}
... | true |
5c720ebb32f00c19f997d59d4c8a0bba0b81d8ac | Ruby | espadrine/pto-maximizer | /main.rb | UTF-8 | 651 | 3.125 | 3 | [] | no_license | require 'time'
require './optimizer'
longest_holidays = longest_pto(
start: Date.today,
stop: Date.today + 365,
pto_count: 35, # days
max_holiday_size: 20, # days
)
max_holidays = max_holiday_days(
start: Date.today,
stop: Date.today + 365,
pto_count: 35, # days
min_holiday_size: 4, # days
)
puts lon... | true |
564df48b7e87479b2c33e739212a51a6228a4c44 | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz76_sols/solutions/Gregory Seidman/scramble.rb | UTF-8 | 616 | 2.96875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
if /^(-[?])|(-h)|(-help)|(--help)$/ =~ ARGV[0] || ARGV.length > 1
$stderr.puts "Usage: #{$PROGRAM_NAME} [filename]"
exit 1
end
infile = $stdin
if ARGV.length == 1
infile = File.new(ARGV[0]) rescue begin
$stderr.puts("File not found: '#{ARGV[0]}'")
exit 2
end
end
tok_exp = /([a-zA-... | true |
0680c50859fc67df52cbdd89e7571b657f1aceea | Ruby | amittambe000/myappssample | /card.rb | UTF-8 | 495 | 3.125 | 3 | [] | no_license | require 'rspec'
class Card
def self.build(suit,rank)
new(suit:suit,rank:rank)
end
def initialize(suit:,rank:)
@suit=suit
@rank=case rank
when :jack then 11
when :queen then 12
when :king then 13
else rank
end
end
def suit
@suit
end
... | true |
0f216f9d71ded0b6178505e4ed7ba97643a8d3e1 | Ruby | VarvaraBabkova/GoT_trivia | /bin/q3.rb | UTF-8 | 819 | 3.40625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def q3(prompt)
c_ids = Character.characters_that_has_culture
random_id2 = c_ids[rand(c_ids.length)]
correct_ans = Character.which_culture_character_is(random_id2)
ans = [correct_ans]
num = 0
while num < 4
i=rand(Character.all_cultures.length)
if !ans.include? (Character.all_cult... | true |
abe92e8a8ebf5f0bb5a28283519e78f6a8c6f7e8 | Ruby | likawoods/learn-rails | /app/models/owner.rb | UTF-8 | 263 | 3.03125 | 3 | [] | no_license | class Owner
def name
name = 'Foobar Kadigan'
end
def birthdate
birthdate = Date.new(1990,9,22)
end
def countdown
today = DateTime.now
birthday = Date.new(today.year, self.birthdate.month, self.birthdate.day)
countdown = (birthday - today).to_i
end
end | true |
61c19b89c0e2d3ba932d87a903e7aa405c41f222 | Ruby | jkshareef/badges-and-schedules-seattle-web-career-042219 | /conference_badges.rb | UTF-8 | 788 | 3.9375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def badge_maker(name)
"Hello, my name is #{name}."
end
def batch_badge_creator(array)
arr = Array.new
for name in array
arr.push(badge_maker(name))
end
arr
end
#def assign_rooms(array)
# arr = []
#counter = 1
#for name in array
# arr.push("Hello, #{name}! You'll be assign... | true |
8217ea51081ca8c13b2b43eec03a49ac7463ff21 | Ruby | Wowip/Repo | /Ejemplos del libro/array_of_ten.rb | UTF-8 | 137 | 4.125 | 4 | [] | no_license | class Array
def array_of_ten
(1..10).to_a
end
end
arr = Array.new
ten = arr.array_of_ten
p ten # => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
| true |
e01c36e9873138f490e90489e8ee5d3ab7939787 | Ruby | anithri/ate_8 | /app/models/game/seat.rb | UTF-8 | 750 | 2.578125 | 3 | [] | no_license | module Game
class Seat
attr_reader :player, :board_space, :board
DEFAULT_SEAT = {
worker_ids: [].freeze,
version: '1.0.0'.freeze
}.freeze
def initialize(player, board)
@player = player
@board = board
@board_space = board[player.slug]
end
delegate... | true |
e8ab355971e9e38d7ee8111e366d8565aa4ced8f | Ruby | Daivasmara/head_first_ruby | /chapter_04/employee.rb | UTF-8 | 1,001 | 3.640625 | 4 | [] | no_license | class Employee
attr_reader :name
def initialize(name = 'Anonymous')
self.name = name
end
def name=(name)
if name == ''
raise "Name can't be blank!"
end
@name = name
end
def print_name
puts "Name: #{name}" # without explicitly specify receiver, default receiver is the current ob... | true |
437a1adb2fd00c14be11778c168ce3a1b031fab1 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/gigasecond/a05185924a1a484cb87e2215690048e6.rb | UTF-8 | 245 | 2.75 | 3 | [] | no_license | class Gigasecond
def self.from(a_date)
gigaseconds = 10 ** 9
seconds_since_epoch = a_date.to_time.to_i
gs_seconds = seconds_since_epoch + gigaseconds
gigaseconds_date = Time.at(gs_seconds).to_date
end
end
| true |
c5f8cf044df7931fd1b592ab34dd773fa4dbfde4 | Ruby | Ianwaterski/phase-0 | /week-5/die-class/my_solution.rb | UTF-8 | 2,187 | 4.5625 | 5 | [] | no_license | # Die Class 1: Numeric
# I worked on this challenge [by myself]
# I spent [1.5] hours on this challenge.
# 0. Pseudocode
# Input: A number of sides for the object
# Output: A random number in the range to that object from 1.
# Steps: define a new class die, that accepts an input of how many sides. Once the number o... | true |
7fe8ae9c378c7e80e2af104f19e81451653bd3a0 | Ruby | digideskio/rletters | /app/models/documents/stop_list.rb | UTF-8 | 1,286 | 2.578125 | 3 | [
"MIT",
"BSD-3-Clause",
"Apache-2.0"
] | permissive |
# Code for objects belonging to documents
module Documents
# A list of common words to exclude from analysis
#
# We often need to remove commonly occurring words from bodies of text for
# analysis purposes. To make that process easy, we seed lists of those words
# into the database.
#
# @!attribute lang... | true |
4004ab7ea699756b3a278df8e8a7a8d46a575a88 | Ruby | CorruptedPhazite/cobalt-cluster | /src/helper/tags.rb | UTF-8 | 6,544 | 2.75 | 3 | [] | no_license | # Module: Tags
# Friendly wrapper for Tag entries.
class UserTag
# Construct a new UserTag.
def initialize(hash)
@tag_name = hash[:tag_name]
@item_entry_id = hash[:item_entry_id]
@owner_user_id = hash[:owner_user_id]
@tag_content = hash[:tag_content]
end
# Get the tag's name/invocation ... | true |
a1a3406970a57126ce3a51b716532b7c99119453 | Ruby | seanyen0507/web_scraper | /bin/application.rb | UTF-8 | 881 | 3.25 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# require '../lib/NBA_info/NBA_info_ex.rb'
require 'NBA_info'
sam = Scraper.new
puts "Enter 1 to see starting lineup today, enter 2 to see any player's "\
'profile you want.'
control = gets.chomp
control = control.to_i
if control == 2
puts "Which player's profile you want to see?"
name = gets... | true |
517c4de6ef10abfd53a9dacb68e1d36c847dfc10 | Ruby | ecksma/wdi-darth-vader | /05_full_stack_sinatra/d02/Sonju_Walker/morning_models/app.rb | UTF-8 | 629 | 2.671875 | 3 | [] | no_license | require 'bundler'
Bundler.require
# connecting to a database using ActiveRecord
ActiveRecord::Base.establish_connection(
:adapter => "postgresql",
:database => "vader"
)
require './StudentsModel'
get '/' do
'hi'
end
get '/allstudents' do
Students.all.to_json
end
# RETURNED student table & converted to jso... | true |
f4c9b962d7a82bfdca88564c8195add1d0c2479a | Ruby | timgluz/muhv | /lib/muhv/cli.rb | UTF-8 | 2,835 | 2.578125 | 3 | [] | no_license | require 'thor'
require 'muhv/generators'
module Muhv
# this glass combines and calls sub generators
class Cli < Thor
DEFAULT_SERVICE_TARGET_PATH = 'app/services'.freeze
DEFAULT_SERVICE_SPEC_PATH = 'spec/services'.freeze
DEFAULT_SERVICE_FILE_EXT = 'rb'.freeze
check_unknown_options!
desc 'versi... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.