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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
f0a721298b128594bb768ff19a5575de3837bcc6 | Ruby | dmgoeller/mime | /lib/mime/composite_content.rb | UTF-8 | 2,661 | 2.96875 | 3 | [
"MIT"
] | permissive | module Mime
# Represents a message content consisting of multiple parts.
#
# ### Example
#
# The following example illustrates how to create a `multipart` message
# content using the `CompositeContent` class:
#
# ```ruby
# content = CompositeContent.new("mixed", "boundary")
# content << PlainConten... | true |
798b10e090181e2aa7a2e08ef8732d25764f88bc | Ruby | luanlinares/Exercicio_Dojo_1 | /Resolução_2.rb | UTF-8 | 548 | 3.765625 | 4 | [] | no_license | #RESOLUCAO 2
puts "Informe o nome do vendedor: "
vendedor = gets.chomp
puts "Informe o valor do salário: "
salario = gets.chomp.to_i
puts "Informe o total de vendas no mês: "
vendas = gets.chomp.to_i
class Calculos
def comissao(total_vendas)
total_vendas * 0.15
end
def total(salario_mes, valor_vendas, n_... | true |
eecef8169983043e7566bad05e83c8075c4fe137 | Ruby | pieter/gitbot | /lib/support/tinyurl.rb | UTF-8 | 530 | 2.59375 | 3 | [
"MIT"
] | permissive | class TinyURL
def self.tiny(url)
return nil unless url
http = Net::HTTP.start("tinyurl.com", 80)
begin
response = http.post("/create.php", "url=#{url}")
rescue Exception => e
return url
end
if response.code == "200"
begin
body = response.read_body
line = bod... | true |
ff203422c261b3fe3c4b84b69bc7c373be76bc82 | Ruby | jameszhan/rhea | /codes/ruby/rubygems/activesupport/callbacks.rb | UTF-8 | 1,481 | 3.140625 | 3 | [] | no_license | require 'active_support/callbacks'
class Record
include ActiveSupport::Callbacks
define_callbacks :save, :create
set_callback :save, :before, -> { puts "hello..." }
set_callback :save, :after, -> { puts "world..." }
set_callback :create, :before, -> { puts "hello..." }
set_callback :create, :after, -> { pu... | true |
5750bfd0e14d84679d0e2291a1fb77de1e1fda95 | Ruby | Alexendoo/Advent-of-Code-2016 | /Day 01/part-2.rb | UTF-8 | 548 | 3.125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'set'
direction = %w(N E S W)
x = 0
y = 0
visited = Set.new [[0, 0]]
ARGF
.first
.split(', ')
.map { |e| e.split('', 2) }
.map { |(turn, length)| [turn, length.to_i] }
.each do |(turn, length)|
direction.rotate!(turn == 'R' ? 1 : -1)
length.times do
case direction.... | true |
599723e57fb63119bb26e1675e617cdfa690d517 | Ruby | English3000/algorithms | /binary-search-tree/lib/bst_practical.rb | UTF-8 | 211 | 3.125 | 3 | [] | no_license | require 'binary_search_tree'
def kth_largest(tree_node, k) #input is a Node, not a BST
return nil if k == 0
tree = BinarySearchTree.new
tree.root = tree_node
tree.find(tree.in_order_traversal[-k])
end
| true |
259e9bbbec787982b3bfc9d732700b0df84f4eda | Ruby | StevenXL/testfirst | /12_rpn_calculator/rpn_calculator.rb | UTF-8 | 1,949 | 4.09375 | 4 | [] | no_license | class RPNCalculator
attr_reader :value
def initialize
@stack = Array.new
@value = 0
end
def push(integer)
@stack << integer
end
def plus
operands = @stack.pop(2)
if operands.size == 0
raise("calculator is empty")
else
@... | true |
6c2cbb11abe322e5c979ae55979017b45cee1be4 | Ruby | jpileto/ruby-fundamentals-1 | /exercise4.rb | UTF-8 | 180 | 3.109375 | 3 | [] | no_license | n = (1..100)
n.each do |n|
if n % 3 == 0 && n % 5 == 0
puts "Bitmaker"
elsif n % 3 == 0
puts "Bit"
elsif n % 5 == 0
puts "Maker"
else
puts "#{n}"
end
end
| true |
0e0d2dbf53be2c2456ff1ddfcd437025c9748100 | Ruby | miyagawa/feeda | /feeda.rb | UTF-8 | 2,106 | 2.671875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'feedzirra'
require 'pathname'
require 'digest/sha1'
require 'thor'
require 'htmlentities'
module Feeda
class Feed
attr_accessor :feed, :new_entries
def initialize(url)
@url = url
@path = cache_path
@first = true
end
def cache_path
base = Pathname... | true |
1c9b435edaa5982d6e5a143163fc8ffae8748903 | Ruby | AmineNGB/Gocine | /app/services/movie_matcher.rb | UTF-8 | 860 | 2.90625 | 3 | [] | no_license | class MovieMatcher
def initialize(event)
@event = event
@score = Hash.new(0)
end
def find_best_seance
calculate_scores
# ap "Je suis la"
# ap @event.good_movies.where(film_id: best_score[0])
# ap "Et puis la"
# ap best_score
if best_score.nil?
return 0
end
@event.goo... | true |
42ae8430f8f343df15c377b858f476c95bcab530 | Ruby | davidkellis/benchmarks | /sudoku/ruby2.5.1/solver2.rb | UTF-8 | 18,586 | 3.40625 | 3 | [
"MIT"
] | permissive | require 'pp'
require 'set'
# this is a ruby port of http://codepumpkin.com/sudoku-solver-using-backtracking/
# improved with rules taken from http://byteauthor.com/2010/08/sudoku-solver/
# list of difficult puzzles: http://staffhome.ecm.uwa.edu.au/~00013890/sudoku17
# Abstractly, a Tag is used for is coordinating cha... | true |
0e8b725fb24475eea5181e837c4fc10b56d63768 | Ruby | tamnil/codeeval | /ruby/easy/delta_times/delta.rb | UTF-8 | 603 | 2.953125 | 3 | [] | no_license |
def entrada(*args)
File.read(ARGV[0]).split("\n")
end
teste = entrada()
# processa a linha:
teste.each do |line|
tmp = line.split(" ")
start = tmp[0].split(":")
finish = tmp[1].split(":")
timestart = Time.new(1,1,1,start[0],start[1],start[2])
timestop = Time.new(1,1,1,finish[0],finish[1],finish[2])
delta = (timest... | true |
5dedf97d67e2bf48ab6ad1b4db6369575bad5974 | Ruby | hmans/schnitzelpress | /spec/post_spec.rb | UTF-8 | 2,841 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Schnitzelpress::Post do
subject do
Factory.build(:post)
end
context 'slugs' do
before do
subject.slugs = ['some-slug', 'another-slug']
subject.slug = 'a-new-slug'
end
its(:slugs) { should == ['some-slug', 'another-slug', 'a-new-slug'] }
its(:slug) ... | true |
84a20efc5c6194cac290aa6fcbb14cd667e7cf9c | Ruby | timloo0710/spree | /vendor/extensions/tax_calculator/lib/spree/tax_calculator.rb | UTF-8 | 743 | 2.515625 | 3 | [] | no_license | module Spree
module TaxCalculator
def calculate_tax(order)
# For now we're assuming every item in the order is either taxable or non-taxable (depending on the state.)
# We'll replace with something more sophisticated later (plus you can always write your own extension.)
state = order.ship_addres... | true |
ffd65d04f94bb25fbbfc9d467b569374e724a84b | Ruby | TheHamCo/learn_ruby | /02_calculator/calculator.rb | UTF-8 | 1,586 | 4.15625 | 4 | [] | no_license | def add(p1,p2)
p1+p2
end
def subtract(p1,p2)
p1-p2
end
def sum(array)
#My original solution:
#y = 0
#array.each {|element| y += element}
#return y
#Improved:
array.inject(0) {|sum,n| sum + n}
#Lesson:
#http://ruby-doc.org/core-2.2.3/Enumerable.html#method-i-inject
#The inject method, is included in the A... | true |
078b13c76d04299524c12cbded1e07c7c1ba05b9 | Ruby | tpetersen0308/oo-cash-register-v-000 | /lib/cash_register.rb | UTF-8 | 730 | 3.453125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class CashRegister
attr_accessor :total, :discount, :items, :price, :quantity
def initialize(employee_discount = 0)
@total = 0
@discount = employee_discount
@items = []
end
def add_item(title, price, quantity = 1)
@price = price
@quantity = quantity
counter = 0
while (counter < qu... | true |
3d68520b22d74c7e23513efd2089cc7620be6382 | Ruby | hansenjl/flatiron_cohort_lead_lessons | /minis/short_circuit.rb | UTF-8 | 5,384 | 4.78125 | 5 | [] | no_license | ## Setup
class Dog
def initialize(name)
@name = name
end
def name
return @name
end
end
r = Random.new()
## Code snippet 1: What errors are you getting? Why? What is it telling you?
# my_dog = nil
# name = my_dog.name
# puts name
## Code snippet 2: How do... | true |
d25c2806b0a6460c89c65c8c92b4542ff6fdeb98 | Ruby | kares/ruby_speech | /lib/ruby_speech/ssml/audio.rb | UTF-8 | 2,803 | 3.015625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'ruby_speech/ssml/element'
module RubySpeech
module SSML
##
# The audio element supports the insertion of recorded audio files (see Appendix A for required formats) and the insertion of other audio formats in conjunction with synthesized speech output. The audio element may be empty. If the audio ele... | true |
20e566bb150eb294397488d0fc9dbd53a0709a7d | Ruby | air1bzz/organ_cooker_sketchup | /organ_cooker/extensions/string_extend.rb | UTF-8 | 921 | 3.46875 | 3 | [] | no_license | require_relative '../BO/note'
##
# Implementation of Ruby core {http://ruby-doc.org/core-2.3.1/String.html String}
# class in order to access OrganCooker::Note objects.
class String
##
# Converts string to +music note+ object
# @return [OrganCooker::Note]
# @api public
# @example
# n = "a#1".to_note #=> ... | true |
b64740dba61a92dc99b2f6238f39d8afe6dbea4a | Ruby | adamhundley/exercism | /ruby/nth-prime/prime.rb | UTF-8 | 277 | 3.4375 | 3 | [] | no_license | class Prime
def self.nth(num)
return false if num <= 1
2.upto(Math.sqrt(num).to_i) do |x|
return false if num%x == 0
end
true
end
def next_prime
n = num+1
n = n + 1 until n.is_prime?
n
end
end
| true |
2565fdf371de9c8cecb225b967743cf47f5f1c18 | Ruby | svbarilov/ruby_kick_prologs_ass | /problems/lists/04.rb | UTF-8 | 139 | 3.015625 | 3 | [] | no_license | # 1.04 (*) Find the number of elements of a list.
module Problems
module List
def self.size(list)
list.size
end
end
end
| true |
211ff817fcf34423e3d93e8297998dd5aff92311 | Ruby | ExistsAndIs1/newral | /lib/newral/tools.rb | UTF-8 | 4,396 | 3.328125 | 3 | [
"MIT"
] | permissive | module Newral
module Tools
module Errors
class NoElements < StandardError; end
end
def self.mean( array )
array.sum.to_f/array.length
end
def self.sigma( array )
mean = self.mean( array )
sigma_square = array.inject(0){ |value,el| value+(el-mean)**2 }
(sigma_... | true |
c3cda8f4f1064be854f55685f7fdc203df01f789 | Ruby | Ardalan-Saberi/trains_ruby | /lib/trains_ruby/railroad_helper.rb | UTF-8 | 749 | 2.984375 | 3 | [] | no_license | module TrainsRuby
module RailroadHelper
RailroadStringParseError = Class.new(StandardError)
RAILROAD_ITEM_FROMAT = /(^|\W)(?<origin>[a-zA-Z])(?<destination>[a-zA-Z])(?<distance>\d+)(\W|$)/
RAILROAD_ITEM_DELIMITER = ','
module_function
def create_railroad_system_from_string str
create_rai... | true |
d4bb650544b45faa133e7db296e108652155f870 | Ruby | prp-e/basic-rosemary-contribution | /basic-node-adding.rb | UTF-8 | 925 | 2.953125 | 3 | [] | no_license | require 'rosemary'
Rosemary::Api.base_uri 'api06.dev.openstreetmap.org'
client = Rosemary::BasicAuthClient.new('your_osm_username', 'your_osm_password')
api = Rosemary::Api.new(client)
changeset = api.create_changeset("Some meaningful comment, for example a point on Antarctica.")
node = Rosemary::Node.new(:lat =>... | true |
717d313a4d05506ceea0d0e048bc6c733ec05aa4 | Ruby | wisewayfinder/gitsync | /lib/gitsync/command_tool.rb | UTF-8 | 324 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'open3'
class CommandTool
def self.exccmd(cmd)
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
result = wait_thr.value
return { succ: result.success?,
msg: stdout.gets(nil) || stderr.gets(nil) }
end
rescue StandardError => e
return { succ: false, msg: e }
end... | true |
29368b1279ae534192fabe81215543f3649a5ba0 | Ruby | joe2512/Project-Euler | /euler21.rb | UTF-8 | 434 | 3.5625 | 4 | [] | no_license | require_relative 'euler_methods.rb'
def euler21(n)
amicable = []
1.upto(n) do |i|
check = proper_divisors(i).inject(:+)
if i == check then next end
if amicable_numbers?(i, check)
amicable << i and amicable << check unless amicable.include?(i) or amicable.include?(check)
end
end
ami... | true |
452e76ca82486247fcbd162505f2037c85737fc6 | Ruby | Fablic/fablicop | /vendor/bundle/ruby/3.2.0/gems/byebug-11.1.3/lib/byebug/interfaces/script_interface.rb | UTF-8 | 648 | 2.734375 | 3 | [
"MIT",
"BSD-2-Clause"
] | permissive | # frozen_string_literal: true
module Byebug
#
# Interface class for command execution from script files.
#
class ScriptInterface < Interface
def initialize(file, verbose = false)
super()
@verbose = verbose
@input = File.open(file)
@output = verbose ? $stdout : StringIO.new
@er... | true |
b7be70a803abee13188d9e09860d22cdf69e3906 | Ruby | mattbradley/mattlang | /lib/mattlang/types/intersection.rb | UTF-8 | 1,272 | 2.765625 | 3 | [] | no_license | module Mattlang
module Types
class Intersection < Base
attr_reader :types
def initialize(types)
@types = types.uniq
raise "An intersection type cannot be composed of other intersection types" if @types.any? { |t| t.is_a?(Intersection) }
raise "All types in an intersection must... | true |
d19a6d812f3cdeee4107a080bca7462389f98d17 | Ruby | wilbooorn/prepwork | /w1/w1d4/exercises/lib/04_dictionary.rb | UTF-8 | 681 | 3.515625 | 4 | [] | no_license | class Dictionary
attr_accessor :entries
def initialize(entries = {})
@entries = entries
end
def entries
@entries
end
def add(entry)
if entry.is_a?(String)
@entries[entry] = nil
else
@entries = @entries.merge(entry)
end
end
def keywords
@entries.keys.sort
e... | true |
2a9a29cb6992e1515c9f1e747c06daf12a145299 | Ruby | RAllner/fassets_core | /app/models/label_filter.rb | UTF-8 | 360 | 2.578125 | 3 | [
"MIT"
] | permissive | class LabelFilter < Array
def initialize(filter_query)
label_ids = (filter_query || "").split('-').map{|id| id.to_i}
super(label_ids)
end
def to_condition
"labelings.label_id IN(#{self.join(',')})"
end
def to_query_include(id)
(self + [id]).join('-')
end
def to_query_exclude(id)
self.r... | true |
006145166cbe12d55400db25460715a6fd347c83 | Ruby | notenboomtest/MCDC_Ruby | /lib/mcdc.rb | UTF-8 | 3,179 | 3.640625 | 4 | [] | no_license | #!/usr/bin/env ruby
class Condition
attr_accessor :name, :precop, :trailop
end
class Testcase
attr_accessor :seq, :res
def initialize(seq, res)
@seq = seq
@res = res
end
end
class Decision
attr_reader :conditions, :testcases
def initialize
@conditions = []
@testcases = []
end
def ex... | true |
7f361038ae79005cdf1c761126c1a7ce17d6f003 | Ruby | MrObele/learn_ruby | /03_simon_says/simon_says.rb | UTF-8 | 877 | 4.125 | 4 | [] | no_license | #write your code here
def echo(word_to_echo)
word_to_echo
end
def shout(word_to_shout)
word_to_shout.upcase
end
def repeat(word_to_repeat,optional = omitted = true)
word_repeated = []
if omitted
2.times do
word_repeated << word_to_repeat
end
else
optional.times do
word_repeated << word_to_repeat
... | true |
48a02b0d9b98ba9754a7d08095ca37fc69198b17 | Ruby | jbheron/dbc | /week-2/discussions/factory-methods.rb | UTF-8 | 1,325 | 3.8125 | 4 | [] | no_license | require 'csv'
class List
def initialize
@items = []
end
def add(item)
@items << item
end
def self.from_file(thing, filename)
unless thing.respond_to? :from_string
raise ArgumentError, "[#{thing}] must respond to 'from_string'"
end
list = self.new
CSV.foreach(filename, 'r') ... | true |
119f9ff87e323feab31b7adb07238f2a062e0486 | Ruby | kkomaz/co-code | /app/models/problem.rb | UTF-8 | 631 | 2.53125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Problem < ActiveRecord::Base
has_many :language_problems
has_many :languages, :through => 'language_problems'
extend FriendlyId
friendly_id :name, use: :slugged
validates :title, :content, :difficulty, :presence => true
validates :difficulty, {inclusion: {in: 1..10}, numericality: { only_integer: ... | true |
935bfbdbaf7386ca8e790e0cc6e3b421cf812381 | Ruby | kineticdata/peripherals-bmc-remedy | /handlers/bmc_itsm7_person_create_v1/handler/init.rb | UTF-8 | 8,001 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'rexml/document'
require 'ars_models'
class BmcItsm7PersonCreateV1
# Prepare for execution by pre-loading Ars form definitions, building Hash
# objects for necessary values, and validating the present state.
def initialize(input)
# Set the input document attribute
@input_document = REXML::Documen... | true |
7592cabda1ef9d9c9e3428f72c9c26ed320925d7 | Ruby | ahartenstein/skillcrush-challenges | /oo_code_fix.rb | UTF-8 | 1,249 | 3.984375 | 4 | [] | no_license | class Animal
def traits (species, name: "None", owner: "None", speak: "I'm sorry, I don't know what sound that animal makes. Please specify in the traits.")
@species = species
@name = name
@owner = owner
@speak = speak
end
def get_species
return @species
end
... | true |
ab25985da07e77a78e8f3f5405c19ba68ccbbb66 | Ruby | henrygarciaospina/challengers-ruby | /bus_herence.rb | UTF-8 | 616 | 3.75 | 4 | [] | no_license | #Herencia implementada con la clase de mi solución
class Car
attr_reader :velocity
def initialize
@velocity = 0
end
def accelerate(acceleration=nil)
if acceleration.nil?
@velocity = @velocity + 1
else
@velocity = @velocity + acceleration
end
end
def brake(braking=nil)
... | true |
10bca2641c05e5671119223e3ecfb38853a0886a | Ruby | stephenbinns/superblockboy | /lib/tileset.rb | UTF-8 | 3,126 | 2.875 | 3 | [
"MIT"
] | permissive | class Tileset
attr_reader :spawn
def initialize(options = {}, game_state)
@block_height = options[:block_height] || 16
@block_width = options[:block_width] || 16
filename = options[:filename]
tileset_name = options[:tileset_name] || 'tiles'
@tileset = Image.load_tiles($window, "media/#{tileset_... | true |
9748979f2c121d6a101e2bbb6f9ea0f261cc03d4 | Ruby | hysa/perfectruby-book | /chapter2/assign.rb | UTF-8 | 165 | 3.25 | 3 | [] | no_license | # coding: utf-8
array = [1, 2, 3]
# 配列分割
a1, a2 = array
print a1, a2 , "\n"
b1, *b2 = array
print b1, b2, "\n"
# swap
b2, b1 = b1, b2
print b1, b2, "\n"
| true |
b3d112e893479c470368f331e8db6a97a3e31192 | Ruby | Jacobkg/Payroll | /lib/payday_transaction.rb | UTF-8 | 427 | 2.765625 | 3 | [] | no_license | class PaydayTransaction
def initialize(date)
@date = date
@paychecks = Hash.new
end
def execute
for id in PayrollDatabase.get_all_employee_ids
employee = PayrollDatabase.get_employee(id)
if employee.is_pay_date?(@date)
pc = Paycheck.new(@date)
@paychecks[id] = pc
... | true |
93c04792cb7e0177eb9bfaa7fd1e01fa185055ea | Ruby | spikesp/Ex_launchschool | /book_intro_to_ruby/intro_exercises/4.rb | UTF-8 | 108 | 3.328125 | 3 | [] | no_license | origin_arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
origin_arr.push("11")
origin_arr.unshift("0")
puts origin_arr | true |
02c7fa02cb0684db66806d4d95f9cc4208656a7d | Ruby | stephdewolfe/SYDTTSRuby | /hash.rb | UTF-8 | 1,597 | 4.375 | 4 | [] | no_license | #Hashes, like arrays, are also collections of data. However, they are not ordered and the information is stored and accessed in pairs called keys and values.
#You can think of an array as an ordered list and an hash as an unordered dictionary. Remember our trivia app? It would probably be a lot easier to just store an... | true |
dc0988ab1a67fdd8d9c9b7843e042ad6cfb9fedc | Ruby | jakesa/dat_sauce | /lib/dat_sauce/legacy_code/progress_bar/progress_bar.rb | UTF-8 | 3,465 | 2.78125 | 3 | [
"MIT"
] | permissive | # require_relative 'progress_bar_v2'
#
# class ProgressBarEventHandler < DATSauce::EventHandler
#
# def initialize
# self.stdout = true
# end
#
# def start_test_run(test_run)
# @progress_bar = DATSauce::ProgressBar.new({:count => test_run.testCount})
# @progress_bar.start_progress
# @progress_bar.... | true |
818ba3993a5edab192fddc4e4e093c4f85a0c4ac | Ruby | Weltraumschaf/uberblog | /lib/uberblog/model/blog_post_data.rb | UTF-8 | 745 | 2.703125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Beerware"
] | permissive | require 'uberblog/model/markdown_data'
module Uberblog
module Model
class BlogPostData < MarkdownData
def BlogPostData.create_date(filename)
return nil if filename.index('_').nil?
dateParts = filename[0, filename.index('_')].split(/-/)
return nil if 3 != dateParts.size
... | true |
b6315f72537daf8853a7f87d95be8840797bee61 | Ruby | ido1006/turtleHermit | /src/commands/serizawa.rb | UTF-8 | 660 | 3 | 3 | [] | no_license | module Bot::DiscordCommands
module Serizawa
extend Discordrb::Commands::CommandContainer
attrs = {
description: '芹沢構文を返しますよ',
usage: 'seri <first> <second>'
}
command :seri, attrs do |event, first, second|
event.respond(serizawa_message(first: first, second: second))
end
d... | true |
a9387a0c21d6763d2d4485b275226dea7bb2d9db | Ruby | dbwinger/runreg_api | /lib/runreg/event.rb | UTF-8 | 437 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'ostruct'
module Runreg
class Event < OpenStruct
def initialize hash
hash.keys.each do |key|
if key.match?(/Date/) && hash[key]
hash[key] = Runreg::Event.convert_datetime(hash[key])
end
end
super hash
end
# Date/times come in format /Date(159262560000... | true |
3731cb3953d2b8055c23c1a9ee9ff2c9d4a2f257 | Ruby | mashihua/mashihua.github.com | /labs/2010/magic-datauri/gif_script.rb | UTF-8 | 2,266 | 2.828125 | 3 | [] | no_license | #!/usr/bin/ruby
# CONVERT INCORRECTLY TRANSFER DATA. USE GIMP INSTEAD
# USE: ./GIF_SCRIPT.RB [GIF_FILE]
# OPEN GIF FILE IN HEX
orig=File.open("#{ARGV[0]}",'rb'){|f| f.read.unpack("H*")}.to_s
# FUTURE HEADER,SIZE IS 13.
header=orig[0..25]
#DETERMINE WHETHER IT IS A ANIMATED GIF
#ANIMATED GIF HAVE APPLICATION EXTENSIO... | true |
8789e8eca92720d69c5d983c47e6875c4000bd57 | Ruby | MargVander/thp-rubyexo | /exo_07_a.rb | UTF-8 | 180 | 3.25 | 3 | [] | no_license | puts "Bonjour, c'est quoi ton blase ?"
user_name = gets.chomp
puts user_name
#gets.comp sert à ce que l'utilisateur puissent entrer une donné qui sera placer dans une variable.
| true |
be5f581a9e7646549c605cec9695319dc6bfc9c5 | Ruby | stefanooldeman/sample_app | /config/initializers/extensions/string.rb | UTF-8 | 86 | 2.703125 | 3 | [] | no_license | class String
def shuffle
self.split('').sort_by { rand }.join
end
end
| true |
b4f329562c76184e5e10b642b0e9e5b164c5e68f | Ruby | pwillikins/grade-keeper | /app/models/result.rb | UTF-8 | 599 | 2.609375 | 3 | [] | no_license | class Result < ActiveRecord::Base
def self.build_response
all_results = self.all
if all_results.present?
test_scores = all_results.collect(&:test_score)
number_of_scores = test_scores.count
total_average = test_scores.inject(0) { |sum, score| sum += score } / number_of_scores
{results... | true |
9cfe957b5049863ad43e432104c3ac47e18d8820 | Ruby | roadfox303/TIL | /Ruby/Cherry_book/sample_protected_method.rb | UTF-8 | 697 | 3.875 | 4 | [] | no_license | class User
# weight は外部に公開しない
attr_reader :name
def initialize(name, weight)
@name = name
@weight = weight
end
# 自分が other_user より重い場合は true
def heavier_than?(other_user)
other_user.weight < @weight
end
protected
# protected メソッドなので同じクラスかサブクラスであればレシーバ付きで呼び出せる。
def weight
@weight
... | true |
4811a88af331d3a73c11b3d3e0e2a40d2c916e46 | Ruby | AntGarSil/Project-Euler | /problem48.rb | UTF-8 | 1,094 | 3.859375 | 4 | [] | no_license | #problem 48 of projecteuler.net
#The series, 11 + 22 + 33 + ... + 1010 = 10405071317.
#Find the last ten digits of the series, 1**1 + 2**2 + 3**3 + ... + 1000**1000.
def getLastDigits(limit, sum)
number = limit**limit
sum += number
sum = sum % 10000000000
if limit == 751 || limit == 501 || limit == 251 || limit... | true |
3e49de49fb279b49a42071b82583568ce3819e0c | Ruby | nlim/Ruby_Misc | /inheritance_modules_mixins/family.rb | UTF-8 | 401 | 3.8125 | 4 | [] | no_license | class Person
def initialize(name)
@name = name
end
def to_s
"#{self.class} named #{@name}"
end
end
class Parent < Person
def hello
puts "Hello from #{self}"
end
def print_relatives
puts "The Superclass of #{self.class} is #{self.class.superclass}."
end
end
class Child < Parent
end
p = Parent.n... | true |
ea606f3bece70ca2821ca1fd226ae7315a5283dc | Ruby | sachsy/ruby-object-model | /9-the_self_game.rb | UTF-8 | 1,277 | 3.78125 | 4 | [] | no_license | # ===== THE SELF GAME! =====
# At any given time in Ruby, you are in a binding
# that has local variables and is executing in the context
# of some object (you can access its instance variables and methods).
#
# You can see what object you're in by looking at self.
# on main
self
# in a class
class String
self
e... | true |
bc3f3dda6bf85e2aa9ff32ae3703719eafd35749 | Ruby | aabbcc456aa/lovelou | /vendor/plugins/ruby/1.9.1/gems/sass-3.1.16/vendor/listen/lib/listen/adapters/windows.rb | UTF-8 | 1,961 | 2.625 | 3 | [
"MIT"
] | permissive | require 'set'
module Listen
module Adapters
# Adapter implementation for Windows `fchange`.
#
class Windows < Adapter
# Initializes the Adapter. See {Listen::Adapter#initialize} for more info.
#
def initialize(directories, options = {}, &callback)
super
@worker = init_... | true |
2acb9948baeb40d10d2a9cd5f98601a99e44b24a | Ruby | jasonronalddavis/best_movies_2 | /codewars.rb | UTF-8 | 537 | 3.40625 | 3 | [
"MIT"
] | permissive | require "pry"
def counter(str)
splitter = str.split("")
new_a = (0...splitter.size).step(2).map {|i| splitter.values_at(i, i.next).join}
if new_a[-1].length == 1
new_a[-1] = new_a[-1] + "_"
end
new_a
end
"hello".sub('l', '*')
"he*lo"
"hello".gsub('l', '*')
"he**o"
rag... | true |
36f9baeaf3054f620c05e709b00603b9966d8316 | Ruby | cjohansen/acts_as_prototype | /test/property_list_test.rb | UTF-8 | 533 | 2.5625 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + '/abstract_unit'
class PropertyListTest < Test::Unit::TestCase
def test_get
prototype = Prototype.find(1)
properties = PropertyList.new(prototype)
prototype.set(:prop, "Value")
assert_equal prototype.get(:prop), properties[:prop]
end
def test_set
prototype ... | true |
5d4533e139eeee6eed73685c9cf426f992c32cae | Ruby | hubertlepicki/scrumastic | /vendor/plugins/amberbit-config/lib/hash_struct.rb | UTF-8 | 231 | 2.765625 | 3 | [
"MIT"
] | permissive | require "ostruct"
# Defines HashStruct class, which is simply OpenStruct and has additional
# accessor mode via square brackets like hashes
class HashStruct < OpenStruct
def [](key)
self.send key unless key == nil
end
end
| true |
8808f4f53dc689a9a9837c32a4868253e1f891d2 | Ruby | PavelSher09/thinknetica | /lesson2/exc_02.rb | UTF-8 | 112 | 3.375 | 3 | [] | no_license | array = []
i = 5
until i >= 100
i +=5
array.push(i)
end
puts array
arr2 = (10..100).step(5).to_a
puts arr2
| true |
c4bdb5ffd9fc99047ac47c86547010ffb948bde5 | Ruby | rrA12d9p/practice | /ruby/adopt_a_dog/dog.rb | UTF-8 | 334 | 3.640625 | 4 | [] | no_license | class Dog
attr_reader :type, :has_tail, :size, :cuteness, :name, :gender
def initialize
@type = "Doberman"
@has_tail = true
@size = "large"
@cuteness = 4
@name = ["Fido", "Sparky", "Rover", "Spot", "Scooby", "Astro", "Lassie"].sample
@gender = ["male", "female"].sample
end
def bark
puts "Bark bark b... | true |
b210985f02793286afa06ad2b8d8c87efdbf12a0 | Ruby | homelesshack/sar | /app/lib/sar/spareroom/insights.rb | UTF-8 | 688 | 3.078125 | 3 | [] | no_license | module SAR
module Spareroom
class Insights
def initialize(data)
@data = data.sort
end
def mean
(@data.reduce(0, :+)/total_results)
end
def median
(@data[(total_results - 1) / 2] + @data[total_results / 2]) / 2.0
end
def highest
@data.las... | true |
eded32f21dfe7d99626f744744d3e5cd8352a562 | Ruby | tiy-houston-q1-rails/day-23 | /books/app/models/author.rb | UTF-8 | 127 | 2.515625 | 3 | [] | no_license | class Author < ActiveRecord::Base
has_many :books
def book_titles
books.map{ |book| book.title }.join(", ")
end
end
| true |
01a92a392b2dc1aa600498b2273c896a459a2040 | Ruby | bmaingret/contextual-golo-lang | /src/main/ruby/generate_math.rb | UTF-8 | 1,772 | 3.15625 | 3 | [
"Apache-2.0"
] | permissive | # Copyright 2012-2014 Institut National des Sciences Appliquées de Lyon (INSA-Lyon)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# U... | true |
79dfe9f68ab35a2db45ac1c834f389123b46924b | Ruby | diingo/coder_match_v2 | /lib/gladiator_match/use_cases/update_user.rb | UTF-8 | 1,831 | 2.671875 | 3 | [] | no_license | module GladiatorMatch
class UpdateUser < UseCase
def run(inputs)
user = GladiatorMatch.db.get_user_by_session(inputs[:session_key])
return failure(:no_user_with_that_session_key) if user.nil?
if inputs[:interests]
return failure(:invalid_interest) unless valid_interests?(inputs[:intere... | true |
ddf69c308a4a547d83bc6eb2b5c999eaf1b7d148 | Ruby | bnv2103/NGS | /utils/allele-freq_from_pool-nonzero.rb | UTF-8 | 745 | 2.984375 | 3 | [] | no_license | ## only print SNVs with MAF > 0
## example:
##chr pos marker 15 16 9
#chr11 121299288 rs12576704HA-a 0;4;0;16;0 4;3;0;13;0 16;0;0;4;0
def main
while line = ARGF.gets do
next if line.match("^#")
cols = line.chomp.split(/\s+/)
allelec = [0,0,0,0]
pos =... | true |
8174e14fd4ff2f3f25cf48ae16abe9365b72f300 | Ruby | gwright/jig | /test/test_parse.rb | UTF-8 | 2,215 | 2.9375 | 3 | [
"MIT"
] | permissive |
require 'jig'
require 'test/jig'
require 'test/unit'
class TestParse < Test::Unit::TestCase
J = Jig
include Asserts
def test_string
source = "chunky bacon"
j = Jig.parse(source)
assert_equal(source, j.to_s)
end
def test_with_newline
source = "before %{:alpha:} after\n"
j = Jig.parse(so... | true |
49ef04ac6322877e908ec7655af3d2e0b1e0e34c | Ruby | stegrial/accrd-automation | /features/pages/accr_number_page.rb | UTF-8 | 5,302 | 2.546875 | 3 | [] | no_license | # encoding: UTF-8
require_relative '../../helpers/http_helper'
require_relative '../../features/support/utils'
require 'capybara/rspec'
require 'mongo'
require 'json'
include HTTPHelper
include Utils
module SearchNumber
def open_search_number_page(user)
begin
url = "/accrd-ui/accr/search?ad-token=#{HT... | true |
072671aa4857c8a90983db9287452f030e9b5efc | Ruby | matosca/Stock-Castle-Ruby_Solo_Project | /models/category.rb | UTF-8 | 2,057 | 3.140625 | 3 | [] | no_license | require_relative('../db/sql_runner.rb')
class Category
attr_reader :type, :id
def initialize(options)
@id = options['id'].to_i if options['id']
@type = options['type']
end
def products()
sql = "SELECT categories.*, products.* FROM categories
INNER JOIN products
ON categories... | true |
16ec2bbf3c0f278dcf320943825b523be9de549a | Ruby | merwan/CS169.1x | /HW1/lib/rock_paper_scissors.rb | UTF-8 | 798 | 3.46875 | 3 | [] | no_license | class RockPaperScissors
# Exceptions this class can raise:
class NoSuchStrategyError < StandardError ; end
def self.winner(player1, player2)
s1 = player1[1]
s2 = player2[1]
validate_strategy s1
validate_strategy s2
if s1 == 'R'
return player2 if s2 == 'P'
elsif s1 == 'P'
retu... | true |
9e7fcfec168094df0dc698818434d50a7ecac52b | Ruby | rovf/tut_fa | /app/models/user.rb | UTF-8 | 2,569 | 2.671875 | 3 | [] | no_license | class User < ActiveRecord::Base
has_many :microposts, dependent: :destroy
has_many :relationships, foreign_key: "follower_id", dependent: :destroy
# The followed users are those in relationships, which have followed_id,
# but we don't want to access them by user.followeds, but by the more
... | true |
8efbd82b59143ca1a2f370f6dd00cfc4e2975bd8 | Ruby | suyesh/project_euler_ruby | /problem_1.rb | UTF-8 | 428 | 4.0625 | 4 | [] | no_license | #Multiples of 3 and 5
#If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
#Find the sum of all the multiples of 3 or 5 below 1000.
sum = (1...1000).select {|x| x if x % 3 == 0 || x % 5 == 0}.reduce(:+)
puts sum
#Answer is 233168. First i w... | true |
be009a5850e12ec14f4a2389c439ecdec878c8aa | Ruby | MastersOfFoo/dunordmap-ws | /app/models/office.rb | UTF-8 | 359 | 2.53125 | 3 | [] | no_license | class Office
include ActiveModel::Model
attr_accessor :name, :updated_at
def self.all
@offices ||= begin
offices = []
['Departamento de Sistemas', 'Departamento de Civil', 'Almacen KM5', 'Departamento de Derecho'].each do |name|
offices << Office.new(name: name, updated_at: Time.now)
... | true |
a113755a1ff2ff5ac5a5fcaef582eb056ad2ec8b | Ruby | bradx3/fundation | /app/models/dollar_methods.rb | UTF-8 | 390 | 3.0625 | 3 | [] | no_license | module DollarMethods
def dollar_method
if self.respond_to?(:amount_in_cents)
return :amount_in_cents
elsif self.respond_to?(:initial_balance_in_cents)
return :initial_balance_in_cents
end
end
def dollars=(amount)
self.send("#{ dollar_method }=", (amount.to_f * 100.0).round)
end
d... | true |
1ef8c4456c8d71f3532e91e979657b93a5f8f238 | Ruby | tkshi/tenhou_uraippatu_toukei | /main.rb | UTF-8 | 2,092 | 2.859375 | 3 | [] | no_license | # # -*- coding: utf-8 -*-
#
# require 'mongo'
#
# # データベースと接続
# connection = Mongo::Connection.new
# # connection = Mongo::Connection.new('localhost');
# # connection = Mongo::Connection.new('localhost'27017);
# db = connection.db('paihu')
# coll = db.collection('kyokus')
#
# doc = { 'name' => 'MongoDB', 'type' => 'dat... | true |
812af00bd99c19931052e6fdc5802a173cdf8962 | Ruby | Anmolbhati30/ruby-practice | /fav_animals.rb | UTF-8 | 675 | 3.75 | 4 | [] | no_license | favourite_animals = {}
while true
print "Name an animal you like: "
animal = gets.chomp.to_s
print "What do you like about them: "
reason = gets.chomp.to_s
print "Can you get this animal as a pet? (y/n): "
can_own = gets.chomp.to_s == "y"
favourite_animals[animal] = Hash.new
favourite_animals[a... | true |
64ba683e493a88607fb7294be2a04789448c0de4 | Ruby | y-ken/fluent-mixin-rewrite-tag-name | /lib/fluent/mixin/rewrite_tag_name.rb | UTF-8 | 3,283 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | module Fluent
module Mixin
module RewriteTagName
include RecordFilterMixin
attr_accessor :tag, :hostname_command
DEFAULT_HOSTNAME_COMMAND = 'hostname'
def configure(conf)
super
@placeholder_expander = PlaceholderExpander.new
hostname_command = @hostname_command |... | true |
d636e7c792b8e3bde7969ec6e1a7e2c1cb3d603a | Ruby | cogito-lang/cogito-rb | /lib/cogito.rb | UTF-8 | 436 | 2.5625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'cogito/cogito'
require 'cogito/version'
# A small ruby library that wraps libcogito
module Cogito
class << self
def to_json(str, subs = {})
convert_to_json(substitute(str, subs))
end
private
def substitute(str, subs)
substituted = str.dup
su... | true |
8821e09b713ea82afb3c437b9d821181f7166090 | Ruby | mainangethe/learn-to-code-w-ruby-bp | /section_4/empty_and_nil_methods.rb | UTF-8 | 192 | 3.703125 | 4 | [] | no_license | #empty only returns true if the argument is empty
empty_str = ""
p empty_str.empty?
p empty_str.nil?
#nil is not empty
name = "Donald Duck"
last_name = name[100,4]
p last_name
p last_name.nil?
| true |
13682574203807899d8b5d6c92b158a3d59c8297 | Ruby | lukeredpath/minisculus | /minisculus/quiz_master.rb | UTF-8 | 1,843 | 2.78125 | 3 | [] | no_license | require 'restclient'
require 'json'
require 'uri'
module Minisculus
class QuizMaster < RestClient::Resource
def self.connect
new('http://minisculus.edendevelopment.co.uk/')
end
def start
self['start'].get(headers) do |response, request, result|
case response.code
when 303... | true |
1d300414dfc223976626f431fc877d328f93ff1a | Ruby | manisjp/PlanetSim | /planet.rb | UTF-8 | 992 | 3.328125 | 3 | [] | no_license | require "gosu"
class Planet
attr_reader :xpos, :ypos, :xvel, :yvel, :mass
G = 6.67408e-11
def initialize data, system_size, window_size
@system_size, @window_size = system_size, window_size
@xpos, @ypos = data[0].to_f, data[1].to_f
@xvel, @yvel = data[2].to_f, -data[3].to_f
@oxvel, @oyvel = data[2].to_f... | true |
7768f270708cf11632194dd3cc54e300edbaba8c | Ruby | arilsonsouza/the_odin_project | /ruby/project_file_io_and_serialization/hangman/game.rb | UTF-8 | 5,015 | 3.484375 | 3 | [] | no_license | require 'json'
class Game
def initialize()
@attempts = 6
@correct_guesses = []
@incorrect_guesses = []
@secret_word = choose_word
@hidden_word = []
@guess = ""
@game_over = false
@you_won = false
@is_from_json = false
@file_name = 'game_state.json'
end
def play
ini... | true |
d8311575020adb6a685ea698bcad4d50702bee4d | Ruby | hocus2pocus/study_projects | /ruby_module_8/interface.rb | UTF-8 | 4,353 | 2.984375 | 3 | [] | no_license | require_relative 'interface_support.rb'
require_relative 'interface_station.rb'
require_relative 'interface_route.rb'
require_relative 'interface_train.rb'
require_relative 'interface_wagon.rb'
class Interface
include InterfaceSupport
include InterfaceStation
include InterfaceRoute
include InterfaceTrain
inc... | true |
df667379a54a39adb6df61480ed7fac090e62979 | Ruby | derek-schaefer/advent_of_code_2k18 | /lib/day1.rb | UTF-8 | 416 | 3.1875 | 3 | [] | no_license | require 'set'
module Day1
def self.part1(input)
input.sum
end
def self.part2(input)
frequency = 0
frequencies = Set.new([frequency])
input.cycle do |change|
frequency += change
break if frequencies.include?(frequency)
frequencies << frequency
end
frequency
end
... | true |
2b90b4273bdec540bc21336629a0bee3e683d96a | Ruby | wallezhang/aliyun-odps-ruby-sdk | /lib/odps/models/project.rb | UTF-8 | 2,240 | 2.53125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | =begin
Copyright 2015 ZhangZhaoyuan
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, softwa... | true |
0598105a85eddaa6f6569495877b8f8dc2627d67 | Ruby | emperol2/nuttaponp | /TestSpec/spec/myModel_spec.rb | UTF-8 | 1,229 | 2.515625 | 3 | [] | no_license | #require 'minitest/spec'
require 'selenium-webdriver'
# arranges for minitest to run (in an exit handler, so it runs last)
require 'minitest/autorun'
#require 'minitest'
require 'test/unit'
#require 'rspec'
require_relative '../myModel'
describe 'Alpha' do
before(:all) do
@driver = Selenium::WebDriver.for :fir... | true |
17f4b04d68665db979fa79f1fb6410ff45e4506f | Ruby | caius/codebase | /lib/codebase.rb | UTF-8 | 3,394 | 2.59375 | 3 | [] | no_license | $:.unshift File.dirname(__FILE__)
require 'rubygems'
require 'json'
require 'codebase/command'
trap("INT") { puts; exit }
module Codebase
extend self
class Error < RuntimeError; end
class NotConfiguredError < StandardError; end
class MustBeInRepositoryError < StandardError; end
VERSION = "4.0.8"
... | true |
66d2fb055e5893431b0268a984ad2cae4f878f3f | Ruby | nanma80/euler_project | /p051_075/p057/main.rb | UTF-8 | 187 | 3.453125 | 3 | [] | no_license | up = 1
down = 1
count = 0
1000.times do |index|
up += down # + 1
up, down = down, up # 1/x
up += down # + 1
if up.to_s.length > down.to_s.length
count += 1
end
end
p count | true |
0abb9679888a5c06f55faf4c0561ff2cf3bab791 | Ruby | newrelic/newrelic-ruby-agent | /lib/new_relic/agent/priority_sampled_buffer.rb | UTF-8 | 2,173 | 2.65625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-generic-cla",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
# frozen_string_literal: true
require 'new_relic/agent/heap'
require 'new_relic/agent/event_buffer'
module NewRelic
module Agent
class PrioritySampledBuffer <... | true |
41307d5bf49f21c1fa3c02ddaee950fbf929ea15 | Ruby | Asilver-jpg/ruby-enumerables-hash-practice-emoticon-translator-lab-nyc-web-030920 | /lib/translator.rb | UTF-8 | 853 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # require modules here
require "yaml"
require "pry"
def load_library(file_path)
emoticons= YAML.load_file(file_path)
newHash= { :get_meaning => {},
:get_emoticon => {}
}
emoticons.each do |key, value|
# :get_meaning points to english definitions
# :get_emoticon points to Japanese emoticon
n... | true |
df41b2cc5905bbd0bacb6a12dd5f318cfdd9e0aa | Ruby | kulbida/aws_docker_utils | /lib/aws_docker_utils/controllers/configurator.rb | UTF-8 | 817 | 2.578125 | 3 | [] | no_license | require 'io/console'
require_relative '../aws_config_storage'
module AwsDockerUtils
module Controllers
class Configurator
def initialize(opts={})
@opts = opts
@config = AwsConfigStorage.new
end
def activate
if @opts.fetch('init')
publish(:access_key, std_inp... | true |
3802aaaa24c74e7600606756a7f6a1c332948d6b | Ruby | bulters/damxml | /app/views/problems/index.xml.builder | UTF-8 | 1,075 | 2.53125 | 3 | [] | no_license | xml.instruct! :xml, :version => "1.0"
xml.problems do |xml_problems|
@problems.each do |problem|
problem_number = problem.try(:number) || problem.id
xml_problems.problem :id => problem_number do |xml_problem|
xml_problem.moves do |xml_moves|
problem.moves.each do |move|
xml_moves.move ... | true |
c3816f3caccfce35971e269ed1fc8b2d002db367 | Ruby | ririli47/Project_Euler | /problem1.rb | UTF-8 | 154 | 2.875 | 3 | [] | no_license | num = 1000;
sum = 0;
for i in 0...num do
if i%3 == 0 then
sum = sum + i;
end
if i%5 == 0 then
sum = sum + i;
end
end
print(sum, "\n");
| true |
116f81e61519391ab8e1a774dd6a5f0f4b322fbe | Ruby | ZylberbergJ23/ruby-collaborating-objects-lab-web-1116 | /lib/mp3_importer.rb | UTF-8 | 224 | 2.8125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MP3Importer
attr_accessor :path
def files
Dir.entries(path)[2..-1]
end
def initialize(path)
@path = path
end
def import
files.each do |filename|
Song.new_by_filename(filename)
end
end
end | true |
1d0be5e60c7f11d69bb772dceb4260441fb22892 | Ruby | wrenisit/enigma | /test/encryption_test.rb | UTF-8 | 1,648 | 3.109375 | 3 | [] | no_license | require_relative 'test_helper'
require './lib/encryption'
require './lib/encryption_key'
class EncryptionTest < MiniTest::Test
def setup
@message = "hello world"
@key = EncryptionKey.new("011119")
@key.stubs(:random_number_generator).returns([1,2,3,4,5])
@encryption = Encryption.new(@key.offset_make... | true |
4675d53580a784fa8a6a1786c284f06cf5273e75 | Ruby | arnnow/hydrograph | /fish_poller.rb | UTF-8 | 2,755 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env ruby
# Pull data from http://hubeau.eaufrance.fr/page/api-poisson
# And push it to influx
require 'yaml'
require 'logger'
require 'json'
require 'date'
require 'influxdb'
require_relative 'lib/platform/hubeau_fish'
## Load logger lib
begin
require 'logger/colorz'
rescue LoadError
else
Logger::Color... | true |
37ab8bb5941273c0f616b46d8d4ebc95327814eb | Ruby | arslanyousaf77/coeus-ruby-basic-practice | /customerClass.rb | UTF-8 | 641 | 3.625 | 4 | [] | no_license | class Customer
@@no_of_customers = 0
def initialize(id, name, addr)
@@no_of_customers += 1
@cust_id = id
@cust_name = name
@cust_address = addr
end
def display_details()
puts "Customer ID: #@cust_id"
puts "Customer Name: #@cust_name"
puts "Cu... | true |
0e4f5c39f10bd16cffb26ce7d1e42d6989e220dd | Ruby | Markhenn/LS-RB101 | /Exercises/Easy 6/ex2.rb | UTF-8 | 1,416 | 4.59375 | 5 | [] | no_license | # Delete vowels
# Problem:
# input: array of strings
# output: array of strings
# method that deletes the vowels from the strings
# capitalization doesnt matter
# Questions?
# Empty array?
# not an array?
# validation?
# Data structure / algorithm
# call map on array
# call reject on denominator
# check ... | true |
91cdb676ffeddeed8a4f9b981bcbc547ee2688d7 | Ruby | cpfergus1/enigma | /test/cipher_key_test.rb | UTF-8 | 1,166 | 2.8125 | 3 | [] | no_license | require './test/test_helper'
require './lib/cipher_key.rb'
class CipherKeyTest < Minitest::Test
def test_cipher_key_has_attributes
cipherkey = '02715'
cipherdate = '040895'
cipher_key = CipherKey.new(cipherkey, cipherdate)
assert_equal '02715', cipher_key.cipherkey
assert_equal '040895', cipher_k... | true |
fb66ded3c37f9e756877fea949c798b5622d9006 | Ruby | Azkel/AdventOfCode | /2015/16/Solver.rb | UTF-8 | 957 | 3.171875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# Comment line 6 for part 1 or line 7 for part 2 solution.
aunts = []
File.open('input.txt', 'r').each_line do |line|
line = line.tr(':', '').tr(',', '').split(' ')
aunt = Hash.new
(0...line.length).step(2) do |n|
aunt[line[n]] = line[n+1].to_i
end
aunts.push(aunt)
end
g... | true |
e7eee4bdfbffecdc0640043c4f649b832dd337fd | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/roman-numerals/5532c79724ce4bf1b38874a3055ffe78.rb | UTF-8 | 928 | 3.484375 | 3 | [] | no_license | class Fixnum
def to_roman
output = roman_recurse(self, output='')
end
private
def roman_recurse(n, output='')
if n == 0
output.reverse!
output = output.sub 'DCCCC', 'CM'
output = output.sub 'CCCC', 'CD'
output = output.sub 'LXXXX', 'XC'
output = output.sub ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.