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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
1c56ec8c0a8f7304bd2e011f1ab22ddaa575f981 | Ruby | adamhundley/exercism | /ruby/hamming/hamming.rb | UTF-8 | 425 | 3.46875 | 3 | [] | no_license | class Hamming
attr_reader :zipper
VERSION = 1
def self.compute(one, two)
raise ArgumentError if one.length != two.length
calculate(one,two)
end
def self.zip_town(one, two)
one.chars.zip(two.chars)
end
def self.calculate(one,two)
score = 0
zip_town(one, two).each do |x,y|
if ... | true |
0cb8b738809e1ea2c9478031307454bfc059213c | Ruby | diatmpravin/modbDev | /lib/filter_query.rb | UTF-8 | 496 | 2.890625 | 3 | [] | no_license | class FilterQuery
# Given a query string, parse it out into an appropriate Hash
# structure for Model.search to work properly.
def self.parse(query)
filter = {:full => query}
key = :query
query.split("\s").each do |word|
filter[key] ||= []
if word =~ /(.*):$/
key = $1.to_sym
... | true |
095ad6f3e867191615aacd9318f32aa57149d926 | Ruby | AlexFrz/Le-scrappeur-fou---THP | /lib/dark_trader.rb | UTF-8 | 1,586 | 3.53125 | 4 | [] | no_license | require 'rubygems'
require 'nokogiri'
require 'open-uri'
#1 Première méthode : Déclaration de la page à scrapper
def get_page
page = Nokogiri::HTML(open("https://coinmarketcap.com/all/views/all/"))
return page
end
#2 Deuxième méthode : Collecte des abbréviations des noms des monnaies
def scrapp_symbols
page = get... | true |
19bba609d0071601e01bd21517cdb13024bb9008 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/nucleotide-count/986b42c131c244de81f1eb5093ce2d44.rb | UTF-8 | 455 | 3.53125 | 4 | [] | no_license | class DNA
NUCLEOTIDES = "ATCG"
def initialize(string)
raise ArgumentError unless good_genes(string) || string.empty?
@string = string
end
def count(nucleotide)
raise ArgumentError unless good_genes(nucleotide)
@string.count(nucleotide)
end
def nucleotide_counts
Hash[*NUCLEOTIDES.char... | true |
cf5d5d06d90cdaffe4d4213d2eb38831d3f5bfb1 | Ruby | jaggederest/ragi | /ragi/test.rb | UTF-8 | 3,922 | 2.828125 | 3 | [
"BSD-3-Clause"
] | permissive | #
# RAGI - Ruby classes for implementing an AGI server for Asterisk
# The BSD License for RAGI follows.
#
# Copyright (c) 2005, SNAPVINE LLC (www.snapvine.com)
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following ... | true |
702ced8a23bc9caf518f6dca26ae82306a82016a | Ruby | schan1031/AppAcademy-Master | /W2D3/Poker/spec/deck_spec.rb | UTF-8 | 363 | 2.734375 | 3 | [] | no_license | require 'rspec'
require 'deck'
describe Deck do
subject(:deck) {Deck.new}
describe "#initialize" do
it 'initializes a full deck' do
expect(deck.deck_list.length).to eq(52)
end
describe "#shuffle" do
it 'shuffles the deck' do
temp = deck.deck_list.dup
expect(deck.shuffle!).n... | true |
1690db640fad7e5d112cebad2fcd5ac76728702d | Ruby | danidemi/shop_management | /lib/worksheet.rb | UTF-8 | 3,814 | 2.671875 | 3 | [] | no_license | class Worksheets
attr_accessor :operators, :time_intervals
def build_operator_headers
operators = Operator \
.select(:first_name, :last_name) \
.joins(:company) \
.where(:companies => {:id => current_operator.company.id})
operatorHeaders = Array.new
operators.each{ |operator|
oper... | true |
4edb59252ea7f908c599ef3f1db28b21d4bbacdb | Ruby | KirkMartinez/cryptopals | /lib/c14_byte_ecb_decrypt_harder.rb | UTF-8 | 4,829 | 3.3125 | 3 | [] | no_license | # Challenge 14: byte at a time ECB decryption
require_relative 'cbc_encryptor'
require_relative 'ecb_encryptor'
require_relative 'utilities'
KEYSIZE=16
# Oracle encrypts using a consistent, but unknown key with ECB
# Oracle encrypts like this:
# AES-128-ECB(random-prefix || attacker-controlled || target-bytes, rand... | true |
cbc5629aba53a168a146ad6b20b0e3e5abbd2469 | Ruby | jns/Aims | /bin/aims_output.rb | UTF-8 | 5,548 | 2.703125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'optparse'
require 'aims'
options = {:step => :all}
optParser = OptionParser.new do |opts|
opts.banner = "usage: #{File.basename $0} [options] file1 [file2 ...]"
opts.on('-s', '--step [N]', 'Output information for relaxation step.',
"Specify an in... | true |
069d6d5bb8b990133b7557d9759f214efb948b01 | Ruby | Alias-a/DrivingHistoryAnalyzer | /spec/trip_spec.rb | UTF-8 | 669 | 3.265625 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../lib/driving_history_analyzer/trip'
require 'date'
describe DrivingHistoryAnalyzer::Trip do
describe "#to_s" do
it "should print all the attributes of the trip object" do
time_elapsed = 2220
start_time = Time.new(2018, 11, 16, 9, 3)
end_time = Time.new(2018, 11, 1... | true |
56329108288bbf0c3678ae1a29a4c4e8489a983a | Ruby | mariangelds/pitagoras | /app/models/archivo.rb | UTF-8 | 5,159 | 2.59375 | 3 | [] | no_license | class Archivo < ActiveRecord::Base
has_no_table
column :ruta, :string
def validar_extension (archivo)
nombre = archivo.original_filename
$extension = nombre.slice(nombre.rindex("."),nombre.length).downcase
if ($extension == ".xls" || $extension ==".xlsx")
true
else
false
end
end
def subirArchiv... | true |
778055fc399e7914ca4a5f5f0bcf988e02ee2af2 | Ruby | rvna/black_thursday | /lib/item_analyst.rb | UTF-8 | 532 | 3.21875 | 3 | [] | no_license | require_relative '../lib/statistics'
class ItemAnalyst
attr_reader :all_items
include Statistics
def initialize(all_items)
@all_items = all_items
end
def item_prices
all_items.map do |item|
item.unit_price
end
end
def average_price_standard_deviation
standard_deviation(item_pric... | true |
bb0181ca2fce6831a2107d52cab8ee76d30dadf0 | Ruby | xldenis/ruby | /test/parser/success/expression/begin.rb | UTF-8 | 368 | 2.90625 | 3 | [] | no_license | begin 1 end
begin
1
ensure
2
end
begin
ensure
end
begin
rescue
rescue
end
begin
else
ensure
end
begin 1 ; ensure 2 end
begin 1 ensure 2 end
begin
1
rescue 2
end
begin
1
else
2
end
begin
rescue def a ; end
2
end
begin
rescue 'A' => e
end
begin
rescue :a => e
end
begin
rescue 2, 4, 5
end
begin
r... | true |
69e8353360b687234d25b0617b19e683cfcad819 | Ruby | awagner85/tealeaf_book | /array.rb | UTF-8 | 58 | 3.234375 | 3 | [] | no_license | x = [1,2,3]
y = []
x.each do |i|
y << i + 2
end
p x
p y | true |
1b2a35f21715b16f005b7f55a87898fdaf0e2575 | Ruby | emilyjspencer/ruby-practice1 | /odd_numbers_below_100.rb | UTF-8 | 146 | 3.78125 | 4 | [] | no_license | #Print only odd numbers under 100 to the console
number = 0
while number < 100 do
if number.odd?
puts number
end
number += 1
end
| true |
8c95c9e92cbf59cf42b4ccbd92c51bf10657b699 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/a2145fda6a8843c08358cb3e27da16e0.rb | UTF-8 | 414 | 3.875 | 4 | [] | no_license | class Bob
def hey(message)
silence(message) || shouting(message) || question(message) || "Whatever."
end
private
def silence(message)
return nil unless message.strip.empty?
"Fine. Be that way!"
end
def shouting(message)
return nil unless message.upcase == message
"Woah, chill out!"
en... | true |
e845b9f61d5df8438fa5f144107eed521703c0f8 | Ruby | sjchakrav/ruby_interview_exercises | /reversestring.rb | UTF-8 | 151 | 3.34375 | 3 | [] | no_license | s = "1234567890"
rs = ""
i = 1
while i <= s.length
rs << s[i*(-1)]
i+=1
end
puts "The original string: '#{s}'"
puts "The reversed string: '#{rs}'"
| true |
e1b4d5b377f77e37199e94948728326441a79354 | Ruby | CodeCoreYVR/debugging-lab | /db/seeds.rb | UTF-8 | 444 | 2.625 | 3 | [] | no_license | QUESTIONS_TO_CREATE = 250
def create_answer
Answer.create(body: Faker::Pokemon.name)
end
QUESTIONS_TO_CREATE.times do
Question.create title: Faker::StarWars.quote,
body: Faker::Hipster.paragraph,
view_count: rand(100)
end
Question.all.each do |question|
rand... | true |
42d958c7ee0b249dd12e0c4bb7008e644f7dd87d | Ruby | EricaJCasePhD/ride-share-two | /driver.rb | UTF-8 | 779 | 2.734375 | 3 | [] | no_license | require 'pry'
require 'csv'
require_relative 'record_magic.rb'
module Rideshare
class Driver
extend RecordMagic
attr_reader :id, :vin, :name
def initialize(args)
@id= args[:driver_id]
@vin = args[:vin]
@name = args[:name]
end
private
def proof_data
raise ArgumentErr... | true |
d30dd98a0984f2ef69d90b77ff809250c64ed8a4 | Ruby | ChristyTropila/SuperheroRuby | /app/models/superhero.rb | UTF-8 | 1,570 | 2.8125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Superhero < ActiveRecord::Base
#macro that connects our ruby models to the db
#a superhero belongs to a superpower and an organization
belongs_to :superpower
belongs_to :organization
has_many :user_superheros
has_many :users, through: :user_superheros
#CRUD METH... | true |
8f1e85f82c0b07c1681e14f89f2bc8a75338bb5a | Ruby | davidcelis/snap | /lib/cinch/plugins/ping.rb | UTF-8 | 331 | 2.546875 | 3 | [] | no_license | require 'cinch'
module Cinch
module Plugins
class Ping
include Cinch::Plugin
match /ping/
# An easy check to see if the bot is responding to basic commands.
#
# <davidcelis> !ping
# <snap> davidcelis: Pong!
def execute(m)
m.reply "Pong!", true
end
end... | true |
0cf8179114cf3251a90eed792cccb482ce6f7317 | Ruby | Clem-svg/TheGossipProjectSinatra | /lib/gossip.rb | UTF-8 | 1,073 | 3.21875 | 3 | [] | no_license | require 'csv'
require 'sinatra'
class Gossip
attr_accessor :author, :content
def initialize(author,content)
@author = author
@content = content
end
# Sauvegarde chaque gossip dans un fichier csv, n'écrase pas les lignes ayant déjà du contenu
def save
CSV.open("./db/gossip.csv", "ab") do |csv|
... | true |
c979abc40c441aa323b0b73504bddaf850131f65 | Ruby | dougjohnston/yearbook-planner | /test/unit/yearbook/yearbook_method_test.rb | UTF-8 | 1,034 | 2.796875 | 3 | [] | no_license | require 'minitest_helper'
class YearbookMethodTest < UnitTest
# years
test "returns a the yearbook years" do
yearbook = FactoryGirl.build(:yearbook, :starting_year => 2013, :ending_year => 2014)
assert_equal '2013-2014', yearbook.years
end
# title
test "returns a nice title" do
yearbook = Factor... | true |
ab18ef66b011d894017e1f29c5c6a3c76371708a | Ruby | felkh/image_blur | /image_blur_3.rb | UTF-8 | 1,340 | 3.875 | 4 | [] | no_license | class Image
def initialize(array)
@image = array
end
def output_image
@image.each do |row|
puts row.join
end
end
def get_ones
ones = []
@image.each_with_index do |img_array, img_array_index|
img_array.each_with_index do |img_array_item, img_array_item_index|
if img_ar... | true |
802d2e73a2b978e021cc1863500c002e759f6db0 | Ruby | hooopo/direct_web_spider | /downloader/normal_downloader.rb | UTF-8 | 672 | 2.59375 | 3 | [] | no_license | # encoding: utf-8
require 'open-uri'
require 'timeout'
module Spider
class NormalDownloader < Downloader
def initialize(items)
@items = items
end
def run
@items.each do |item|
begin
html = open(item.url).read
rescue Timeout::Error, Errno::ECONNREFUSED
logge... | true |
d78f8f7653dfee7006299f09944e8e2a1518cd48 | Ruby | mmthatch12/ruby-proj-1 | /MathHelper.rb | UTF-8 | 157 | 3.34375 | 3 | [] | no_license | module MathHelpers
def double(num)
num *2
end
end
class Savings
include MathHelpers
end
my_savings = Savings.new
my_savings.double(500) | true |
6e9a796ed1ec25dfa8f8b68e01ad73fa81c747e1 | Ruby | kamilkowalski/timetable-parsers | /lib/timetabler.rb | UTF-8 | 876 | 2.859375 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
class Timetabler
def initialize(parser=nil)
@lines = []
@routes = []
@stops = []
@times = []
@parser = parser
if !@parser.nil?
use_parser @parser
end
end
def parsers
Dir.entries(File.join(File.dirname(__FILE__), "parsers")).select{|f| !["..", "."].inclu... | true |
6ddba65b0f63d326937ba292aec391d758c33ed0 | Ruby | icvlahovic/meal-choice-prework | /meal_choice.rb | UTF-8 | 54 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def meal_choice(diet = "meat")
return "#{diet}"
end
| true |
99282d725006cce2f3ea343bfd19cc94187bd550 | Ruby | Auggum/Meta_Filter | /csv.rb | UTF-8 | 930 | 2.71875 | 3 | [] | no_license | require 'csv'
def output_update(r_desc, r_id)
puts "UPDATE pp SET pp.meta_description = \"#{r_desc}\" WHERE pp.id = #{r_id};"
end
CSV.foreach('/home/augo/Documents/RubyTests/finalchange.csv') do |row|
row_description = row[2]
row_id = row[0]
row_meta_description = row[1]
if (!row_description.nil? && row_me... | true |
01b3181c1fc20f81bf4d141b561a45a1c425671f | Ruby | brianw921/W2D2 | /BrianRamChess/Board.rb | UTF-8 | 2,221 | 3.734375 | 4 | [] | no_license | require_relative "null_piece"
require_relative "Piece"
require_relative "RBQ"
require "byebug"
class NoPieceError < StandardError
def m2
puts "ther's no piece in this position"
end
end
class CannotMoveError < StandardError
def m1
puts "you can't move the piece or the piece can't make that move"
end
e... | true |
1b6db66d3390ff47f672b3f063a828fbb4dc97c3 | Ruby | OwenKLenz/ruby_small_problems | /medium_2/unlucky_days.rb | UTF-8 | 1,737 | 4.375 | 4 | [] | no_license | # Write a method that returns the number of Friday the 13ths in the year given by an argument. You may assume that the year is greater than 1752 (when the United Kingdom adopted the modern Gregorian Calendar) and that it will remain in use for the foreseeable future.
# Examples:
# Input: an integer (the year)
# Ouput... | true |
f9af824ca113d1e8032e0e333541f03b844701f6 | Ruby | jenlindner/Seurrat | /image.rb | UTF-8 | 3,115 | 3.96875 | 4 | [] | no_license | #i would love to be able to synch this between javascript and ruby over a socket connection.
#chow about ruby has the read data ready, does it execute a callback to the js function to write?
#does the write function have a pre-hook saying check this flag to call read function's data?
#i could use node callbacks to coo... | true |
6b809da5c0f1ee367425eb267299762a95e09a78 | Ruby | scfcode/My-Scripts | /flickr_download.rb | UTF-8 | 4,792 | 2.5625 | 3 | [] | no_license | #!/usr/bin/ruby
#
# == Synopsis
#
# flickr_download: batch downloader for photos stored on Flickr
#
# == Usage
#
# flickr_download -u NAME -i ID [OPTION] ...
#
# flickr_download -u NAME -t TITLE [OPTION] ...
#
# -h, --help
# this usage message
#
# -i, --photoset-id
# target photoset id
#
# -t, --photoset-title
#... | true |
dc9409ead39b9982d4fbe216a7096a38b01a2763 | Ruby | PhilippaElliott/lesson_4 | /loops20.rb | UTF-8 | 83 | 3 | 3 | [] | no_license | def greeting
while number_of_greetings puts 'Hello!'
end
number_of_greetings = 2 | true |
37859c045ef1ba64aa4635ff7d412404dc4b6ddb | Ruby | geluso/roguebike | /lib/actors/player.rb | UTF-8 | 2,358 | 2.9375 | 3 | [] | no_license | class Player < Actor
attr_accessor :xx, :yy, :facing, :speed
attr_accessor :hp, :fuel, :fuel_capacity
attr_accessor :sensor_range
attr_accessor :inventory
def initialize(xx: 0, yy: 0)
@xx = xx
@yy = yy
@facing = :EAST
@speed = 1
@hits = 0
@hp = 10
@fuel = DEFAULT_FUEL_CAPACI... | true |
946ab026b54e9810471e9f580488198b0c14785a | Ruby | myronmarston/reports_as_sparkline | /lib/simplabs/reports_as_sparkline/reporting_period.rb | UTF-8 | 2,902 | 2.671875 | 3 | [
"MIT"
] | permissive | module Simplabs #:nodoc:
module ReportsAsSparkline #:nodoc:
class ReportingPeriod #:nodoc:
attr_reader :date_time, :grouping
def initialize(grouping, date_time = nil)
@grouping = grouping
@date_time = parse_date_time(date_time || DateTime.now)
end
def self.first(group... | true |
854e379d3e28d394f08f82e640d5e635d0e6218b | Ruby | tehut/BankAccounts | /lib/savingsaccount.rb | UTF-8 | 582 | 3.25 | 3 | [] | no_license | require_relative 'account.rb'
module Bank
class SavingsAccount < Account
def initialize(id = "", balance = 10, date_opened = "" )
super(id, balance, date_opened)
raise ArgumentError.new("balance must be >= 10") if balance < 10
end
def withdraw(amount)
total_withdrawl = amount + 2
... | true |
f708b3a435d6d421c8dca774aa58b109916d2f5e | Ruby | Ad00M87/fink | /db/seeds.rb | UTF-8 | 834 | 2.78125 | 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).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
3df3538ea5ff383fdfe8b932ffb3834f699582ec | Ruby | emikojima/oxford-comma-v-000 | /lib/oxford_comma.rb | UTF-8 | 188 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(array)
new_array = []
if array.count <= 2
array.join(" and ")
else
new_array << array.pop
return "#{array.join(", ")}, and #{new_array.join}"
end
end
| true |
751d6944bb5241b6b649fe5d6274ca6b6e488e55 | Ruby | njpa/launchschool-course-100 | /09_exercises/ex_17.rb | UTF-8 | 1,003 | 4.5 | 4 | [] | no_license | # EXERCISE 17
# ===========
# What will the following program output?
hash1 = {shoes: "nike", "hat" => "adidas", :hoodie => true}
hash2 = {"hat" => "adidas", :shoes => "nike", hoodie: true}
if hash1 == hash2
puts "These hashes are the same!"
else
puts "These hashes are not the same!"
end
# Since...
# (1) the d... | true |
b79bf1380d81177476b1058097986e12fd907bb6 | Ruby | sheena-gygax/DemoDayApp | /CA_examples/shopping_cart.rb | UTF-8 | 895 | 3.625 | 4 | [] | no_license | class Item
def initialize(name, price)
@name = name
@price = price
end
def name
@name
end
def price
@price
end
def name=(product)
@name = product
end
def price=(price)
@price = product
end
end
class Cart
def initialize
@cart = []
end
def add(item, ... | true |
3972823a08b34f5feaad22644a386bc9dd90c4fa | Ruby | Cloudxtreme/logtrend | /lib/logtrend.rb | UTF-8 | 5,238 | 2.890625 | 3 | [] | no_license | require 'rubygems'
require 'eventmachine'
require 'eventmachine-tail'
require 'rrd'
require 'logger'
require 'erb'
# A Ruby module that uses RRD (http://www.mrtg.org/rrdtool/) to generate graphs for trending data from log files.
#
# logtrend tails a log file and matches lines one by one, sending matched counters to RR... | true |
cc2e45241516badb0b97f02292ef1e166bd2844f | Ruby | chrisjohncarter123/oxford-comma-onl01-seng-pt-021020 | /lib/oxford_comma.rb | UTF-8 | 442 | 3.46875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(array)
if(array.length == 2)
return "#{array[0]} and #{array[1]}"
end
result = ""
array.each_with_index do |word, index|
remaining = array.length - index
if(index == 0 && remaining == 1)
result = word
elsif(index > 0 && remaining > 1)
result += ", #{word... | true |
1cf491ddacb272059150538c18574a5cb9e0f02f | Ruby | kgardnr/tealeaf | /Tealeaf_Intro/9_MoreStuff/1.rb | UTF-8 | 223 | 2.65625 | 3 | [] | no_license | def lab_exists?(string)
if /lab/.match(string)
p string
else
p "No match"
end
end
lab_exists?("laboratory")
lab_exists?("experiment")
lab_exists?("Pans Labrynth")
lab_exists?("elaborate")
lab_exists?("polar bear")
| true |
810cc59fe8264901acf2dddc2079f5bae2f6ed15 | Ruby | kevin-a-nelson/dwarf_fortress_raw_sparcer | /test.rb | UTF-8 | 823 | 2.921875 | 3 | [] | no_license | require_relative 'DFRawParcerUtil'
class DFRawParser < DFRawParcerUtil
attr_reader :json, :file_length, :file, :file_lines
def initialize(file_name)
@file = File.read(file_name)
@file_lines = @file.split("\n")
@file_length = @file_lines.length
@json = init_json
end
def init_json(line_num = 0)... | true |
c293bfa186d5b37ec4be1347c84ce877c135c2ab | Ruby | norbert/movieapp | /app/models/poster_finder.rb | UTF-8 | 755 | 2.78125 | 3 | [] | no_license | module PosterFinder
def self.medium_width() 185 end
def self.small_width() 92 end
def self.call movie
tmdb_config = Tmdb.configuration
tmdb_images = Tmdb.poster_images movie.tmdb_id
# sort by language ("en" and nil first) then average rating
tmdb_images.sort! { |a, b|
if a.language == b.... | true |
24a27c93f5a2ecc5127445a6610eb6bae39740e2 | Ruby | David-Kirsch/MovieApp | /app/models/Model1.rb | UTF-8 | 1,923 | 3.140625 | 3 | [] | no_license | #class for Model1 goes here
#Feel free to change the name of the class
class MovieGoer
@@all = []
attr_accessor :name, :selected_movie
attr_reader :mgr, :producer
def initialize(name, mgr = false, producer = false)
@name = name
@mgr = mgr
@producer = producer
save
end... | true |
6fd15e71043d1561c1f366ecfc9cbb9c4e20292f | Ruby | martincalvert/html_toc | /lib/htmlfile.rb | UTF-8 | 1,438 | 3.34375 | 3 | [] | no_license | #HtmlFile class takes a name of a file, checks to see if it .htm or .html extesion then performs actions on the file before closing it and returning true for success or false for a error
#Martin Calvert (sdla)
#martin@martin-calvert.com
#Martin-Calvert
class HtmlFile
attr_accessor :file_name,:line_number
@comment_li... | true |
f7205031b2d2ce18e54bc661ee5219a85cae67d0 | Ruby | ciprianna/Ruby | /CP_Book_Practice.rb | UTF-8 | 16,237 | 4.625 | 5 | [] | no_license | #Ruby Practice
#puts = print
puts 1.0 + 2.0
puts 2.0 * 3.0
puts 5.0 - 8.0
puts 9.0 / 2.0
puts 5 * (12-8) + -15
puts 98 + (59872 / (13 * 8)) * -51
#Hours in a year
puts 365 * 24
#Number of seconds in a decade
puts ((60 * 24) * 365) * 10
#My age
puts (((60.0*60.0)*24.0) * 365.0) * 26.5
#Author's age (given in seconds ... | true |
4abffe10495b0a096e2c4de69539cdf2e9aef3fb | Ruby | JPlante9117/oo-cash-register-online-web-ft-100719 | /lib/cash_register.rb | UTF-8 | 939 | 3.390625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
class CashRegister
attr_accessor :total, :discount, :cart
def initialize(discount=0)
@cart = Array.new
@total = 0
@discount = discount
end
def add_item(title, price, quantity = 1)
i = 0
@price = price * quantity
@title = title
#title, price, adds to total
#accepts o... | true |
31e0f91e680dffec1b9d5c5ddfb3bb3b0e6bbefd | Ruby | MattRice12/internal-learning | /classes/user.rb | UTF-8 | 328 | 3.515625 | 4 | [] | no_license | class User
attr_reader :first_name, :last_name
attr_accessor :age
def initialize(first_name, last_name, age)
@first_name = first_name
@last_name = last_name
@age = age
end
def full_name
first_name + " " + last_name
end
def personal_description
"#{full_name} is #{age} years old."
... | true |
7f503384207f2022e030da8347f3c1f13da6cc7b | Ruby | 95mao/furima-34801 | /spec/models/buy_address_spec.rb | UTF-8 | 3,551 | 2.703125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe BuyAddress, type: :model do # RSpec.describe 「 factorybotのクラス名 」, type: :model
before do
item = FactoryBot.create(:item)
user = FactoryBot.create(:user) # FactoryBotで作ったitemとuserのデータを@buy_addressで紐付けするため
@buy_address = FactoryBot.build(:buy_address, user_id: user.i... | true |
7be0d56be3b371e40038edf8a8738da1e8017589 | Ruby | unepwcmc/parcc | /lib/modules/importers/turnover.rb | UTF-8 | 1,255 | 2.578125 | 3 | [] | no_license | class Importers::Turnover < Importers::Base
extend Memoist
STATS = [:median, :upper, :lower]
def self.import
instance = new
instance.import
end
def import
files.each { |file| populate_values file }
end
def populate_values file_path
split_filename = File.basename(file_path, '.csv').split... | true |
919d69d7544dcc199010da65dc1fdf7df5dc22f9 | Ruby | olotintemitope/andela_ruby | /numbers.rb | UTF-8 | 259 | 3.640625 | 4 | [] | no_license | class Numbers
def initialize(array)
if array.kind_of? (Array)
@numbers = array
end
end
def numbers
@numbers
end
def sum_up
sum = 0
@numbers.each { |num| sum+=num }
sum
end
end | true |
42eb0484ee0917440cfc1488bac02ad012f4379c | Ruby | brentluna/knights_travails | /knightpath.rb | UTF-8 | 1,517 | 3.484375 | 3 | [] | no_license | require_relative 'poly_tree_node'
class KnightPathFinder
DELTAS = [[-2, 1], [-2, -1], [-1, 2], [-1, -2], [2, 1], [2, -1], [1, -2], [1, 2]]
def initialize(start_pos)
@start_pos = start_pos
@visited_positions = [@start_pos]
@tree = build_move_tree
end
def self.valid_moves(pos)
valid_moves = []... | true |
65a348c4da07c1a98eb7a917d00d4ed076a97677 | Ruby | richrace/search-properties | /spec/models/parse_search_string_spec.rb | UTF-8 | 3,984 | 2.921875 | 3 | [] | no_license | require 'spec_helper'
describe ParseSearchString do
before(:all) do
@parser = ParseSearchString.new
end
describe "#find_bedrooms" do
it "will detect string with 'bedroom'" do
search_string = "1 bedroom house"
@parser.find_bedrooms(search_string).should eq 1
end
it "will detect str... | true |
13ed60026854336c62a1155482e5e3f37672e81d | Ruby | ryanfb/ruby-opencv | /test/test_cvline.rb | UTF-8 | 1,023 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | #!/usr/bin/env ruby
# -*- mode: ruby; coding: utf-8-unix -*-
require 'test/unit'
require 'opencv'
require File.expand_path(File.dirname(__FILE__)) + '/helper'
include OpenCV
# Tests for OpenCV::CvLine
class TestCvLine < OpenCVTestCase
def setup
@line = CvLine.new
end
def test_initialize
assert_not_n... | true |
febd9803df646629c9e0ec3230b670ec4bdedabd | Ruby | segunadeleye/ruby_track | /Ex14/bin/main.rb | UTF-8 | 133 | 3.234375 | 3 | [] | no_license | require_relative "../lib/string"
string = "An apple a day keeps the doctor away"
puts "'#{string}' reversed to '#{string.reverse}'"
| true |
20c350c6572284fbc65fb54fbbf56ea867f1437b | Ruby | AlexStoll/RB101 | /lesson_2/pseudo2.rb | UTF-8 | 1,254 | 4.71875 | 5 | [] | no_license | # 1. a method that returns the sum of two integers
# Define the two integers before the method definition, maybe get them from the user.
# Create the method which takes int1 and adds it to int2, making sure it's doing integer addition.
# START
# PRINT request for two integers
# SET int1 = GET first value
# SET int2 =... | true |
0df15640d4a5d4652b7489cbb1973ea40960732e | Ruby | jeff-chen/codon-autocorrelation-calculate | /root_distance_translator.rb | UTF-8 | 142 | 2.625 | 3 | [] | no_license | require 'translator'
class RootDistanceTranslator < Translator
def distance(pos1, pos2)
Math.sqrt(((pos2 - pos1).abs)+1).to_f
end
end | true |
1d95ac4309e63b4f9f8cb6d25b681b03f1ad46cc | Ruby | kimihito/whitehall | /db/data_migration/20130812130035_migrate_document_series_join_data.rb | UTF-8 | 1,296 | 2.734375 | 3 | [] | no_license | require "benchmark"
# Takes the existing data that joins document series to editions and creates
# the corresponding joins to link series directly with documents instead.
time = Benchmark.measure do
# results will contain an array of hashes mapping document series to document ids in the form:
# { 'document_series... | true |
394917d75b490f51df337352e9b491b466270970 | Ruby | Rinthm/phase-0 | /week-4/leap-years/my_solution.rb | UTF-8 | 312 | 3.265625 | 3 | [
"MIT"
] | permissive | # Leap Years
# I worked on this challenge with: Jerrie Evans.
# Your Solution Below
def leap_year?(year)
if year % 4 == 0 && year % 100 != 0
return true
elsif year % 400 == 0
return true
elsif year % 4 == 0 && year % 100 == 0 && year % 400 != 0
return false
else year % 4 != 0
return false
end
end
| true |
20e65d01298c3a4decb6cdd162ec8fa609f0be1b | Ruby | matthiashaefeli/Practice-Problems | /src/solution_ruby.rb | UTF-8 | 4,567 | 3.921875 | 4 | [] | no_license | require "pry"
class Solution
def reverse(string)
array = []
string.split('').each do |letter|
array.unshift(letter)
end
return array.join('')
end
def factorial(n)
result = 1
while n > 0
result = result * n
n -= 1
end
return result
end
def longest_word(sentence)
result ... | true |
c6344cc500391505b86ee2d36481043cb6d6b5b9 | Ruby | kianinyvr/AR_stores_and_employees | /exercises/exercise_4.rb | UTF-8 | 804 | 2.984375 | 3 | [] | no_license | require_relative '../setup'
require_relative './exercise_1'
require_relative './exercise_2'
require_relative './exercise_3'
puts "Exercise 4"
puts "----------"
Store.create(name: "Surrey", annual_revenue: 224000, mens_apparel: false, womens_apparel: true)
Store.create(name: "Whistler", annual_revenue: 1900000, mens_a... | true |
879b215433a770b7fca5fa34df190a94d2cb3645 | Ruby | anishkhithani/hangman | /hangman_test.rb | UTF-8 | 1,637 | 3.578125 | 4 | [] | no_license | require 'test/unit'
require_relative 'Hangman'
class TestHangman < Test::Unit::TestCase
def setup
@game = Hangman.new
@game.word = "booger"
@game.board = @game.draw_board(@game.word)
end
def test_for_initialize_method
assert_equal(8,@game.chances)
assert_equal([]... | true |
c3c72a6883500ae970ae3349107cc9e53d4e075f | Ruby | AndyGauge/prayer-lexer | /app.rb | UTF-8 | 735 | 2.625 | 3 | [] | no_license | require 'sinatra'
require './lib/importer.rb'
require 'net/http'
require 'uri'
require 'json'
set :bind, '0.0.0.0'
get '/' do
'<h1>Lex:</h1> <h2>Prayer-lexer recommends verses based on context of prayers</h2>
<p>Send a post request to this same route to compute the verse appropriate for the content of the reques... | true |
9616a2e34d79ff793ba9e1257767dff5e2e4e18e | Ruby | alexignat/learn_ruby | /02_calculator/calculator.rb | UTF-8 | 186 | 3.609375 | 4 | [] | no_license | def add(x, y)
x + y
end
def subtract(x, y)
x - y
end
def sum(sum_this)
sum_this.inject(0) { |sum, x| sum + x }
sum_this.reduce(0) { |sum, x| sum + x }
sum_this.reduce(:+)
end | true |
b9456cdc4e1ffb5be4e0dd8c0b08e3208775abc3 | Ruby | ganmacs/playground | /ruby/thr/c.rb | UTF-8 | 309 | 3.09375 | 3 | [] | no_license | SIZE = 10
def countup
counter = 0
open('count.txt', 'r') { |f| counter = f.read.to_i + 1 }
open('count.txt', 'w') { |f| f.write counter }
end
open('count.txt', 'w') do |f|
f.write 0
end
m = Mutex.new
Array.new(SIZE).map {
Thread.start {
m.synchronize {
countup
}
}
}.each(&:join)
| true |
4ca4c9bb7aa842e4e05469b10dddf2f971352c16 | Ruby | ahrk-izo/Ruby_object_program1 | /03/judge.rb | UTF-8 | 3,339 | 3.953125 | 4 | [] | no_license | # coding: utf-8
#--------------------
# ジャンケンの審判を表すクラス
#--------------------
class Judge
# 定数定義(大文字で始まる)他クラスの定数を参照
STONE = Player::STONE
SCISSORS = Player::SCISSORS
PAPER = Player::PAPER
def initialize(name = "tmp") # javaでいうコンスタントかな
# インスタンス変数(インスタンスごとに持つ変数)
@name = name # 名前
end
... | true |
cb83a4578368352111840398ee279bccf446966b | Ruby | toddmohney/ennui | /spec/lib/ennui_spec.rb | UTF-8 | 1,426 | 2.625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'pry'
require 'ennui'
include Ennui
class EnnuiTest
include Ennui
end
describe Ennui do
let(:ennui_test) { EnnuiTest.new }
describe "#sometimes?" do
it "is true about %50 of the time" do
score = truthiness_score(1000, Proc.new { sometimes? })
score.should be_withi... | true |
2baf8b3dee839fc0dd19c3fdd2c43f6cbc8b5cac | Ruby | rails/activeresource | /test/cases/reflection_test.rb | UTF-8 | 2,408 | 2.515625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "abstract_unit"
require "fixtures/person"
require "fixtures/customer"
class ReflectionTest < ActiveSupport::TestCase
def test_correct_class_attributes
object = ActiveResource::Reflection::AssociationReflection.new(:test, :people, {})
assert_equal :people, object.name... | true |
85ebb77e762765d904f46b0126f7aef5065b21c3 | Ruby | davluangu/buzzfeed-titanic | /app.rb | UTF-8 | 1,094 | 2.546875 | 3 | [] | no_license | require 'sinatra'
require 'uri'
require 'net/http'
require 'json'
get '/' do
erb :form
end
post "/submit" do
name = "#{params['lastname']}, #{params['title']} #{params['firstname']}"
params["name"] = name
params.delete("firstname")
params.delete("lastname")
params.delete("title")
params["sibsp"] = para... | true |
e011173afd683ca69ae96f6dbe58483036a1c5b8 | Ruby | srishtinath/ruby-oo-relationships-practice-auto-shop-exercise-nyc01-seng-ft-042020 | /app/models/mechanic.rb | UTF-8 | 739 | 3.53125 | 4 | [] | no_license | class Mechanic
attr_reader :name, :specialty
@@all = []
def initialize(name, specialty)
@name = name
@specialty = specialty
Mechanic.all << self
end
def self.all
@@all
end
def cars
Car.all.select { |car_obj| car_obj.mechanic == self}
end
def car_owners
cars.map { |car_obj| ... | true |
8a5dff04652d1d40c8a8873111a9f58dbc8b5208 | Ruby | AteroConfigs/learnstat | /lib/bar_graph_builder.rb | UTF-8 | 2,665 | 2.90625 | 3 | [
"MIT"
] | permissive | require 'rvg/rvg'
include Magick
class BarGraphBuilder
RVG::dpi = 72
@@title_styles = { :text_anchor => 'middle', :font_size => 30, :font_family => 'georgia', :fill=> '#CCC' }
@@label_styles = { :font_size => 20, :font_family => 'verdana', :fill => '#CCC' }
@@axis_styles = { :stroke_width => 2, :stroke => '#... | true |
ec6cb0159094c1c61bc73d002bc5422925c497bf | Ruby | zagoranov/bb-schedule | /app/helpers/application_helper.rb | UTF-8 | 701 | 2.734375 | 3 | [] | no_license | module ApplicationHelper
def day_distance(dt)
n = (Time.now.to_date - dt.to_date).to_i
if dt.wday == 2 && I18n.locale == :ru
zz = "o"
else
zz = ""
end
case n
when 0
rt = t(:today)
when 1
rt = t(:yesterday)
when 2..6
rt = t(:at) + zz + " " + week_day(dt.wday)
else
... | true |
7f6ab7666d775d23f8fb5892548225888804fa55 | Ruby | rishab231/calcentral | /app/models/canvas_lti/webcast_eligible_courses.rb | UTF-8 | 3,223 | 2.546875 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"ECL-2.0"
] | permissive | module CanvasLti
class WebcastEligibleCourses
include ClassLogger
def initialize(sis_term_ids, options = {})
@sis_term_ids = sis_term_ids
@options = options
end
def fetch
courses_by_term = fetch_term_to_course_sections_hash
extract_webcast_eligible_courses courses_by_term
... | true |
4b0f8edb7db952c63e5d85b9709d746f3dc43844 | Ruby | marcelgalang/ruby-collaborating-objects-lab-v-000 | /lib/mp3_importer.rb | UTF-8 | 481 | 2.984375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class MP3Importer
attr_accessor :path, :files
def initialize(path)
@path= path
@files= []
end
def files
@files= []
Dir.foreach(path) do|track|
if track =~ (/[.mp3]{4}/)
@files<< track
end
end
@files
end
def import
@files.map do |file|
b... | true |
153ef5a0c31a86e28872340d9ffeac412fca5689 | Ruby | xiejiangzhi/regexp-examples | /lib/regexp-examples/parser.rb | UTF-8 | 2,551 | 2.96875 | 3 | [
"MIT"
] | permissive | require_relative 'parser_helpers/parse_group_helper'
require_relative 'parser_helpers/parse_after_backslash_group_helper'
require_relative 'parser_helpers/parse_multi_group_helper'
require_relative 'parser_helpers/parse_repeater_helper'
require_relative 'parser_helpers/charset_negation_helper'
# :nodoc:
module RegexpE... | true |
3c9d85a4aebc8cda06fb3f14c2d3c7a4cde2de0e | Ruby | tshepomcode/ceaser_cipher | /ceaser_cipher.rb | UTF-8 | 1,895 | 4.34375 | 4 | [] | no_license | require 'pry'
def ceaser_cipher(string, num)
cipher_arr = []
# provide a-z and A-Z arrays
arr_az_AZ = ("a".."z").to_a + ("A".."Z").to_a
#strip string to character array
string_arr = string.split("")
# for each element of string, check string exists in a-z, A-Z
string_arr.each.with_index do |letter, inde... | true |
77354b584b9143443de964bed3bf44b9c392df59 | Ruby | mvassaramo/OO-mini-project-london-web-071618 | /tools/console.rb | UTF-8 | 1,433 | 2.59375 | 3 | [] | no_license |
require 'pry'
require_relative '../config/environment.rb'
soup_recipe = Recipe.new("soup")
pasta_recipe = Recipe.new("pasta")
bread_recipe = Recipe.new("bread")
sandwich_recipe = Recipe.new("sandwich")
lasagne_recipe = Recipe.new("lasagne")
cake_recipe = Recipe.new("cake")
salad_recipe = Recipe.new("salad")
casey ... | true |
ce7d06a9a7f731149f59f4862e068bb62dbc39db | Ruby | DeveloperAlan/WDI_SYD_7_Work | /w01/d01/chris/strings.rb | UTF-8 | 345 | 3.359375 | 3 | [] | no_license | puts "What is your first name?"
first=gets.strip
puts"Your first name is #{first}"
puts "What is your last name?"
last=gets.strip
puts "Your last name is #{last}"
puts "Your full name is #{first} #{last}"
fullname="#{first} #{last}"
puts "what is your address?"
address= gets.strip
puts "Your name is #{fullname} an... | true |
f94e6c6f42a8d9f426de8cf0d65a94a56b00914c | Ruby | sylwiavargas/Thrive-CLI | /db/seeds.rb | UTF-8 | 7,616 | 3.515625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | Directory.destroy_all
Tip.destroy_all
User.destroy_all
Tip.create(
name: "Golden Rule",
category: "Ruby",
title: "Use pry, don’t cry.",
content: "Although pry may seem a little counter-intuitive (you may think: why would I stop my process to use pry?!?), it will save you a lot of trouble if you pry often.",
... | true |
d5a66af0b54587e525707fadcb23f86e982c35e3 | Ruby | cunctat0r/my_codewars | /4 kyu/Fluent calculator/calc.rb | UTF-8 | 572 | 3.046875 | 3 | [
"MIT"
] | permissive | class Calc
OPERATIONS = {
plus: '.+',
minus: '.-',
times: '.*',
divided_by: './'
}.freeze
DIGITS = {
one: 1,
two: 2,
three: 3,
four: 4,
five: 5,
six: 6,
seven: 7,
eight: 8,
nine: 9,
zero: 0
}.freeze
def initialize
@command = ''
self
... | true |
2279a80f363c5f7ec4a6741b5174ff522e494a39 | Ruby | Karis-T/RB139 | /exercises_challenges/easy1/beer_song.rb | UTF-8 | 739 | 3.96875 | 4 | [] | no_license | class BeerSong
def self.verse(num)
return verse_zero if num.zero?
"#{num} bottle#{num == 1 ? nil : "s"} of beer on the wall, #{num} bottle#{num == 1 ? nil : "s"} of beer.\n" \
"Take #{num == 1 ? "it" : "one"} down and pass it around, #{num - 1 == 0 ? "no more" : num - 1} bottle#{num == 2 ? nil : "s"... | true |
5a9ded715e6ac9db3b9f63ac88a54c7d8e9b3139 | Ruby | jackychen6825/AA_Classwork | /W5/D3/ORM/reply.rb | UTF-8 | 1,592 | 3.0625 | 3 | [] | no_license | require_relative 'user'
require_relative 'question'
require_relative 'questions_database'
class Reply
attr_reader :id, :parent_id, :question_id
def self.find_by_user_id(user_id)
data = QuestionsDatabase.instance.execute(<<-SQL, user_id)
SELECT *
FROM replies
WHERE user_id = ?
SQL
da... | true |
cb214df936d4a088d61713c77bbf94030883e997 | Ruby | Jessicahh7/TTS-Code | /Ruby/loops.rb | UTF-8 | 221 | 3.484375 | 3 | [] | no_license | how_many = 10
how_many.times do
puts "Beetlejuice"
end
# can use this way also
how_many = 10
how_many.time {puts "Beetlejuice"}
# .times only works with integers
# can use this also
10.times {puts "Bettlejuice"} | true |
ce9b81b845e49a76a86845890c37bf89d346cb46 | Ruby | blairanderson/totallycleaner | /_plugins/bannerbear.rb | UTF-8 | 2,386 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'openssl'
require 'date'
require 'fileutils'
require 'active_support'
require 'active_support/core_ext'
BANNERBEAR_SIGNED_URL = "https://on-demand.bannerbear.com/signedurl/qamMwPXe2vwe2KjLgQ/image.jpg"
BANNERBEAR_TAGGED_URL = "https://on-demand.bannerbear.com/taggedurl/OvKJl40B6pQkno2NDV/image.jpg"
module Jeky... | true |
c46305cd069da1d82785e01d340031079c954f48 | Ruby | jdcarey128/sweater-weather | /spec/requests/api/v1/user_registration_spec.rb | UTF-8 | 4,005 | 2.59375 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe 'User Registration' do
# See rails helper for defined_headers, parse_json, and define_body(*)
describe 'with valid and unique credentials' do
it 'responds with the created user\'s email and unique api_key' do
email = 'whatever@example.com'
password = 'pas... | true |
491071a48d29d486ed12ef5e7ff0b8f60631929b | Ruby | mattladany/advent-of-code | /2019/12-01/fuel_calculator.rb | UTF-8 | 280 | 3.375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
total_fuel = 0
file = File.open("mass-input", "r")
file.each_line { |mass|
current_mass = mass.to_i
loop do
current_mass = current_mass / 3 - 2
break if current_mass <= 0
total_fuel += current_mass
end
}
puts total_fuel | true |
ab70a722d5d80c3be60d43baa77d6f22e786372f | Ruby | Rustam-ki/ruby-projects | /3/train.rb | UTF-8 | 1,179 | 3.421875 | 3 | [] | no_license | # frozen_string_literal: true
class Train
attr_reader :number, :type, :route
attr_accessor :station, :speed, :count
def initialize(number, type, count)
@number = number
@type = type
@count = count
@speed = 0
end
def raise_speed(speed)
self.speed += speed
end
def raise_back(_speed_b... | true |
da70d8a03864e5c5109822646fdea70fa5e7f046 | Ruby | sw-contact/LS | /small_problems/easy3/xor.rb | UTF-8 | 236 | 3.125 | 3 | [] | no_license | def xor?(bool1, bool2)
return true if (bool1 && !bool2)
return true if (bool2 && !bool1)
false
end
p xor?(5.even?, 4.even?) == true
p xor?(5.odd?, 4.odd?) == true
p xor?(5.odd?, 4.even?) == false
p xor?(5.even?, 4.odd?) == false | true |
3fad29395f76fb5b1d8211ce75106479ecf3972e | Ruby | ypylypenko/algorithmable | /lib/algorithmable/graphs/traversals/depth_first.rb | UTF-8 | 1,042 | 2.859375 | 3 | [
"MIT"
] | permissive | module Algorithmable
module Graphs
module Traversals
class DepthFirst
include Algorithmable::Graphs::Traversals::Errors
def initialize(graph, source)
@visited = []
@edge_to = []
@source = source
traverse graph, source
end
def visited?... | true |
5c39028158936510e26dffa4bca48d900acde430 | Ruby | afleones/box2share | /app/workflows/creates_paid_plan.rb | UTF-8 | 882 | 2.546875 | 3 | [] | no_license | class CreatesPaidPlan
attr_accessor :remote_id, :name,
:price_cents, :interval, :interval_count,
:space_allowed, :plan
def initialize(remote_id:, name:,
price_cents:, interval:, interval_count:, space_allowed:)
@remote_id = remote_id
@name = name
@price_cents = price_cents
@interva... | true |
b4cdc6e38c87814e188ff3ea65ae8b6ae13b5124 | Ruby | nguyenthuan155632/jmap-api | /app/controllers/inquiry_controller.rb | UTF-8 | 2,013 | 2.65625 | 3 | [] | no_license | class InquiryController < ApplicationController
def create
# res_hash = chk_value(params)
# unless res_hash[:is_success] then
# if res_hash[:failed_code] == 0 then
# output = create_json(code: 102, message: "パラメータの値が不正です。")
# render :json => output
# return
# end
# en... | true |
bbf3256f696ec2084a7d1d25dfb2a4ada9cb2d02 | Ruby | harryuan65/RubyOnStimulants | /app/controllers/excel_controller.rb | UTF-8 | 5,908 | 2.515625 | 3 | [] | no_license | class ExcelController < ApplicationController
def index
@uploads = []
Dir.new(Global::CSV_UPLOAD_PATH).each do |file|
if file.end_with?(".csv")
@uploads.push(file)
end
end
@uploads= @uploads.sort_by{|str| str.split('_')[0].to_i}
@exports=[]
check_exports
Dir.new(Global... | true |
d1e247d7077676731848ebff3de155928e20a855 | Ruby | yurak/fanta | /app/helpers/tours_helper.rb | UTF-8 | 359 | 2.890625 | 3 | [] | no_license | module ToursHelper
def time_to_deadline(time_hash)
return '' if time_hash.blank?
time_str = ''
time_str += "#{time_hash[:days]}d " if time_hash[:days]&.positive?
time_str += "#{time_hash[:hours]}h " if time_hash[:hours]&.positive?
time_str += "#{time_hash[:minutes]}m " if time_hash[:minutes]&.pos... | true |
e827e29a9c5defe6490422bacfd6ba0956837dfc | Ruby | ryanjjosh/Ruby | /team.rb | UTF-8 | 450 | 3.796875 | 4 | [] | no_license | #team.rb
class Team
include Enumerable # LOTS of functionality
attr_accessor :name, :players
def initialize (name)
@name = name
@players = []
end
def add_players (*players) # splat
@players += players
end
def to_s
"#{@name} Team: #{@players.join(",")}"
end
def each
@players.each { |player| yield p... | true |
a70fecc69b2f8e83c3b82a6d503b5cb34afbc15f | Ruby | baezanat/Launch_School_bootcamp | /RB_100/Introduction_to_Programming/loops_and_iterators/conditional_loop.rb | UTF-8 | 53 | 2.6875 | 3 | [] | no_license | i = 0
loop do
i += 2
puts i
if i == 10
break
end
end | true |
be611874bc7469dead53ac4217a95594f9eef21b | Ruby | lachie/oang_orig | /app/models/party.rb | UTF-8 | 465 | 2.578125 | 3 | [] | no_license | class Party < ActiveRecord::Base
has_many :members
named_scope :named, lambda {|name| {:conditions => ['lower(name) = lower(?)',name]} }
before_validation :strip_name
def self.import!(party_name)
@parties ||= {}
party_name.downcase!
if party = @parties[party_name]
party
else
@pa... | true |
4ff28ed1aab26ee7d38d85947304c30dc6055e97 | Ruby | K-Sato1995/ruby_dojo | /Object/methods.rb | UTF-8 | 494 | 3.0625 | 3 | [] | no_license | # Methods
a = 'string'
## methods
puts '============ALL============='
puts a.methods # % * + to_c unicode_normalize unicode_normalize! .......etc
## private_methods
puts '============PRIVATE============='
puts a.private_methods
## protected_methods
puts '============PROTECTED============='
puts a.protected_methods
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.