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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c2843309562e9fabd36437068295d8fd17d60102 | Ruby | YvCodeHong/Oystercard- | /lib/oystercard.rb | UTF-8 | 1,036 | 3.40625 | 3 | [] | no_license | require_relative '../lib/station.rb'
require_relative '../lib/journey.rb'
class Oystercard
attr_reader :balance ,:status, :entry_station, :exit_station, :list_journeys, :journey
MAXIMUM_BALANCE = 90
MINIMUM_CHARGE = 1
def initialize
@balance = 0
@list_journeys =[]
@journey = nil
end
def top_up(money)
fail ... | true |
6f0924c265972cfda20a86f8ae1b049cf663a41a | Ruby | GabrielJSuarez/Enumerable_Methods_With-_Rspec | /spec/my_map_spec.rb | UTF-8 | 865 | 3.359375 | 3 | [] | no_license | require './bin/main'
describe Enumerable do
let(:arr) { [1, 2, 3] }
let(:range) { (1..5) }
let(:block) { proc { |i| i * i } }
describe '.my_map' do
context '#my_map behaviour' do
example 'behaves has .map, takes a block' do
expect(arr.my_map { |x| x * x }).to eq(arr.map { |x| x * x })
... | true |
24d69df8cdc0a662cd9459bf73078c0270eb2121 | Ruby | jssgajendrasingh/berylsystem | /ruby/control_statements/loops/test_3.rb | UTF-8 | 653 | 3.265625 | 3 | [] | no_license | #loop
=begin
A
A B
A B C
A B C D
A B C D E
A B C D E F
A B C D E F G ....
=end
puts "Enter the number of row "
n = gets.chomp.to_i
for i in 1..n do
for j in 1..i do
print "#{(64+j).chr} "
end
puts ""
end
puts "-----------------------------------------------------"
=begin
A
B B
A B C
C C C C
D D D D D
E E E E ... | true |
91ab687aef76f5348e2b5229a7fcbc8f67c0db10 | Ruby | Duod-Notyap/Game | /testfile.rb | UTF-8 | 389 | 2.578125 | 3 | [] | no_license | require 'gosu'
require '.\\assets\\classes.rb'
class TestWindow < Gosu::Window
def initialize
super(700, 500, false, 1)
@cursor = Cursor.new(self.mouse_x, self.mouse_y)
@fps = Gosu::Font.new(20)
end
def update
@cursor.reposition(self.mouse_x, self.mouse_y)
end
def draw
@cursor.draw
@fps.draw(Gosu.fps,... | true |
cdea2a08a4b921f9c9c3627b7d1e989b110d0b35 | Ruby | tacticiankerala/mars-rover | /mars_rover.rb | UTF-8 | 1,059 | 3.46875 | 3 | [] | no_license | class MarsRover
ORIENTATIONS = ["N","E","S","W"]
DIRECTIONS = {:left => -1, :right => 1}
MOVEMENT = {
"N" => {:x => 0, :y => 1},
"S" => {:x => 0, :y => -1},
"E" => {:x => 1, :y => 0},
"W" => {:x => -1, :y => 0}
}
def initialize position
@position = position
end
def rotate_left
rot... | true |
6116e4e01358e2c83909087689f2acbcbdc7fee5 | Ruby | davemaurer/ruby-practice | /fibonacci/fibo1_runner.rb | UTF-8 | 238 | 3.359375 | 3 | [
"MIT"
] | permissive | require_relative 'fibo1'
class FiboRunner
def self.calculate
print "How many times would you like the Fibonacci sequence to run? "
input = gets.chomp.to_i
fib = Fibo.new(input)
fib.start
end
end
FiboRunner.calculate
| true |
6caa75d52332fe0c5cb2a96c91b817365d4c8c57 | Ruby | HAW-AI/blackjack | /lib/blackjack/ui.rb | UTF-8 | 509 | 3.203125 | 3 | [] | no_license | class UI
attr_reader :game_controller
def initialize(*args)
@game_controller = GameController.new
end
def run
puts "Welcome to the blackjack table!"
puts "Extra rules of this casino: Dealer wins ties."
puts "Enter player name"
print ">> "
loop do
input = gets.chomp.strip.downcas... | true |
9c60ffa3d07442e1fc152deb0b72cfa7ac5d94e8 | Ruby | kelvinconnery/ruby-exercise- | /project/skeleton/lib/lexicon.rb | UTF-8 | 928 | 3 | 3 | [] | no_license | class Lexicon
def scan(stuff)
def convert_number(stuff)
begin
Integer(stuff)
rescue ArgumentError
return nil
end
end
hash = {'north' => 'direction', 'south' => 'direction', 'east' => 'direction',
'go' => 'verb', 'kill' => 'verb', 'eat' => 'verb',
'the' => 'stop', 'in' => 'stop', 'of' ... | true |
7df470deb3268df26e306f153ed1b26a03e9450f | Ruby | rglew/SevenLanguagesInSevenWeeks | /ruby/7langDay2.rb | UTF-8 | 1,622 | 3.484375 | 3 | [] | no_license | FIND
1/
File.open("foo.txt","w") { |f| f << "This is sexy" }
instead of forcing us to write this:
file = File.open("foo.txt","w")
file << "This is tedious"
file.close
2/
a1 = ['apple', 1, 'banana', 2]
h1 = Hash[*a1.flatten]
puts "h1: #{h1.inspect}"
a2 = [['apple', 1], ['banana', 2]]
h2 = Hash[*a2.flat... | true |
5b652b6e175eb896ef0f45ef4ac6e1f8a844a988 | Ruby | tonegawa07/calendar_app | /app/views/icp_reservations/history.csv.ruby | UTF-8 | 823 | 2.609375 | 3 | [] | no_license | require 'csv'
bom = "\uFEFF"
csv_data = CSV.generate(bom) do |csv|
csv_column_names = %w(使用日 予約日 研究室名 使用者 サンプル数 開始時間 終了時間 アルゴン残量_1 アルゴン残量_2 アルゴン残量_3 アルゴン残量_4 備考)
csv << csv_column_names
@reservations.each do |reservation|
csv_column_values = [
reservation.start_time.strftime('%Y/%m/%d'),
reserva... | true |
e07b4041295de171618c721befffa343abe19f96 | Ruby | jenbeckham/blackjack_advisor.rb | /blackjack_advisor.rb | UTF-8 | 4,655 | 3.859375 | 4 | [] | no_license | players_cards_array = []
card_value_hash = {"2"=>2,
"3"=>3,
"4"=>4,
"5"=>5,
"6"=>6,
"7"=>7,
"8"=>8,
"9"=>9,
"10"=>10,
"J"=>10,
"Q"=>10,
... | true |
dc09e1fdabc55d87a10d0bd68b32d43941de6e9b | Ruby | johnbeynon/srug-rtanque | /bots/relistan/mydrive.rb | UTF-8 | 2,480 | 2.8125 | 3 | [] | no_license | class Mydrive < RTanque::Bot::Brain
NAME = 'mydrive'
include RTanque::Bot::BrainHelper
CORNERS = [:NW, :NE, :SE, :SW]
TURRET_FIRE_RANGE = RTanque::Heading::ONE_DEGREE * 1.0
def tick!
self.hide_in_corners
if (target = self.acquire_target)
self.fire_upon(target)
else
self.detect_targets... | true |
73e0fb61f9ceb7981708c3bea39e3366db102112 | Ruby | kmaheshwari/crawler | /app/workers/app_detail.rb | UTF-8 | 2,307 | 2.53125 | 3 | [] | no_license | class AppDetail
include Sidekiq::Worker
include Sidetiq::Schedulable
recurrence backfill: true do
minutely(10)
end
def perform()
#url = params[:cateogry].to_s
url = "https://play.google.com/store/apps"
@page = Nokogiri::HTML(open(url))
#@data = @page.css("a.dev-link")[0]["href"]
@data1 ... | true |
ed045b698f3b55126aba96d646317d92ec4efc19 | Ruby | PrabhBrar/rotten-mangoes | /app/models/movie.rb | UTF-8 | 1,301 | 2.546875 | 3 | [] | no_license | class Movie < ActiveRecord::Base
has_many :reviews
validates :title,
presence: true
validates :director,
presence: true
validates :runtime_in_minutes,
numericality: { only_integer: true }
validates :description,
presence: true
validates :release_date,
presence: true
validate :re... | true |
6d1819956a835069e8e58ebd353a5f5fa7ee4918 | Ruby | garedean/rpn_calculator | /app.rb | UTF-8 | 1,273 | 3.75 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
require 'logger'
require_relative 'lib/input'
require_relative 'lib/rpn_calculator'
# Accepts user input via 'gets', interracts with RpnCalculator class
class App
def self.build
logger = Logger.new($stdout)
rpn_calculator = RpnCalculator.new(logger: logger)
new(rpn_calcula... | true |
1ce4aa0a0a33e41daeee0bcc86645167a0dc46d2 | Ruby | kirualex/Flamingo | /vendor/bundle/ruby/2.6.0/gems/declarative-0.0.10/lib/declarative/defaults.rb | UTF-8 | 1,802 | 2.90625 | 3 | [
"MIT"
] | permissive | module Declarative
# {Defaults} is a mutable DSL object that collects default directives via #merge!.
# Internally, it uses {Variables} to implement the merging of defaults.
class Defaults
def initialize
@static_options = {}
@dynamic_options = ->(*) { {} }
end
# Set default values. Usual... | true |
16ae37c1f10284ce9e21439eea5a85da4be1ddf9 | Ruby | BackupTheBerlios/lucie-svn | /tags/ver-0.0.2alpha/lib/deft/debconf-context.rb | SHIFT_JIS | 1,192 | 2.625 | 3 | [] | no_license | #
# $Id$
#
# Author:: Yasuhito Takamiya (mailto:takamiya@matsulab.is.titech.ac.jp)
# Revision:: $LastChangedRevision$
# License:: GPL2
require 'English'
require 'deft'
require 'deft/concrete-state'
update(%q$Date$)
module Deft
# Debconf ɂʑJڂ\NX
class DebconfContext
# ݂ Concrete State
... | true |
9db816833e6cd2c0044f4ab6222b9e0bb3cbf90b | Ruby | rnitta/euler | /ruby/028.rb | UTF-8 | 244 | 2.890625 | 3 | [] | no_license | side = proc { |n| n * 2 - 1 }
sum = 1
now = 1
n = 2
loop do
now += side[n] - 1
sum += now
now += side[n] - 1
sum += now
now += side[n] - 1
sum += now
now += side[n] - 1
sum += now
n += 1
break if side[n] > 1001
end
p sum
| true |
5c123f45a28a2a4b589cbf741d04e7b8e96e9811 | Ruby | tomtomecek/tealeaf1 | /week1/rps.rb | UTF-8 | 1,116 | 4.15625 | 4 | [] | no_license | # Paper, Rock, Scissors assignment
puts "Play Paper Rock Scissors!"
def pick_or_win(choice, opt)
case choice
when 'p' then opt == 'win' ? puts("Paper wraps Rock!") : "Paper"
when 'r' then opt == 'win' ? puts("Rock beats Scissors!") : "Rock"
when 's' then opt == 'win' ? puts("Scissors cuts Paper!") : "Scissors"... | true |
600c759a5115ac0415108e56dd4cd460d25ba548 | Ruby | JuicyLucfier/Ruby_BlackJack | /user.rb | UTF-8 | 237 | 3.03125 | 3 | [] | no_license | # frozen_string_literal: true
# User
class User
attr_accessor :name, :bank, :hand
def initialize(name)
@name = name
@bank = 100
@hand = Hand.new
end
def take_card(deck)
hand.cards << deck.cards.shift
end
end
| true |
d67c3011239dfa67cf58cd15440896a974c6b848 | Ruby | dkosowski87/league_table | /lib/match_table.rb | UTF-8 | 1,179 | 2.921875 | 3 | [] | no_license | class MatchTable < Array
def initialize(league_table)
@league_table = league_table
end
# Public: Dynamically overriding array methods that allow for pushing to the MatchTable object.
# A callback is added to execute the update_standings method on the LeagueTable object
# after an element is added t... | true |
cf5b8f621b6b894435828999d13cc3f25b725134 | Ruby | hwangjf/ruby-oo-practice | /app/models/artist.rb | UTF-8 | 333 | 3.046875 | 3 | [] | no_license | class Artist
ALL = []
def initialize(argument)
@argument = argument
end
def masterpiece(museum)
Painting.new(self, museum)
end
def my_paintings
Painting.all.select {|painting| painting.artist == self}
end
def museum_links
my_paintings.map {|painting| painting.museum}
... | true |
cf828854e5719954a7a8f1920f1a648e79061f88 | Ruby | kanpou0108/launchschool | /Exercises/100_ruby_basics(Programming_Back-end_Prep)/04_Loops_1/loop1_6_ans.rb | UTF-8 | 1,014 | 4.75 | 5 | [] | no_license | # Print While
# Using a while loop, print 5 random numbers between 0 and 99.
# The code below shows an example of how to begin solving this exercise.
numbers = []
while numbers.size < 5
numbers << rand(100)
end
puts numbers
# Approach/Algorithm
# The method Kernel#rand does a nice job of returning a random numbe... | true |
6676c6feb157b598a81efb6bfc10fdbad778ab38 | Ruby | quintel/etengine | /app/models/scenario/editable.rb | UTF-8 | 2,863 | 2.90625 | 3 | [
"MIT",
"LicenseRef-scancode-free-unknown"
] | permissive | # frozen_string_literal: true
# Editable is a wrapper around scenario which exposes some of the internal "store" values as strings
# which can be edited by a user through the inspect interface. User and balanced values are exposed
# as a YAML string, while metadata is displayed as pretty- printed JSON.
#
# This class ... | true |
3778ca4c6ddb7f19e10ac41f402b6df8e1a79268 | Ruby | TuanNghia96/MyRepository | /week1+2/week2_FizzBuzz.rb | UTF-8 | 159 | 3.328125 | 3 | [] | no_license | puts "Nhap so nguyen bat ki"
i = gets.chomp.to_i
# if (i%6) == 0
# printf "FizzBuzz"
# end
if (i%2) == 0
printf "Fizz"
end
if (i%3) == 0
printf "Buzz\n"
end | true |
ffbe439d0db01c01ac0f0d969f87050978b2afca | Ruby | TopShelfBullard/Prime-Numbers-Web-App | /app/models/number_words.rb | UTF-8 | 2,244 | 4.03125 | 4 | [] | no_license | class NumberWords
@ones = {n0:"", n1:"one", n2:"two", n3:"three", n4:"four", n5:"five", n6:"six", n7:"seven", n8:"eight", n9:"nine"}
@tens = {n2:"twenty", n3:"thirty", n4:"forty", n5:"fifty", n6:"sixty", n7:"seventy", n8:"eighty", n9:"ninty"}
@tens_under_20 = {n10:"ten", n11:"eleven", n12:"twelve", n13:"thirteen"... | true |
ce015b6176cf404b57e953b0dc38218a49dda6d0 | Ruby | zhagnx/ruby_study | /script/timeclass.rb | UTF-8 | 1,342 | 3.75 | 4 | [] | no_license | #!/usr/bin/env ruby
p Time.new #get now time
p Time.now #get now time
p Time.now.zone #print now time zone
p Time.now.getutc #get the utc time
now = Time.now.utc #set the timezone to utc
p now.zone #print now time zone
p "---------to_i to_f to_r to_s-----------"
now = Time.now
p n... | true |
59aa589c8a5486ef37775a9ba382621b490b35b3 | Ruby | AmrAdelKhalil/chat-sys | /chat-system/lib/hash.rb | UTF-8 | 159 | 2.84375 | 3 | [] | no_license | class Hash
# Convert hash from structure {k => v, k1 => v} to {v=>[k, k1]}
def safe_invert
self.each_with_object({}){|(k,v),o|(o[v]||=[])<<k}
end
end | true |
0944026615521aa0beaf6889ed0b4b03c452e827 | Ruby | Karis-T/RB101-RB109-Small-Problems | /multiply_all_pairs.rb | UTF-8 | 168 | 3.21875 | 3 | [] | no_license | def multiply_all_pairs(arr1, arr2)
arr1.product(arr2).map{|arr| arr.reduce(:*)}.sort
end
p multiply_all_pairs([2, 4], [4, 3, 1, 2]) == [2, 4, 4, 6, 8, 8, 12, 16]
| true |
c98ea30835491aa5e41f9b9435c1bd637da02156 | Ruby | SMoni/GoL.Ruby | /Neighbourhood.rb | UTF-8 | 1,416 | 3.234375 | 3 | [] | no_license | require "./Elements.rb"
module Neighbourhood
Array.include Elements
def getNeighbourhood()
numberOfElements = self.getNumberOfElements()
lastIndexOfDimensions = numberOfElements.count - 1
offset = -1
return lambda do |coordinates|
resu... | true |
9de12fbb184a8ed607641741eff4d32fc1279b6d | Ruby | Denver-Devs/bookclub-seven-languages-seven-weeks | /ruby/rich/day2.rb | UTF-8 | 1,842 | 4.25 | 4 | [] | no_license | #Print the contents of an array of sixteen numbers, four numbers at a time, using just each. Now, do the same with each_slice in Enumerable.
puts
a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
a.each { |x| puts a[a.index(x)-3..a.index(x)].to_s if (a.index(x) + 1) % 4 == 0 }
a.each_slice(4) {|x| puts "#{x}"}
#The Tree... | true |
c671c6f086664a51f1b35c1b3e590a039e21126f | Ruby | garcia50/jungle_beats | /lib/jungle_beats.rb | UTF-8 | 2,168 | 3.59375 | 4 | [] | no_license | require './lib/node'
class JungleBeats
attr_accessor :head, :count
def initialize
@head = nil
@count = 0
end
def append(data)
node = Node.new(data)
@count += 1
if @head == nil
@head = node
else
append_with_existing_nodes(@head, node)
end
end
def append_with_exist... | true |
02de92443cbb68c87c2cdc110f0ca0cd858bf116 | Ruby | grumoz/launchschool-small-problems-101-109 | /counting_the_number_of_characters.rb | UTF-8 | 214 | 3.921875 | 4 | [] | no_license | puts "Enter word or multiple words:"
input = gets.chomp.split(" ")
def char_count input
chars = 0
input.each { |el| chars += el.size }
chars
end
count = char_count input
puts "There are #{count} in input."
| true |
32f1a2416fc59e186c3a415528f60d34c744db75 | Ruby | ericapeplowski/ruby_challenges | /my_first_method.rb | UTF-8 | 202 | 3.640625 | 4 | [] | no_license | def my_first_method
puts "This is my first method!"
end
my_first_method
def basic_math
puts "What is 2 + 2?"
first_number = [2]
puts "The Answer is " + (first_number + 2).to_s
end
basic_math
| true |
1a870955c9b1f200f820e3686de5bf82c33e0a1b | Ruby | douglaslise/wonder_navigation | /lib/wonder_navigation/deferrable_option.rb | UTF-8 | 1,245 | 3.015625 | 3 | [] | no_license | module WonderNavigation
class DeferrableOption
attr_accessor :fixed_value, :block, :name, :fixed_value_assigned
def initialize(options = {})
@fixed_value_assigned = options.has_key?(:fixed) && !options[:fixed].nil?
@fixed_value = options[:fixed]
@block = options[:block]
@name ... | true |
f59aa7995efb1369f344aa0f6b9a0a92f4e515bc | Ruby | BryceT516/brujula | /lib/brujula/parameters/transformer.rb | UTF-8 | 2,037 | 3.1875 | 3 | [
"MIT"
] | permissive | module Brujula
module Parameters
class Transformer
attr_reader :parameters
def initialize(parameters:)
@parameters = parameters
end
def call(string)
content = string.match(/<<(.*?)>>/)[1]
apply_functions(content)
end
private
def apply_functio... | true |
051f66c051f31f343f14a7534051cd4a22bb3740 | Ruby | malaimes/BSG-API | /post_xml.rb | UTF-8 | 4,006 | 2.59375 | 3 | [] | no_license | require 'net/http'
require 'net/https'
require 'nokogiri'
require "uri"
module BSG
# API documentation https://bsg.hk/developers/
class Client
attr_accessor :login, :password, :sender
def initialize(login, password, sender: nil)
@login = login
@password = password
@sender = sender
... | true |
59fbeb931d3f9e8fa3f5f06d7ee9fe822bcdea3c | Ruby | sathlan/machine-nics | /lib/machine-nics/tree.rb | UTF-8 | 3,546 | 3.671875 | 4 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
module MachineNics
# Builds a tree as a associative array. It takes an hash of an hash
# as input whose root node is a machine's name (as a symbol).
class Tree
attr_reader :root
attr_reader :parent_of
attr_reader :children
def initialize(machine_name)
@root = machine... | true |
53f9d8760ea65ba36d3999d47c98b495ac8efe36 | Ruby | inDinero/finicity | /lib/finicity/logger.rb | UTF-8 | 562 | 2.5625 | 3 | [
"MIT"
] | permissive | module Finicity
module Logger
def log_request
::Finicity.logger.debug do
log = "REQUEST: #{self.class.name}"
log << "\n URL: #{url}" if self.respond_to?(:url)
log << "\n QUERY: #{query}" if self.respond_to?(:query)
log << "\n BODY: #{mask_body(body)}" if self.respond_to?(:... | true |
884b745a0bc9985abdecb19c40fa502d98e24fbe | Ruby | NoriVicJr/canvas_client | /lib/canvas_client/client.rb | UTF-8 | 2,006 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'rest-client'
require 'json'
module Canvas
class Client
class ConfigurationError < Exception
end
attr_accessor :url, :token, :account
def initialize(url: nil, token: nil, account: nil)
@url, @token, @account = url, token, account
@url ||= ENV['CANVAS_URL']
@token |... | true |
951e998067049775646921b005ff36c9128e2978 | Ruby | rekapap/Problem-solving | /Hackerrank/Ruby/methods/hash_arg4.rb | UTF-8 | 447 | 3.09375 | 3 | [] | no_license |
def f_c(f)
(f - 32) * 5/9
end
def k_c(k)
k - 273.15
end
def c_f(c)
(c * 9/5) + 32
end
def c_k(c)
c + 273.15
end
def f_k(f)
c = f_c(f)
c_k(c)
end
def k_f(k)
c = k_c(k)
c_f(c)
end
def convert_temp(n, input_scale:'kelvin', output_scale: 'celsius')
return n if input_scale == output_scale
send((in... | true |
34dd26a7d27dc6194853e92a00d49304572dc569 | Ruby | yortz/smsonrails | /lib/sms_on_rails/model_support/draft.rb | UTF-8 | 7,146 | 2.546875 | 3 | [
"MIT"
] | permissive | module SmsOnRails
module ModelSupport
module Draft
def self.included(base)#:nodoc
base.send :accepts_nested_attributes_for, :outbounds
#base.acts_as_deliverable :fatal_exception => SmsOnRails::FatalSmsError
base.validates_presence_of :message
base.validate :validates_messa... | true |
2d68f13818e185fa5bfe46cbce67d304a603b7b4 | Ruby | sashaProdan/intro-to-ruby-exercises | /Final-Exercises/exercise_6.rb | UTF-8 | 273 | 3.71875 | 4 | [] | no_license |
# Get rid of duplicates without specifically removing any one value.
arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3]
new_arr = arr.uniq
p new_arr # => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
p arr # => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3]
| true |
63c89d52297eb1b3d1847f725242651c37fcab8f | Ruby | Carpe-Omnia/ruby-collaborating-objects-lab-cb-000 | /lib/song.rb | UTF-8 | 422 | 2.90625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative "./artist.rb"
#require_relative "./mp3_importer.rb"
class Song
attr_accessor :name, :artist, :genre
def initialize(name)
@name = name
end
def self.new_by_filename(filename)
ray = filename.split(" - ")
track = Song.new(ray[1])
creator = Artist.find_or_create_by_name(ray[0])
t... | true |
702d1607b5a54a9307693c62bca3392284e1af0a | Ruby | jacobn9000wow/new_app | /app/models/room.rb | UTF-8 | 753 | 2.546875 | 3 | [] | no_license | class Room < ActiveRecord::Base
attr_accessible :room_name, :room_id
#has_many :users
has_many :inclusions, foreign_key: "including_room_id"
has_many :included_users, through: :inclusions, source: :included_user
has_many :posts
#def add_member #maybe make private?
# @user = User.find_by_id(params[:us... | true |
b2b10741986b78f9b069b6087f2c407987b0e54b | Ruby | akutarba/courses | /lesson5/cargo_train.rb | UTF-8 | 315 | 2.609375 | 3 | [] | no_license | require_relative '../lesson5/train'
require_relative 'validation'
class CargoTrain < Train
include Validation
attr_reader :number
validate :number, :presence
validate :number, :type_number, String
validate :number, :format, NUMBER_TEMPLATE
def initialize(number)
super(number, :cargo)
end
end
| true |
8bc1f9067a663a7457f8c3660bd4a38a778c1b16 | Ruby | cider-load-test/i-created-something-cool | /app/models/user.rb | UTF-8 | 1,112 | 2.609375 | 3 | [] | no_license | require 'digest/sha1'
require 'md5'
class User < ActiveRecord::Base
attr_accessor :password
validates_confirmation_of :password
validates_uniqueness_of :email
has_many :projects
after_create :create_stub
def create_stub
self.stub = name.gsub(/\W+/, ' ').strip.downcase.gsub(/\ +/, '_') + "_#{... | true |
0fa90450036edff2d66e49dd581d476ac41feb43 | Ruby | celtic93/education | /lesson6/carriage.rb | UTF-8 | 338 | 2.984375 | 3 | [] | no_license | require_relative 'manufacturer'
class Carriage
include Manufacturer
include Validation
attr_reader :type
def initialize(type)
@type = type
validate!
end
def validate!
raise 'Неизвестный тип. Выберите :cargo или :passenger' unless [:cargo, :passenger].include? type
true
end
end
| true |
2c673d722c3900bb5014ab288c65c3aa5a2042de | Ruby | iplay88keys/ShowTracker2 | /test/models/episode_test.rb | UTF-8 | 2,048 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class EpisodeTest < ActiveSupport::TestCase
test "setup" do
assert_equal(Episode.count, 3)
end
test "getEpisodesForSeasonWithWatches" do
user_id = 1
series_id = 2
season_id = 1
watchOne, _ = setupWatches(user_id)
returned = Episode.getEpisodesForSeasonWithWatches(... | true |
d359d3e4e721b19c117a353d0b8274728b110b1e | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/difference-of-squares/518bad61e74941a8ba38a0941ff44ec7.rb | UTF-8 | 442 | 3.765625 | 4 | [] | no_license | require 'pry'
class Squares
def initialize(num)
@num = num
end
def square_of_sums
sum_num = @num
sum = 0
while sum_num > 0
sum += sum_num
sum_num -= 1
end
sum ** 2
end
def sum_of_squares
squared_num = @num
total = 0
while squared_num > 0
total += square... | true |
5b53d329550146e1ef2fb502d7d86e38f7b28fb9 | Ruby | lizbur10/boston-events-cli-app | /lib/boston_events/cli.rb | UTF-8 | 3,380 | 3.359375 | 3 | [
"MIT"
] | permissive | # CLI Controller
class BostonEvents::CLI
attr_accessor :category
def call
puts; puts
puts "Hi! Welcome to the Boston Events Finder"
puts "You can quit this app at any time by typing exit."
puts; puts "Categories loading..."
input = nil
scraper = BostonEvents::Scraper.new
while input != ... | true |
5ee628c55f2691b896f4b704b19fa5321205ad08 | Ruby | jdejesu2/com331_bookrepo1 | /chapter6/chap6exercise4.rb | UTF-8 | 1,056 | 3.703125 | 4 | [] | no_license | letters = 'aAbBcCdDeE'
puts letters.upcase
puts letters.downcase
puts letters.swapcase
puts letters.capitalize
puts ' a'.capitalize
puts letters
##AABBCCDDEE
##aabbccddee
##AaBbCcDdEe
##Aabbccddee
## a
##aAbBcCdDeE
line_width = 50
puts( 'Old Mother Hubbard'.center(line_width))
puts( 'Sat in her cupboard'.center(line... | true |
876ff4fbfcff9d17f8ece88a9185ac2320eeb882 | Ruby | leadtune/queue_map | /spec/integration_spec.rb | UTF-8 | 2,619 | 2.59375 | 3 | [
"MIT"
] | permissive | require "spec_helper"
def timing(&block)
time = Time.now
yield
(Time.now - time)
end
describe "Integration" do
context "Running consumers in separate processes" do
def start_consumers
@process = BackgroundProcess.run("#{BIN_PATH}/queue_map_consumer -f start #{SPEC_PATH}/support/greet_consumer.rb")
... | true |
d27111f799fad1e3367323b6cac0eef673478491 | Ruby | peter665/learn_ruby | /01_temperature/temperature.rb | UTF-8 | 76 | 2.9375 | 3 | [] | no_license | def ftoc temp
(temp-32)/9.0*5.0
end
def ctof temp
(temp*9.0/5.0)+32
end
| true |
5f4a16832f7b0e8344c7b483a4cf83a84d0eeb7c | Ruby | alan-nakagiri/minesweeper | /tile.rb | UTF-8 | 772 | 3.375 | 3 | [] | no_license | require './board'
class Tile
attr_reader :parent, :is_bomb
attr_accessor :revealed, :value, :is_flagged
def initialize(parent, position, bomb)
@parent = parent
#@value = "*"
@revealed = false #(revealed or not, flagged)
@pos = position
@is_bomb = bomb
@is_flagged = false
end
def va... | true |
671ec3f3411c633f08697d82aa2d549528e4416e | Ruby | muhammad-awan/ruby-restaurant | /restaurant.rb | UTF-8 | 6,399 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'terminal-table'
class MenuItem
def initialize(name, description, price)
@name = name
@description = description
@price = price
end
attr_accessor :name, :price, :description
end
class Order
def initialize()
@items = []
end
def << (menu_item)
@items << menu_item
end
def to... | true |
e913b505ecf23598aacb832d23c59d0959e23333 | Ruby | cwillionaire/ruby_practice | /10.21.practice.rb | UTF-8 | 213 | 3.453125 | 3 | [] | no_license | class Animal
def speak
"Hello!"
end
end
class GoodDog < Animal
def bark
"Bark"
end
end
class Cat < Animal
end
sparky = GoodDog.new
paws = Cat.new
puts sparky.bark
puts paws.speak | true |
2206cdb0ab409b6f1c0bf5c5c1b3c263525dba85 | Ruby | vitalyp/activefile | /lib/active_file/base.rb | UTF-8 | 426 | 2.546875 | 3 | [
"MIT"
] | permissive | module ActiveFile
require 'ostruct'
class Base < OpenStruct
include Adapter
extend Adapter::ClassMethods
def ahola
return "ahola here!!!!"
end
#'a'.camelize.safe_constantize
#def child_of(parent_name)
# puts "ok, I am a child of #{parent_name}"
#end
#
... | true |
50ba131caa43bbab653788e4a17620d18cc9b745 | Ruby | johnofsydney/toy-robot | /src/ingestor.rb | UTF-8 | 659 | 3.203125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# definition of class Ingestor for coding test.
class Ingestor
attr_reader :file
def initialize(filename)
@file = File.expand_path(filename)
raise "Cannot read file #{file}: Does not exist" unless File.exist?(@file)
end
def instructions
import.select { |command| legi... | true |
d41451ffae4853940af42b05530a5f9850c09d83 | Ruby | jasnow/medlink | /app/models/timeline.rb | UTF-8 | 985 | 2.578125 | 3 | [
"MIT"
] | permissive | class Timeline
include Enumerable
attr_reader :user, :duration
def initialize user, duration: 1.year, requests: nil, responses: nil, messages: nil
@user, @duration = user, duration
end
def each
(requests + responses + messages).
sort_by(&:created_at).
reverse_each { |e| yield presenter_... | true |
c7edb8f29eb3c9a855f5e006b98fa8a867af089c | Ruby | kyanny/competitive-programming-ja | /abc044/abc044_b/main.rb | UTF-8 | 190 | 3.40625 | 3 | [] | no_license | w = gets.chomp
chars = w.split(//)
ntimes = Hash.new{ |h,k| h[k] = 0 }
chars.each do |char|
ntimes[char] += 1
end
if ntimes.values.all? { |v| v.even? }
puts 'Yes'
else
puts 'No'
end
| true |
8ca049d612b84a3fa265cd42818084c7010b2edf | Ruby | branning/rails-mini | /mini_proj/app/controllers/users_controller.rb | UTF-8 | 646 | 2.515625 | 3 | [] | no_license | class UsersController < ApplicationController
def index
@users = User.all
.paginate(:page => params[:page], :per_page => params[:per])
end
def show
@user = User.find(params[:id])
@items = @user.items
# lambdas on rails, amirite
@recommended_items = @items
.map {|item| item.categories}.flatten.uniq
... | true |
154fa26471342bce50d65366c333ec176ede6b43 | Ruby | goofycoder/arsenal | /Ruby/read_parse.rb | UTF-8 | 148 | 2.859375 | 3 | [] | no_license | require 'json'
file = File.read('in.json')
data_hash = JSON.parse(file)
keys = data_hash.keys
puts keys
for k in keys
puts data_hash[k]
end
| true |
8f988a4705d2ec7312fe782911cf5c657d38dd3d | Ruby | yasiasz/RUBY | /ruby.rb | UTF-8 | 519 | 4.09375 | 4 | [] | no_license | #diferencia entre get y get.chomp
#name = gets
#puts " hola " + name + "jejeje"
#name = gets.chomp
#puts " hola " + name + " " + "Cómo estas"
print "ingrese su nombre: "
name = gets.chomp
print "Su edad: "
z = gets.chomp
x = 2016 - z.to_i #to_i se utiliza para pasar la z a variable numerica
z.to_i #identifico la va... | true |
86a2566c5d3ca19abb6a899ecff7fcc14cc4a9c6 | Ruby | yonatanmk/backup | /chillow/spec/dwelling_spec.rb | UTF-8 | 597 | 2.734375 | 3 | [] | no_license | require 'spec_helper'
describe Dwelling do
subject(:dwelling) {Dwelling.new('77 Summer St.', 'Boston', 'MA', '02110')}
describe '#initialize' do
it "accepts 4 arguments and initializes" do
expect(dwelling).to be_a(Dwelling)
end
it "has an address" do
expect(dwelling.address).to eq('77 Sum... | true |
6d6b9e98c944a6175376d6cdd184c5c41ff8b78e | Ruby | shawniut/RELREA | /lib/membership_function_helper.rb | UTF-8 | 946 | 2.953125 | 3 | [] | no_license | module MembershipFunctionHelper
def index value
parameters = "10:20:"
puts shape2(parameters, value)
end
def get_satisfaction_degree parameters, metric_value, shape
if shape == "Shape 1"
return shape1 parameters, metric_value
elsif shape == "Shape 2"
return shape2 parameters, metric_valu... | true |
030b7400dc0e6be7b1b5bb6baa1a346a30126549 | Ruby | cthulh/Ruby-beginnings | /Chris Pine - Learn To Program/numbers.rb | UTF-8 | 81 | 2.921875 | 3 | [] | no_license | puts 1+2
puts 1.0 + 0.02
puts 1.0 + 0.2
puts 1.1 * 3
puts (1+2) * 8
puts 9 / 2.00 | true |
c13d7050947cbbcfab8a4c031c445d57bee347cf | Ruby | jgpettibone/ruby-intro | /ruby_data_structures/spec/tree_spec.rb | UTF-8 | 497 | 3.015625 | 3 | [] | no_license | require './src/tree.rb'
describe Tree do
before(:each) do
@tree = Tree.new(1)
end
it "initializes empty" do
@tree.value.should == 1
end
describe "#add" do
it "should add the first item correctly" do
@tree.addChild(2)
@tree.children[0].value.should == 2
end
it "should add ot... | true |
6e929e1b4d005385f524f48188548c3a2877f1e2 | Ruby | omorest/ASIR | /add1718-oscar/11-scripts/actividades/crear_borrar_usuarios/create-and-delete-users.rb | UTF-8 | 1,411 | 3.234375 | 3 | [] | no_license | #!/usr/bin/ruby
# Funciones
def create_user(camp)
user_exist = system("id #{camp[0]} 2> /dev/null 1>/dev/null")
case user_exist
when true
if camp[4] == "delete"
if camp[2] == ""
puts("El campo de correo del usuario #{camp[0]} necesita ser rellenado")
else
puts("Borrando usuario #{... | true |
724f3cfbe7181663d3bd8961707d6096ae4f64cd | Ruby | trial646/phase-0-tracks | /ruby/hamsters.rb | UTF-8 | 1,177 | 4.03125 | 4 | [] | no_license | # list of program objectives
# allow user to name hamster (method 1) - string
# allow user to rename hamster (method 2) - string
# record hamster noise level of squeaks ranked by number 1-10 - integer
# record hamster fur color - string
# record hamster age - integer
# answer whether good candidate for adoption - bool... | true |
c93914dcaa80ab553c7ab9c94f54bbdaf2518a1b | Ruby | LuuuFan/daywork | /W2D1/inheritance/Employee.rb | UTF-8 | 1,158 | 3 | 3 | [] | no_license | # require_relative "Manager"
require 'byebug'
class Employee
attr_reader :name, :salary, :title
def initialize(name, title, salary, boss = nil)
@name = name
@title = title
@salary = salary
# debugger
unless boss.nil?
self.boss=(boss)
else
@boss = boss
end
end
def bonus... | true |
260155eedc4393e8e9b69b8da4903ec9e2405320 | Ruby | cohei/tddbc | /lib/average_calculator.rb | UTF-8 | 191 | 3.1875 | 3 | [] | no_license | class AverageCalculator
def calc(appearances, at_bat, hits)
if appearances == 0
nil
elsif at_bat == 0
0
else
(hits.to_f / at_bat).round(3)
end
end
end
| true |
c7b322da86ac955885b48535313edde4499980a7 | Ruby | SimonTanner/lrthw | /ex03/ex3_study_drill_01.rb | UTF-8 | 1,013 | 4.5 | 4 | [] | no_license | puts "I will now count my chickens:"
puts "Hens #{25 + 30 / 6}" # Calculates the number of hens and outputs this
puts "Roosters #{100 - 25 * 3 % 4}" # Calculates the number of roosters and outputs this
puts "Now I will count the eggs:" # Prints the text inside quotes
puts 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 # Prints o... | true |
757a5b31690f79a4193ef3a0aa948d5e0386818f | Ruby | shreyas098/rubylearning | /DataTypes.rb | UTF-8 | 280 | 3.046875 | 3 | [] | no_license | num=1_234;
puts num
puts (78.9+99.5)
puts (2>3)
sea_creatures = ['shark', 'cuttlefish', 'squid', 'mantis shrimp']
puts sea_creatures[0] # shark
puts sea_creatures[2] # squid
user = {"first_name" => "Sammy", :last_name => "Shark"}
print user["first_name"]
print user[:last_name]
| true |
a025bd8f1ae66162522646cbe1f203d5efaf49ef | Ruby | spencerkevans/sinatra-nested-forms-lab-superheros-v-000 | /app/models/team.rb | UTF-8 | 173 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Team
attr_reader :name, :motto
TEAMS = []
def initialize(args)
@name = args[:name]
@motto = args[:motto]
TEAMS << self
end
def self.all
TEAMS
end
end | true |
af6c3845ce6c987ebcf55013104bc346ff75fa1a | Ruby | hybernaut/lionbridge-api-example | /translate.rb | UTF-8 | 1,563 | 2.6875 | 3 | [] | no_license | require 'OpenSSL'
require 'time'
require 'httparty'
# http://developers.lionbridge.com/content/docs
# https://support.liondemand.com/hc/en-us/articles/201095990-Writing-your-first-API-Call
class LionBridge
include HTTParty
LOD_BASE_URI = ENV['LOD_BASE_URI'] || 'developer-sandbox.liondemand.com'
LOD_PREFIX = 'L... | true |
97b7bf20deb8a4fd7fff26574017cd515e8f4806 | Ruby | barbarafux/ruby_exercises | /learntoprogram/chapter2/minutes_in_a_decade.rb | UTF-8 | 384 | 4.09375 | 4 | [] | no_license | # Minutes in a decade. How many minutes are in a decade?
minutes_year = 365 * 24 * 60
minutes_leap_year = 366 * 24 * 60
# if there are 2 leap years in that decade
minutes_decade = minutes_year * 8 + minutes_leap_year * 2
# if there are 3 leap years in that decade
# minutes_decade = minutes_year * 7 + minutes_leap_ye... | true |
eeaba82686a2d0790dddd298063fef9aacf44665 | Ruby | Saltside/thrifter | /test/acceptance_test.rb | UTF-8 | 7,293 | 2.515625 | 3 | [
"MIT"
] | permissive | require_relative 'test_helper'
class AcceptanceTest < MiniTest::Unit::TestCase
SimulatedError = Class.new StandardError
class TestClient < TestService::Client
def echo(message)
message
end
end
class BrokenTestClient < TestService::Client
def echo(message)
fail SimulatedError
end
... | true |
37e8c034b3f4eb15f5d681023a200316fc1694df | Ruby | ylhoony/ttt-with-ai-project-v-000 | /lib/game.rb | UTF-8 | 1,073 | 3.78125 | 4 | [] | no_license | class Game
attr_accessor :player_1, :player_2, :board
WIN_COMBINATIONS = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[6,4,2]]
def initialize(player_1=Players::Human.new("X"), player_2=Players::Human.new("O"), board=Board.new)
@player_1 = player_1
@player_2 = player_2
@board = board
en... | true |
ed77d543144f9b18ce5a2a4ed42b666ef4ddd3c9 | Ruby | sojastar/teeny-tiny-jam-2020-launcher | /app/main.rb | UTF-8 | 11,476 | 2.75 | 3 | [] | no_license | class Label # Just a label
def initialize x:, y:, text:, se: 0, ae: 0, r: 255, g: 255, b: 255, a: 255
@x = x
@y = y
@text = text
@se = se
@ae = ae
@r = r
@g = g
@b = b
@a = a
@w, @h = $gtk.calcstringbox(text, se)
end
def box
return [@x, @y - @h, @w, @h]
end
def d... | true |
ff00cd85b5a32937f5cc878b5c7e4a25ba847fff | Ruby | aaronwtan/RB101 | /small_problems/easy4/q2.rb | UTF-8 | 910 | 4.53125 | 5 | [] | no_license | # Write a method that takes a year as input and returns the century.
# The return value should be a string that begins with the century number,
# and ends with st, nd, rd, or th as appropriate for that number.
# New centuries begin in years that end with 01.
# So, the years 1901-2000 comprise the 20th century.
SUFFIX... | true |
4c0bd6c8b4a121badd5d6820679d1a3af4aeaa3e | Ruby | exagil/AgileStore | /app/models/cart.rb | UTF-8 | 669 | 2.890625 | 3 | [] | no_license | class Cart < ActiveRecord::Base
has_many :line_items, dependent: :destroy
# adds a product to the cart if not already present
# if already present, bumps up the quantity
def add_product(product_id)
current_item = line_items.find_by(product_id: product_id)
if current_item
current_item.quant... | true |
ce03c678823c7487a97c96348d6190d75b5c26c2 | Ruby | nblackburn87/English-Math-Calculator | /spec/word_calculator_spec.rb | UTF-8 | 1,188 | 3.515625 | 4 | [] | no_license | require ("rspec")
# require ("word_calculator")
require ("alternative")
describe("word_calculator") do
it("adds 5 plus 3 and gets 8") do
word_calculator("What is 5 plus 3?").should(eq("8"))
end
it("subtracts 5 minus 3 and gets 2") do
word_calculator("What is 5 minus 3?").should(eq("2"))
end
it("multi... | true |
c5cb3769f0a68fbc991f9340320acb488c04f0e4 | Ruby | tannyque/ruby-spending-tracker | /tests/models/transaction_test.rb | UTF-8 | 538 | 2.640625 | 3 | [] | no_license | require_relative '../test_helper'
require_relative '../../models/transaction'
require_relative '../../models/user'
require_relative '../../models/merchant'
class TransactionTest < MiniTest::Test
def setup
@user = User.new('name' => 'Robert')
@merchant1 = Merchant.new(
'name' => 'Costa Coffee'
)
... | true |
7156be08d6edfb53ae01855df7fefa346d5df65f | Ruby | wleborgne/homework_assignments | /objects/cash_register.rb | UTF-8 | 1,769 | 4.0625 | 4 | [] | no_license | #!/usr/bin/env ruby
# class CashRegister
# Implements a simple cash register
class CashRegister
# Initial total is zero
def initialize
@total = 0.0
end
# Return total as a formatted string
def total
format_money(@total)
end
# Add purchase amount to total
def purchase(purchase_amount)
@tota... | true |
0b213d288c62b7dea204959e1b0921e8464d245b | Ruby | charithperera/LaunchSchool | /Back End/Prep/back_end/intro_to_programming/type_conversion.rb | UTF-8 | 707 | 4.3125 | 4 | [] | no_license | #1
string_one = 'charith'
string_two = 'perera'
puts string_one + ' ' + string_two
puts
#2
big_number = 1294
thousands = big_number / 1000
hundreds = big_number % 1000 / 100
tens = big_number % 1000 % 100 / 10
ones = big_number % 1000 %100 % 10
puts big_number
puts hundreds
puts tens
puts ones
puts
#2
movies =... | true |
c65d06f7755b5ba8ccc0e5a14beeadd9bb58d620 | Ruby | kaileeagray/activerecord_reading | /lib/student.rb | UTF-8 | 442 | 2.65625 | 3 | [] | no_license | class Student < ActiveRecord::Base
end
Student.column_names
#=> [:id, :name]
Student.create(name: 'Jon')
# INSERT INTO students (name) VALUES ('Jon')
Student.find(1)
Student.find_by(name: 'Jon')
# SELECT * FROM artists WHERE (name = 'Jon') LIMIT 1
student = Student.find_by(name: 'Jon')
student.name
#=> 'Jon'
stu... | true |
8da8439938e45b0eaac6dc30c56369cb53a2b337 | Ruby | ayush-amura/Assignments | /Occurance_count.rb | UTF-8 | 572 | 3.984375 | 4 | [] | no_license | # Write a method which will solve the following use case.
# input - Array. ex: [1, 8, 215, 258 1, 0, 10, 2, 12, 14, 16, 54, 32, 18, 129, 172]
# output - Occurrence of '1' in the array is '2' times. (Print this line for every possible number in the array.)
def Occurrence_count(arr)
h1={}
arr.each do |element|
h1[... | true |
2f69d1cb1c110741b865dbc4190a8deda6b88cfc | Ruby | JoePeterson51/black_thursday | /spec/repo_brain_spec.rb | UTF-8 | 4,235 | 2.5625 | 3 | [] | no_license | require 'simplecov'
SimpleCov.start
require './lib/sales_engine'
require './lib/merchant_repository'
require './lib/item_repository'
require './lib/invoice_repository'
RSpec.describe RepoBrain do
describe '#find_by_id' do
it 'finds by id or returns nil' do
mock_sales_engine = instance_double('SalesEngine'... | true |
179e427048a3ce9e961096cde3cee4c24f042df3 | Ruby | trizen/sidef | /scripts/Graphical/sierpinski_pentagon.sf | UTF-8 | 971 | 2.875 | 3 | [
"Artistic-2.0"
] | permissive | #!/usr/bin/ruby
#
## http://rosettacode.org/wiki/Sierpinski_pentagon
#
# Generates a SVG image to STDOUT
define order = 5
define sides = 5
define dim = 500
define scaling_factor = ((3 - 5**0.5) / 2)
var orders = order.of {|i| ((1-scaling_factor) * dim) * scaling_factor**i }
say <<"STOP";
<?xml version="1.0" stand... | true |
072f553719bd60ff17cfd25736a5b0a7fc050080 | Ruby | jyotty/omnibus-flapjack | /create_directory_listings | UTF-8 | 3,899 | 2.75 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'erb'
# creates an index.html file in every directory below (and including) the current directory
# each index.html file contains a list of files and directories that are in its parent directory
def process_directory(path)
directories = []
files = []
sizes = {}
mtimes ... | true |
db1b53732039bfeb3dd5c98cf5627b8750f5367c | Ruby | Wanbli83470/Ruby | /tp2.rb | UTF-8 | 704 | 3.78125 | 4 | [] | no_license | class Utilisateur
attr_accessor :prenom, :amis
def initialize(prenom, sexe)
if sexe == "f"
puts "c'est une femme"
@prenom = "Madame " + prenom
else
@prenom = "Monsieur " + prenom
end
end
def numbers_amis
amis.size
end
def amis_avec(prenom)
puts "On va tester si amis avec " + prenom
ami... | true |
ff0228100dbce89a5fba1192ba5d6dc7d5785afe | Ruby | SvitlanaLana/loan_calculator | /spec/services/annuity_calculator_spec.rb | UTF-8 | 490 | 2.515625 | 3 | [] | no_license | require 'spec_helper'
describe 'AnnuityCalculator' do
describe '#total_contribution' do
it 'return odject class Float' do
ac = AnnuityCalculator.new(100, 2, 20)
total = ac.total_contribution
expect(total.class).to eq(Float)
end
end
describe '#get_table' do
it 'return not empty a... | true |
130780662ff15bbf36b2e85787a903e3d031ad34 | Ruby | peter-james-allen/sinatra | /lib/app.rb | UTF-8 | 373 | 2.71875 | 3 | [] | no_license | require "sinatra"
set :session_secret, 'super secret'
get '/' do
'Testing 2'
end
get '/random-cat' do
@name = ["Amigo", "Misty", "Almond"].sample
erb :index
end
get '/named-cat' do
@name = params[:name]
erb :index
end
get '/hello/:name' do
# matches "GET /hello/foo" and "GET /hello/bar"
# params['nam... | true |
f538f4ff9c47af6d7ad6b51e9160a666941beebf | Ruby | holyketzer/ctci_v6 | /ruby/spec/17_hard/24_max_submatrix.rb | UTF-8 | 2,948 | 3.109375 | 3 | [
"MIT"
] | permissive | module MaxSubmatrix
# Time=O(n^4) Mem=O(n^2) n - count of rows ~ count of cols
def solve_a(matrix)
cache = Hash.new { |hash, key| hash[key] = {} }
rows_count = matrix.size
cols_count = matrix[0].size
each_matrix_size(rows_count, cols_count) do |max_row, max_col|
sum = 0
(0..max_row).e... | true |
865526796bfff29b4bc46dbfbeba6a18bd107834 | Ruby | scottwillson/racing_on_rails | /app/models/competitions/rider_rankings.rb | UTF-8 | 512 | 2.609375 | 3 | [
"MIT",
"Ruby"
] | permissive | # frozen_string_literal: true
module Competitions
# WSBA rider rankings. Members get points for top-10 finishes in any event.
# No longer used. Class remains for archived results.
class RiderRankings < Competition
def friendly_name
"Rider Rankings"
end
def notes
if year.to_i > 2011
... | true |
5a560572b858cb2bcd4c8c7ca2aea349427d19e0 | Ruby | devinrieger/oo-my-pets-web-0217 | /lib/owner.rb | UTF-8 | 1,304 | 3.71875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Owner
attr_reader :species
attr_accessor :name, :pets
@@owners = []
def initialize(name)
@name = name
@pets = {fishes: [], cats: [], dogs: []}
@@owners << self
@species = "human"
end
def buy_fish(name)
fish = Fish.new(name)
fish.owner = self
self.pets[:fishes] << fish... | true |
83e457a0976ffffafc284617c5267fac72941221 | Ruby | andrix/tinyruby | /ejemplos/ejemplo011_if.rb | UTF-8 | 163 | 3.625 | 4 | [] | no_license | a = "hola"
if (a == "hola")
puts "a es hola"
end
b = "mundo"
if (b == "cruel")
puts "no es igual"
else
puts "el mundo es cruel"
puts "----"
end
| true |
5be49ee6cc86b176e6022f3affe9869b2c32b67f | Ruby | kruss/Feedback | /ruby/lib/feedback/result.rb | UTF-8 | 1,771 | 2.921875 | 3 | [
"BSD-2-Clause"
] | permissive |
class Result
@@Status = [ :UNDEFINED, :SUCCEED, :WARNING, :ERROR ]
def self.STATUS_UNDEFINED
return @@Status[0]
end
def self.STATUS_SUCCEED
return @@Status[1]
end
def self.STATUS_WARNING
return @@Status[2]
end
def self.STATUS_ERROR
return @@St... | true |
c93ecd6dbcfd03062353746391aab4fa303c5875 | Ruby | PaulineLabaisse/exo_ruby | /exo_07_b.rb | UTF-8 | 100 | 3.078125 | 3 | [] | no_license | puts"Bonjour, c'ets quoi ton blaze ?"
print">"
user_name = gets.chomp
puts "Enchanté belle gosse !" | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.