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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
040fd428221834255ec4b60ce9e44db8ca00cbb2 | Ruby | NcUltimate/BasicAlgos | /ruby/sorting_algos.rb | UTF-8 | 4,417 | 3.53125 | 4 | [] | no_license | class Algorithms
class Sorting
class << self
############################
# RUBY SORT
# The system O(nlogn) sort.
def ruby_sort(ary)
ary.sort
end
############################
# BUBBLE SORT
# Your textbook O(n^2) sort.
def bubble_sort(ary)
ret... | true |
e17db55856ddba42629553a2f31547e7d737259c | Ruby | yasslab/ruby-metaprogramming-tokyo | /quizzes/2.dynamic_methods/data_source.rb | UTF-8 | 733 | 3.3125 | 3 | [] | no_license | # This is just the test for the Computer class. Don't modify this file!
# Imagine that this is a class in a library that you cannot change.
# Read the exercise instructions in computer.rb.
class DS
def initialize
# connect to data source...
end
def get_cpu_info(workstation_id)
"2.9 Ghz quad-core"
end
... | true |
1e9de08140e15e946192a91cd23b60b66ca2bd0b | Ruby | Day-101/scrap_crazy | /lib/03_cherdepute.rb | UTF-8 | 884 | 2.796875 | 3 | [] | no_license | require 'rubygems'
require 'nokogiri'
require 'open-uri'
a = []
def profile(url)
begin
page = Nokogiri::HTML(URI.open(url))
identity = {first_name: page.xpath("/html/body/div/div[3]/div/div/div/section[1]/div/article/div[2]/h1").text.split[1],
last_name: page.xpath("/html/body/div/div[3]/div/div/div/section[1]/div... | true |
af106cef1d4655346918733603c905a12069e2b2 | Ruby | xtone/programming-contest | /20140602_MinesweeperMaster/take/main.rb | UTF-8 | 2,572 | 3.375 | 3 | [] | no_license | require 'pp'
casecount = 0
cases = []
open( ARGV[0] ) {|f|
casecount = f.gets.to_i
casecount.times {
cases.push(f.gets.split(' ').map{|s| s.to_i })
}
}
def solve(r,c,m)
cells = Array.new(r){Array.new(c){'.'}}
# 地雷が無い場合はどこでもよい
if m == 0
cells[0][0] = 'c'
return cells
end
# 1つ以外地雷の場合は全て埋めてどこか一つだけクリック
... | true |
1089433459aab8122ebb5de6ed8c3dd044a4a0a8 | Ruby | fastlogin/funny-lol | /api-server/lib/external/riot.rb | UTF-8 | 3,822 | 2.609375 | 3 | [] | no_license |
require 'http'
require 'json'
require 'http_exceptions'
##
# Riot API
#
# @author: George Ding (gd264)
# @description: Ruby object to interface with and interact with the Riot API. This object was made
# to abstract out API calls for ease of use. Also allows for easy modular implementation for any
# part of the code ... | true |
29e01402760fa2db9f79098dbdb359ae453dcc81 | Ruby | damaneice/-supermarket-pricing | /lib/checkout.rb | UTF-8 | 540 | 3.234375 | 3 | [] | no_license | class Checkout
def initialize rules
@items = {}
@rules = rules
end
def scan item
if @items[item].nil?
@items[item] = 0
end
@items[item] = @items[item] + 1
end
def total
price = 0
@items.each_pair do | item, qty |
(1..qty).each do | i |
price = price +... | true |
030a8cd1ff2a7cc6726ea1944e0f6d6d43d109f2 | Ruby | pturley/Setlist | /app/models/setlist_websocket_server.rb | UTF-8 | 1,116 | 2.75 | 3 | [] | no_license | require 'eventmachine'
require 'em-websocket'
class SetlistWebsocketServer
@@websocket_connections = []
def self.start(host, port=8080)
@@pid ||= fork do
EM.run {
@@websocket_connections = []
EM::WebSocket.start( :host => host, :port => port ) do |socket|
sock... | true |
84936be3850a9e38a7bbabf463eba90be47e5dd1 | Ruby | Nabox68/Mardi13-projet | /exo_17.rb | UTF-8 | 285 | 3.703125 | 4 | [] | no_license | puts "Quel est ton âge ?"
age = gets.chomp
age = age.to_i
naissance = 0
age.times do
naissance +=1
age -=1
if age < naissance || age > naissance
puts "Il y #{age} ans, tu avais #{naissance} ans"
else
puts "Il y a #{age}ans, tu avais la moitié de l'âge que tu as aujourd'hui"
end
end | true |
b02b3d56745b9f8dab22fcd9bb52c5fda4e78bc1 | Ruby | chrisgonzgonz/student-orm | /app.rb | UTF-8 | 623 | 2.71875 | 3 | [] | no_license | require 'sqlite3'
require 'sinatra/base'
require './lib/models/student.rb'
# Why is it a good idea to wrap our App class in a module?
module StudentSite
class App < Sinatra::Base
get '/' do
"hello world!"
end
get '/students' do
@students = Student.all
erb :students
end
get '... | true |
21281dcb09ef5605d31f3669ebcb78d75262744a | Ruby | sachiko0811/React_on_Rails_Eats | /app/controllers/api/v1/line_foods_controller.rb | UTF-8 | 7,671 | 2.59375 | 3 | [] | no_license | # --- ここから追加 ---
module Api
module V1
class LineFoodsController < ApplicationController
before_action :set_food, only: %i[create replace] #before_actionではそのコントローラーのメインアクションに入る"前"に行う処理を挟める -> callback
def index
line_foods = LineFood.active # 全てのLineFoodモデルの中から、activeなものを取得し、line_foodsという変数に代入
... | true |
e88f94068fc4406f3bcbd297675ce9d21a031b10 | Ruby | PLOS/rich_citations_processor | /lib/rich_citations_processor/uri_resolvers/uris_from_reference.rb | UTF-8 | 2,349 | 2.53125 | 3 | [
"MIT"
] | permissive | # Copyright (c) 2014 Public Library of Science
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, pub... | true |
ea8bf77a464aa4992000ed9ea9938ae89becbd5f | Ruby | md1961/ruby | /unit_test/lib/test_reverse_line_reader.rb | UTF-8 | 1,275 | 3.21875 | 3 | [] | no_license | # vi: set fileencoding=utf-8 :
require 'test/unit'
require 'reverse_line_reader'
require 'stringio'
class TestReverseLineReader < Test::Unit::TestCase
def test_empty_file
data = ''
actual_lines = read_lines_with_ReverseLineReader(data)
assert_equal(0, actual_lines.size, "Number of lines")
end
... | true |
065ca4ead10d796f2ec319541510b2289aa01cf3 | Ruby | Bartlebyy/Iron_Yard_Projects | /Day_2/Hangman.rb | UTF-8 | 1,178 | 3.828125 | 4 | [] | no_license | Hangman Design
If the computer is creating, it needs a database, with a list of words or
phrases that it can use as its word. Maybe a hint for each one. (Dictionary
would be a good place to start). Maybe booktitles. And then use a random readline to get the word.
Ideally it would have graphics.
I would make a metho... | true |
d575af8dc53dd934a8ffe13148d0b39d9cee914c | Ruby | tiborh/ruby | /sort_words.rb | UTF-8 | 343 | 4.125 | 4 | [] | no_license | #!/usr/bin/env ruby
def sort_string(string)
string.downcase.split.sort.join(" ")
end
def sort_string_by_length(string)
string.split.sort{|a,b| a.length <=> b.length}.join(" ")
end
s1 = "Sort words in a sentence"
puts sort_string(s1)
puts sort_string_by_length(s1)
s2 = 'Awesome I am'
puts sort_string(s2)
puts sor... | true |
4cfc5b22a4b32b282433e996f97522567ed46fbf | Ruby | theoluyi/ruby-project-alt-guidelines-dumbo-web-010620 | /lib/command_line_interface.rb | UTF-8 | 489 | 3.15625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class CommandLineInterface
attr_accessor :dev, :action, :result
def run
greet
whats_your_name
end
def greet
puts "Initializing new software developer... "
sleep 1.5
puts "Wake up!!!"
end
def whats_your_name
prompt = TTY::Prompt.new
d... | true |
81a6299d5d7827b05bd5c307f56b424dc48bde4f | Ruby | wangjoc/betsy | /test/models/product_test.rb | UTF-8 | 5,370 | 2.78125 | 3 | [] | no_license | require "test_helper"
describe Product do
describe "validations" do
describe "name validation" do
it "is invalid without a title" do
product = products(:diaper)
product.name = nil
# Act
result = product.valid?
# Assert
expect(result).must_equal false
... | true |
cd0ae9b74db46a646cb906090c6409ee84938dfc | Ruby | jnikelski/beagle | /beagle_run_initialization | UTF-8 | 3,884 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env ruby
# ==============================================================================
# Purpose:
# This is the first script in the Loris pipeline. Its purpose is to
# set up all output directories, and initialize them with a smattering
# of required files.
#
# =====================================... | true |
1db7e7538579445fe975ba9ce4e40a78bf57b702 | Ruby | ohookins/pmacctstats | /lib/summarise.rb | UTF-8 | 11,218 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'active_record'
require 'ipaddr'
require 'bigdecimal'
require 'inifile'
require 'app/models/pmacct_entry'
require 'app/models/usage_entry'
require 'app/models/host'
class NoConfFileError < Exception; end
class UnreadableConfFileError < Exception; end
class MissingConfSectionError < Exception... | true |
fc8ab70c943c6b2d73ea45a1030d6066a0fa4d42 | Ruby | ckennington/cs404 | /src/ruby/no_return.rb | UTF-8 | 212 | 2.75 | 3 | [] | no_license | def no_return
# straight up expression, no variables or nothin'.
10 + 10
# notice there's no return statement.
# 20 gets return automatically because it was the last eval'd expression
end
puts no_return
| true |
6219e60cc3c4dbc05b19d0c62c62d6fb7f9fd430 | Ruby | acltc-the-el-ninos/whirlwind-ruby | /test.rb | UTF-8 | 470 | 3.765625 | 4 | [] | no_license | class Song
attr_reader :lyrics
attr_writer :lyrics
def initialize(input_lyrics)
@lyrics = input_lyrics
end
def play
`say "#{@lyrics}"`
end
# def set_lyrics(input_lyrics)
# @lyrics = input_lyrics
# end
# def lyrics
# @lyrics
# end
end
song = Song.new("hello is it me you're lookin... | true |
c2f4a601fbd623e2eaa9d6e34b58530714a34c57 | Ruby | mzsanford/twitter-search | /lib/trends.rb | UTF-8 | 718 | 2.84375 | 3 | [
"MIT"
] | permissive | module TwitterSearch
class Trend
VARS = [ :query, :name ]
attr_reader *VARS
def initialize(opts)
VARS.each { |each| instance_variable_set "@#{each}", opts[each.to_s] }
end
end
class Trends
VARS = [:date, :exclude_hashtags]
attr_reader *VARS
include Enumerable
d... | true |
393671ceabd4f6056cf164d329edfa98a2bf9e6c | Ruby | moranja/Cocktailor | /app/models/Ingredient.rb | UTF-8 | 1,205 | 2.90625 | 3 | [] | no_license | class Ingredient < ActiveRecord::Base
has_many :recipe_ingredients
has_many :recipes, through: :recipe_ingredients
has_many :user_ingredients
has_many :users, through: :user_ingredients
validates :name, uniqueness: true
def amount
self.recipe_ingredient.amount
end
def amount=(amt)
self.recipe... | true |
9c516aeceddf01d977c38f06daa0f40ccde5e929 | Ruby | vjdhama/twitchblade | /spec/twitter/timeline_model_spec.rb | UTF-8 | 935 | 2.5625 | 3 | [] | no_license | require "spec_helper"
module Twitter
describe "TimelineModel" do
def get_id(name)
Connection.open.exec("select uid from users where username = '#{name}'").getvalue(0, 0)
end
before(:each) do
name = "vjdhama"
password = "password"
Connection.open.exec("begin")
Co... | true |
d71717fe86c7b11c9c15eb3d24e3c334bbf33f1d | Ruby | TeamGambit/Chessapp | /app/models/knight.rb | UTF-8 | 334 | 2.984375 | 3 | [] | no_license | class Knight < Piece
def valid_move?(x, y)
# Knight has no concern for obstruction, only check required is valid move of spaces.
return true if (self.x_position - x).abs == 2 && (self.y_position - y).abs == 1
return true if (self.x_position - x).abs == 1 && (self.y_position - y).abs == 2
return false... | true |
9a59eb0ae125b4786b94aa25b64e779d7345cab7 | Ruby | IndianGuru/RPCFN10 | /18_MichaelCramm/app.rb | UTF-8 | 1,204 | 3.359375 | 3 | [] | no_license | require 'day'
require 'business_hours' # renamed by ashbb
require 'time'
hours = BusinessHours.new("9:00 AM", "3:00 PM")
hours.update :sun, "9:00 AM", "10:45 AM"
hours.update :mon, "7:46 AM", "4:00 PM"
hours.update :thu, "10:00 AM", "12:01 PM"
hours.update "Dec 24, 2009", "11:00 AM", "2:00 PM"
hours.closed :tue, :we... | true |
08c7205d85567f15ab5a921c84b53f93da9bf466 | Ruby | Turzhanskyi/thoughtbot | /fundamentals-of-TDD/step-02/calculator.rb | UTF-8 | 677 | 3.75 | 4 | [] | no_license | # frozen_string_literal: true
require 'rspec/autorun'
class Calculator
def add(first_number, second_number)
first_number + second_number
end
def factorial(number)
if number.zero?
1
else
(1..number).reduce(:*)
end
end
end
describe Calculator do
describe '#add' do
it 'returns... | true |
1ffa21255765e2b4b99cf54ddb02eeea3c8556e6 | Ruby | t-mangoe/get_favorite_tweets | /get_favorite_tweets.rb | UTF-8 | 2,798 | 2.953125 | 3 | [] | no_license | #!/usr/bin/env ruby
require './twitter_client.rb'
require 'open-uri'
class GetFavoriteTweets
def initialize
@client = TwitterClient.new
@picture_counter_hash
end
def fetch(url)
p url
html = open(url)
body = html.read
mime = html.content_type
return body, mime
end
def check_pic... | true |
e27b6e2c54ffd83e535e7a94c34933e216ddcd26 | Ruby | kbrock/benchmark-sweet | /lib/benchmark/sweet.rb | UTF-8 | 3,805 | 2.875 | 3 | [
"MIT"
] | permissive | require "benchmark/sweet/version"
require "benchmark/sweet/ips"
require "benchmark/sweet/memory"
require "benchmark/sweet/queries"
require "benchmark/sweet/job"
require "benchmark/sweet/comparison"
require "benchmark/sweet/item"
require "benchmark/ips"
module Benchmark
module Sweet
def items(options = {memory: t... | true |
6125c3ffa57f41c4f88f8502234f6121402721db | Ruby | Sadeshakur/dev | /kilos_to_pounds.rb | UTF-8 | 594 | 4.03125 | 4 | [] | no_license | # Read in a weight from Standard input (in kilos)
$stdout.puts("Please input the weight of your puppy, in kilos?")
# weight in kilos
weight_in_kilos=$stdin.gets.to_i
# print out puppy's weight in kilos
weight_in_lbs = 2.20462 * weight_in_kilos
# convert in pounds
# data type comes in as string so need to turn weight in... | true |
2f0dcf6475562e3efd710b3b594d3c6284a0c9f2 | Ruby | ytorii/cyclepark_rails | /app/models/multi_seals_update.rb | UTF-8 | 1,398 | 2.640625 | 3 | [] | no_license | # Model for updating multiple seals.
class MultiSealsUpdate
include ActiveModel::Model
include StaffsExist
attr_accessor :sealed_date
attr_accessor :sealsid_list
attr_accessor :staff_nickname
date_format =
%r(\A20[0-9]{2}(/|-)(0[1-9]|1[0-2])(/|-)(0[1-9]|(1|2)[0-9]|3[01])\z)
# All parameters are req... | true |
6656c135c05d41ec31741dbbecc27f3cb1892b88 | Ruby | leedu708/assignment_toh | /procedural_ToH.rb | UTF-8 | 3,127 | 4.21875 | 4 | [] | no_license | class TowerOfHanoi
def initialize(num_disks)
@disks = num_disks
end
def start_game
# introductory message
puts "Welcome to Tower of Hanoi"
puts "Instructions:"
puts "Enter where you'd like to move disks from a column and to another column in the format [1,3]. Enter 'q' to quit."
end
de... | true |
95e5c81ce748ea47bd4d537db5eedf7091c12dac | Ruby | sandiks/Trader_bot | /lib/arr_helper.rb | UTF-8 | 471 | 3.09375 | 3 | [] | no_license | class Array
def sum
inject(0.0) { |result, el| result + el }
end
def mean
sum / size
end
end
class Time
def to_datetime
# Convert seconds + microseconds into a fractional number of seconds
seconds = sec + Rational(usec, 10**6)
# Convert a UTC offset measured in minutes to one measured... | true |
22b4c013d6a2b607752b0c5cf0c1cd892ac3b796 | Ruby | Ecthelion3/codaisseur-week1 | /day3/exercise3.rb | UTF-8 | 106 | 2.984375 | 3 | [] | no_license | loop do
puts "Got all ingredients you need?"
all_ingredients = gets.chomp
if all_ingredients == "Y"
end | true |
2bfa1f9cd6226116b5c296d27f742875dd62ac30 | Ruby | gavdaly/Deleted-Appointment-Finder | /find_patient.rb | UTF-8 | 501 | 2.78125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'fileutils'
include FileUtils
# A quick little ruby script that
# goes through every file in the log/'subdirectory'
# and matches the arguments for each patient ID
def find_id(value)
Dir['logs/**/*'].each do |name|
unless File.directory?(name)
File.open(name, 'r').each_line d... | true |
51859286e0ed6109a03917ebccc8bd1751c30342 | Ruby | tchryssos/reverse-each-word-001-prework-web | /reverse_each_word.rb | UTF-8 | 346 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # def reverse_each_word(sentence)
# split_array=sentence.split(" ")
# reverse_array=[]
# split_array.each do |word|
# reverse_array<<word.reverse!
# end
# reverse_array.join(" ")
# end
def reverse_each_word(sentence)
split_array=sentence.split(" ")
split_array.collect { |word|
word.reverse!
}
... | true |
0a2dab9463392ecaf584078432be9290d6549720 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/series/76960f2a39c846bd894ce9a08d3ed491.rb | UTF-8 | 298 | 3.390625 | 3 | [] | no_license | class Series
def initialize(digits)
@digits = digits.split(//).map { |d| d.to_i }
end
def slices(length)
raise ArgumentError if length > @digits.length
0.upto(@digits.length - length).each_with_object([]) do |index, array|
array << @digits[index, length]
end
end
end
| true |
34c631af5b1ac8fed11d1838a2bee6fb4c1df9bb | Ruby | keatongreve/modiflow_bots | /notification-checker/notif.rb | UTF-8 | 2,303 | 2.859375 | 3 | [] | no_license | #!/usr/bin/env ruby
# Corrects the names (and values) of NSNotification names to match the format Notif[UniqueIdentifer],
# which adheres to the modi style guide.
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
source_extensions = [".h", ".m", ".c", ".swift", ".cpp"]
path = A... | true |
eadf99c98783350614d16787cd43b341ed00e33b | Ruby | simonoff/bank | /spec/bic_spec.rb | UTF-8 | 1,235 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
RSpec.describe Bank::BIC do
let(:bic) { ::Bank::BIC.new('ABNACHZ8XXX') }
it 'returns the right bank code' do
expect(bic.bank_code).to eq 'ABNA'
end
it 'returns the right country code' do
expect(bic.country_code).to eq 'CH'
end
it 'returns the right location code' do
exp... | true |
aab1cb21804065a7a650c089c0811a1bbbfb3e67 | Ruby | joviane/streaming | /app/models/fila.rb | UTF-8 | 335 | 2.734375 | 3 | [] | no_license | require 'observer'
class Fila
include Singleton
def initialize
@observers = []
end
def notifica(noticia)
notify_observers(noticia)
end
def notify_observers(noticia)
@observers.each do |observer|
observer.update(noticia)
end
end
def add_observer(observer)
@observers << obse... | true |
fbc910e482b40779309a51ba909c38a9eef14d8b | Ruby | little-chi-mai/seic43-homework | /Priyanka Patel/week_4/accounts/main.rb | UTF-8 | 3,915 | 2.609375 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
require 'active_record'
require 'sqlite3'
require 'pry'
# Rails will do all this for you automatically:
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => 'database.sqlite3'
)
# Optional bonus:
ActiveRecord::Base.logger = Logger.new(STDERR)
# ... | true |
bba400b93fcf949138f53a6c5e17972f9e93c954 | Ruby | pjmorse/mbta-api | /lib/mbta/mode.rb | UTF-8 | 361 | 2.734375 | 3 | [
"MIT"
] | permissive | module Mbta
class Mode
attr_accessor :route_type, :mode_name, :routes
def initialize(data_hash)
@raw_data = data_hash
@route_type = data_hash["route_type"]
@mode_name = data_hash["mode_name"]
@routes = data_hash["route"]
end
def show_routes
@routes.map { |route| Mb... | true |
454619a6e807f7502507c29af49315d16eb2c1de | Ruby | ondreian/Olib | /lib/Olib/combat/metadata.rb | UTF-8 | 436 | 2.671875 | 3 | [] | no_license | class Creatures
module Metadata
@repo = JSON.parse File.read File.join(__dir__, "creatures.json")
def self.put(name:, level:, tags: [])
@repo[name.downcase] = {name: name, level: level, tags: tags}
end
def self.get(name)
@repo.fetch(name.downcase) do {name: name, level: Char.level, tags:... | true |
84353012a6ebdb257aeffa16102eaa36467c181e | Ruby | mmanousos/ruby-small-problems | /challenges/advanced1/02_pythagorean_triplet/triplet.rb | UTF-8 | 714 | 3.609375 | 4 | [] | no_license | class Triplet
attr_reader :numbers
def self.where(min_factor:1, max_factor:, sum:nil)
triplets = create_triplet_objects(min_factor, max_factor)
if sum
triplets.select { |trio| trio.pythagorean? && trio.sum == sum }
else
triplets.select { |trio| trio.pythagorean? }
end
end
def sel... | true |
f5f8e62de25c70d8923961734a39f68fa05e92a5 | Ruby | ianderse/roguelike | /lib/fov.rb | UTF-8 | 7,560 | 3.125 | 3 | [] | no_license | #Shamelessly copied from: http://www.roguebasin.com/index.php?title=Ruby_precise_permissive_FOV_implementation
#Because math
module PermissiveFieldOfView
# Determines which co-ordinates on a 2D grid are visible
# from a particular co-ordinate.
# start_x, start_y: center of view
# radius: how far field ... | true |
f186c6ca868779d672a8929df826dc9f847c96d6 | Ruby | EulaConstellar/greentusk | /app/actions.rb | UTF-8 | 3,721 | 2.515625 | 3 | [] | no_license | ##
# Copyright 2012 Evernote Corporation. All rights reserved.
##
require 'shotgun'
require 'sinatra'
require 'byebug'
require_relative "../evernote_config"
require_relative 'helpers'
before "/editor/?" do
redirect '/' unless session[:access_token]
end
get '/editor/?' do
erb :'editor'
end
##
# Index page
##
get... | true |
319521563a498f4d844f8389e8e7fa8cc67c50f1 | Ruby | afide26/studio_game | /lib/berserk_player_spec.rb | UTF-8 | 644 | 3.015625 | 3 | [] | no_license | require_relative "berserk_player"
describe "BerserkPlayer" do
before do
initial_health = 50
@player = BerserkPlayer.new("berserker", @initial_health)
end
it "does not go berserk when wooted upto 5 times" do
1.upto(5) {@player.w00t}
expect(@player.berserk?).to be_falsey
end
it "goes... | true |
a07c45e2c2d829c2b33facb381abc648efc6f145 | Ruby | gabriel376/exercism | /ruby/boutique-inventory/boutique_inventory.rb | UTF-8 | 503 | 3.3125 | 3 | [] | no_license | class BoutiqueInventory
def initialize(items)
@items = items
end
def item_names
@items.map{|item| item[:name]}.sort
end
def cheap
@items.filter{|item| item[:price] < 30}
end
def out_of_stock
@items.filter{|item| item[:quantity_by_size].empty?}
end
def stock_for_item(name)
@item... | true |
56ab2c5470463b165c57b76166d7ee7ff5effeb5 | Ruby | Miel2000/pyramide | /exo_07_c.rb | UTF-8 | 386 | 3.171875 | 3 | [] | no_license | user_name = gets.chomp
puts user_name
# a) dit bonjour, prend l'information qui suit et la stock dans user_name puis la renvoi dans le terminal
# b) dit bonjour, demande l'information avec un >, prend l'information et la stock dans user_name puis la renvoi dans le terminal
# c) dit pas bonjour (...), prends la prochai... | true |
42eec7056f6bd8c82d4fd7864f892b0f34bf38d4 | Ruby | sometimesfood/ldumbd | /db/migrations/005_set_uid_and_gid_start_value.rb | UTF-8 | 1,838 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def set_min_max_value_commands(dbtype, min, max)
case dbtype
when :postgres
options = "start #{min} restart #{min} minvalue #{min} maxvalue #{max}"
["alter sequence users_id_seq #{options};",
"alter sequence groups_id_seq #{options};"]
when :sqlite
id = min-1
name = '#dummyname#'
dir = '#... | true |
004e179ef80deed191bae13ed29fac85d65f9907 | Ruby | marklombardinelson/user-input-statistics | /hello_world.rb | UTF-8 | 498 | 4.4375 | 4 | [] | no_license | # keep track of to numbers , one is total, and the other is count. both are now 0.
total = 0
count = 0
# ask for a number.
loop do
puts "give me a number"
input = gets.chomp
# If that nuber is blank, stop asking for numbers.
if input == ""
break
end
# add that number to total
total += input.to_f
#... | true |
eb1f466c1738c60bd00cf5a3e7b4c22d9c0110ba | Ruby | possumtale/ruby-challenges | /hello_world_spec.rb | UTF-8 | 698 | 2.765625 | 3 | [] | no_license | # we need to tell Rack (remember what Rack is?) that we are just testing.
# normally this is 'development'
ENV['RACK_ENV'] = 'test'
# look in this directory!
$:.unshift File.join(File.dirname(__FILE__))
require 'index' # <-- your sinatra app
# require testing gems
require 'rspec'
require 'rack/test'
describe 'Our H... | true |
e1449b06d715729f75e067f48ff733b48d027338 | Ruby | Gues1211/rack-responses-lab-v-000 | /app/application.rb | UTF-8 | 259 | 2.828125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Application
def call(env)
resp = Rack::Response.new
time = Time.now.hour
# time2 = Time.new(2017, 10, 16, 12, 00, 00)
if time < 12
resp.write "Morning"
else
resp.write "Afternoon"
end
resp.finish
end
end
| true |
e98de1064549198be87a7dff50b5fbc8a93205ff | Ruby | joshuawootonn/caesar_cipher | /caesar_cipher.rb | UTF-8 | 574 | 2.8125 | 3 | [] | no_license | require 'sinatra'
#require 'sinatra/reloader' if development?
get '/' do
erb :index
end
get '/submit' do
post = params[:post]
@word = params['word']
@shift = params['shift']
@shifted_word = caesar_cipher(@word,@shift.to_i)
erb :index
end
def caesar_cipher( words , shift )
encoded_msg = ""
... | true |
54f0deab5ef1ae673c7a30d4f10f870a7d696a13 | Ruby | ericfirth/app_academy_projects | /checkers/player.rb | UTF-8 | 910 | 3.75 | 4 | [] | no_license | class HumanPlayer
attr_reader :color
def initialize(color)
@color = color
end
def play_turn(board)
board.display
puts "It's your turn #{color.to_s.capitalize}"
from = get_input("Which Piece do you want to move?")
to = to_input("Where to? If its multiple moves, seperate them by a space")
... | true |
e685d1588d05fef42275edf774af8b9ee7b9e055 | Ruby | dmalyuta/config-public | /.my_scripts/tmux/tmux-list-words | UTF-8 | 2,663 | 2.890625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# frozen_string_literal: true
# Copied from
# https://github.com/junegunn/dotfiles/blob/master/bin/tmuxwords.rb
require 'optparse'
require 'set'
require 'English'
# NOTE(infokiller): splitting by \W will also split by dashes and dots which are
# often part of valid identifiers, so we also do spli... | true |
201f16e9659fb9330a9f582d3750c8fef2492990 | Ruby | crupar/secretsanta | /secretsanta.rb | UTF-8 | 1,324 | 3.234375 | 3 | [] | no_license | require 'yaml'
class Person
attr_accessor :name, :household, :santa
def initialize(attrs)
self.name = attrs["name"]
self.household = attrs["household"]
self.santa = attrs["santa"]
end
def can_be_santa_of?(other)
@household != other.household
end
def already_santa_of?(other)
@name != ... | true |
13734ace7c0cac7112db4d99f99d2fdbbde57bbc | Ruby | apoorvparijat/ruby-example-code | /profiler.rb | UTF-8 | 282 | 3.578125 | 4 | [] | no_license | require 'profile'
class Peter
def initialize amt
@value = amt
end
def rob amt
@value -= amt
end
end
class Paul
def initialize
@value = 0
end
def pay amt
@value += amt
amt
end
end
peter = Peter.new 1000
paul = Paul.new
1000.times do
paul.pay(peter.rob 10)
end
| true |
29d1cca4d6c50b2d898a5c5c762b0906fef1f2e6 | Ruby | dan5/rec_game | /app/models/user.rb | UTF-8 | 1,167 | 2.578125 | 3 | [] | no_license | class User < ActiveRecord::Base
class UnAuthorized < Exception ; end
attr_accessible :description, :mail, :url, :name, :summary, :categorys_text, :teams_text
has_many :results, dependent: :destroy, :order => ['date desc', 'created_at desc']
validates :name, :presence => true,
:length => { ... | true |
531076f1b6b3b792239d471be647fdadb6fd4f74 | Ruby | wwilco/week08 | /d01/server.rb | UTF-8 | 1,423 | 2.953125 | 3 | [] | no_license | require 'pry'
require 'sinatra'
require 'json'
require 'httparty'
get '/' do
url = "http://api.randomuser.me/"
response = HTTParty.get(url)
person = response["results"][0]["user"]
person_json = {
first: person["name"]["first"],
last: person["name"]["last"],
email: person["email"],
username: per... | true |
116d08e6f9280b21c660f7bb6f5207a147c15488 | Ruby | bbuchalter/tictactoe_core | /test/tictactoe/board_test.rb | UTF-8 | 3,253 | 3.109375 | 3 | [] | no_license | require_relative '../test_helper'
require 'tictactoe/board'
class BoardTest < Minitest::Test
def test_new_board_is_empty
board = new_board
assert_board_empty(board)
end
def test_position_index
board = new_board
assert_equal 1, board.at(1).position
assert_equal 9, board.at(9).position
end
... | true |
0b1a73a19bafeaf81cd603019551fa129ba5f171 | Ruby | WhatsARanjit/controlrepo_gem | /lib/controlrepo/node.rb | UTF-8 | 857 | 2.703125 | 3 | [] | no_license | require 'controlrepo'
class Controlrepo
class Node
@@all = []
attr_accessor :name
attr_accessor :beaker_node
attr_accessor :fact_set
def initialize(name)
@name = name
@beaker_node = nil
# If we can't find the factset it will fail, so just catch that error and ignore it
... | true |
ba6ae7fd0cdc69872bcb71b4d78b9d044d47320d | Ruby | pyrocat101/hackerrank | /discrete-math/minimum-draws.rb | UTF-8 | 47 | 3.09375 | 3 | [
"MIT"
] | permissive | Integer(gets).times { puts Integer(gets) + 1 }
| true |
15082003df5f56f48a435ef1a447b6d448be006b | Ruby | mbj/substation | /lib/substation/utils.rb | UTF-8 | 1,733 | 3.140625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Substation
# A collection of utility methods
module Utils
# Get the constant for the given FQN
#
# @param [#to_s] name
# the FQN denoting a constant
#
# @return [Class, nil]
#
# @api private
def self.const_get(name)
list = name.to_s.split("::")
list.shift i... | true |
c86568fde5aaa3eeb71adb524b5ce3a6837353f2 | Ruby | jschoolcraft/urlagg | /vendor/plugins/typus/lib/support/array.rb | UTF-8 | 293 | 3.25 | 3 | [
"MIT"
] | permissive | class Array
#--
# Taken from http://snippets.dzone.com/posts/show/302
#
# >> %W{ a b c }.to_hash_with( %W{ 1 2 3 } )
# => {"a"=>"1", "b"=>"2", "c"=>"3"}
#++
def to_hash_with(other)
Hash[ *(0...self.size()).inject([]) { |arr, ix| arr.push(self[ix], other[ix]) } ]
end
end
| true |
7ca63672adde2e19defcb9e9cdb72d2573cfa581 | Ruby | dasstoni/algorithms | /linked_list2_iterative.rb | UTF-8 | 939 | 4.25 | 4 | [] | no_license | class LinkedListNode
attr_accessor :value, :next_node
def initialize(value, next_node=nil)
@value = value
@next_node = next_node
end
end
def print_values(list_node)
if list_node
print "#{list_node.value} --> "
print_values(list_node.next_node)
else
print "nil\n"
return
end
end
# S... | true |
05b58f9ae90a775503a30c8ab034825417752112 | Ruby | micaelbergeron/backend-coding-challenge | /app/engine/geo.rb | UTF-8 | 1,876 | 2.640625 | 3 | [] | no_license | require 'engine'
require 'model/geoname'
include SinCity::Model
module SinCity::Engine
class GeoEngine < Base
include SinCity::Engine
@@defaults = {
radius: 10000,
distance_unit: 'km',
result_count: 100,
input_file: INPUT_FILE,
}
def initialize(**args)
super(@@default... | true |
b76ff8ca8f582ba1688cde6cf2fe72ecda9e4fda | Ruby | ariel-alvear/desafios-arrays-primerasesion | /filtro_procesos.rb | UTF-8 | 366 | 3.015625 | 3 | [] | no_license | def process_filter(file)
data = open(file).readlines
lines = data.count
array = []
lines.times do |i|
array << data[i].to_i
end
n = ARGV[0].to_i
new_array = array.select{ |x| x > n}
File.new("procesos_filtrados.data", "w")
File.write('procesos_filtrados.data', new_array.joi... | true |
415360e4e841014e44bb00eafac3556599091bc9 | Ruby | RocketRobC/exercism | /ruby/rail-fence-cipher/rail_fence_cipher_3.rb | UTF-8 | 1,408 | 3.09375 | 3 | [] | no_license | class RailFenceCipher
VERSION = 1
def self.encode(string, rails)
new(string, rails).encode
end
def self.decode(string, rails)
new(string, rails).decode
end
def encode
puts sequence.inspect
puts code_map(sequence).inspect
cypher(string, code_map(sequence))
end
def decode
puts ... | true |
4ed18fcb0021af6156306ff01b39e8faa28d9cfe | Ruby | marcosfparreiras/10-days-of-statistics-hacker-rank | /app/src/d3t2_cards_of_the_same_suit.rb | UTF-8 | 1,765 | 3.890625 | 4 | [] | no_license | ###############################
# Task:
# You draw 2 cards from a standard 52-card deck without replacing them.
# What is the probability that both cards are of the same suit?
#
# ANSWER by calculus
#
# P = ( (4)C(1) * (13)C(2) ) / (52)C(2)
# => (4)C(1) => combination for 1 out of the 4 suits
# => (13)C(2) => combinati... | true |
80f27bbcb603a137ec002bca0844140f93c44c40 | Ruby | Mia-J-Russell/LaunchSchool | /RB101/small_problems/easy_7/combine.rb | UTF-8 | 389 | 3.8125 | 4 | [] | no_license | def interleave(array1, array2)
# newarr = []
# counter = 0
# loop do
# break if counter >= array1.size
# newarr << array1[counter]
# newarr << array2[counter]
# counter += 1
# end
# newarr
#Further Exploration
array1.zip(array2).flatten
end
puts interleave([1, 2, 3], ['a', 'b', 'c'])
put... | true |
0de3f090cfd665a2206b0bd8073abfa3b3e6c7ef | Ruby | radu-constantin/small-problems | /reverseit1.rb | UTF-8 | 207 | 3.34375 | 3 | [] | no_license | def reverse_sentence (string)
string.split.reverse.join('')
end
puts reverse_sentence('') == ''
puts reverse_sentence('Hello World')
puts reverse_sentence('Reverse these words') == 'words these Reverse'
| true |
037324e79985183bb0c076ef2b6765d025e9c7bd | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/rna-transcription/461686df714848eaae495b4151020472.rb | UTF-8 | 366 | 3.203125 | 3 | [] | no_license | class Complement
def self.of_dna(dna)
replace(dna)
return dna.gsub("A","U").gsub("T","A")
end
def self.of_rna(rna)
replace(rna)
return rna.gsub("A","T").gsub("U","A")
end
def self.replace(str)
for i in 0..str.length
if str[i] == "C"
str[i] = "G"
elsif str[i] == "G"
... | true |
913661f25da81f47fa7dfdc1b0ac105b1f129422 | Ruby | natevenn/enigma | /lib/encryptor.rb | UTF-8 | 993 | 3.359375 | 3 | [] | no_license | require_relative 'number_generator'
require_relative 'cipher'
class Encryptor
attr_reader :rotation, :message, :character_map
def initialize(message, key = nil, date = nil)
@message = message
@rotation = NumberGenerator.new(key, date).rotation
@character_map = Cipher.new.character_map
end
def en... | true |
79eddb4b94b22e95a9cc876ad22b67ac42d3219f | Ruby | manageyp/grape_demo | /app/models/error_code.rb | UTF-8 | 943 | 2.75 | 3 | [] | no_license | # -*- coding: utf-8 -*-
class ErrorCode
SUCCESS = '0000'
CODES = {
success: [SUCCESS, '成功'],
invalid_parameters: ['1001', '参数不完整'],
default_system_error: ['1002', '系统内部错误'],
invalid_user_token: ['1003', '验证信息无效,请重新登录'],
expired_user_token:... | true |
8986b32ec5b5ea407908ee63c1c324234b9e111c | Ruby | flyptkarsh/Cracking-The-Coding-Interview-Ruby-Solutions | /recursion_and_dynamic_programing/kadanes_algorithm.rb | UTF-8 | 1,337 | 4 | 4 | [] | no_license | # frozen_string_literal: true
# Dynamic Programming – Kadane’s Algorithm
# Find the maximum max contiguous sub array
# brute force
# check every combination
# too slow :(
def max_subarray(arr)
max_so_far = -1.0 / 0 # this is negative INFINITY
max_ending_here = -1.0 / 0 # this is negative INFINITY
arr.each do |... | true |
f60f6196f3863a1f23c9b75eef03a04610588453 | Ruby | timcharper/bond | /lib/bond/missions/object_mission.rb | UTF-8 | 1,604 | 2.90625 | 3 | [
"MIT"
] | permissive | # A mission which completes an object's methods. For this mission to match,
# the condition must match and the current object must have an ancestor that matches :object.
# Note: To access to the current object being completed on within an action, use the input's
# object attribute.
#
# ==== Bond.complete Options:
# [*:... | true |
b75818aef5db41719f2c23ce712bcbcb32c99cc1 | Ruby | jepetersohn/basic-OO-Orange-Trees | /source/orange_tree.rb | UTF-8 | 593 | 3.703125 | 4 | [] | no_license | # This is how you define your own custom exception classes
class NoOrangesError < StandardError
end
class OrangeTree
# Ages the tree one year
def age!
end
# Returns +true+ if there are any oranges on the tree, +false+ otherwise
def any_oranges?
end
# Returns an Orange if there are any
# Raises a NoOr... | true |
dc574ba2134459589b9e1ecd40d0eb19f5a09a12 | Ruby | GregPK/cv-from-ruby | /src/model/competence.rb | UTF-8 | 538 | 2.5625 | 3 | [
"MIT"
] | permissive | class Competence
attr_accessor :overall, :specific_hash
def initialize(overall, complex_commercial = true,simple_commercial = true,personal_complex = true, edu_projects_or_simple = true,simple_scripts = true)
@overall = overall
@specific_hash = {
simple_scripts: simple_scripts,
edu_projects_o... | true |
e93a2c179cccac593cb0586d80347bd1a8969254 | Ruby | PeterTucker/ruby_learning | /ProgrammingRuby/to_test.rb | UTF-8 | 105 | 3.375 | 3 | [] | no_license | class Multiplier
def initialize num1, num2
@value = num1 * num2 + 0
end
def to_i
@value
end
end | true |
2917753d18697f57bc3591209d7d8a87b50e0d93 | Ruby | imranansari/platesurfer-web-landing | /api.rb | UTF-8 | 1,654 | 2.546875 | 3 | [] | no_license | require 'sinatra'
require 'json'
#require 'mongoid'
class API < Sinatra::Base
# MongoDB configuration
=begin
Mongoid.configure do |config|
if ENV['MONGOHQ_URL']
conn = Mongo::Connection.from_uri(ENV['MONGOHQ_URL'])
uri = URI.parse(ENV['MONGOHQ_URL'])
config.master = conn.db(uri.path.gsub(/^\... | true |
64219aaa09063e3fd57538ff0d07c37ccf9700e3 | Ruby | buzzy-rental-cars/website | /app/helpers/application_helper.rb | UTF-8 | 3,200 | 2.546875 | 3 | [] | no_license | module ApplicationHelper
def title(page_title)
content_for(:title) { page_title }
end
def description(page_description)
content_for(:description) { page_description }
end
def markdown_to_html(markdown_text)
# Converts remaining Markdown syntax to html tags using Kramdown.
require 'kramdown'
... | true |
1d75b60cfc8a6b9b6f3851103cc51cc28d300dca | Ruby | muminovic/cs61aPrepCourse | /ch9/modern_roman_numerals.rb | UTF-8 | 1,146 | 4.03125 | 4 | [] | no_license | def modern_roman_numeral num
new = ''
#see how many I,X,C,M we have (V, L, D are in-between symbols of themselves)
#similar pattern to ORN, but this time using only 1,10,100,1000
ones = num % 10
tens = (num % 100)/10
hundreds = (num % 1000)/100
thousands = num/1000
new += 'M' * thousands
#take care of the special ca... | true |
70a3525633462c335a5c7f5c00d28c650583ad0b | Ruby | mecampbellsoup/flatiron | /take_a_number.rb | UTF-8 | 568 | 3.859375 | 4 | [] | no_license | def take_a_number(current_line, name)
current_line << name
puts current_line.index(name)+1
end
def now_serving(current_line)
puts "Currently serving #{current_line.first}"
current_line.shift
end
def line(current_line)
current_line.each_with_index do |p,i|
print "#{i+1}. #{p.capitalize}"
if i < curre... | true |
7baefc1929d598a1b2c64b62fb2ede43bc975286 | Ruby | littlegustv/redemption | /affects/affects_b.rb | UTF-8 | 10,757 | 2.75 | 3 | [] | no_license | require_relative 'affect.rb'
class AffectBarkSkin < Affect
def initialize(target, source = nil, level = 0)
super(
target, # target
source, # source
level, # level
300, # duration
{ resist_bash: 5 }, # modifiers: nil
nil, # period: nil... | true |
dbcc8bbc2db09615c8e686144b4145fb6933870c | Ruby | imac18078/advanced-hashes-hashketball-001-prework-web | /hashketball.rb | UTF-8 | 7,591 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here!
require 'pry'
def game_hash
game_hash = {
home: {
team_name: "Brooklyn Nets",
colors: ["Black", "White"],
players: [
{"Alan Anderson" =>
{player_name: "Alan Anderson",
number: 0,
shoe: 16,
points: 22,
rebo... | true |
936bbfcda1037eacdecf0cb5424e74059dadba31 | Ruby | hambrice/ruby-music-library-cli-v-000 | /lib/musiclibrarycontroller.rb | UTF-8 | 2,390 | 3.578125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class MusicLibraryController
attr_accessor :path
def initialize(path = "./db/mp3s")
@path = path
MusicImporter.new(path).import
end
def call
puts "Welcome to your music library!"
puts "To list all of your songs, enter 'list songs'."
puts "To list all of the artists in your lib... | true |
b64d7abc5b730655a9f165f3b5e13e8d73fd4929 | Ruby | carbonfive/raygun | /lib/raygun/template_repo.rb | UTF-8 | 2,360 | 2.859375 | 3 | [
"MIT"
] | permissive | module Raygun
class TemplateRepo
attr_reader :name, :branch, :tarball, :sha
def initialize(repo)
@name, @branch = repo.split("#").map(&:strip)
fetch
end
private
def fetch
return if @branch && @sha
@branch ? fetch_branches : fetch_tags
end
def handle_github_erro... | true |
7c35a1fc854b2222a9c8deceee0e97e1a9a09d32 | Ruby | dhanesana/sea-c21-ruby | /lib/class4/exercise3.rb | UTF-8 | 2,338 | 4.6875 | 5 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
#
# 5 points
#
# Write a program that asks whether or not you like tacos:
#
# If you reply with 'y', then we're friends:
#
# $ ruby exercise3.rb
# Do you like eating tacos? (y or n)
# y
# We can be friends!
#
# If you reply with 'n', then we're enemies:
#
# $ ruby exercise3.rb
# Do you l... | true |
060958dc03cc5ce8c631e4217fcd773a30a77547 | Ruby | adbasner/code_snippets | /job_training/interview.rb | UTF-8 | 1,025 | 4.125 | 4 | [] | no_license | # def print_odds(max_number)
# odd_numbers = []
# number = 1
# max_number.times do
# if number % 2 != 0
# odd_numbers << number
# end
# number += 1
# end
# return odd_numbers
# end
# loop_until = gets.chomp.to_i
# p print_odds(loop_until)
# Question 2
def is_palindrome(string)
str... | true |
1ed597da05445f3ac43a0b2ce9c29b34d16c63f7 | Ruby | YumaInaura/YumaInaura | /ruby/keyword-args-hash-args.rb | UTF-8 | 596 | 3.828125 | 4 | [] | no_license | # receive keyword args method
def foo(x:, y:)
p x
p y
end
# OK
# Pass keyword args
foo(x: "x", y: "y")
# OK
# Pass hash but convert as keyword args explicity
foo(**{x: "x", y: "y"})
# OK
# Pass hash but convert as keyword args explicity
hash = {x: "x", y: "y"}
foo(**hash)
# NG
# Pass Hash Args
# warning: Using ... | true |
dae006b0f02ed2a538c364125a901122bf9f1bf0 | Ruby | cdlib/cedilla_service_commons | /lib/cedilla/author.rb | UTF-8 | 7,937 | 2.921875 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Cedilla
class Author
# Author attributes
attr_accessor :corporate_author
attr_accessor :full_name, :last_name, :first_name, :suffix
attr_accessor :middle_initial, :first_initial, :initials
attr_accessor :dates, :authority
attr_accessor :extras
# --------------------------... | true |
18b7a10711d8ad85eef37660c7d0ddca8a367a05 | Ruby | guragt/bugsnag_to_webex_teams | /app/models/webex_teams/message.rb | UTF-8 | 601 | 2.609375 | 3 | [] | no_license | module WebexTeams
class Message
WEBEX_URL='https://api.ciscospark.com/v1/messages'
def initialize(markdown:)
@markdown = markdown
end
def deliver(room_id)
response = Net::Hippie::Client.new.post(URI.parse(WEBEX_URL),
body: {roomId: room_id, m... | true |
44bd7fd0a05c486e61d58a0519576dc668b8e007 | Ruby | Noah2610/TextAdventure_v2 | /src/Test/rb/Tests/InputConversationMode.rb | UTF-8 | 1,299 | 2.921875 | 3 | [] | no_license |
### Tests for user input in conversation mode
class TestInputConversationMode < MiniTest::Test
include TestInputHelpers
def reset args = {}
super
PLAYER.talk_to @persons[:Parsley] unless (args[:no_talk] == true)
end
## CONVERSATION MODE ##
def test_talk_to_unknown_person
reset no_talk: true
@persons[:... | true |
be295f4bee7b4a96792a140a4bdd315a144ce163 | Ruby | itdddjulius/bitmap_editor | /spec/command_spec.rb | UTF-8 | 9,542 | 2.640625 | 3 | [] | no_license | # frozen_string_literal: true
describe Command do
let(:command) { Command.new(input) }
describe '#initialize' do
context 'invalid input format' do
let(:input) { 'I A' }
it 'should raise an invalid format error' do
expect { command }.to raise_error(Command::InvalidFormatError)
end
... | true |
04869564d71201b2c31f71414de882795d89a3d9 | Ruby | jordanhudgens/exercism | /ruby/raindrops/raindrops.rb | UTF-8 | 254 | 3.046875 | 3 | [] | no_license | class Raindrops
FACTORS = {
'Pling': 3,
'Plang': 5,
'Plong': 7
}.freeze
def self.convert(num)
sounds = FACTORS.map do |sound, factor|
sound if (num % factor).zero?
end.join
sounds.empty? ? num.to_s : sounds
end
end
| true |
ad14e2e53ea3446aed718da51e183ff177ae8a5c | Ruby | amateharu/homework | /HW03/Volodymyr Larkin/HW3/lib/mentor.rb | UTF-8 | 813 | 2.75 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'person.rb'
require_relative 'student.rb'
class Mentor < Person
attr_accessor :student
def initialize(name:, surname:)
super(name: name, surname: surname)
@student
end
def subscribe_to!(student)
@student = student
student.mentor = self
end
... | true |
c5829ac4a3eb1634405e8fe314b5a095c7ff97e2 | Ruby | cyber-dojo-retired/ragger | /test/client/test_base.rb | UTF-8 | 926 | 2.5625 | 3 | [
"BSD-2-Clause"
] | permissive | require_relative '../id58_test_base'
require_relative '../require_src'
require_src 'externals'
require_src 'ragger_service'
class TestBase < Id58TestBase
def externals
@externals ||= Externals.new
end
def ragger
RaggerService.new(externals)
end
# - - - - - - - - - - - - - - - - - - - - - - - - - -... | true |
a8e973b2ddfbb131ac6572edcebf76ef9ffbb60a | Ruby | sawangupta92/VTAPP | /Ruby_exercise/customer/lib/customer.rb | UTF-8 | 748 | 4.03125 | 4 | [] | no_license | class Customer
@@count = 0
def initialize(name)
@name = name
@balance = 1000.0
@@count += 1
@account_number = @@count
end
def to_s
"name is #{ @name }, balance is #{ @balance }, account number is #{ @account_number }"
end
def deposit(balance) # minimum balance you can add in your acc... | true |
c129c2007393748ac3895efab80741f3dc3a0d47 | Ruby | ReseauEntourage/entourage-ror | /config/initializers/json_validator.rb | UTF-8 | 504 | 2.53125 | 3 | [
"MIT"
] | permissive | # Accepts ISO 8601, then converts it to RFC 3339 (JSON Schema standard)
#
# derived from
# https://github.com/ruby-json-schema/json-schema/blob/v2.6.2/lib/json-schema/attributes/formats/date_time_v4.rb
JSON::Validator.register_format_validator("date-time-iso8601", -> (data) {
begin
return unless data.is_a?(Strin... | true |
1a6ffa87cb74d4446b4bdd36031f45771f2cba6e | Ruby | erikbenton/connect_four | /spec/connect_four_spec.rb | UTF-8 | 5,142 | 3.109375 | 3 | [] | no_license | require "connect_four.rb"
describe "ConnectFour" do
subject(:game) {ConnectFour.new()}
let(:empty_board) {Hash[(0..5).map { |row| [row, [".",".",".",".",".",".","."]]}]}
let(:full_board) {Hash[(0..5).map { |row| [row, ["O","O","O","O","O","O","O"]]}]}
let(:horizontal_win_board) {{0 => ["O", "O", "O", "X", "O", ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.