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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
659fb8ceaf5f025fcd71696e371c7bcced210556 | Ruby | jkeen/trackerific | /spec/lib/trackerific/event_spec.rb | UTF-8 | 1,727 | 2.5625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'spec_helper'
describe Trackerific::Event do
before do
@date = Time.now
@description = 'description'
@location = 'location'
@code = "02"
@required_parameters = {
:date => @date,
:description => @description,
:location => @location
}
@vali... | true |
5152ee83a9e7d4b01898d6edcf5a69d59da9cb58 | Ruby | pooza/mulukhiya-toot-proxy | /app/lib/mulukhiya/mime_type.rb | UTF-8 | 864 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'rack/mime'
module Mulukhiya
class MIMEType
include Singleton
DEFAULT = 'application/octet-stream'.freeze
attr_reader :types, :extnames
def extname(type)
return @extnames[type]
end
def type(ext)
ext = File.extname(ext) if File.extname(ext).present?
return @types[ex... | true |
2c4661d237012894ee5d9653cc449f712f92cec8 | Ruby | nscarlyon/collections_practice-v-000 | /collections_practice.rb | UTF-8 | 737 | 3.796875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(numbers)
numbers.sort
end
def sort_array_desc(numbers)
numbers.sort.reverse
end
def sort_array_char_count(words)
words.sort do |a, b|
a.length <=> b.length
end
end
def swap_elements(elements)
elements.insert(1, elements[2])
elements.pop
elements
end
def rever... | true |
8f025a45c1dcfb4b6ebfb87dc9449d4eee36b2d4 | Ruby | esselt/evolis-premium_sdk | /lib/evolis/premium_sdk/cmd.rb | UTF-8 | 1,540 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'evolis/premium_sdk/sdk_base'
module Evolis
module PremiumSdk
class Cmd < SdkBase
# Default timeout for CMD service
TIMEOUT = '3000'
# Initializes the class and sets SDK host and port
#
# @param host [String] host or IP for SDK
# @param port [String, Fixnum] port for ... | true |
57c70b855a08ca72d01fb03e1046f833afd52cdf | Ruby | Jamesredux/learn_ruby | /05_book_titles/book.rb | UTF-8 | 456 | 3.46875 | 3 | [] | no_license | class Book
attr_accessor :title
def title=(book_title)
words = book_title.split
littleuns = ['if','and','over','it','the','a','an','or','but','for','on','is','of','in'i]
words.each do |x|
if littleuns.include?(x)
x
else
x.capitalize!
end
end
words[0].capitalize!
words = words.join(... | true |
9d3c9950da081129681c21e1e7f1e1ee220e256c | Ruby | uimarshall/ruby-oop | /class_methods_variables.rb | UTF-8 | 1,416 | 3.953125 | 4 | [] | no_license | =begin
CLASS METHODS AND VARIABLES
=========================================================
We already have instance variables & methods
That is, they are methods that pertain to an instance or object of the class.
There are also class level methods, called class methods.
Class methods are methods we can call dire... | true |
d342f6da368dfa23d06a4c011d6e475eac9073f4 | Ruby | sgoldens/account-checker | /vendor/bundle/ruby/2.3.0/gems/pp-0.1.1/lib/pp.rb | UTF-8 | 781 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'pp/room'
# Provides a method to listen and respond to messages in a Campfire room.
module Pp
# Listen and respond to messages in a Campfire room.
#
# @example Interact in the room https://xxx.campfirenow.com/room/123 as the user with token 'abcd'
#
# require 'pp'
# Pp.run 'xxx', 123, 'abcd'
... | true |
2ce1515989fe02102cb7547c454d40025ffe16cd | Ruby | nofxx/run-a-log | /ral/Parser.rb | UTF-8 | 1,581 | 3.390625 | 3 | [] | no_license | require "Container.rb"
class Parser
def parse(file)
fileHandle = File.open(file)
#creating a new container, this is what out parsers will fill
#there might be a call by value/reference problem... closures could help
container = Container.new
#detect the thile extention ...
extension = fi... | true |
8de85fb250d719006d6996d45dc1a9f695d6ce61 | Ruby | peterastrong/object_oriented_ruby | /pair_programming.rb | UTF-8 | 341 | 3.34375 | 3 | [] | no_license | count = 0
until count == 10
puts count
count += 1
end
p count
x = 10
y = 4
puts y >= x
if y >= x != true
puts " great"
else
puts "bad"
end
unless y >= x
puts "great"
else
puts "bad"
end
unless y >= x #if change to false, will not print
puts "HELLO!"
end
class BankAccountInfo
... | true |
592645f60634df2fed6731a836de981d0bb13a39 | Ruby | SpiritBreaker226/object_oriented_programming | /ex3/tax.rb | UTF-8 | 313 | 3.34375 | 3 | [] | no_license | class Tax
attr_reader :tax_rate, :exempt
def initialize(tax_rate_in_precent, exempt)
@tax_rate = tax_rate_in_precent
exempt = []
exempt.each { |type| @exempt << type }
end
def is_exempt?(product_type)
@exempt.include?(product_type)
end
def +(other_tax)
@tax_rate + other_tax.tax_rate
end
end | true |
a8a334b4b8ad1edf635e0dbbce65337d4c082b4d | Ruby | chris-roerig/between_the_sheets | /lib/between_the_sheets/game/screens.rb | UTF-8 | 678 | 2.703125 | 3 | [
"MIT"
] | permissive | module BetweenTheSheets
class Game
module Screens
def intro_screen
if @credits <= Game::ANTE
puts "You're out of credits."
raise GameOver
end
puts Game.message :banner
puts "Round: #{@rounds} | Jackpot: #{@jackpot} | Ante: #{Game::ANTE} | Credits: #{@cre... | true |
2da30a4aa53cb5105147f6781677ad270ea397f4 | Ruby | kWhittington/united_states | /spec/united_states/state/postal_code_spec.rb | UTF-8 | 3,333 | 2.890625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'spec_helper'
require 'united_states/state/postal_code'
RSpec.describe UnitedStates::State::PostalCode do
subject(:postal_code) { described_class.new(string) }
let(:string) { Faker::Lorem.characters(2) }
describe '.new(string)' do
subject(:new) { described_class.new(s... | true |
30c301262b8d592d2ae62849c2df4f69f7f09b34 | Ruby | jrose444/w1d5 | /skeleton/lib/00_tree_node.rb | UTF-8 | 1,123 | 3.390625 | 3 | [] | no_license | require "byebug"
class PolyTreeNode
attr_reader :parent, :children, :value
def initialize(value)
@value = value
@parent = nil
@children = []
end
def parent=(new_parent=nil)
unless parent == nil
@parent.children.delete(self) if @parent.children.include?(self)
end
unless n... | true |
cd70c04ab7f8a22d848e2ac046dbf8f3dd6c0197 | Ruby | abhiram25/ruby_object_oriented_rps | /pseudo.rb | UTF-8 | 363 | 4 | 4 | [] | no_license | class Student
@@number_of_students = 0
def initialize(name, course)
@@number_of_students += 1
@name = name
@course = course
end
def self.number_of_students
@@number_of_students
end
end
puts Student.number_of_students # => 0
dog1 = Student.new("Jason", 100)
dog2 = Student.new("Abhi", 100)... | true |
a6285ee20a62ce80384b0530f646a085f88c25f5 | Ruby | kyletolle/frisbee_sim | /frisbee.rb | UTF-8 | 2,240 | 3.46875 | 3 | [] | no_license | # Class to hold constants
class Physics
G = -9.81 # Gravity in m/s
RHO = 1.23 # Air density in kg/m^3
AREA = 0.0568 # Area of average frisbee
CLO = 0.1 # Lift Coefficient at Alpha=0
CLA = 1.4 # Lift Coefficient at Alpha
CDO = 0.08 # Drag Coeff at Alpha=0
CDA = 2.72 # Drag Coeff at Alpha
... | true |
ab60366fec922cf7f954e7791c0254eb3bf300f7 | Ruby | cantierecreativo/activeadmin-generator | /lib/active_admin/generator/bricks/base.rb | UTF-8 | 1,713 | 2.578125 | 3 | [] | no_license | require 'active_support/core_ext'
module ::Bricks
class Base
attr_reader :context, :base_path
delegate :inject_into_file, :directory, :copy_file, :remove_dir, :gsub_file,
:rake, :generate, :route, :empty_directory, :gem, :git, :remove_file,
:append_file, to: :context
def init... | true |
5a1c3ccc27493c849d18f323f6574e62954d5c30 | Ruby | ritabc/time-angle | /lib/time_angle.rb | UTF-8 | 251 | 3.328125 | 3 | [] | no_license | def time_angle(time_array)
if (time_array[0].class != Integer) || (time_array[1].class != Integer)
false
elsif
time_array[0] > 0 && time_array[1] > 0
x = (time_array[0]*30)
y = (time_array[1]*6)
(x - y).abs
end
end
| true |
91a292034ba3e03b33fd7878648118f080d88e78 | Ruby | levthedev/huffman_tree | /huffman_test.rb | UTF-8 | 2,607 | 3.34375 | 3 | [] | no_license | require "minitest"
require "minitest/autorun"
require "minitest/pride"
require "byebug"
class Node
attr_accessor :left, :right, :value
@@all = []
def self.root
@@root
end
def self.all
@@all.select { |n| n.value != nil }
end
def initialize(value, left = nil, right = nil)
@value, @left, @rig... | true |
d91a2dba0d944cb942c8b217aabcfffcd835121d | Ruby | AdrielTrigger/Ruby-Linked-List | /linked_list.rb | UTF-8 | 5,117 | 3.890625 | 4 | [] | no_license | class LinkedList
def initialize
@head = Node.new(rand(1000), nil)
end
def append(value)
current = @head
while current.next != nil
current = current.next
end
current.next = Node.new(value, nil)
end
def pre_pend(value)
current = @head
... | true |
3443fc0897e336fb58be435a7a29759cfb73d1f5 | Ruby | MattHDwyer/TerminalApp | /DogVariableRDWV1.rb | UTF-8 | 6,171 | 2.78125 | 3 | [] | no_license | # require 'name_generator'
# class Dog
# attr_accessor()
# def initialize()
# generator = NameGenerator::Main.new
# @dog_name = generator.next_name
new_rand = Random.new()
# @dog_strength = new_rand_instance.rand(0...100)
# end
# end
# dog1 = Dog.new()
# dog2 = Dog.new()
# dog3 = D... | true |
746d052e159beb04e6f488132605bad9d83d9596 | Ruby | thiagomay1/test-dev-backend-ruby | /test/models/receiver_address_test.rb | UTF-8 | 2,163 | 2.59375 | 3 | [] | no_license | require 'test_helper'
class ReceiverAddressTest < ActiveSupport::TestCase
test "receiver_address should be valid" do
receiver_address = build_receiver_address
assert receiver_address.valid?
end
test "street_name should be valid" do
receiver_address = build_receiver_address
receiver_address.stree... | true |
94c449432f0c8b10f4f336b8f692db0028c87dfc | Ruby | danchuparkoff/coreruby32 | /lib/exercises/week4/w4e1_dog_class.rb | UTF-8 | 1,080 | 3.75 | 4 | [] | no_license | =begin
\netbeans\rubylearn\coreruby32\lib\samples\week4\???.rb
Developer: Dan Chuparkoff (Twitter: @chuparkoff )
Creation Date: 4/23/2012
Initial Ruby Version: Ruby 1.9.3-p125
Initial Development Environment: Windows 7 Home Premium - SP1
Initial Development IDE: NetBeans 7.1.1 with Ruby for Netbeans Plugin... | true |
1d5e86131c1b44f310e4ad4da9d01dbdf4987536 | Ruby | yanbin92/Rails_shop | /db/seeds.rb | UTF-8 | 1,769 | 2.546875 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
# test data
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings'... | true |
583f6b3c7f843d31048638b5dd02437c9b16f5c6 | Ruby | Rmartinez75/LS_IntroToProgramming | /FlowControl/flowCon_2.rb | UTF-8 | 105 | 3.34375 | 3 | [] | no_license | def change_string(str)
if str.length > 10
str.upcase
end
end
puts change_string('hello worlds')
| true |
32c3c2497df7a38bc760d6ee37a24bc73fd7d9c3 | Ruby | MikeCleary/compsci | /lib/factorial.rb | UTF-8 | 141 | 3.390625 | 3 | [] | no_license | class Factorial
class << self
def to(i)
if i > 1
i = i * to(i-1)
else
return i
end
end
end
end | true |
b214b55897fe5c02abb691d509f6b4af63f395fa | Ruby | edwardkerry/rps-challenge | /spec/game_spec.rb | UTF-8 | 1,490 | 2.90625 | 3 | [] | no_license | require 'game'
describe Game do
subject(:game) { described_class.new(player1, player2, weapons) }
let(:player1) { double :player1, name: 'Ed', choice: :paper, add_score: nil }
let(:player2) { double :player2, name: 'Computer', choice: :paper}
let(:weapons) { double :weapons, compare: nil, result: :paper }
l... | true |
e8c53f3a728dd5d5af43591b410fdc288fe989cd | Ruby | AsafDavidov/collections_practice_vol_2-prework | /collections_practice.rb | UTF-8 | 1,823 | 3.625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # your code goes here
require 'pry'
def begins_with_r(arr)
begins_r = true
arr.each do |tool|
if tool.chars[0] != 'r'
begins_r = false
end
end
begins_r
end
def contain_a(arr)
arr.select do |element| element.include?("a")
end
end
def first_wa(arr)
arr.find do |element| element.to_s.start_wi... | true |
5085c39db817eed2abf308557c242c355c9b4830 | Ruby | sploving/shogun | /examples/undocumented/ruby_modular/kernel_top_modular.rb | UTF-8 | 2,478 | 2.796875 | 3 | [] | no_license | # this was trancekoded by the awesome trancekoder
require 'narray'
require 'modshogun'
require 'load'
require 'pp'
traindat = LoadMatrix.load_dna('../data/fm_train_dna.dat')
testdat = LoadMatrix.load_dna('../data/fm_test_dna.dat')
label_traindat = LoadMatrix.load_labels('../data/label_train_dna.dat')
fm_hmm_pos=[trai... | true |
9268b856129fa599ac5e4cc39b85641d6ff95e72 | Ruby | smithevan/Wk2_day_2_hw_bear_fish_river | /bear.rb | UTF-8 | 273 | 3.4375 | 3 | [] | no_license | class Bear
attr_reader :name, :type
def initialize(name, type)
@name = name
@type = type
@stomach = []
end
def fish_count
return @stomach.length
end
def add_fish(fish)
@stomach.push(fish)
end
def roar()
return "Roaar"
end
end
| true |
df505feb73955d0fd939c4a18f5db9fcd7c5fe1c | Ruby | Datenschule/spaziergang-creator | /app/concerns/nextable.rb | UTF-8 | 575 | 2.609375 | 3 | [
"MIT"
] | permissive | module Nextable
extend ActiveSupport::Concern
def set_next(max_prio)
if priority < (max_prio - 1)
self.next = priority + 1
else
self.next = nil
end
end
def set_prev
if self.priority == 0
self.prev = nil
else
self.prev = self.priority - 1
end
end
def set_ne... | true |
948c34d26d5ea5461c365697bba60da78eb96359 | Ruby | coderbydesign/crontab_generator | /crontab_formatter.rb | UTF-8 | 557 | 3.109375 | 3 | [] | no_license | class CrontabFormatter
attr_reader :minute, :hour, :day_of_month, :month, :day_of_week, :command
def initialize(args)
@minute = args[:minute]
@hour = args[:hour]
@day_of_month = args[:day_of_month]
@month = args[:month]
@day_of_week = args[:day_of_week]
@command = args[:command]
end
de... | true |
422010e046ed114afc10ebb64b50c49a47c8edcd | Ruby | loophalen/band-directory | /bands/app/models/band.rb | UTF-8 | 2,387 | 2.78125 | 3 | [] | no_license | class Band
attr_reader :id, :name, :image, :description, :website
# connect to postgres
DB = PG.connect({:host => "localhost", :port => 5432, :dbname => 'bands_development'})
def self.all
results = DB.exec("SELECT * FROM bands;")
return results.map do |result|
{
... | true |
cadb8e7ae673c781c055b327b5fd197bd5988de6 | Ruby | shinnc/sudoku | /main.rb | UTF-8 | 818 | 3.203125 | 3 | [] | no_license | require './models/sudoku'
sudoku = Sudoku.new
puts "
____ _ _ ____ _
/ ___| _ _ __| | ___ | | ___ _/ ___| ___ | |_ _____ _ __
\\___ \\| | | |/ _` |/ _ \\| |/ / | | \\___ \\ / _ \\| \\ \\ / / _ \\ '__|
___) | |_| | (_| | (_) | <| |_| |___) | (_) | |\\ V / __/ |
|____/ \\__... | true |
493fa33e9baa1d1ab4b397a38792c7159e5770c9 | Ruby | jgayfer/snakes | /spec/die_spec.rb | UTF-8 | 347 | 2.5625 | 3 | [
"MIT"
] | permissive | RSpec.describe Snakes::Die do
let(:die_sides) { 6 }
let(:die) { Snakes::Die.new(die_sides) }
describe '#initialize' do
subject { die }
it { is_expected.to be_a Snakes::Die }
end
describe '#roll' do
subject { die.roll }
it 'returns an int within range' do
is_expected.to be_between(1, di... | true |
6d360a437be060957522aa6a682f9f8a5559f99e | Ruby | liln/anagram | /test/models/anagramm_test.rb | UTF-8 | 331 | 2.71875 | 3 | [
"MIT"
] | permissive | require "test_helper"
class AnagrammTest < Minitest::Unit::TestCase
def test_solve
a = Anagramm.new("iceman","cinema")
assert a.solve
b = Anagramm.new("iceman","noticeman")
assert !b.solve
c = Anagramm.new("c", "")
assert !c.solve
d = Anagramm.new("iceman","iceman")
assert !d.solve... | true |
894ecd2a21f69a0b62dac20aa962c77e7f31b75e | Ruby | dmaster18/ruby-collaborating-objects-lab-online-web-sp-000 | /lib/mp3_importer.rb | UTF-8 | 308 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MP3Importer
def initialize(filepath)
@filepath = filepath
@song_array = []
end
def files
@mp3_array = @filepath.split("/")
@mp3_string = @mp3_array.slice(@mp3_array.find_index("mp3s"),@mp3_array.length).join
end
def import
Song.new_by_filename(@mp3_string)
end
end | true |
62ae21bf7f0902006d8b4bfbb2ffbc1bc1fa556f | Ruby | gitvar/OOP | /Lesson 5/2. OO 21/Old/rev2_oop_21.rb | UTF-8 | 7,888 | 3.5625 | 4 | [] | no_license | # frozen_string_literal: false
class Deck
CARD_SUITS = %w(Hearts Diamonds Spades Clubs).freeze
CARD_FACES = %w(1 2 3 4 5 6 7 8 9 10 Jack Queen King Ace).freeze
def initialize
@deck = new_shuffled_deck
end
def deal_card
@deck.pop
end
private
def new_shuffled_deck
new_deck = CARD_SUITS.pro... | true |
6bf903b1ba83c3a0b92e655f405ce56d1a7ade54 | Ruby | georgeliu96/AppAcademy | /Software Engineering Foundations/Week 2/procs_project/lib/part_2.rb | UTF-8 | 550 | 3.59375 | 4 | [] | no_license | def reverser(str, &prc)
return prc.call(str.reverse)
end
def word_changer(str, &prc)
return (str.split(" ").map {|ele| prc.call(ele)}).join(" ")
end
def greater_proc_value (n, prc1, prc2)
return [prc1.call(n), prc2.call(n)].max
end
def and_selector (arr, prc1, prc2)
return arr.select {|ele| prc1.ca... | true |
889b48c2aa88b0512f0979b3c7d5b13476716ee5 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/rna-transcription/c0496cd1199d477fa3872928253fccef.rb | UTF-8 | 127 | 2.578125 | 3 | [] | no_license | class Complement
def self.of_dna(r)
r.tr("CGTA", "GCAU");
end
def self.of_rna(d)
d.tr("CGUA", "GCAT");
end
end
| true |
06811e223a711a03ca0a46c1155d22bfde926fee | Ruby | rsantaella/myfitnesspal-ruby | /lib/binary/sync_response.rb | UTF-8 | 2,540 | 2.5625 | 3 | [] | no_license | require_relative 'packet'
require_relative 'type'
module MFP
module Binary
class SyncResponse < Binary::Packet
PACKET_TYPE = Binary::Type::SYNC_RESPONSE
attr_reader :last_sync_pointers
def initialize
super(PACKET_TYPE)
end
def to_h
super.merge(
status_co... | true |
28f91f7c69cfd27a6869a87cc0a6c7a1fb2c04b1 | Ruby | brancz/tree_outline | /lib/tree_outline.rb | UTF-8 | 1,600 | 3.296875 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
require 'tree_outline/version'
class TreeOutline
DEFAULT = '├── '
LINE = '│ '
SINGLE = '└── '
EMPTY = ' '
def initialize(tree)
@tree = tree
@label_method = :to_s
@children_method = :children
end
def label_method(method_symbol)
@label_method = method_symbol
... | true |
393c568a34e13ac6ad25af6bf880f12ae0fce431 | Ruby | macosgrove/toy-robot | /spec/toy_robot_spec.rb | UTF-8 | 2,320 | 2.78125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "stringio"
require_relative "../lib/toy_robot"
describe ToyRobot do
let(:input) { double(IO) }
let(:output) { StringIO.new }
subject(:toy_robot) { described_class.new(input, output) }
context "When the input IO stream returns some commands and ends on nil" do
let(:... | true |
c01e545b627012df113d4fade2bb5016c9346a2b | Ruby | pulseenergy/scout-plugins | /nginx/nginx-average-response-times.rb | UTF-8 | 4,218 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | require 'time'
require 'stringio'
class NginxAvgResponseTimes < Scout::Plugin
needs 'yaml'
OPTIONS=<<-EOS
nginx_log_file:
default: "/var/log/nginx/access.log"
name: Log File
notes: Location of the nginx log file to examine
frequency:
default: 5
... | true |
bb546195a64f38b95b644719a592a43e76d1afc8 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/leap/2021765dd9cb47c5ae6c2747b715bc8a.rb | UTF-8 | 130 | 3.125 | 3 | [] | no_license | class Year
def self.leap?(year)
quan, modul = year.divmod(100);
date = (modul == 0) ? quan : year
(date % 4 == 0)
end
end
| true |
a7c9d6295bf6675036b4b29ecc118c9f20428a7f | Ruby | PSESD/csv-deidentifier | /deidentify.rb | UTF-8 | 567 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env ruby
require './lib/csv-deidentifier.rb'
directory = '.'
infile = ARGV[0].to_s
outfile = (ARGV[1] == "auto" || ARGV[1].nil?) ? infile.gsub(".csv", "-deidentified.csv").to_s : ARGV[1].to_s
@encoding = ARGV[2] == "auto" ? nil : ARGV[2]
raise Exception.new("Usage: ./deidentify.rb infile.csv outfile.csv enc... | true |
f2030a7fdcdccfb53f0fbc96a6302f74b9f40354 | Ruby | haeky/advent-of-code | /2017/day20-p1.rb | UTF-8 | 337 | 2.65625 | 3 | [] | no_license | particles = File.read('day20.txt').each_line.map { |line| line.scan(/(-?\d+)/).flatten.map(&:to_i).each_slice(3).to_a }
1000.times do
particles.each do |p, v, a|
3.times do |i|
p[i] += v[i] += a[i]
end
end
end
distances = particles.map(&:first).map { |p| p.map(&:abs).inject(:+) }
puts distances.inde... | true |
7068316ef7c22dd5b47cc46f2ad2e3d0c69b753e | Ruby | vicentedpsantos/leet-code | /easy_number_of_lines_to_write_string.rb | UTF-8 | 1,340 | 4.15625 | 4 | [] | no_license | # We are to write the letters of a given string S, from left to right into lines.
# Each line has maximum width 100 units, and if writing a letter would cause the
# width of the line to exceed 100 units, it is written on the next line. We are
# given an array widths, an array where widths[0] is the width of 'a', widths... | true |
d9c19bbe3f48208d010ca2b5165e5300045aef59 | Ruby | yadukrishnan88/basic_ruby_programs | /Classes/CallTask1.rb | UTF-8 | 97 | 2.609375 | 3 | [] | no_license | ###Task 1 Call
require './Task1'
x=Task1.addition (20,100)
y=Task1.subtract(20,10)
Task1.mul(x,y) | true |
ce1c1d6cd1b3adab939a1b9d5b12248c30f410d0 | Ruby | natify/nordea | /lib/nordea.rb | UTF-8 | 1,296 | 3.328125 | 3 | [
"MIT"
] | permissive | require 'nordea/bank'
require 'nordea/exchange_rates'
require 'nordea/version'
require 'tzinfo'
# Ruby interface to the Nordea Bank exchange rate data.
module Nordea
# The default timezone, Europe/Helsinki
TZ = ::TZInfo::Timezone.get('Europe/Helsinki')
extend self
class << self
# Parses the datetime forma... | true |
85697fc93ad7103366fca43cbe8be5dcb4cc96a4 | Ruby | YusukeYoshida8849/tbpgr_utils | /lib/open_classes/string/ascii_unicode_html_table.rb | UTF-8 | 1,400 | 3.125 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require 'open_classes/numeric/is_ascii'
require 'open_classes/string/ascii1_other2_size'
# String
class String
# get ascii_unicode_table
#
# === Example
#
# input
# 'aあb'
#
# result
#
# <table>
# <tr>
# <th>char</th>
# <th>ASCII</th>
# <th>ascii2<... | true |
09c5c8313775ac6eed339c4f7b7749345646579e | Ruby | chill-debug/boris_bikes- | /projects/Birthday/app.rb | UTF-8 | 725 | 2.828125 | 3 | [] | no_license | require 'sinatra'
get '/' do
"Happy birthday"
end
get '/birthday' do
p params
@name = params[:name]
erb :index
end
post '/happy_birthday' do
params
month = params[:month]
day = params[:days]
year = params[:years]
p Date.parse("#{day} #{month} #{year}")
p today = DateTim... | true |
19f995af4c77521f6ee9d8ab5e9f6d4420fef350 | Ruby | kh-fanis/fs_html | /lib/fs_html/fs_html_tag.rb | UTF-8 | 1,864 | 2.875 | 3 | [] | no_license | require 'fs_html'
class FsHtml
class FsHtmlTag
attr_accessor :name, :content, :is_line_tag
attr_reader :children, :attributes
def initialize name = "div", content = nil, attributes = Hash.new(""), is_line_tag = false, &block
_set_deafults
@name, = name, is_line_tag
if content.kind_o... | true |
2a7c791c91beabab6702220f762922f177b92c6c | Ruby | LE-HU/rratvar-task | /app/services/get_paginated_posts_service.rb | UTF-8 | 821 | 2.84375 | 3 | [] | no_license | class GetPaginatedPostsService
def initialize(post_model: Post, page:, limit:)
@post_model = post_model
@page = page
limit > 100 ? @limit = 100 : @limit = limit
end
def call
posts_hash
end
private
attr_reader :post_model, :page, :limit
def posts_hash
posts.map do |post|
{
... | true |
de45f86568497f3e4952ef526672511d2f84181a | Ruby | Plasmarobo/adventofcode2017 | /day10.rb | UTF-8 | 1,286 | 3.375 | 3 | [
"MIT"
] | permissive | class TieHash
class HashPtr
def initialize(value, limit)
@value = value
@limit = limit
end
def inc
@value += 1
if @value >= @limit then
@value = 0
end
end
def dec
@value -= 1
if @value < 0 then
@value = @limit - 1
end
end
... | true |
942611a185909b2bdaa0736bbf5bb0899215de10 | Ruby | jeniatret/ruby_fundamentals2 | /exercise6.rb | UTF-8 | 1,078 | 4.15625 | 4 | [] | no_license | def store(grocery_list)
#grocery list with an item on each line with an * in front of it
grocery_list.each {|item| puts "* #{item}"}
end
#original line
grocery_list = ["carrots", "apples", "chips", "salmon"]
store(grocery_list)
puts "-----------------------"
#add rice to the list and output it in the list
grocer... | true |
445560182476ee6d92f8358c1024e21d113a678f | Ruby | mvillis/7lang | /ruby-day1.rb | UTF-8 | 1,032 | 4.09375 | 4 | [] | no_license | # example string matcher
a = "foo,bar,baz"
b = a.sub( "foo", "boo" )
puts b
# example reg expression
m1 = /Ruby/.match("The future is Ruby")
puts m1.class # it returns MatchData
m2 = "The future is Ruby" =~ /Ruby/
puts m2 # it returns 14
# ruby ranges
(-1..-5).to_a #=> []
(-5..-1).to_a ... | true |
bd804924a7c0b4e9e0f052424ebacc719bfa22e0 | Ruby | dominicfraser/snakes_and_ladders | /spec/player_spec.rb | UTF-8 | 1,302 | 3.3125 | 3 | [] | no_license | require "require_all"
require ("minitest/autorun")
require ("minitest/rg")
require_relative "../player"
require_relative "../die"
require_relative "../board"
require_relative "../ladder"
require_relative "../snake"
class TestPlayer < MiniTest::Test
def setup
@player1 = Player.new("Jake")
@board1 = Board.n... | true |
69148637a635f74c54d8b482f669c1c581a66528 | Ruby | mlkelly/ruby-oo-complex-objects-school-domain-yale-web-yss-052520 | /lib/school.rb | UTF-8 | 501 | 3.9375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # code here!
class School
attr_accessor :school_name, :roster
def initialize(school_name)
@school_name = school_name
@roster = {}
end
def add_student(student_name, grade)
if @roster[grade]
@roster[grade] << student_name
else
@roster[grade] = ... | true |
51fefd709b4ad52d0d4889e1f4869e98dd71ad2e | Ruby | adrian-lara/black_thursday | /lib/customer_repository.rb | UTF-8 | 863 | 3.265625 | 3 | [] | no_license | require_relative 'customer'
require 'csv'
class CustomerRepository
attr_reader :all, :parent
def initialize(file_path, parent = nil)
@all = from_csv(file_path)
@parent = parent
end
def from_csv(file_path)
customers = []
options = {headers: true, header_converters: :symbol, converters: :numer... | true |
9d5669e2b6827f41647a14030fda92de713a1059 | Ruby | endofhome/rps-challenge | /spec/alt_game_spec.rb | UTF-8 | 1,818 | 3.046875 | 3 | [] | no_license | require 'alt_game'
describe AltGame do
let(:player) { double :player, name: 'Player 1' }
let(:cpu_player) { double :cpu_player, name: 'Computer' }
subject(:game) { described_class.new(player,cpu_player,1)}
describe 'initialization' do
it {is_expected.to respond_to(:player)}
it {is_expected.to respo... | true |
622799a5cef450aa6572f92be136c38a64a42aa1 | Ruby | haraguchi12/paiza | /sample8.rb | UTF-8 | 123 | 3.25 | 3 | [] | no_license | # -100から100までの整数 n が与えられるので、絶対値を出力して下さい。
N = gets.to_i
puts N.abs | true |
8f747983cca1aefc012ae87ad0c38eba37a16093 | Ruby | glowf/precourse | /introduction/5-Loops/Ex2.rb | UTF-8 | 82 | 2.953125 | 3 | [] | no_license | begin
puts "What's your name?"
answer = gets.chomp
end until answer == 'STOP'
| true |
d301ff6bbffc98eaf89a635693ae643083d14924 | Ruby | FLawrence/contextus | /253/utilities/twofivethree2tinderbox.rb | UTF-8 | 3,204 | 2.859375 | 3 | [] | no_license | require 'rubygems'
require 'ftools'
require 'json'
$pro_count = []
$con_count = []
$all_links = []
$basic_id = "11111111"
$all_ids = []
PRO_XVAL = -0.5
CON_XVAL = 5
class Link
attr_accessor :name
attr_accessor :source
attr_accessor :destination
def initialize(name, source, destination)
@name = name
... | true |
6becc281269e7507396e567b43d1d28f67d9db94 | Ruby | FergusLemon/boris_bikes | /spec/feature_spec.rb | UTF-8 | 3,939 | 3.53125 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require './lib/docking_station'
require './lib/bike'
require './lib/van'
require './lib/garage'
puts
puts "docking_station = DockingStation.new"
puts docking_station = DockingStation.new
puts
puts "bike = Bike.new"
puts bike = Bike.new
puts
puts "another_bike = Bike.new"
puts another_bike = Bike.new
#As a member of t... | true |
4c4689fa021a3d41d7c4763df9b9286863e050fc | Ruby | AndyStabler/Stable-Financing | /app/models/transfer/factory.rb | UTF-8 | 628 | 2.53125 | 3 | [] | no_license | class Transfer::Factory
RECURRENCES = [
Transfer::Daily::RECURRENCE,
Transfer::Weekly::RECURRENCE,
Transfer::Monthly::RECURRENCE,
Transfer::NoRecurrence::RECURRENCE
]
def self.build(recurrence, attributes)
case recurrence
when Transfer::Daily::RECURRENCE
Transfer::Daily.new(attribu... | true |
e103b9ce3d4f8f93fcff6a9c50daa843a3b1105c | Ruby | Tkam13/atcoder-problems | /1st-saikyou-student-programer/a.rb | UTF-8 | 172 | 2.78125 | 3 | [] | no_license | m,d = gets.chomp.split.map(&:to_i)
cnt = 0
(1..m).each do|k|
(0..d).each do|i|
if (i/10)*(i%10) == k && i/10 >= 2 && i%10>=2
cnt += 1
end
end
end
puts cnt | true |
b52faef8a9864d65f5982604f5b50e3afc0a1cc3 | Ruby | zeshaans/lessons | /forms.rb | UTF-8 | 794 | 4.09375 | 4 | [] | no_license | #gets will take a user input
print "What's your name? "
name = gets.chomp #chomp get rid of the space from pressing enter
print "What's your job title? " #using print means the terminal will ask for the input on the same line
job_title = gets.chomp
print "What's your team name? "
team = gets.chomp
print "How long ha... | true |
ebbacd6c485cea506b7e5efaa38bb0feefcb5f0b | Ruby | eniolar10/deli-counter-onl01-seng-ft-012120 | /deli_counter.rb | UTF-8 | 532 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
katz_deli = []
counter = 1
take_a_number(katz_deli, "Ada")
puts "Welcome Ada. You are #{counter} in line."
take_a_number(katz_deli, "Grace")
puts "Welcome Grace. You are #{counter} in line."
take_a_number(katz_deli, "Kent")
puts "Welcome Kent. You are #{counter} in line."
line(katz_deli) ... | true |
2841254426edf3ff46f6eb675e1ef0aff9cf379c | Ruby | allerin/rails_currency | /lib/rails_currency/convertor.rb | UTF-8 | 1,482 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'uri'
require 'open-uri'
require 'timeout'
require 'hpricot'
require 'rails_currency/conversion_services/google'
require 'rails_currency/conversion_services/xe'
module RailsCurrency
class RailsCurrencyError < StandardError
end
class InvalidAmountError < RailsCurrencyError
end
class UnknownCurrency... | true |
ceec187950b02d938a29f401ab4341075a8aab6a | Ruby | Runnantina/oo-kickstarter-web-031317 | /lib/backer.rb | UTF-8 | 913 | 3.15625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
class Backer
attr_accessor :name, :backed_projects
def initialize(name)
@name = name
@backed_projects = []
end
def back_project(project)
@backed_projects << project
# adds the backer to the project's backers array
project.backers << self
end
# Donation.new(sel... | true |
e0ea196c88603d59f289b22996b38397bb1d3bf7 | Ruby | cosmo0920/datapipes | /examples/basics.rb | UTF-8 | 564 | 3.046875 | 3 | [
"MIT"
] | permissive | require 'datapipes'
class List < Datapipes::Source
def run
(1..10).each {|i| produce(i) }
end
end
class Triple < Datapipes::Tube
def run(data)
[data, data, data]
end
def accept?(data)
data.is_a? Integer and data > 3
end
end
class Print < Datapipes::Sink
def run(data)
puts data
end
... | true |
609e591859b39e5a570db50bb0f49434ffec627c | Ruby | Azbury/ttt-with-ai-project-online-web-sp-000 | /lib/board.rb | UTF-8 | 1,032 | 3.875 | 4 | [] | no_license | class Board
attr_accessor :cells
def initialize
self.reset!
end
def self.copy_constructor (cells)
@cells = cells
end
def reset!
self.cells = [" "," "," "," "," "," "," "," "," "]
end
def display
puts " #{self.cells[0]} | #{self.cells[1]} | #{self.cells[2]} "
puts "-----------"
... | true |
65d3314bacb1143fb1ae108544b23f195e313857 | Ruby | jhordman/applied-programming | /weather.rb | UTF-8 | 1,280 | 3.328125 | 3 | [] | no_license | require "forecast_io"
# configure the Dark Sky API with your API key
ForecastIO.api_key = "48bf33cc5ec4243ed7cd8671816f25cd"
# do the heavy lifting, use Global Hub lat/long
forecast = ForecastIO.forecast(42.0574063,-87.6722787).to_hash
# pp = pretty print
# use instead of `puts` to make reading a hash a lot easier
# ... | true |
e1dcdd8ff8ab350b1db221202e688441f5cf7c8f | Ruby | oesgalha/laranja | /lib/laranja/generators/pt-BR/documento.rb | UTF-8 | 1,181 | 2.828125 | 3 | [
"MIT"
] | permissive | module Laranja
class Documento < Generator
class << self
def cpf(uf = nil)
number = strf('########') + uf_code(uf)
number + verification_digits(number).join
end
def cpf_formatado(uf = nil)
c = cpf(uf)
'%03d.%03d.%03d-%02d' % [ c[0..2].to_i, c[3..5].to_i, c[6..8].... | true |
15faaeadd900bd875537a56611f47471c02f0b62 | Ruby | huasmc/classes_practice | /specs/library_class_spec.rb | UTF-8 | 1,718 | 3.40625 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative('../library_class.rb')
class TestLibrary < Minitest::Test
def setup
@books = Library.new(
[
{
title: "into the wild",
rental_details: {
student_name: "Yoni",
date: "monday"
}
},
{
title: "so... | true |
182b1bb80ac547023c3831c5289aab74aebfeb90 | Ruby | rhomobile/rhodes | /spec/framework_spec/app/spec/core/objectspace/fixtures.rb | UTF-8 | 577 | 2.5625 | 3 | [
"MIT"
] | permissive | module ObjectSpaceFixtures
def self.garbage
blah
end
def self.blah
o = "hello"
@garbage_objid = o.object_id
return o
end
@last_objid = nil
def self.last_objid
@last_objid
end
def self.garbage_objid
@garbage_objid
end
def self.make_finalizer
proc { |obj_id| @last_obji... | true |
b2155d641a2e32d990b56f2b1b2b14a14af59d78 | Ruby | szTheory/web_pipe | /lib/web_pipe/extensions/dry_view/dry_view.rb | UTF-8 | 4,436 | 2.5625 | 3 | [] | no_license | # frozen_string_literal: true
require 'web_pipe/types'
require 'web_pipe/conn'
require 'dry/view'
#:nodoc:
module WebPipe
# Integration with `dry-view` rendering system.
#
# This extensions adds a {#view} method to {WebPipe::Conn} which
# sets the string output of a `dry-view` view as response body.
#
# @... | true |
4b1b0ca8dc58b1c6164048b136072bb8a479a73a | Ruby | DewaldoDev/fantasy_financial | /app/models/base_stock.rb | UTF-8 | 1,641 | 2.734375 | 3 | [] | no_license | class BaseStock < ActiveRecord::Base
require 'yahoo_finance'
has_many :owned_stocks
has_many :logs
validates :current_market_price, numericality: {greater_than: 0}
def self.seed_stocks_from_file(filename)
tickers = read_tickers_from_file(filename)
stocks = fetch_stock_data(tickers, [:name, :last_trade_pri... | true |
55ce9a1dc0874663b02bedf86186b5ff81e10a7d | Ruby | RafCas88/student-team | /specs/student_spec.rb | UTF-8 | 976 | 3.09375 | 3 | [] | no_license | require("minitest/autorun")
require("minitest/rg")
require_relative("../student")
class TestStudent < MiniTest::Test
def test_get_name
student = Student.new("Raffaele", "E34", " ")
assert_equal("Raffaele", student.get_name())
end
def test_get_cohort
student = Student.new("Raffaele", "E34", " ")
assert_equal(... | true |
94b75507b4ae4623350844727beb7a7c358e8dc1 | Ruby | CaseyAMeakin/configurator | /configurator.rb | UTF-8 | 3,173 | 3.171875 | 3 | [] | no_license | require 'json'
require 'yaml'
require 'optparse'
class Configurator
DEFAULTS = "defaults"
CLI = "cli"
REQUIRED_KEYS = [
DEFAULTS,
CLI
]
def initialize(conf_file)
@raw = ingest_yaml_conf(conf_file)
@conf = process_raw_conf
end
def hash
@conf
end
def json
@conf.to_json
end
... | true |
ccc78ee218a45d940be81258987acda2b30950eb | Ruby | karmapoint/chess | /piece.rb | UTF-8 | 244 | 3.09375 | 3 | [] | no_license | require "colorize"
class Piece
attr_reader :color
attr_accessor :pos
COLORS = [:black, :white, :null]
def initialize(pos, color)
@pos = pos
@color = color
end
def inspect
"piece"
end
def to_s
"X"
end
end
| true |
c8464e803c3db732c0972de7c39701ac3df5f22b | Ruby | rlcoble8/expertiza | /features/step_definitions/create_team_assignment_add_participants.rb | UTF-8 | 3,440 | 2.78125 | 3 | [] | no_license | =begin
To login as a student,
go to the login page,
fill in username and password
and click on login button
The method below does this
=end
Given /^I am logged in as a "(\S+)"$/ do |username|
first('#logout-button').try(:click)
step 'I go to the login page'
fill_in 'login_name', :with => username
... | true |
c73b247b9395bb955ad421d16270490ae441dcb3 | Ruby | lujanfernaud/test-first-ruby | /08_book_titles/book.rb | UTF-8 | 543 | 3.59375 | 4 | [] | no_license | class Book
attr_accessor :title
def title
array = @title.scan(/\w+/)
word_stop = ['a', 'an', 'in', 'on', 'at', 'of', 'and', 'the']
final_title = []
array.each do |word|
if final_title.include? word.capitalize and word_stop.include? word and word == array[0]
final_title.push word
elsif word_stop.i... | true |
e9e198526e9866b08bcf38efa04f2990e20324af | Ruby | justindelatorre/rb_101 | /lesson_3/easy_1/easy_1_1.rb | UTF-8 | 346 | 3.984375 | 4 | [] | no_license | =begin
What would you expect the code below to print out?
numbers = [1, 2, 2, 3]
numbers.uniq
puts numbers
Solution:
1
2
2
3
=end
numbers = [1, 2, 2, 3]
numbers.uniq
puts numbers
=begin
Explanation:
Array#uniq does not mutate the caller, so printing numbers after #uniq is
called will print all elements in the ori... | true |
44f6197924f99f1fffc87c78180faa41f7be49d1 | Ruby | umezizi/grade_app | /app/models/gym.rb | UTF-8 | 1,805 | 2.53125 | 3 | [] | no_license | class Gym < ApplicationRecord
has_many :reviews, dependent: :destroy
has_many :passive_relationships, class_name: 'Relationship',
foreign_key: 'favorite_gym_id',
dependent: :destroy
has_many :guest_users, through: :passive_relationships
defa... | true |
ff820a5b1bb7dc4f66b6a4ca55865a03f137dd4f | Ruby | chocolateboy/string_splitter | /test/position.rb | UTF-8 | 2,486 | 2.9375 | 3 | [
"Artistic-2.0"
] | permissive | # frozen_string_literal: true
require_relative 'test_helper'
# confirm split.position and its split.pos alias is 1-based
describe 'split.position' do
ss = StringSplitter.new
it 'is 1-based for a split at the beginning' do
result = ss.split('foo:bar:baz:quux', ':') { |split| split.position == 1 }
assert ... | true |
24268712fcb688a06e7ec14979616dffed4fe892 | Ruby | erlog/codingpractice | /Ruby/Advent/Day007.rb | UTF-8 | 1,976 | 3.265625 | 3 | [] | no_license | input = open("Day007-input.txt").readlines.map!(&:strip)
Commands = Hash.new{[]}
Registers = Hash.new
def notgate(value)
value = 65535 - value
return value
end
def lshiftgate(value, amount)
value = value << amount
return value
end
def rshiftgate(value, amount)
value = value >> amount
return value
end
def and... | true |
2abb89208a3427591710c1f963f6340317fca890 | Ruby | MakoaDeVincent/my-collect-onl01-seng-ft-032320 | /lib/my_collect.rb | UTF-8 | 125 | 3.21875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_collect(col)
i = 0
array = []
while i < col.length
array << yield(col[i])
i = i + 1
end
array
end
| true |
2077b1cdd5e2533fda491b3cb537a2c8a8806793 | Ruby | kharigai/ruby | /atcoder/abc128_c.rb | UTF-8 | 425 | 2.765625 | 3 | [] | no_license | # abc128 c
N, M = gets.strip.split.map(&:to_i)
a = M.times.map { gets.strip.split.map(&:to_i) }
pp = gets.strip.split.map(&:to_i)
p a
p pp
c = 0
(1<<N).times do |i|
sum = Array.new(M){0}
s = "%0#{N}b" % i
s.size.times do |j|
if s[j] == '1'
p j
p a[j]
a[j][1..-1].each do |k|
sum... | true |
085e4886aca0327704aafc89affaf576e591e223 | Ruby | jacksteven7/HackerRank | /Recursion- Fibonacci Numbers.rb | UTF-8 | 110 | 3.640625 | 4 | [] | no_license | def fibonacci(n)
return n if n < 2
fibonacci(n-2) + fibonacci(n-1)
end
n = gets.to_i
puts (fibonacci(n)) | true |
74a8ef56f7688a3e7f2c1e916ca7734e3cbf4361 | Ruby | obj3-unahur/method-overload-ruby | /spec/implementacion_spec.rb | UTF-8 | 647 | 2.96875 | 3 | [] | no_license | require_relative '../src/implementacion'
describe "Implementacion Suite" do
it "Creacion Implementacion correcta" do
implementacion = Implementacion.new([Integer, Integer]) do |n1, n2|
n1 * n2
end
expect(implementacion).not_to be(nil)
end
it "Creacion Implementacion incorrecta falla" do
ex... | true |
e78b2ca417c13556674b37469f8f9f3e253d587b | Ruby | goshacmd/medberry | /app/interactors/consultation_extender.rb | UTF-8 | 1,049 | 2.703125 | 3 | [] | no_license | # A service to extend consultations.
class ConsultationExtender
EXTENSION_WINDOW = 1.5.minutes
attr_reader :consultation
delegate :extension_span, :max_extensions, to: :policy
# Initalize a +ConsultationExtender+.
#
# @param consultation [Consultation]
def initialize(consultation)
@consultation = c... | true |
af7e51c5d9e03df25bae26205792e1f35af29892 | Ruby | jerrypan90/ruby_code_challenge | /DNA-Analyzer/index.rb | UTF-8 | 638 | 3.125 | 3 | [] | no_license | dna = "GCTCGATCGATCTAGCTAGCATGATAATCGATGATCTAGCCGGGCCCTTAGCGGATCTAGCATCGATCGACTCGATCGAGCGCTAGCTACGATCAG"
#qn1
dna_array = dna.split('')
# puts dna_array.uniq.count
#qn2
count_a_bases = dna_array.count { |x| x.include? "A" }
# puts count_a_bases
#qn3
octet = dna_array.each_slice(8).to_a
# puts octet.uniq.count
#qn4
... | true |
b816ff8aff5f3faa9d99c12603a028c304e3774d | Ruby | rodrigomg/advent-of-code | /lib/day2.rb | UTF-8 | 687 | 3 | 3 | [] | no_license | f = File.open("#{Dir.pwd}/input_day2.txt", "r")
total = []
f.each_line do |line|
data = line.split("x")
l = Integer(data[0])
w = Integer(data[1])
h = Integer(data[2])
sideA = (2 * l * w)
sideB = (2 * w * h)
sideC = (2 * h * l)
minSide = [l*w, w*h, h*l ].min
total << (sideA + sideB+ sideC + minSide)
end
f.clo... | true |
91c84fc46406b9691da296fa224d5c73ecacc45b | Ruby | mark/Battleship | /ship.rb | UTF-8 | 946 | 3.6875 | 4 | [] | no_license | class Ship
attr_reader :coords
# get starting coordinates, direction, and ship length
#create an array for the coordinates of the ship.
# ship starting at (x,y), next tile @ (x+1, y), next (x+2, y)
#(x+3, y), (x+4, y)
DELTAS = { :up => [0, -1], :down => [0, 1], :left => [-1, 0], :right => [1, 0] }
def ... | true |
565b8d20cde1d1e0c8eede47df69adf545b10333 | Ruby | chet-k/AppAcademy-Open-Work | /1-Ruby/06-OOP/Simon/lib/simon.rb | UTF-8 | 1,386 | 3.75 | 4 | [] | no_license | require "byebug"
class Simon
COLORS = %w(red blue green yellow)
attr_accessor :sequence_length, :game_over, :seq
def initialize
@sequence_length = 1
@game_over = false
@seq = []
end
def play
take_turn until @game_over
game_over_message
reset_game
end
def take_turn
show_seq... | true |
06cbe1e08de1df309e5cdd5af8a6729558718eb4 | Ruby | vurokrazia/CursoRubyOnRails2017 | /RubyBasico/capitulo12.rb | UTF-8 | 67 | 3.171875 | 3 | [] | no_license | # Loops
var = 0
while var <= 1000000
puts var
var += 1
end | true |
019ca7ada4baaf0a21139a8183567b993e5fc335 | Ruby | bencorbet/Intro-to-Programming | /variables/name.rb | UTF-8 | 349 | 4.21875 | 4 | [] | no_license | =begin
Write a program called name.rb that asks the user to
type in their name and then prints out a greeting
message with their name included.
=end
puts "Hi, what's your first name?"
first_name = gets.chomp
puts "What's your surname?"
surname = gets.chomp
puts "Hello #{first_name} #{surname}, nice to meet you!"
10... | true |
c06b6447ad799b2cb1622584702b74a83a1939dd | Ruby | Yann233/programming-univbasics-4-simple-looping-lab-chicago-web-033020 | /lib/simple_loops.rb | UTF-8 | 1,032 | 4.3125 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # https://learn.co/tracks/fswd-prework-2-01/fswd-prework-2-01-fswd-prework/fswd-prework-2-01-fswd-prework-programming-as-conversation-part-4-collection-data-types-array-and-hash/basic-looping-lab
#takes in a message and outputs it five times
def loop_message_five_times(message)
count = 0
while count < 5 do
puts... | true |
eaa66ef2e0f48fcbbaedbf90ddd79f565ab4c7a7 | Ruby | zibbet/etsy | /lib/etsy/profile.rb | UTF-8 | 1,045 | 2.515625 | 3 | [
"MIT"
] | permissive | module Etsy
# = Profile
#
# Represents a profile resource of an Etsy user.
#
class Profile
include Etsy::Model
attribute :id, :from => :user_profile_id
attribute :user_id
attribute :bio
attribute :username, :from => :login_name
attribute :gender
attribute :birth_day
attribut... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.