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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c7da84b3c0a92a1b628736a2544c004ccd878cd4 | Ruby | marekdano/rps-go | /app/controllers/game_controller.rb | UTF-8 | 1,851 | 3.265625 | 3 | [] | no_license | class GameController < ApplicationController
def index
end
def play
@player_name = params[:user_name]
@wins = params[:wins].to_i
@losses = params[:losses].to_i
end
def compare
@player_name = params[:user_name]
if params.has_key?(:wins) && params.has_key?(:losses)
wins = params[... | true |
cf10108c0a70a2a95b8ca5422515c96dbec25d98 | Ruby | osbornegabriel/phase-0-tracks | /ruby/gps6/my_solution.rb | UTF-8 | 4,339 | 4 | 4 | [] | no_license | # Virus Predictor
# I worked on this challenge [by myself, with: ].
# We spent [#] hours on this challenge.
# EXPLANATION OF require_relative
#require_relative is a subset of require.
#r_r = to the location you are in.
#r = full address
require_relative 'state_data'
class VirusPredictor
#Initailizes all the instanc... | true |
026842591c669a9c8d6dab358275337e04c49b1e | Ruby | SpeciesFileGroup/taxonworks | /lib/batch_load/import/sequence_relationships/primers_interpreter.rb | UTF-8 | 2,942 | 2.546875 | 3 | [
"NCSA",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module BatchLoad
class Import::SequenceRelationships::PrimersInterpreter < BatchLoad::Import
# @param [Hash] args
def initialize(**args)
@sequence_relationships = {}
super(**args)
end
# @return [Integer]
def build_sequence_relationships
@total_data_lines = 0
i = 0
g... | true |
ca53d12cfb677a876fd1b9c4bb02f1c5bcbeb3d9 | Ruby | webgago/wsdl-reader | /lib/xsd/reader/types_registry.rb | UTF-8 | 438 | 2.53125 | 3 | [] | no_license | class XSD::TypeNotFound < StandardError
end
class XSD::TypesRegistry < Hash
attr_reader :namespaces
def initialize(namespaces)
@namespaces = namespaces
end
def find(ns, name)
raise XSD::TypeNotFound.new("types in namespace [#{ns}] not found") unless self[ns]
self[ns].find { |e| e.name == name }
... | true |
88e42c94d10b6732cf8a3ab8291d461db63442b9 | Ruby | tanaken0515/atcoder | /virtual-contests/pepabo/005/abc108/C.rb | UTF-8 | 194 | 3.109375 | 3 | [] | no_license | # https://atcoder.jp/contests/abc108/tasks/arc102_a
N, K = gets.split.map(&:to_i)
x = N / K
y = if K.odd?
0
else
x * K + K / 2 <= N ? x + 1 : x
end
puts x ** 3 + y ** 3
| true |
48891016da77d991920c536ee40baa592916088c | Ruby | EmperDeon/rails-theatre | /app/helpers/utils_helper.rb | UTF-8 | 2,393 | 2.625 | 3 | [] | no_license | module UtilsHelper
#
# Get list of pairs <id, name>
# Needed by API(TComboBox)
#
def self.get_list(type)
allowed_tables = %w(performances theatres p_types)
if allowed_tables.include? type
sql = 'SELECT '
# Field names
sql += get_fields(type)
# Table names
sql += get_t... | true |
22710fba173a2fc749b88a7bc82f127c605d4f85 | Ruby | linstula/golf | /lib/course_reader.rb | UTF-8 | 464 | 3.25 | 3 | [] | no_license | require 'csv'
class CourseReader
def initialize(course_filename)
@course_filename = course_filename
@course = load_course
end
def course_path(course_filename)
File.expand_path(File.dirname(__FILE__) + '/' + course_filename + '.csv')
end
def load_course
course_data = []
CSV.foreach(co... | true |
be0414aea47fce5bc7183eeb904fd9b2b0d3eafb | Ruby | mfeinLearn/ruby-objects-has-many-through-lab-dumbo-web-082718 | /lib/genre.rb | UTF-8 | 325 | 3.03125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Genre
attr_accessor :name
# has_many :songs
# has_many :artist, through: :songs
@@all = []
def initialize(name)
@name = name
@@all << self
end
def Genre.all
@@all
end
def songs
Song.all{|song| song.genre == self}
end
def artists
songs.map{|song| song.artist }
end
... | true |
482e6b376a9cdfcc0a8ee8bae78798993edfadc2 | Ruby | AlexWayfer/tripment_job_test | /lib/tasks/procedures/importer.rb | UTF-8 | 881 | 3.171875 | 3 | [] | no_license | # frozen_string_literal: true
class ProceduresImporter
def initialize(procedures_names, parent:)
## `uniq` to avoid duplicate names error, Wiki has such
@procedures_names = procedures_names.uniq
@parent = parent
end
def import
@procedures_names.each do |procedure_name|
case procedure_name
... | true |
9b53cb7f3600913201f04947d6a1f3f73af60689 | Ruby | IfeOlogbese/rspec-tutorial | /spec/array_2_spec.rb | UTF-8 | 317 | 2.640625 | 3 | [] | no_license | RSpec.describe Array do
subject(:sally) do
[1, 2]
end
it 'should have 2 elements' do
expect(sally.size).to eq(2)
sally.pop
expect(sally.size).to eq 1
end
it 'should have original contents' do
expect(sally.size).to eq(2)
expect(sally).to match_array([1, 2])
end
end | true |
a7d426337236dabeef75d211c712c134eb2dd35c | Ruby | yunomae/auto_cast_tool | /wshorten_64_to_32.rb | UTF-8 | 4,422 | 2.546875 | 3 | [] | no_license | DEBUG=FALSE
filename = ARGV[0];
warning = /(.+\.cpp):(\d+):(\d+): warning: implicit conversion loses integer precision: '([\w\s<>\*:]+)'.*to '([\w\s<>\*:]+)'(.*)\[-Wshorten-64-to-32\]/
class UpdateLine
class << self
def insert_should_be(source, warning_line, warning_char_count, current, should_be)
... | true |
37e20a52f9e08fb57fea63a6bf413da05fdc6474 | Ruby | mcat56/little_shop_1908 | /spec/models/merchant_spec.rb | UTF-8 | 4,374 | 2.671875 | 3 | [] | no_license | require 'rails_helper'
describe Merchant, type: :model do
describe "validations" do
it { should validate_presence_of :name }
it { should validate_presence_of :address }
it { should validate_presence_of :city }
it { should validate_presence_of :state }
it { should validate_presence_of :zip }
end... | true |
b85b1e19501ba4126d87d6f619a53e8245c3d0ec | Ruby | TranHuyHoang95/Exam | /app/controllers/Exam1.rb | UTF-8 | 696 | 3.546875 | 4 | [] | no_license | exam = "Bài 1"
# ========1.1=========
puts " #{exam.center(50)}"
a = []
puts "Nhập giá trị cho mảng"
(0..4).each do |i|
print "a[#{i}]="
a[i] = gets.chomp.to_i
end
puts "- Mảng vừa nhập là: #{a}"
# ====== End 1.1 =======
# ======== 1.2 =========
puts "- Tổng các phần tử trong mảng: #{a.inject{|sum,e| sum +=e}}... | true |
91a5d424ff21b7cc6e866c888b443ba8ad042f22 | Ruby | gwho/cryptosphere | /lib/cryptosphere/blobs/tree.rb | UTF-8 | 425 | 2.828125 | 3 | [
"MIT"
] | permissive | module Cryptosphere
class Tree < Blob
def self.[](*entries)
new(entries)
end
def initialize(entries)
@entries = entries
end
def to_s
@entries.sort_by { |e| e.name }.map(&:to_s).join("\n")
end
# Individual entries in a tree
class Entry < Struct.new(:mode, :type, :id... | true |
abb27981e6e78c3157a870c7e31ee3dd1094a639 | Ruby | modENCODE-DCC/validator | /make_metadata_chadoxml.rb | UTF-8 | 4,218 | 3.0625 | 3 | [] | no_license | #!/usr/bin/ruby
# make_metadata_chadoxml.rb
# usage : ./make_metadata_chadoxml.rb <sourcechado> <destchado>
### HELPER FUNCTIONS ###
# Does this line contain an open tag that we want to remove?
def open_tag?(line)
case line
when /<data_feature>/
"datafeature"
when /<feature id=.*>/
"feature"
... | true |
ae138edcfe4de593ab193ffa3200c8eedb9f1af9 | Ruby | bentrojan/learn_ruby | /07_hello_friend/friend.rb | UTF-8 | 125 | 3.3125 | 3 | [] | no_license | class Friend
def greeting person=nil
if person.class == String
"Hello, #{person}!"
else
"Hello!"
end
end
end | true |
b9501ad7b931e2a4ee30407ed725822db010c9d2 | Ruby | LuciaMarcu/TicTacToe | /lib/game.rb | UTF-8 | 3,331 | 3.65625 | 4 | [] | no_license | class Game
WINNER_COMB = [[2, 5, 8], [1, 4, 7], [3, 6, 9], [3, 5, 7], [1, 5, 9], [1, 2, 3], [4, 5, 6], [7, 8, 9]]
CELLS_INDEX = [1, 5, 9, 13, 17, 21, 25, 29, 33]
attr_accessor :human, :computer, :cells, :CELLS_INDEX, :difference_hum, :difference_comp, :human_picks, :comp_picks, :WINNER_COMB
def... | true |
49dc611d0c19c41016dbe0e82da6f75e8503f023 | Ruby | codyloyd/cli_chess | /game/Game.rb | UTF-8 | 1,281 | 3.9375 | 4 | [] | no_license | require "./game/GameBoard"
require "./game/Player"
class Game
attr_accessor :game_board, :player_1, :player_2
def initialize
@game_board = GameBoard.new
@player_1 = Player.new("player 1","white")
@player_2 = Player.new("player 2", "black")
@game_over = false
end
def get_input(player)
puts "#{player.name... | true |
b92a67bcc8369c79df1d27f22eb543c1bab5f49f | Ruby | sabudaye/kaize_test | /solutions/no_limit.rb | UTF-8 | 107 | 2.828125 | 3 | [] | no_license | class NoLimit
def initialize(str)
@str = str
end
def solution
@str.split(/,/, -1)
end
end
| true |
f6418608210eaf4ad4fc06599d52bf67ca8c05c1 | Ruby | idkjay/Launch | /week1-advoop/object-oriented-marathon/lib/zoo.rb | UTF-8 | 888 | 3.421875 | 3 | [] | no_license | class Zoo
attr_reader :cages, :employees
def initialize(name, season_opening_date, season_closing_date)
@name = name
@season_opening_date = season_opening_date
@season_closing_date = season_closing_date
@cages = []
@employees = []
10.times do
@cages << Cage.new
end
end
def a... | true |
a67474105eccb00e033ba12ee9b2f4c34fb33377 | Ruby | drstonebraker/algorithms | /binary_search_tree/lib/binary_search_tree.rb | UTF-8 | 2,552 | 3.625 | 4 | [] | no_license | require_relative 'bst_node'
require 'byebug'
# There are many ways to implement these methods, feel free to add arguments
# to methods as you see fit, or to create helper methods.
class BinarySearchTree
attr_accessor :root
def initialize
@root = nil
end
def insert(value)
new_node = value.is_a?(BSTNod... | true |
b9a8a87dc3d27d513d42100bc8c0db651a790d4f | Ruby | ChristieRenaud/launch-school-course-101 | /small_problems/easy_5_6.rb | UTF-8 | 511 | 3.515625 | 4 | [] | no_license | def word_sizes(string)
sizes = []
string.split(' ').each do | word |
sizes << word.size
end
size_hash = sizes.each_with_object({}) do | num, size_hash |
size_hash[num] = sizes.count(num)
end
size_hash.sort_by { |key, value| key }
end
p word_sizes('Four score and seven.') #== { 3 => 1, 4 => 1, 5... | true |
f1cd5656fb496174268d0b97b24a3b2dba1bd8a2 | Ruby | PatrickSunico/rails-blog | /app/helpers/application_helper.rb | UTF-8 | 1,528 | 2.640625 | 3 | [] | no_license | module ApplicationHelper
# status_tag method that takes up 2 parameters, the boolean value from page.visible and the default parameters for the options hash
# now if boolean == true or visible show the content_tag with the span class of status true and append the double quotes from within the "<span>" "</span" tag... | true |
2e3aab331284a09d093ae3318b27aafc65bd2a3e | Ruby | nhutwkm/bai_tap_ruby | /Baitap/input.rb | UTF-8 | 191 | 2.78125 | 3 | [] | no_license | class Input
def initialize
end
def nhap
puts "nhap Ten"
$Ten= gets.chomp
puts "DiaChi"
$Diachi=gets.chomp
puts "Gioi tinh:"
$Gioitinh= gets.chomp
end
end
| true |
3c43111e842dd974ab8463da6acd270b6d848ede | Ruby | edshadi/graphql-ruby | /lib/graphql/language/generation.rb | UTF-8 | 3,302 | 2.640625 | 3 | [
"MIT"
] | permissive | module GraphQL
module Language
module Generation
def self.generate(node, indent: "")
case node
when Nodes::Document
node.definitions.map { |d| generate(d) }.join("\n")
when Nodes::Argument
"#{node.name}: #{generate(node.value)}"
when Nodes::Directive
... | true |
52cd08cfb3228976687c5027fa42a06dbd79405e | Ruby | JackNolan/Steam-Watch | /lib/price_awareness.rb | UTF-8 | 471 | 2.859375 | 3 | [] | no_license | module PriceAwareness
def is_lowest?
current_price.ammount == lowest_price.ammount
end
def lowest_price
prices.order("ammount ASC").limit(1).first
end
def add_price(price)
if new_price?(price)
prices.build(:ammount => price, :start_date => Time.now)
self.current_price = price
en... | true |
3113232f0a5efed9e2569b041e6c09274df0e4d4 | Ruby | mcheban/pgq | /lib/pgq_event.rb | UTF-8 | 880 | 2.796875 | 3 | [
"MIT"
] | permissive | class PgqEvent
attr_accessor :id, :type, :data, :extra1, :extra2, :extra3, :extra4
def initialize pgq_tuple = nil, use_yaml = true
if pgq_tuple.is_a? Hash
@id = pgq_tuple['ev_id']
@time = pgq_tuple['ev_time']
@type = pgq_tuple['ev_type']
if use_yaml
@data = YAML.load pgq_tuple... | true |
c2ee7b2f3e572f9615ae86472d83c252e5b4a74c | Ruby | drihu/c2-module2 | /week-2/day-1/put_n.rb | UTF-8 | 445 | 3.8125 | 4 | [] | no_license | def put_n(string, n)
if !n.is_a? Integer
raise ArgumentError.new('Second argument should be an integer.')
elsif n < 0
raise ArgumentError.new('Second argument should be greater than 0.')
end
n.times { puts string }
end
put_n("This will be printed 5 times!", 5)
# Logs
# This will be printed 5 times!
# T... | true |
7ee7afcd7d90f07248b4c427a333370439ea427a | Ruby | ebarendt/omniauth-playground | /app/models/wl_api.rb | UTF-8 | 434 | 2.609375 | 3 | [] | no_license | class WlApi
BASE_URL = 'https://apis.live.net/v5.0'
attr_reader :token
def initialize(token)
@token = token
end
def albums
get('/me/albums')['data']
end
def folder(folder_id)
get("/#{folder_id}/files")['data']
end
def thumbnail_url(file_id)
get("/#{file_id}")['images'][1]['source... | true |
7950af716f089efd71fdd44a2042916524705c72 | Ruby | JTREX/Examen_fase0.rb | /examen_fase_0.rb | UTF-8 | 7,104 | 3.921875 | 4 | [] | no_license | #Crea el método vowels que recibe una lista
#de palabras words y remueve las vocales
#de cada string. Haz pasar la prueba correspondiente.
def vowels(arr)
arr.each do |item|
if item.tr!("aeiou","")
end
end
end
p vowels(["banana", "carrot", "pineapple", "strawberry"]) == ["bnn", "crrt", "pnppl", "strwbrry"]... | true |
566db2946691108f90b0a7255afe3a94b345790e | Ruby | MattDawson2020/Battle | /lib/game.rb | UTF-8 | 637 | 3.765625 | 4 | [] | no_license | require_relative 'player'
class Game
attr_reader :player_1, :player_2, :current_turn, :opponent
def initialize(player_1, player_2)
@player_1 = player_1
@player_2 = player_2
@current_turn = @player_1
@opponent = @player_2
@players = [@player_1, @player_2]
end
def attack(player)
player.... | true |
19dd203128952ba796b9a979469365cef23bc528 | Ruby | hwgordon247/rps-challenge | /spec/player_spec.rb | UTF-8 | 573 | 2.875 | 3 | [] | no_license | require 'player'
describe Player do
subject(:player) {described_class.new 'Harry'}
context '#name' do
it 'returns the name of the player' do
expect(player.name).to eq 'Harry'
end
end
context '#choice' do
it 'can return the most recent player choice (rock)' do
player.rock
expec... | true |
9a1d7d90f872f41a2cf0906ce4f24c5eadffa5b6 | Ruby | jakeheft/battleship | /lib/board.rb | UTF-8 | 2,353 | 3.3125 | 3 | [] | no_license | class Board
attr_reader :cells
def initialize
@cells = {
"A1" => Cell.new("A1"),
"A2" => Cell.new("A2"),
"A3" => Cell.new("A3"),
"A4" => Cell.new("A4"),
"B1" => Cell.new("B1"),
"B2" => Cell.new("B2"),
"B3" => Cell.new("B3"),
"B4" => Cell.new("B4"),
"C1" => ... | true |
c0778ab881bf476f157bae21d3d74f1c27518bd5 | Ruby | handwerger/launch-school-repo | /chapter_4/case_statement.rb | UTF-8 | 265 | 4.0625 | 4 | [] | no_license | a = 5
case a
when 5
puts "a is 5"
when 6
puts "a is 6"
else
puts "a is neither 5 nor 6"
end
puts "Another version of the same code outputs: "
answer = case a
when 5
"a is 5"
when 6
"a is 6"
else
"a is neither 5 nor 6"
end
puts answer
| true |
d11f32c74c7ba489cc5680995f143a25348ea724 | Ruby | kchivorn/todo | /app/mailers/users_mailer.rb | UTF-8 | 861 | 2.53125 | 3 | [] | no_license | class UsersMailer < ApplicationMailer
def inform_todolist(user_id, todo_list_id, todo_list_title, todo_list_description, todo_item_content=nil, action=nil)
@user = User.find(user_id)
@todo_list_id = todo_list_id
@todo_list_title = todo_list_title
@todo_list_description = todo_list_description
@tod... | true |
65274a3a590d3f30b1a3799830dea55ac385705d | Ruby | shugo/immutable | /lib/immutable/promise.rb | UTF-8 | 3,165 | 3.234375 | 3 | [
"MIT"
] | permissive | module Immutable
# +Immutable::Promise+ represents a promise to evaluate an expression
# later.
#
# @example Delayed computation
# promise = Promise.delay { puts "hello"; 1 + 2 }
# x = promise.force #=> hello
# p x #=> 3
# y = promise.force #=> (no output; the value is memoized)
... | true |
a1ac8d21a46b8794e0f2bcc108fd6a2043a13416 | Ruby | lgants/cli-project-week-guidelines-no-scrape-web-0716 | /app/data_fetchers/nytimes-api-caller.rb | UTF-8 | 761 | 2.53125 | 3 | [] | no_license | require 'pry'
class NYTimesAPIWrapper
attr_accessor :article_hash
def initialize
uri = URI("https://api.nytimes.com/svc/search/v2/articlesearch.json")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
uri.query = URI.encode_www_form({
"api-key" => "600a03a7aa294ca8a9c5ac843ace1690... | true |
81753091e60a5825718a8c61ffaf04eb7e553c72 | Ruby | Scott-Borecki/black_thursday | /spec/merchant_spec.rb | UTF-8 | 935 | 2.734375 | 3 | [] | no_license | require 'CSV'
require_relative '../lib/merchant'
require 'simplecov'
SimpleCov.start
RSpec.describe Merchant do
before :each do
@m = Merchant.new(
id: 5,
name: 'Turing School',
created_at: Time.now,
updated_at: Time.now
)
end
describe 'instantiation' do
it ... | true |
1a83e1c4e73949ffac862f8226250d6ca3e8b128 | Ruby | DaniyarKulmanov/ruby_full | /Lesson_3/fibonacci.rb | UTF-8 | 125 | 3.140625 | 3 | [] | no_license | fibonacci = [0,1]
loop do
sum = fibonacci[-1] + fibonacci[-2]
break if sum >= 100
fibonacci << sum
end
puts fibonacci | true |
f5576bf658cf8ac5f089226d9ac8b4dee031fc16 | Ruby | DiegoSalazar/RubyCuboidCodingChallenge | /lib/cuboid.rb | UTF-8 | 1,426 | 3.515625 | 4 | [
"MIT"
] | permissive | require './lib/vertex'
require './lib/faces'
# Represent a cuboid in 3D space
class Cuboid
include Faces
attr_reader :dims, :pos
# @params dimensions, position: Vertex instances
# For dimensions x, y, z represents width, height, length
def initialize(dimensions, position)
@dims = dimensions
@pos = p... | true |
f10efb4c309abc2c1ff3603abad50709dbcc2f55 | Ruby | maxim198307/hierarchy_tree | /spec/lib/tree_node/data_structure_composer_spec.rb | UTF-8 | 8,271 | 2.671875 | 3 | [] | no_license | require 'tree_node/data_structure_composer.rb'
describe TreeNode::DataStructureComposer do
describe '.call' do
subject { described_class.call(input) }
context 'when input data does not contain trailing children' do
let(:input) { [['A', nil], ['B', 'A'], ['C', 'B'], ['D', 'C']] }
let(:expected_r... | true |
80a677b4dd047336d759d1b999cf6be548886302 | Ruby | equivalent/maze_magic | /lib/maze_magic/maze_generator/recursive_backtracking/north.rb | UTF-8 | 344 | 2.546875 | 3 | [
"MIT"
] | permissive | module MazeMagic
module MazeGenerator
class RecursiveBacktracking
class North
include Singleton
def direction_x
0
end
def direction_y
-1
end
def oposite
South.instance
end
def to_i
1
end
... | true |
b4371b40102db375a4f95d298160dde5809022b6 | Ruby | jpka/todo | /features/step_definitions/task_steps.rb | UTF-8 | 2,581 | 2.546875 | 3 | [] | no_license | When /^I cross "(.*?)"$/ do |task|
page.find(:xpath, "//span[text()='#{task}']").find(:xpath, "..").find(".task-done").set(true)
end
Then /^"(.*?)" should be crossed$/ do |task|
page.find(:xpath, "//span[text()='#{task}']").find(:xpath, "..").find(".task-done").should be_checked
end
When /^I create task "(.*?)" w... | true |
2ac42867ff06892773f87d776378d6f699a6189b | Ruby | micahabanschick/anilector-sinatra | /app/models/genre.rb | UTF-8 | 733 | 2.671875 | 3 | [
"MIT"
] | permissive | class Anilector::Genre < ActiveRecord::Base
has_and_belongs_to_many :animes, class_name: "Anilector::Anime", foreign_id: "anime_id"
# attr_accessor :name, :details
# @@all = []
# def initialize(name)
# @name = name
# self.save
# end
# def save
# @@all... | true |
eee963015580b16eabcb71900ccf2389912ae272 | Ruby | QPC-WORLDWIDE/rubinius | /rakelib/instruction_parser.rb | UTF-8 | 23,654 | 3.296875 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # A simple parser to transform a description of the VM instructions into
# various implementation files.
#
# The parser recognizes three forms presently:
#
# 1. define NAME <value>
# 2. section "Some description"
# 3. instruction opcode_name(arg1, arg2) [ consumed -- produced ]
# body
# end
#
# Once t... | true |
1ac2b40b3226f7aa4b9d6b7da31e483b62eddd8b | Ruby | risacan/Ruby | /http_get.rb | UTF-8 | 417 | 3.921875 | 4 | [] | no_license | class Point
attr_accessor :x, :y
def initialize(x=0, y=0)
@x, @y = x ,y
def inspect
"#{x}, #{y}"
end
def +(other)
self.class.new(x + other.x, y + other.y)
end
def -(other)
self.class.new(x - other.x, y - other.y)
end
def +@
dup
end
def -@
self.class.New(-x, -y)
end
... | true |
e8bf5846f380be3a231f5bf4914449d0b8bfed5e | Ruby | alexeyeva/katas | /reverse_polish_notation_calculator.rb | UTF-8 | 407 | 3.703125 | 4 | [] | no_license | def calc(expr)
stack = []
expr.split(" ").each do |char|
stack.push(char.to_f) if char =~ /[-+]?([0-9]*\.[0-9]+|[0-9]+)/
stack.push(stack.pop(2).reduce(char)) if char =~ /\+|\-|\*|\//
end
return 0 if stack.empty?
return stack.last
end
p calc("") #0
p calc("1 2 3") #3
p calc("1 2 3.5"... | true |
04ed20b93c36c9da66540f57a80469269ce43ec6 | Ruby | robertbrook/parlytags | /spec/models/item_spec.rb | UTF-8 | 4,490 | 2.671875 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../spec_helper.rb'
describe Item do
describe 'when asked to find by placetag' do
before do
@item1 = mock_model(Item)
@item2 = mock_model(Item)
@tag1 = mock_model(Placetag)
@tag2 = mock_model(Placetag)
end
it 'should return a list of items when... | true |
924fb71b32a860546c56a9941c5ff8663b88ce81 | Ruby | Nordstrom/fileutils-cookbook | /libraries/change_help.rb | UTF-8 | 3,948 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | #
# Cookbook:: fileutils
# Library:: helper
#
# Copyright:: 2017 Nordstrom, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
#
# Utility methods to change directory and file attributes
module DirChangeHelper
require 'etc'
require 'find'
# Permissions
R = 0o444 # Read
W = 0o222 # Write... | true |
1207a99356190a62fccf6dd75af0ea0f2fc1e59f | Ruby | osyoyu/slack-logger | /import.rb | UTF-8 | 1,198 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'json'
require 'zip'
require 'fileutils'
require './lib/db'
def importMessages(channel, messages)
messages.each do |m|
m['channel'] = channel[:id]
insert_message(m)
end
end
def importChannels(channels)
Channels.find.delete_many
Channels.insert_many(channels)
end
def importUsers(users)
Users... | true |
cef567362965230523fda789eacfbb9f3ec39e07 | Ruby | tonycwu888/phase-0-tracks | /ruby/hashes_squirrel.rb | UTF-8 | 3,320 | 4.03125 | 4 | [] | no_license | #designer to input:
#client's name
#client's age
#number of children
#decor theme
#fav_color
#smoker = true or false
#hobby
#Prompt the designer/user for all of this information.
#get input from user with gets.chomp
#Convert any user input to the appropriate data type.
#convert data with .to_s or .to_i t... | true |
2e5bcfc18828f833aec4563dec8676cf23c6e896 | Ruby | CityBaseInc/ris-clients | /Ruby/lib/kount/request/update.rb | UTF-8 | 943 | 2.5625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | module Kount
##
# This class extends the Request class and is used in the
# process of sending updates to an existing transaction
# generated by a previous Inquiry request.
class Update < Request
# Initialize an Update object
#
# Example usage
# {:MACK => "Y", :AUTH => "A"}
#
# @par... | true |
917b4626e0f4476891135f318c33c6491d43b9b3 | Ruby | shiroyasha/copy_to_clipboard | /bin/copy_to_clipboard | UTF-8 | 443 | 3.21875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
def colorize(text, color_code)
"\e[#{color_code}m#{text}\e[0m"
end
def red(text); colorize(text, 31); end
def green(text); colorize(text, 32); end
if ARGV.empty?
puts red('You should pass a file as parameter!')
exit
end
unless File.exist? ARGV[0]
puts red("File doesn't exist!")
exit
en... | true |
0f54468628d3d218314371114f63f36eb3dd769f | Ruby | turboladen/effing | /lib/effing/streams/video_stream.rb | UTF-8 | 2,002 | 2.625 | 3 | [
"MIT"
] | permissive | require_relative 'base_stream'
require_relative '../frames/video_frame'
class Effing
module Streams
# Represents a video stream from within a container file.
class VideoStream < BaseStream
include LogSwitch::Mixin
attr_reader :raw_frame, :width, :height, :pixel_format
# @param [FFI::FFm... | true |
144523442c6448daad9fb0483a38e8be92cc9f54 | Ruby | selenamarie/openconferenceware | /app/models/event.rb | UTF-8 | 2,145 | 2.546875 | 3 | [
"MIT"
] | permissive | # == Schema Information
# Schema version: 20090121212823
#
# Table name: events
#
# id :integer not null, primary key
# title :string(255)
# deadline :datetime
# open_text :text
# closed_text :text
# created_at :datetime
# updated_at :dat... | true |
d619c2462026f316cb1166f378c90a03d2196fbb | Ruby | baluneboy/gems | /sketchupsams/learning_circles.rb | UTF-8 | 1,586 | 2.5625 | 3 | [
"MIT"
] | permissive | mod = Sketchup.active_model # Open model
ent = mod.entities # All entities in model
sel = mod.selection # Current selection
# Draw a circle on the ground plane around the origin.
center_point = ORIGIN #Geom::Point3d.new(0,0,0)
normal_vector = Geom::Vector3d.new(0,0,1)
radius = 10
edgearray = ent.add_circle center_poin... | true |
e27ed2ab5c7e915fc048470a23654ce1f7066e3e | Ruby | DiormaisavecunLaudebut/le_parigo_for_free | /db/seeds.rb | UTF-8 | 2,720 | 2.6875 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
date_selector = ".timestamp.width_full.margin_top_ten.ui"
author_selector = ".margin_top_sm.ui_bold"
summary_selector = ".subheadline"
paragraph_selector = ".article-section"
title_category_selector = '.story-headline'
div_selector = ".story-preview a"
categories = %w[politique e... | true |
3fa4a701b6c1f1d56578efefed1234c42cf56d85 | Ruby | Tshamp7/App_Academy_Classwork | /DIY_ADTs/map.rb | UTF-8 | 671 | 3.84375 | 4 | [] | no_license | class Map #stores list items as key value pairs.
def initialize
@map = []
end
def set(key, value)
if !@map.include?(key)
@map << [key, value]
else
puts "There is already a key = value pair with that key. Please choose another key."
end
end
d... | true |
7eaa6b49661b04d21800c66afda2d12f61760daf | Ruby | veritasphoenix/LS_intro_to_ruby | /flow_control/num_100.rb | UTF-8 | 681 | 5.03125 | 5 | [] | no_license | # num_100.rb
# Takes in a number and reports back if the string is:
# between 0 and 50, between 51 and 100, or over 100
print 'Please enter a number between 0 and 100: '
number = gets.chomp.to_i
# def num_100(n)
# result =
# case n
# when 0..50 then 'Number is between 0 and 50'
# when 51..100 then 'Number i... | true |
61459bfac204dd2ddcf9f00b1c53f2ad48746e68 | Ruby | arizz96/ruby-json-transformer | /operations/remove_keys.rb | UTF-8 | 732 | 2.734375 | 3 | [] | no_license | require_relative 'base'
class Operations::RemoveKeys < Operations::Base
def operate(obj)
_json_remove_keys(obj)
end
private
def _json_remove_keys(json, key_path: nil)
res = {}
object_key_path = key_path
json.each do |k, v|
# keep track of nested object names
key_path = object_key... | true |
d6acd93e1352aa33f9066b5ccb18b726c1d8634e | Ruby | adambair/rails-initiate | /labs/solutions/05_post_comment_association.rb | UTF-8 | 1,418 | 3.25 | 3 | [] | no_license | # --------------------------
# Lab 05: Post Comment Association [ 05_post_comment_association.rb ]
# --------------------------
# Create a migration that adds a 'post_id' field to the comments table
# Create a has_many relationship between the Post and Comment models
# Verify the relationship through the Rails console
... | true |
588e08723323728d8fc72e517d7383150cf15f2d | Ruby | hjdalton/student-directory | /exercises.rb | UTF-8 | 1,165 | 3.828125 | 4 | [] | no_license | #the list of students in an array
students = [
{name: "Harry Potter", cohort: :november},
{name: "Ron Weasley", cohort: :november},
{name: "Hermione Grainger", cohort: :november},
{name: "Draco Malfoy", cohort: :november},
{name: "Luna Lovegood", cohort: :november},
{name: "Fred Weasley", cohort: :november}... | true |
ea136a04b13fa6f5af9154989fea1517ec02c518 | Ruby | adr29truck/Discordbot-Wingslammer | /discord.rb | UTF-8 | 3,911 | 3.1875 | 3 | [] | no_license | class Object
def is_number?
self.to_f.to_s == self.to_s || self.to_i.to_s == self.to_s
end
end
token = File.read("token.save")
#####################
require "discordrb"
require "date"
quotes = []
bot = Discordrb::Commands::CommandBot.new token: token, client_id: 285078420239679488, prefix: "2"
## Out... | true |
efa5cd2d35ef471cf98e52dfa2e637bb92ac2d72 | Ruby | kwleland/ruby-benchmark-suite | /benchmarks/micro-benchmarks/bm_primes.rb | UTF-8 | 519 | 3.0625 | 3 | [
"MIT",
"BSD-3-Clause"
] | permissive | # This tests the Prime class' generation speed.
#
# Ruby 1.8 MRI has an extremely poor/naive implementation of Prime
# therefore it is expected to timeout on most machines for all but
# n = 3_000. The higher parameters are still useful to test Ruby 1.9
# and other implementations.
#
# Ruby 1.9 generates a warning abou... | true |
284b93aedb372fa2f603676a712c6439aa00a70b | Ruby | mmarini/search_app | /lib/database/database.rb | UTF-8 | 1,245 | 2.890625 | 3 | [] | no_license | require_relative '../helpers/validators'
require 'singleton'
module Database
class Database
include Singleton
include Helper::Validators
def initialize()
initialize_tables
end
def add_table(name)
table_name = validate_string_presence(name, 'name')
raise StandardError.new("tab... | true |
b609920b8699abd8e2d0a21598a75822b4592b48 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/accumulate/a9e623c0fa6b4a4aa06457a7881c9318.rb | UTF-8 | 159 | 3.1875 | 3 | [] | no_license | class Array
def accumulate
return self if self.empty?
for i in (0..self.index(self.last))
self[i] = (yield self[i])
end
self
end
end
| true |
8cd217d471655ab869bac45d6ec2bb2e8792aa27 | Ruby | alexdavidow/hw | /hw_may_20-june_1/animal_client_hw/Animal.rb | UTF-8 | 446 | 3.53125 | 4 | [] | no_license | require 'pry'
class Animal
attr_accessor :name, :breed, :age, :gender, :fave_toy, :owner
def initialize(args = {})
@name = args[:name]
@breed = args[:breed]
@age = args[:age]
@gender = args[:gender]
@fave_toy = args[:fave_toy]
@owner = args[:owner]
end
def to_s
"Name: #{@name} / Br... | true |
431cf2d7eefb56bd7901ec1e8e580ee9238655ec | Ruby | billyboy118/chess | /lib/modules/game_messages.rb | UTF-8 | 365 | 3.28125 | 3 | [] | no_license | # frozen_string_literal: false
# this module provides a number of messsages to be used thoughout the game
module GameMessages
def self.whos_who(player1, player2)
puts "\nHello #{player1.name} and #{player2.name}!\n\n\u265F #{player1.name} your colour is white"
puts "\u2659 #{player2.name} your colour is blac... | true |
afe10439901ed00fbbdc0465f22b86d7712d8529 | Ruby | ONordander/ruby_projects | /ceasar_cipher.rb | UTF-8 | 415 | 3.875 | 4 | [] | no_license | def ceasar_cipher(string, shift = 0)
letters = ('a'..'z').to_a.concat(('A'..'Z').to_a)
output_string = ""
string.each_char do |char|
if letters.include?(char)
output_string += letters[letters.index(char) - shift]
else
output_string += char
end
end
return output_string
end
puts "Enter a string"
string ... | true |
8c8fc2765c8c655220d1be633a4e0dd7eed4157b | Ruby | kgrz/query_parser | /mongo_generator.rb | UTF-8 | 464 | 2.828125 | 3 | [] | no_license | require 'date'
require 'mongo'
require 'uri'
accounts = (2000_0000_000...2000_1000_000).lazy
names = ("aaaaa".."zzzzz").lazy
balances = (1..9999).lazy.to_a
begin
(Date.new(2013, 03, 01)..Date.today).each do |date|
@balance = balances.shuffle
@folder = date.strftime("%d-%m-%Y")
names.rewind
accounts.each d... | true |
e17f88428a87c4f96fc28fb8e0959c976ed04b02 | Ruby | leanguardia/FinalTaller | /generator/generator.rb | UTF-8 | 1,934 | 2.703125 | 3 | [] | no_license | require 'rubygems'
require 'mechanize'
require 'net/http'
require 'uri'
puts 'Desired user id'
user = gets.chomp
puts 'Desired band id'
band = gets.chomp
puts 'Desired workout id (0 for none)'
workout = 0
workout = gets.chomp
if workout == 0
workout = nil
end
puts 'Start year'
year = gets.chomp
puts 'Start mon... | true |
6dd3f9b3df187a31b85f1fee7fabc931ea149b75 | Ruby | AoifeNiD/AoifesRoman | /lib/AoifesRoman.rb | UTF-8 | 1,075 | 3.703125 | 4 | [
"MIT"
] | permissive | class DecimaltoRoman
@roman = {
1000 => "M",
900 => "CM",
500 => "D",
400 => "CD",
100 => "C",
90 => "XC",
50 => "L",
40 => "XL",
10 => "X",
9 => "IX",
5 => "V",
4 => "IV",
1 => "I"
}
# create keys to store the decimal values
def self.c... | true |
b7db046b4aece87a87d5132645eac002413c8e99 | Ruby | ksaveljev/ProjectEuler | /089/089.rb | UTF-8 | 313 | 2.546875 | 3 | [] | no_license | require 'romans'
# M-M-MONKEY PATCH!
class String
def is_roman_numeral?
true
end
end
RomanNumerals.send(:remove_const, :MAX)
RomanNumerals.const_set(:MAX, 100500)
p File.open('roman.txt').
each_line.
map(&:chomp).
map{|roman| roman.size - roman.to_i_roman.to_s_roman.size }.
inject(:+)
| true |
f1aaa759b44419bdd2b192e6b335b06824e04247 | Ruby | cassiodias/pivotal-life | /jobs/go_train.rb | UTF-8 | 1,842 | 2.65625 | 3 | [] | no_license | stouffville_timings_from_schedule = YAML.load(File.read('go_train.yml'))['stouffville']
lakeshore_east_timings_from_schedule = YAML.load(File.read('go_train.yml'))['lakeshore_east']
richmond_timings_from_schedule = YAML.load(File.read('go_train.yml'))['richmond']
TIME_INTERVAL = 2 * 3600 * 1000
SCHEDULER.every '300s'... | true |
0c57b5f277a05d95b3f1b306e32a9a85dbf4a958 | Ruby | Dahie/metro | /spec/metro/models/properties/options_property/options_spec.rb | UTF-8 | 3,422 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Metro::Model::OptionsProperty::Options do
describe "ClassMethods" do
describe "#empty" do
it "should generate an empty set of options" do
described_class.empty.should be_kind_of described_class
end
end
end
subject { described_class.new [ :a, :b ] }
... | true |
5da3769fbd788be33bd437c88c77edc7bbcaba39 | Ruby | collinsmith1990/events_challenge | /app/helpers/events_helper.rb | UTF-8 | 1,466 | 2.71875 | 3 | [] | no_license | module EventsHelper
def create_table_rows(events, tracks)
time = events.minimum(:start)
finish = events.maximum(:finish)
html = String.new
while(time < finish) do
if time.min == 0
html += "<tr>"
html += "<td rowspan='4'>#{time}</td>"
html += create_events_row(events... | true |
463f8e9ed83ca66dd063c2c5f4ac6f5a3b384a31 | Ruby | byroot/frozen_record | /spec/scope_spec.rb | UTF-8 | 12,783 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe 'querying' do
describe '.first' do
it 'returns the first country' do
country = Country.first
expect(country.id).to be == 1
end
it 'can be called on any scope' do
country = Country.where(name: 'France').first
expect(country.id).to be == 2
end
... | true |
b4b68eb0135aa3da962b012c00ecd0df5c4160b5 | Ruby | pharhadnadi/kyubits | /other/matrices/mat_spiral_print.rb | UTF-8 | 1,315 | 3.453125 | 3 | [] | no_license |
def spiral_print mat
return if mat.empty?
rows = mat.size
cols = mat[0].size
# n, s, e, w = rows-1, rows-1, cols-1, cols-1
e_min, e_max = 0, cols-1
w_min, w_max = 0, cols-1
n_min, n_max = 1, rows-1
s_min, s_max = 0, rows-1
total_rounds = rows * cols
directions ={
'e' => [],
'w' => [],... | true |
39059f427e97b0797917a8eb25fc3c7116eeefd6 | Ruby | diasks2/proz | /lib/proz/freelancer.rb | UTF-8 | 1,079 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'httparty'
module Proz
class Freelancer
include HTTParty
base_uri 'https://api.proz.com/v2'
attr_reader :key, :uuid
def initialize(key:, uuid:)
@key = key
@uuid = uuid
end
def freelancer
case
when freelancer_response.has_key?('error')
if freelancer_res... | true |
c8aaab3188b7ad1651a4e3812382338dd34c6a3d | Ruby | aik-stok/thinkneticka | /lesson_8/cargo_wagon.rb | UTF-8 | 433 | 3.15625 | 3 | [] | no_license | class CargoWagon < Wagon
attr_reader :type, :hold_capacity
def initialize(capacity = 22)
@type = 'cargo'
@hold_capacity = capacity
@volume_taken = 0
end
def loading(meters)
if @volume_taken + meters > @hold_capacity
p 'Overload!'
else
@volume_taken += meters
end
end
de... | true |
1b39ba60fde2f97163d6885aa6d082d731c16686 | Ruby | jamesspwalker/w02-weekend-hw | /specs/rooms_spec.rb | UTF-8 | 1,070 | 2.96875 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative('../rooms')
require_relative('../guests')
require_relative('../songs')
class TestGuests < Minitest::Test
def setup
@room1 = Room.new([@guest2, @guest3], [], 2, 3)
@guest1 = Guest.new("Mark")
@song1 = Song.new("Mardy Bum")
@guest2 = ... | true |
05c5cf75808ec330af286d0a787c9cfb7a6792a0 | Ruby | LiamCusack/backend_mod_1_prework | /day_1/ex6.rb | UTF-8 | 1,399 | 4.3125 | 4 | [] | no_license | # defines the variable types_of_people as 10
types_of_people = 10
#defines the variable x as the string "There are #{types_of_people} types of people."
x = "There are #{types_of_people} types of people."
# defines the variable binary as the string "binary"
binary = "binary"
# defines the variable do_not as the st... | true |
2a09c8e640e967369ab1c7d65c82711f31f1e023 | Ruby | peggyl/Ruby | /assignments/q2-sort.rb | UTF-8 | 494 | 3.953125 | 4 | [] | no_license | def sort(arr)
mergesort(arr)
end
def mergesort(arr)
n = arr.length
return arr if n <= 1
l = arr[0...n/2]
r = arr[n/2..n]
l = mergesort(l)
r = mergesort(r)
return merge(l, r)
end
def merge(l, r)
a = Array.new()
# shift removes and returns the first element
while l.length > 0 or r.length > 0
if l.len... | true |
61208deacb139cd63d7eb38a58d3e0a51d8c9bad | Ruby | t-recx/blocks | /piece_factory.rb | UTF-8 | 282 | 2.859375 | 3 | [] | no_license | require './piece.rb'
require './piece_types.rb'
class PieceFactory
def get_new_piece(x, y, blocks)
blocks = get_new_blockset unless blocks
Piece.new(x, y, blocks)
end
def get_new_blockset
PieceTypes::BLOCKS[Random.new.rand(PieceTypes::BLOCKS.length)]
end
end
| true |
83a811b83503c3acdacf6f9f0efda1597e70e93b | Ruby | 8secz-johndpope/caver-ruby | /lib/caver/abi/contract/function.rb | UTF-8 | 1,185 | 2.546875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "active_model"
require "caver/abi/contract/parameter"
module Caver::ABI
class Contract
class Function
include ActiveModel::Model
attr_accessor :name, :constant, :inputs, :outputs, :payable, :type, :stateMutability
def initialize(attributes = {})
... | true |
35cbcaa13fbe68bd16d3e9ef96d6576f30762460 | Ruby | joshleblanc/form-reflex | /app/reflexes/form_reflex.rb | UTF-8 | 2,998 | 2.6875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
class FormReflex < ApplicationReflex
include Optimism
before_reflex do |reflex|
# Handle change keeps the session[:model] object up to date with what's going on in the form.
# We need to track changes in order to reconcile what fields_for fields we're deleting, as
# well ... | true |
4bc3c8107a355440554217beb4c6b4f225f16bf9 | Ruby | hmans/microformats2 | /lib/microformats2/format.rb | UTF-8 | 2,857 | 2.9375 | 3 | [
"MIT"
] | permissive | module Microformats2
class Format
CLASS_REG_EXP = /^(h-)/
attr_reader :method_name
def initialize(element, base)
@element = element
@base = base
@method_name = to_method_name(format_types.first)
@property_names = []
end
def parse
format_types
properties
... | true |
29dde3e691cebda566a75a9ce000917c48e90f2a | Ruby | Xyko/tools | /lib/lib/cache.rb | UTF-8 | 1,145 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'singleton'
class ToolsCache
include Singleton
def initialize(options = {})
end
# Create a cache file in work area
#
# @param arguments
# @return
def self.create_cache_file cache_name, cache_dir
unless File.exists? cache_dir
ToolsLog.tools_error "Invalid directory in new config file... | true |
df9bf668539d1c42f2821619cbdf2123651add07 | Ruby | Bodhisattva2-0/hero_explore | /lib/direction_south.rb | UTF-8 | 191 | 2.703125 | 3 | [] | no_license | require 'singleton'
class DirectionSouth
include Singleton
def key
"S"
end
def turn_left
DirectionEast.instance
end
def turn_right
DirectionWest.instance
end
end
| true |
bca4c07ac502b85f31d98a34bfdb385592e9d00e | Ruby | AlanDaniels101/odin-ruby-project | /09_timer/timer.rb | UTF-8 | 522 | 3.5625 | 4 | [] | no_license | class Timer
attr_accessor :seconds
def initialize()
@seconds = 0
end
def seconds=(seconds)
@seconds = seconds
end
def getH(time_in_s)
time_in_s/60/60
end
def getM(time_in_s)
time_in_s/60 % 60
end
def getS(time_in_s)
time_in_s % 60
end
def time_string
return ""+padde... | true |
ef55592593b29ec710f85811af5085fdb48a8fd2 | Ruby | MaximeD/dot-files | /.pryrc | UTF-8 | 2,382 | 3.21875 | 3 | [] | no_license | # === EDITOR ===
Pry.editor = 'vim'
# === CUSTOM PROMPT ===
# wrap ANSI codes so Readline knows where the prompt ends
def colour(name, text)
if Pry.color
"\001#{Pry::Helpers::Text.send name, '{text}'}\002".sub '{text}', "\002#{text}\001"
else
text
end
end
def base_prompt(obj, nest_level, eol_char)
rub... | true |
73bb0cb21f5a922e66e46bb1934f8b9ff463cc3c | Ruby | tovemercer/phase-0-tracks | /ruby/gps6_squirrels/my_solution_squirrels.rb | UTF-8 | 4,384 | 3.640625 | 4 | [] | no_license | # Virus Predictor
# I worked on this challenge [by myself, with: Yibin ].
# We spent 1.5 hours on this challenge.
# EXPLANATION OF require_relative
# allows the current document to access the content of the linked document. relative to the documents you're working on
# require is a broader search for the linked docum... | true |
2862d19d454d5875350312f189158e3b118a700e | Ruby | teeerevor/hotmess_rails | /lib/tasks/youtube.rake | UTF-8 | 2,144 | 2.546875 | 3 | [] | no_license | require 'uri'
require 'nokogiri'
require 'open-uri'
require 'googleajax'
desc 'youtube loader'
task :load_youtube => :environment do
year = ENV['current_year']
Song.where(year: year, youtube_url: nil).each do |song|
puts "-----------------------------------"
puts "#{song.name} - #{song.artist.name}"
#... | true |
50a6c90a241ad2a64b284a77a5a018fa779f26d4 | Ruby | tan-tan-kanarek/logstash-input-gzfile | /lib/logstash/inputs/gzfile.rb | UTF-8 | 26,387 | 2.625 | 3 | [] | no_license | # encoding: utf-8
require "logstash/inputs/base"
require "logstash/namespace"
require "pathname"
require "socket" # for Socket.gethostname
# BufferedTokenizer takes a delimiter upon instantiation, or acts line-based
# by default. It allows input to be spoon-fed from some outside source which
# receives arbitrary len... | true |
197f07825da50b0d79ffff2f28e0fea742382005 | Ruby | teskew/Breweries_Cli_Project | /lib/breweries_cli/cli.rb | UTF-8 | 2,813 | 3.609375 | 4 | [
"MIT"
] | permissive | require 'pry'
class CLI
#communicationg with user and data
# an entryway method
def start
# API.get_data
puts ""
puts "***************************************"
puts " WELLCOME TO BREWERY CO"
puts " DATA BASE "
... | true |
ec557399a336b2523b8990f37284757fe35be537 | Ruby | GustavoZiaugra/ten-pin-bowling | /spec/printer_spec.rb | UTF-8 | 4,552 | 2.65625 | 3 | [
"MIT"
] | permissive | RSpec.describe TenPinBowling::Printer do
describe '#print' do
it 'should return the outputed game to the screen into the perfect format(sample match)' do
input =
{ 'Jeff' =>
[{ 'pins' => [10], 'score' => 20 }, { 'pins' => [7, 3], 'score' => 39 },
{ 'pins' => [9, 0], 'score' => 4... | true |
c196e604d1bfd56e17e4ad45ae5d04781da8e56d | Ruby | alterago/dapp | /lib/dapp/builder/chef/berksfile.rb | UTF-8 | 1,893 | 2.546875 | 3 | [
"MIT"
] | permissive | module Dapp
module Builder
class Chef < Base
# Berksfile
class Berksfile
# Parser
class Parser
def initialize(berksfile)
@berksfile = berksfile
parse
end
def cookbook(name, *_args, path: nil, **_kwargs)
@berksfile.add_l... | true |
41d4a4c18449cca754497a4db827e4a1dee7b7ff | Ruby | MasudaAfrin/Ruby-Design-Pattern | /CompositePattern-example-2/music_component.rb | UTF-8 | 768 | 3.625 | 4 | [] | no_license | class MusicComponent
attr_reader :children
def initialize
@children = []
end
# The 'add' method adds a child component
# to the current component class.
def add_child(component)
@children.push(component)
puts "Adding parent of #{component.class} to #{self.class}"
component.parent = self
end
... | true |
511e9263d8f646ef1180300c19d492dd297cb6f7 | Ruby | m-delarosa/pirate_party_one_to_many | /lib/pirate.rb | UTF-8 | 447 | 3.234375 | 3 | [] | no_license | class Pirate
attr_accessor :name,
:age,
:eye_patch,
:ship
@@all = []
def initialize(name, age, ship, eye_patch = true)
#When you set a default you have to put it as a last argument.
@name = name
@age = age
@eye_patch = eye_patch
@ship = ship... | true |
4ad786205815a991cd95d5a11ba27b56b5b1951e | Ruby | ahmedhossammontasser/modifier_refactor | /spec/float_spec.rb | UTF-8 | 469 | 2.640625 | 3 | [] | no_license | require File.expand_path('spec_helper', File.dirname(__FILE__))
require 'float'
require 'rspec'
describe Float do
context "#float" do
context "should return a float" do
input = 12.345
it { expect(input.to_german_s).to eq("12,345") }
it { expect(input.to_german_s).to be_a String }
end
context "should r... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.