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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8c4952e469b121c71dac430f73083027f312ae93 | Ruby | BaobabAfter17/Sudoku | /board.rb | UTF-8 | 2,471 | 3.6875 | 4 | [] | no_license | require_relative 'tile.rb'
require 'colorize'
class Board
attr_reader :grid
VALUES = (1..9).to_a.map(&:to_s)
def self.from_file
start_arr = []
text_name = 'sudoku1.txt'
File.open(text_name, 'r').each_line do |line|
start_arr << line.chomp
end
Board.gri... | true |
fb9a67e94ab8cfd90a84251ad49629cbf7506015 | Ruby | jakef203/RB130-RubyFoundationsMoreTopics | /Exercises/Easy2/multiple_arguments.rb | UTF-8 | 456 | 3.640625 | 4 | [] | no_license | ## Example 1
def hello(v1, *v2)
p v1
p v2
end
arr = [1, 2, 3, 4]
hello(arr) # prints [1, 2, 3, 4], []
## Example 2
def hello(v1, *v2)
p v1
p v2
end
arr = [1, 2, 3, 4]
hello(*arr) # prints 1, [2, 3, 4]
## Example 3
def hello(v1, v2, v3, v4)
p v1 # prints 1
p v2 # prints 2
p v3 # prints 3
p v4 ... | true |
fcbfe63942a8f21142bc2603673b0fc8d5a7be4a | Ruby | totocorvidoni/knight-moves | /knight.rb | UTF-8 | 1,190 | 4 | 4 | [] | no_license | class KnightMovement
attr_accessor :position, :parent, :children
def initialize(position, parent = nil)
@position = position
@parent = parent
@children = []
end
def move
possible_moves = []
moves = [position, [2, 1]], [position, [2, -1]], [position, [-2, 1]], [position, [-2, -1]],... | true |
d3f21f29e93eabbccf5743074d55aacfca851d8a | Ruby | kurbmedia/tipsy | /lib/tipsy/helpers/asset_paths.rb | UTF-8 | 1,216 | 2.71875 | 3 | [] | no_license | require 'pathname'
module Tipsy
module Helpers
module AssetPaths
def asset_path(path)
return path if path.match(/^https?:/) || Pathname.new(path).absolute?
"/" << path_for_asset_type(path)
end
def path_with_ext(path, ext)
return path if path.match(/^https?:... | true |
c5d9febf89d848dc0a84dc3fb116bbb4a6489fc5 | Ruby | niyoko/keisan | /lib/keisan/functions/default_registry.rb | UTF-8 | 3,908 | 2.84375 | 3 | [
"MIT"
] | permissive | require_relative "let"
require_relative "puts"
require_relative "if"
require_relative "while"
require_relative "diff"
require_relative "replace"
require_relative "range"
require_relative "map"
require_relative "filter"
require_relative "reduce"
require_relative "to_h"
require_relative "rand"
require_relative "sample"
... | true |
41f5943aee908c7aba2ea67595e9e664460cb990 | Ruby | cider-load-test/rage | /lib/rage/aid.rb | UTF-8 | 2,267 | 2.9375 | 3 | [] | no_license | module RAGE
class AgentIdentifier
# The symbolic name of the agent (a string)
attr_reader :name
#
# Return an initialized agent identifier.
#
def initialize(params={})
@name = params[:name]
@addresses = params[:addresses] || []
@resolvers = params[:resolvers] || []
end... | true |
5a89c104b372b27c3f40646042514c86b05f0721 | Ruby | ckib16/drills | /z_past_practice/2017-09/2017-09-01.rb | UTF-8 | 643 | 4.1875 | 4 | [] | no_license | class Animal
attr_accessor :age, :weight
def initialize(age:, weight:)
@age = age
@weight = weight
end
def speak
"Hi, my age is #{@age} and my weight is #{@weight}"
end
end
module Barkable
def bark
"Bark"
end
end
class Dog < Animal
include Barkable
attr_accessor :color
def init... | true |
52c2486cb7bd356f0bc5931eb6f3277651ad8273 | Ruby | aphyr/salticid | /lib/salticid/interface/view.rb | UTF-8 | 975 | 2.5625 | 3 | [
"MIT"
] | permissive | class Salticid
class Interface
class View
include Resizeable
attr_accessor :window, :height, :width, :top, :left
def initialize(interface, params = {})
@interface = interface
@height = params[:height] || Curses.lines
@width = params[:width] || Curses.cols
@top =... | true |
e21a2bfb379fe14691bcd31a5342ccc94f0c4e2b | Ruby | elight/rbwikipedia-film | /lib/rbwikipedia-film/fetch.rb | UTF-8 | 377 | 2.703125 | 3 | [] | no_license | require 'net/http'
require 'uri'
# borrowed from Net::HTTP
def fetch(uri_str, limit = 10)
raise ArgumentError, 'HTTP redirect too deep' if limit == 0
response = Net::HTTP.get_response(URI.parse(uri_str))
case response
when Net::HTTPSuccess then response
when Net::HTTPRedirection then fetch(response['... | true |
beb339a4d0ac7b15970980b6d9fa223829ec84f9 | Ruby | DrCooksALot/reading-errors-and-debugging-how-tests-work-nyc01-seng-ft-051120 | /calculator.rb | UTF-8 | 210 | 2.671875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Add your variables here
first_number = 5
second_number = 4
sum = first_number+second_number
difference = first_number-second_number
product = first_number*second_number
quotient = first_number / second_number | true |
3cedf4cdc390ec5e2cef22204a4aaabf2c982b59 | Ruby | Patrick-Mondala/W6D3 | /Chess/knight_king.rb | UTF-8 | 118 | 2.578125 | 3 | [] | no_license | require_relative "piece"
class KnightKing < Piece
def initialize(symbol, board, pos)
super
end
end | true |
23013e1ad9f53e9690842562e1dad2723e7d989d | Ruby | conradbuys11/ruby-oo-object-relationships-has-many-through | /lib/waiter.rb | UTF-8 | 1,319 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Waiter
attr_accessor :name, :years
@@all = []
def initialize(name, years)
@name = name
@years = years
@@all << self
end
def self.all
@@all
end
def new_meal(customer, total, tip)
Meal.new(self, customer, total, tip)
end
def meals
... | true |
7c5f381a53dd7d4f4f98910201bb842ab45704de | Ruby | StevenGerdes/ECE421-project-1 | /matrix_factory_contract.rb | UTF-8 | 1,025 | 2.546875 | 3 | [] | no_license | gem 'test-unit'
require 'test/unit'
require './matrix'
require './sparse_matrix'
require './sparse_matrix_factory'
class MatrixFactoryContract < Test::Unit::TestCase
def test_is_valid_sparse
input_matrix = Matrix.I(5)
#Invarient
old_matrix = input_matrix.clone
#Pre-conditions
assert_kind_of(Ma... | true |
b685ec4d73e60a4e58c918af4452638797b9eb5d | Ruby | JakePEGG/Pairing-Exercises | /scrabble.rb | UTF-8 | 604 | 3.40625 | 3 | [] | no_license | $scoring = {
0 => [''],
1 => ['E', 'A', 'I', 'O', 'N', 'R', 'T', 'L', 'S', 'U'],
2 => ['D', 'G'],
3 => ['B', 'C', 'M', 'P'],
4 => ['F', 'H', 'V', 'W', 'Y'],
5 => ['K'],
8 => ['J', 'X'],
10 => ['Q', 'Z']
}
class Scrabble
def initialize(word)
@word = word
end
def score
total = 0
... | true |
9cae132a4cbb42fe9f82bced828ccb7776b4b2f4 | Ruby | dbtee/amazon_rails | /app/models/product.rb | UTF-8 | 531 | 2.609375 | 3 | [] | no_license | class Product < ApplicationRecord
belongs_to :user
validates :title, presence: true, uniqueness: true
validates :price,
numericality:
{ greater_than: 0 }
validates :description, presence: true, length: { minimum: 10 }
has_many :reviews, dependent: :destroy
before_valida... | true |
629c7300f01d0abd775febd3adb97feddeb584d6 | Ruby | saloni1911/warm-up-exercises | /27.6.17 - dice game /dice.rb | UTF-8 | 2,535 | 4.0625 | 4 | [] | no_license | # https://gist.github.com/kasun-maldeni/9f54de1a1dee4515c32ba335fb31e721/
# Dice
# Write a program using classes to generate a standard dice roll.
# Dice.roll
# # => 6
# It should give you a different result each time.
# Dice.roll
# # => 5
# Dice.roll
# # => 2
# When you pass in a number, it rolls the dice that man... | true |
a690f3578cdc78e393d4a60964a4b0ba3bcaebfe | Ruby | Beertaster/yield-and-return-values-online-web-ft-100719 | /lib/practicing_returns.rb | UTF-8 | 191 | 3.796875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def hello(array)
i = 0
arr = []
while i < array.length
arr << yield(array[i])
i += 1
end
arr
end
hello(["Tim", "Tom", "Jim"]) { |name| puts "Hi, #{name}" }
| true |
5bfa347adadae2dd4c7604ddf6b47ef45f6489e6 | Ruby | blsrofe/module_3_assessment | /app/services/store.rb | UTF-8 | 440 | 2.953125 | 3 | [] | no_license | class Store
attr_reader :long_name, :store_type, :distance, :phone_number, :city
def initialize(attrs = {})
@long_name = attrs[:longName]
@store_type = attrs[:storeType]
@distance = attrs[:distance]
@phone_number = attrs[:phone]
@city = attrs[:city]
end
def self.find_by_zip(zip)
raw_st... | true |
03fa87fd85d672b2452a9533e77ab5a5f047360d | Ruby | rubybench/rubybench | /bin/dashboard.rb | UTF-8 | 1,329 | 2.515625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'yaml'
rubies = YAML.load_file(File.expand_path('../rubies.yml', __dir__))
benchmarks = YAML.load_file(File.expand_path('../benchmark/yjit-bench/benchmarks.yml', __dir__), symbolize_names: true)
ruby = rubies.keys.max
dashboard = {
date: rubies[ruby].match(/ruby [^ ]+ \(([^)T ]+)/)[1],
... | true |
cf977959f216e52714cbcadffcc12c2f782caffa | Ruby | leadot/ClassExercises | /CollectionMethods.rb | UTF-8 | 4,853 | 4.125 | 4 | [] | no_license | class Home
attr_accessor :name, :city, :capacity, :price
def initialize(name, city, capacity, price)
@name = name
@city = city
@capacity = capacity
@price = price
end
end
class Inventory
attr_accessor :homes
def initialize
@homes=[]
end
def add_home(home)
@homes << home
def arra... | true |
886430b2f6210f6c4db3c47207e53e6f43a6db88 | Ruby | ikroni/ruby------------- | /kurs_mod_lesya/classes/queue.rb | UTF-8 | 203 | 3.125 | 3 | [] | no_license | class Queue
def initialize
@store = []
end
def empty?
@store.empty?
end
def enq(a)
@store << a
end
def deq
@store.shift
end
def length
@store.length
end
end | true |
4434183ff39f8e0ec412e6c72b6ce93bf9cfc95a | Ruby | jviveiros/phase-0-tracks | /ruby/media_archiver/media_archiver.rb | UTF-8 | 1,915 | 3.296875 | 3 | [] | no_license | #require gems
require 'SQLite3'
#Create Table for my media archiver
db = SQLite3::Database.new('media_archive.db')
create_table_cmd = <<-sql
CREATE TABLE IF NOT EXISTS media (
id INTEGER PRIMARY Key,
mediatype VARCHAR (255),
title VARCHAR (255),
renLease VARCHAR (255),
mediaconsumed VARCHAR... | true |
29a63c200d1714c7129a3811c8b4c3ae3e0bb7de | Ruby | JoeNicewonger/gitimmersion | /lib/hello.rb | UTF-8 | 123 | 3.171875 | 3 | [] | no_license | # Default is "World"
#Author: Joseph Nicewonger (joenicewonger@gmail.com)
name = ARGV.first || "World"
greeter = Greeter.new(name)
puts greeter.greet | true |
cefb6bcf3ceb6d374cae2e870b45063dcad091d5 | Ruby | takagotch/ruby | /perfect_auth/sample_files/part3/10/list10.13.rb | UTF-8 | 357 | 2.5625 | 3 | [] | no_license | # coding: utf-8
class HasConstans
CONST_VARIABLE = 1
end
HasConstans.const_get :CONST_VARIABLE
#=> 1
HasConstans.const_get :UNDEFINE_CONST_VARIABLE
#=> `const_get': uninitialized constant HasConstans::UNDEFINE_CONST_VARIABLE (NameError)
HasConstans.const_get :not_const_variable
#=> `const_get': wrong constant... | true |
322cf47789f8fddaf1195806122cc871dd3d8282 | Ruby | gbenavid/phase-0-tracks | /ruby/hashes.rb | UTF-8 | 1,838 | 3.3125 | 3 | [] | no_license | puts "Welcome to the Client2Hash Mixer 2000™! \nAnswer the following questions about your client and a data structure will be created for them."
client = {
}
puts "What id your clients name?"
client[:name]= gets.chomp
puts "How old is this client?"
client[:age]= gets.chomp.to_i
puts "How many children does your client ... | true |
a29dfe9caa4ee591324b34bc33a6bacf5dca73af | Ruby | townie/L2PDanPickettWork | /learningYAML.rb | UTF-8 | 439 | 3.171875 | 3 | [] | no_license | require 'yaml' #woot require
M = 'land'
o = 'water'
test_array = true
# Here's half of the magic:
test_string = test_array.to_yaml
#you see? YAML description of test_array
filename = 'RimmerTShirts.txt'
File.open filename, 'w' do |f|
f.write test_string
end
read_string = File.read filename
#And the other half ... | true |
4bb7ef1c235be6d94e9aa19873c9a9deffdd4e21 | Ruby | jamesonwatts/natural | /lib/assn1.rb | UTF-8 | 3,872 | 3.4375 | 3 | [] | no_license | require 'rubygems'
#function
def get_words(corpus)
tagged_words = corpus.split(" ")
words = []
for tword in tagged_words
words << tword.split("/")
end
return words
end
#create n-grams
def ngrams(words)
#unigrams
word_uni_grams = Hash.new(0)
pos_uni_grams = Hash.new(0)
word_bi_grams = Hash.new(0)... | true |
0666242b4c47101f4840a2aabde128ba3d43387b | Ruby | bulletgani/afterburner | /lib/afterburner/analytics.rb | UTF-8 | 4,941 | 2.546875 | 3 | [
"MIT"
] | permissive | # design and implementation of analytics by Blake Miller
require 'resque'
module Analytics
MAX_ANALYTICS_DATA_FIELDS = 12
def self.included(base)
base.send(:cattr_accessor, :analytics)
base.instance_eval do
self.analytics = AnalyticsHelper.new(self)
end
end
class AnalyticsHelper
attr_... | true |
df92d18ff904824e0003dd30a1c133efde02d55d | Ruby | huayumeng/intime.ims | /app/models/version.rb | UTF-8 | 396 | 2.515625 | 3 | [] | no_license | # encoding: utf-8
class Version < ActiveRecord::Base
attr_accessible :desc, :downloadurl, :no, :status,:versionno,:updatetype
class << self
def version_fromstring(version)
return 0 if version.nil?
version_int = 0
version.split('.'). each_with_index do |v,i|
break if i > 2
versio... | true |
fb019d6b5627863e576dfd1fce6e8c495da472bc | Ruby | Immers23/Boris-Bikes | /lib/docking_station.rb | UTF-8 | 664 | 3.296875 | 3 | [] | no_license | require_relative 'bike'
class DockingStation
DEFAULT_CAPACITY = 20
attr_reader :capacity, :bikes
def initialize(capacity=DEFAULT_CAPACITY)
@bikes = []
@capacity = capacity
end
def release_bike
fail "No bikes available" if empty?
@bikes.each_with_index do |bike, index|
if bike.working... | true |
a3e8d67394906490ee8c2bcfc49ecdb394261dc4 | Ruby | mattapayne/Report-It2 | /app/models/search_results/base_search_results.rb | UTF-8 | 394 | 2.671875 | 3 | [] | no_license | module SearchResults::BaseSearchResults
attr_accessor :items, :total_pages, :current_page, :per_page
def has_next?
@current_page < @total_pages
end
def has_previous?
@current_page > 1
end
protected
def setup(items)
@items = items
@total_pages = @items.total_pages
@curren... | true |
92f76388ce8484f8125ae737744dcc98fa4276a0 | Ruby | rhomobile/rhodes | /spec/framework_spec/app/spec/core/regexp/union_spec.rb | UTF-8 | 1,392 | 2.546875 | 3 | [
"MIT"
] | permissive | require File.expand_path('../../../spec_helper', __FILE__)
describe "Regexp.union" do
it "returns /(?!)/ when passed no arguments" do
Regexp.union.should == /(?!)/
end
it "returns a regular expression that will match passed arguments" do
Regexp.union("penzance").should == /penzance/
Regexp.union("sk... | true |
80ba42b3f426a5651c488ec2fcdd62e2a43b459f | Ruby | 6ex06en/game | /app/stone_scissors/stone_scissors.rb | UTF-8 | 823 | 2.765625 | 3 | [] | no_license | require_relative "stone_scissors/connection"
require_relative "stone_scissors/core"
require_relative "stone_scissors/player"
module StoneScissors
class << self
def games
@games ||= []
end
def new_game(connection1, connection2, timer = 10, max_score = 3)
p1 = Player.new connection1
... | true |
aa08382eeb91a10415c0b01c07b7ac4f6918f994 | Ruby | SesameSeeds/betsy | /app/models/category.rb | UTF-8 | 344 | 2.5625 | 3 | [] | no_license | class Category < ApplicationRecord
has_and_belongs_to_many :products
validates :name, presence: true, uniqueness: { case_sensitive: false }
before_save do |category|
category.name = category.name.downcase
end
def self.existing_cat?(string)
Category.find_by(name: string.downcase) ? (return true) : (r... | true |
f6726effb00bf20d27ed441c6a90010039736ca3 | Ruby | AshleyRapone/Intro_to_Programming_Ruby | /Hashes/Example5.rb | UTF-8 | 221 | 4.28125 | 4 | [] | no_license | #What method could you use to find out if a Hash contains a specific value in it? Write a program to demonstrate this use.
numbers = {one: 1,
two: 2, three: 3}
if numbers.has_value?(3)
puts "Yes"
else
puts "No"
end
| true |
c82eb3826d5557e99ccdf1351ac9c396590fbef3 | Ruby | YuLinChen83/works | /rubyCalculate.rb | UTF-8 | 13,282 | 3.625 | 4 | [] | no_license | #要進位/借位
def degit(level,op)
num1=Array.new
num2=Array.new
if level==1
n=rand(2)+1
elsif level ==2
n=rand(2)+3
else
n=rand(2)+5
end
if op==1
k=0
while k!=n
num1[k]=rand(9)+1
num2[k]=rand(9)+1
if (num1[k]+num2[k])>10
k=k+1
end
end
n1=0
n2=0... | true |
66a96e2c20b495189984898c1bab3a901ee33a40 | Ruby | kwi/BrB | /spec/brb/brb_logger_spec.rb | UTF-8 | 664 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
class CustomLogger
attr_accessor :level, :history
def initialize
@history = []
end
def info(msg)
@history << msg
end
alias :error :info
alias :warn :info
alias :debug :info
end
describe :brb_logger do
before(:each) do
@original_logger = BrB.logger
end
after(:... | true |
d63c145d22f31183562ddd7337f3a09138031559 | Ruby | andyzen619/ar-exercises | /exercises/exercise_7.rb | UTF-8 | 471 | 2.828125 | 3 | [] | no_license | require_relative '../setup'
require_relative './exercise_1'
require_relative './exercise_2'
require_relative './exercise_3'
require_relative './exercise_4'
require_relative './exercise_5'
require_relative './exercise_6'
puts "Exercise 7"
puts "----------"
# Your code goes here ...
@store1.employees.create(first_name... | true |
cc88cd495662e38793df0b8013df1e72f6948a5a | Ruby | robisacommonusername/SVGBuilder | /lib/SVGElements/Ellipse.rb | UTF-8 | 345 | 2.765625 | 3 | [
"MIT"
] | permissive | require_relative '../Base/AbstractShape'
class SVG < SVGAbstract::SVGContainer
class Ellipse < SVGAbstract::AbstractShape
def initialize(rx, ry, cx=0, cy=0)
super()
@name = 'ellipse'
@attributes.merge!({
:rx => rx,
:ry => ry,
:cx => cx,
:cy => cy
})
yield self if block_given?
re... | true |
93c2a75c2d103d5418e97f7c062622252ebca5df | Ruby | lucasefe/opi | /lib/opi/credit_card_parser.rb | UTF-8 | 2,432 | 2.9375 | 3 | [
"MIT"
] | permissive | module Opi
class CreditCardParser
def initialize(text)
@text = text
end
def process
records = []
year = @text.match(/VENCIMIENTO(.*)CIERRE(.*)/)[2].split(' ').last
cards = parse_cards(@text)
cards.each do |card, lines|
records += process_lines(card, lines, year)
... | true |
bfa337345c940541a754ce92ccc60d07ed35f462 | Ruby | thunderenlight/DBC_phase1 | /thursday.rb | UTF-8 | 870 | 3.78125 | 4 | [
"MIT"
] | permissive | class BoggleBoard
def initialize
# letters = ('A'..'Z').to_a.shuffle.first(4 * 4).sort
# @board = Array.new(4) { letters.sample(4) }
@board = Array.new(4) { "_" * 4}
end
def erase
@board.clear
end
def shake!
erase
letters = ('A'..'Z').to_a.shuffle.first(4 * 4).sort
@board.each... | true |
abf8ca6c2a32d93dc098d3aeeca9f4f93e746b4f | Ruby | oklasoft/ngs_scripts | /fastq_to_gvcf.rb | UTF-8 | 31,937 | 2.640625 | 3 | [
"BSD-2-Clause",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env ruby
#
# analyze_sequence_to_snps.rb
# Created by Stuart Glenn on 2010-12-22
#
# == Synopsis
# Quick script to build the "analyze.sh" script used to run through the
# pipeline of steps for analysis going from fastq to vcf
#
# == Inputs
# The actual input to this script is just an job config file, which i... | true |
0441e26c4676750e81d8d6b8a3e2b28fec989120 | Ruby | jarombra/codecademy_Ruby | /lessonSeries/13_RB_theZenOfRuby/05_whenAndThenTheCaseStatement.rb | UTF-8 | 421 | 3.953125 | 4 | [] | no_license | puts "What's your spoken language?"
puts "('English', 'French', 'German', 'Finnish', 'Japanese')"
greeting = gets.chomp
# Add your case statement below!
case greeting
when "English" then puts "Hello!"
when "French" then puts "Bonjour!"
when "German" then puts "Guten Tag!"
when "Finnish" then puts "Halo... | true |
33bcc864429d5e13b03e8d7b8519f6540e43b45b | Ruby | ayamau/intro_to_ruby- | /arrays/check_array.rb | UTF-8 | 63 | 2.765625 | 3 | [] | no_license | # check_array.rb
arr = [1, 3, 5, 7, 9, 11]
arr.include?(3)
| true |
aa74d1d863d0976d31955c525abb4a0635d934a0 | Ruby | Jeff-Adler/ruby-oo-relationships-practice-art-gallery-exercise-nyc01-seng-ft-062220 | /app/models/painting.rb | UTF-8 | 342 | 3.375 | 3 | [] | no_license | class Painting
attr_reader :title, :price
@@all = []
def initialize(title, price)
@title = title
@price = price
self.class.all << self
end
def self.all
@@all
end
end
# Painting.all
# Returns an array of all the paintings
# Painting.total_price
# Returns an integer that is the total p... | true |
76dac54ce100def216724279b155b9b62079bfc6 | Ruby | jojo080889/Atelier | /app/models/folder.rb | UTF-8 | 1,468 | 2.671875 | 3 | [] | no_license | require 'format'
class Folder < ActiveRecord::Base
belongs_to :user
has_many :projects
has_many :critiques, through: :projects
attr_accessible :name, :description, :user_id
validates_presence_of :name
validates_presence_of :description
def self.get_order_clause(order_by)
case order_by
when "alp... | true |
a641fced2bd8e1cb7f71a9a484dd0dcdf5d8f54f | Ruby | AaronLasseigne/polyfill | /lib/polyfill/v2_4/integer.rb | UTF-8 | 1,588 | 2.921875 | 3 | [
"MIT"
] | permissive | module Polyfill
module V2_4
module Integer
def ceil(ndigits = 0)
ndigits = InternalUtils.to_int(ndigits)
return super() if ndigits == 0
return to_f if ndigits > 0
place = 10**-ndigits
(to_f / place).ceil * place
end
def digits(base = 10)
base = I... | true |
a623924a3160b24ec40a4f61d83b50d33dd7a26a | Ruby | blaines/tasque | /lib/tasque/configuration.rb | UTF-8 | 1,744 | 2.625 | 3 | [
"MIT"
] | permissive | require 'yaml'
require 'singleton'
require 'logger'
# tasque:
# threads: 3
# stomp:
# subscription: /queue/example
# connection:
# hosts:
# - login: admin
# passcode: admin
# host: localhost
# port: 61613
# reliable: true
# max_reconnect_attempts: 0
# initial_reconnect_delay:... | true |
32a9aedf4b10bb0abf7c4c66b44d4d9099d30a0a | Ruby | nbogie/production_log_analyzer | /lib/report/report_differ.rb | UTF-8 | 6,456 | 2.78125 | 3 | [
"BSD-2-Clause"
] | permissive | require 'report/report_parser.rb'
module AnsiHelp
def ansi(code, text)
"\033[#{code}m#{text}\033[0m"
end
def noattrs(text); ansi(0,text); end
def bold(text); ansi(1,text); end
def red(text); ansi(31,text); end
def green(text); ansi(32,text); end
def yellow(text... | true |
43ac814b0f5d1d9da7c496eb993f47cf518f4556 | Ruby | acornellier/adventofcode | /2017/19.rb | UTF-8 | 490 | 2.8125 | 3 | [] | no_license | require_relative 'util'
lines = $stdin.read.chomp.split("\n")
grid = Util.new(lines, 0, lines[0].index('|'), DOWN)
path = []
steps = 0
loop do
steps += 1
grid.move
# grid.draw
case grid.cur
when '+'
if grid.dir == UP || grid.dir == DOWN
grid.dir = grid.neighbor(LEFT).match?(/\w|-/) ? LEFT : RIG... | true |
5e897e911cfe0e4489c08bf72eb465d6fdc763ef | Ruby | anneKay/sales-receipt-generator | /lib/task_builder.rb | UTF-8 | 913 | 3.046875 | 3 | [] | no_license | class TaskBuilder
def initialize(filename)
@filename = filename
end
def print_receipt
if transformed_input.nil?
puts "please check that your file name is correct and it's in the input folder"
elsif transformed_input.empty?
puts "please check that you have added valid inputs in your test f... | true |
1375a26fb8c60c951077ce1e3fa8e9e27d6e6f81 | Ruby | AJavier55/new_project | /app/models/restaurant.rb | UTF-8 | 655 | 2.609375 | 3 | [] | no_license | require "bcrypt"
class Restaurant < ApplicationRecord
has_many :reviews
has_many :wholesalers, through: :reviews
has_secure_password
validates :name, :location, uniqueness: true
validates :name, :cuisine, :owner, :location, presence: true
# validates :name, inclusion: {in: Restaurant.all}
# def fave_... | true |
f873dd560a3d68a53fa5b248c24ed2b2e8979367 | Ruby | wdcunha/Nov-2017-Cohort | /ruby/day8_oop/assignments/cat_bird.rb | UTF-8 | 889 | 4.21875 | 4 | [] | no_license | # Model the following in Ruby Classes & Objects: The cat catches the bird and eats it
#
# Stretch 1: Use inheritance
#
# Stretch 2: Give the cat and the bird names.
#
# Stretch 3: Make the chances of the cat catching the bird 50%.
#
# Stretch 4: Simulate having 100 cats trying to catch and eat 100 birds.
#
# Stretch 5:... | true |
345539e7d0cf8ee075afc3a675533db256b3070a | Ruby | jamesncox/rack-intro-online-web-pt-031119 | /application.rb | UTF-8 | 200 | 2.546875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Application
def call(env)
resp = Rack::Response.new
resp.write "Hello, my name is James! I have just built my very own website from scratch! BOOYAH BABY!"
resp.finish
end
end
| true |
0a7fe2e56eb49ecb329fa410ee2aeb454eda46d9 | Ruby | csemrm/git-runner | /lib/git-runner/text.rb | UTF-8 | 1,347 | 2.828125 | 3 | [
"MIT"
] | permissive | module GitRunner
module Text
extend self
COLOR_START = "\033["
COLOR_END = "m"
COLOR_RESET = "#{COLOR_START}0#{COLOR_END}"
COLORS = {
:black => 30,
:red => 31,
:green => 32,
:yellow => 33,
:blue => 34,
:purple => 35,
:cyan => 36,
:white ... | true |
53b3aa99062680914d3848bb9a5f115371b99c65 | Ruby | royriley/intro-to-prog | /arrays/exercise_seven/solution.rb | UTF-8 | 133 | 3.625 | 4 | [] | no_license | arr = [3, 5, 7, 9, 12]
new_arr = []
arr.each do |n|
new_arr << n + 2
end
p arr
p new_arr
# [3, 5, 7, 9, 12]
# [5, 7, 9, 11, 14] | true |
d251cfd5389e39d6a922703bf21afd2f4da31fed | Ruby | jimlindstrom/InteractiveMidiImproviser | /music/specs/pitch_class_spec.rb | UTF-8 | 1,357 | 2.96875 | 3 | [] | no_license | # beat_position_spec.rb
require 'spec_helper'
describe Music::PitchClass do
before(:each) do
end
context "initialize" do
it "should take a value in 0..11 and return a new PitchClass" do
Music::PitchClass.new(0).should be_an_instance_of Music::PitchClass
end
it "should raise an error for pitc... | true |
22fb01db8df84d118e0f00fb04558e2a2ae9acfc | Ruby | sfu-rcg/jenkers | /lib/puppet/parser/functions/transform_plugins_list.rb | UTF-8 | 1,197 | 2.53125 | 3 | [] | no_license | module Puppet::Parser::Functions
newfunction(:transform_plugins_list, :type => :rvalue, :doc => <<-EOS
Returns an Array of curl commands that will install Jenkins plugins. Accepts a base URL and Hash.
EOS
) do |args|
if args.size != 3
e = "transform_plugins_list(): Wrong number of args: #{args.size} ... | true |
f4c5f1c3b4d85b6dff055a9964279bede7fc2ebc | Ruby | christopheralcock/rps-challenge | /lib/war_web.rb | UTF-8 | 2,049 | 2.65625 | 3 | [] | no_license | require 'sinatra/base'
require_relative 'war.rb'
class WarWeb < Sinatra::Base
set :views, Proc.new { File.join(root, "..", "views") }
enable :sessions
get '/' do
session[:name] ? @visitor = session[:name] : @visitor = nil
$player_count = 0
erb :homepage
end
get '/weapon' do
$player_count +=... | true |
8a667a6a9f18cb2a9976be926ef1a1d0e4bd696e | Ruby | rails/rails | /activesupport/test/log_subscriber_test.rb | UTF-8 | 4,958 | 2.59375 | 3 | [
"MIT",
"Ruby"
] | permissive | # frozen_string_literal: true
require_relative "abstract_unit"
require "active_support/log_subscriber/test_helper"
class MyLogSubscriber < ActiveSupport::LogSubscriber
attr_reader :event
def some_event(event)
@event = event
info event.name
end
def foo(event)
debug "debug"
info { "info" }
... | true |
a2a141f5fbadc7c2b39dcebc079987e40ca2d6e8 | Ruby | mmanousos/ruby-small-problems | /intro_to_programming/loops_iterators/three.rb | UTF-8 | 267 | 4.3125 | 4 | [] | no_license | # Use the each_with_index method to iterate through an array of your creation that prints each index and value of the array.
my_array = [5, 17, "house", true, "what have you", 42, 'wherefore']
my_array.each_with_index { |el, index|
puts "index #{index}: #{el}"
}
| true |
8c8300b41e3edba5d069ff66147cc1df0851a99a | Ruby | ChitaChita/ito_ruby | /lib/array_exam.rb | UTF-8 | 3,817 | 4.15625 | 4 | [] | no_license | # 配列 位置(添え字) 長さ 2 3 4
a = [1, 2, 3, 4, 5]
p a[1,3]
# 添え字の複数指定 1 3 5
p a.values_at(0, 2, 4)
# [配列の長さ-1]で最後の要素を取得する 5
p a[a.size - 1]
# 最後の要素を取得する 5
p a[-1]
# 最後から2番目の要素を取得する 4
p a[-2]
# 最後から2番目の要素から2つの要素を取得する 4 5
p a[-2, 2]
# lastメソッド 5 4 5
p a.last
p a.last(2)
# firstメソッド 1 1 2
p a.first
p a.first(2)
# 要素の置き換え... | true |
5e99f60696a09d62ef27630a5ffb25bc7f38909f | Ruby | smalls108/shred | /db/seeds.rb | UTF-8 | 15,487 | 2.875 | 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:
require "open-uri"
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the ... | true |
0a848433551fa8488ec46cc27f1cc1838b99cea8 | Ruby | melody97/ict_login | /login.rb | UTF-8 | 668 | 2.765625 | 3 | [] | no_license | # Author: aetheryang
# Contact: aetheryang@gmail.com
require 'net/http'
require 'io/console'
puts 'Please input the username'
uname = gets.chomp
puts 'please input the password'
pass = STDIN.noecho(&:gets).chomp
uri = URI('http://159.226.39.22/cgi-bin/do_login')
res = Net::HTTP.post_form(uri, 'uname' => uname, 'pas... | true |
86e3f9651bdd25d88274631c1432a16840104e89 | Ruby | mizuK46/contest_163 | /coffee.rb | UTF-8 | 85 | 3.078125 | 3 | [] | no_license | str = gets
if str[2] == str[3] && str[4] == str[5]
puts "Yes"
else
puts "No"
end
| true |
3867bc9e678307aba1c395651f4b4372db2c427a | Ruby | whoojemaflip/aoc | /2016/02/keypad_spec.rb | UTF-8 | 1,794 | 3.15625 | 3 | [] | no_license | require_relative 'keypad'
describe Keypad do
let(:subject) { Keypad.new }
let(:result) { subject.num }
context "test 1" do
let(:data) { "ULL\nRRDDD\nLURDL\nUUUUD" }
let(:result) { subject.door_code(data) }
it "should be right" do
expect(result.join).to eql '1985'
end
end
describe "va... | true |
46ee400aa6196a9ea85682a2f979c28a970e58b8 | Ruby | SuperSus/some_tasks | /lib/components/table_component.rb | UTF-8 | 1,108 | 2.90625 | 3 | [] | no_license | # frozen_string_literal: true
require_relative('row_component')
# sorry sorry for magic numbers and other things here and there :)
class TableComponent
DEFAULT_STYLES = {
padding: 3
}.freeze
attr_reader :table
def initialize(table)
@table = table
end
def render
buffer = []
buffer << bo... | true |
f7ef35b62deef1e2a06dd09aeb78f0ff30cea0a3 | Ruby | SasukeBo/wangbo-study | /ruby/programingRuby/Chapter2/reading_and_riting.rb | UTF-8 | 867 | 3.828125 | 4 | [] | no_license | printf("Number: %5.2f,\nString: %s\n", 1.23, "hello") #Prints its arguements under the control of a format string (just like printf in C )
line = gets #gets method can receive the next line from your program's standard input stream.
printf line
#the gets method has a side effect :as well as returning the line just re... | true |
91f0e882fdc6b0e278147044008494a848a75eca | Ruby | roselynemakena/selenium | /navigation.rb | UTF-8 | 763 | 2.515625 | 3 | [] | no_license | require 'selenium-webdriver'
require 'test-unit'
class CookiesTest < Test::Unit::TestCase
def setup
@my_driver = Selenium::WebDriver.for :firefox
@url = "https://www.google.com/"
end
def test_navigate
#creating cookies
@my_driver.get(@url)
search_box = @my_driver.find_element(:name, "q")
search... | true |
ddb19b67e6098ba4b0d5535434aa8a75fd677401 | Ruby | allychitwood/webapps-project-scrapper | /web_scraper.rb | UTF-8 | 3,499 | 3.1875 | 3 | [] | no_license | require_relative 'input_grabber'
require 'mechanize'
# Method to find the jobs after the search form was submitted
# Author: Carter Brown
# @params
# agent: Mechanize instance
# page: Mechanize::Page
# @return number of jobs in search
def find_jobs(agent, page)
search_count = 0
loop do
# Strip html tags
... | true |
c7e22ef77450848078af93ce70fc72a7fc90ce7c | Ruby | ShabelnikM/tests | /SimpleTasks/6.rb | UTF-8 | 198 | 3.703125 | 4 | [] | no_license | # Дан целочисленный массив. Найти все нечетные элементы.
array = [ 1, 2, 3, 4, 5 ]
odd = array.select { |x| x.odd? }
p "Odd elements of array: #{odd}" | true |
c48a992379704e734f5b9588db84b0e71eb121b4 | Ruby | bragboy/Euler-using-Ruby | /src/problem_055.rb | UTF-8 | 237 | 3.609375 | 4 | [] | no_license | def is_lynchrel(n)
50.times do
n += n.to_s.reverse.to_i
return false if n.to_s == n.to_s.reverse
end
true
end
count = 0
1.upto(9999) do |n|
count +=1 if is_lynchrel(n)
end
puts "Lynchrel numbers below 10000 is #{count}"
| true |
1e46df28529adfbb2de515a22d6bd563804eaa54 | Ruby | meh/colorb | /examples/colortest.rb | UTF-8 | 81 | 2.875 | 3 | [] | no_license | #! /usr/bin/env ruby
require 'colorb'
0.upto(255) {|n|
puts "#{n}".color(n)
}
| true |
028e530884b2a8bfcb3a8d1cb50c5ec6c7bc7e74 | Ruby | adityatechracers/project | /config/initializers/ri_cal_patch.rb | UTF-8 | 412 | 2.515625 | 3 | [] | no_license | # There is a bug in the ri_cal gem that causes x properties to have an extra
# colon, which leads to calendar names starting with a colon.
#
# Found this fix in the pull request thread
class RiCal::Component::Calendar
def export_x_properties_to(export_stream) #:nodoc:
x_properties.each do |name, props|
prop... | true |
bce57bcfcb2fdf607398a03ab325e8af1db04005 | Ruby | KingCCJ/Mastermind | /lib/feedback.rb | UTF-8 | 677 | 3.03125 | 3 | [] | no_license | class Feedback
def incorrect_input(player_guess, magic_number, messages)
if player_guess.length > magic_number
messages.feedback_too_many
elsif player_guess.length < magic_number
messages.feedback_not_enough
end
end
def pin_check(player_guess, secret_code)
white_pins = 0
red_pins ... | true |
0048c810c93f7f911411115aae7ed83a26f51861 | Ruby | kbs5280/http | /test/server_test.rb | UTF-8 | 1,262 | 2.625 | 3 | [] | no_license | require './test/test_helper.rb'
require './lib/server.rb'
require 'faraday'
class ServerTest < Minitest::Test
def test_it_returns_a_success_response
skip
response = Faraday.get("http://127.0.0.1:9292/")
assert response.success?
end
def test_it_gets_path_response
skip
response = Faraday.get("h... | true |
9240dbe84291565e13e16114fffca5783f1f9bcf | Ruby | marceltoben/evandrix.github.com | /xcode-ios/Sparrow/sparrow/util/hiero2sparrow/hiero2sparrow.rb | UTF-8 | 2,233 | 2.890625 | 3 | [
"BSD-2-Clause"
] | permissive | #!/usr/bin/env ruby
#
# hiero2sparrow.rb
# Sparrow
#
# Created by Daniel Sperl on 11.02.2010
# Copyright 2010 Incognitek. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the Simplified BSD License.
#
# This script converts Bitmap Font files ... | true |
5d6ed3b449b0886f99af2c8215d903742ce1d46e | Ruby | kkrmno/imgrb | /lib/imgrb/headers/minimal_header.rb | UTF-8 | 1,101 | 2.921875 | 3 | [
"MIT",
"CC0-1.0"
] | permissive | module Imgrb::Headers
##
#A minimal header. Provides basic functionality.
#Other headers subclass this one.
class MinimalHeader
attr_reader :width, :height, :bit_depth, :compression_method, :image_type
def initialize(width = 1, height = 1, bit_depth = -1,
compression_method = -1, imag... | true |
6839a371c0eb2bc1e93317078078b3c0bba8d523 | Ruby | dpholbrook/ruby_small_problems | /more_topics/advanced_1/2.rb | UTF-8 | 2,259 | 4.53125 | 5 | [] | no_license | # Group 1
# my_proc = proc { |thing| puts "This is a #{thing}." }
# puts my_proc
# puts my_proc.class
# my_proc.call
# my_proc.call('cat')
# A proc can be created with proc { |param| code } syntax in addition to Proc.new { |param| code }
# Procs seem to have leniant arity. Even if the proc has a parameter, we don't ha... | true |
66a74660ffbf4d1ac064428306ba55628d58dd92 | Ruby | gormanjp/oo-counting-sentences-v-000 | /lib/count_sentences.rb | UTF-8 | 359 | 3.59375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class String
def sentence?
self.end_with?('.') ? true:false
end
def question?
self.end_with?('?') ? true:false
end
def exclamation?
self.end_with?('!') ? true:false
end
def count_sentences
count = 0
self.split(/[.!?]/).each do |string|
if string.length > 2
count... | true |
348f58eb66a22fa11dae11a270de9220ac5c7cf9 | Ruby | sbnair/td_ameritrade_institution | /lib/td_ameritrade_institution/requester.rb | UTF-8 | 836 | 2.609375 | 3 | [
"MIT"
] | permissive | module TDAmeritradeInstitution
module Requester
def post(url:, body:, headers:)
_wrap_request(url) do |conn|
conn.post do |req|
req.headers = headers
req.body = body
end
end
end
def get(url:, headers:)
_wrap_request(url) do |conn|
conn.get do ... | true |
ad68184717104e0ac8733a2dd03641976a1eaf76 | Ruby | redferret/ruby_practice | /minis/candy_game.rb | UTF-8 | 566 | 3.96875 | 4 | [] | no_license | total_candies = 32
puts "There are a total of #{total_candies} to pick from"
loop do
computer_choice = total_candies % 3
if computer_choice > 0
total_candies -= computer_choice
else
total_candies -= 1
end
puts "Computer takes a turn... number of candies left is #{total_candies}"
if total_candies ... | true |
36e72db0d7d08150cc2d7c35c7a6b71a3afbc069 | Ruby | annikulin/code-classifier | /naive_bayes/resources/ruby/loggable.rb | UTF-8 | 1,744 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | # Copyright (C) 2009-2014 MongoDB, Inc.
#
# 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 ... | true |
ae0dadd97cb97c696de9ed82a8fcf6d9f5da993b | Ruby | Weltenbastler/template-mac | /lib/default.rb | UTF-8 | 3,204 | 2.71875 | 3 | [] | no_license | require 'nanoc'
module Nanoc::Filters
class Wikilink < ::Nanoc::Filter
include ::Nanoc::Helpers::HTMLEscape
def run(content, params = {})
content.gsub(/\[\[([^\]|]*)(\|([^\]]*))?\]\]/) do |match|
# [[Link]] or [[Title |Link]]
# ^^^^=$1 or ^^^^^=$1 ^^^^=$3
link = $3 ?... | true |
06fec653003f33ad1c4d2f28995236faaa721d79 | Ruby | billwright/rattlesnake_ramble | /app/services/ost/translate_race_entry.rb | UTF-8 | 1,487 | 2.65625 | 3 | [] | no_license | module OST
class TranslateRaceEntry
TRANSLATION_KEY = {first_name: {racer: :first_name},
last_name: {racer: :last_name},
gender: {racer: :gender},
birthdate: {racer: :birth_date},
email: {racer: :email},
... | true |
6ab0c1b415b9f5b553b905db3d24d181e425495e | Ruby | yasutaka0116/projecteuler | /problem5.rb | UTF-8 | 573 | 3.546875 | 4 | [] | no_license | # Smallest multiple
# Problem 5
# 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
# What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
require 'prime'
sosu = Prime.each(20).to_a
answer = []
count = 0
toma = 0... | true |
39eb558f4bc1dd7759d7e7522e39297d10271d56 | Ruby | apeiros/baretest | /examples/components/mocha.rb | UTF-8 | 520 | 2.609375 | 3 | [
"Ruby",
"LicenseRef-scancode-public-domain"
] | permissive | class User; end
BareTest.suite "Mocha", :use => :mocha do
suite "When mocking the 'find' method on the 'User' class to return :jane" do
setup do
User.expects(:find).with(42).returns(:jane)
end
assert "Calling User.find returns :jane" do
same :jane, User.find(42)
end
assert "Calling ... | true |
51d8120f1f2703b198d3155f5f4b29c5288a6530 | Ruby | alexmcbride/futureprospects | /app/helpers/home_helper.rb | UTF-8 | 717 | 2.765625 | 3 | [] | no_license | # * Name: Alex McBride
# * Date: 24/05/2017
# * Project: Future Prospects
# Module for home controller helpers. These are functions that can be called in views.
module HomeHelper
# Creates HTML for home page stage item.
#
# @param text [String] the text of the item.
# @param selected [Boolean] whether t... | true |
7557fe8efe07ef600f7ffb39b1b1b718c8d430cb | Ruby | asifbshaikh/accountapp | /app/models/dashboard.rb | UTF-8 | 881 | 2.640625 | 3 | [] | no_license | class Dashboard < ActiveRecord::Base
def self.todays_birthday(company)
@users = company.users.joins(:user_information).where(:user_informations => {:birth_date => Time.zone.now.to_date})
end
def self.weeks_birthday(company)
@users = company.users
@birthdays = []
@users.each do |b|
if !b.user_inform... | true |
7d9cf5bdb7f63a8ac6adbb1d4189ef16179303d5 | Ruby | epimorphics/lds-deploy | /conf/scripts/bwq/prf-intercept.rb | UTF-8 | 3,083 | 2.90625 | 3 | [] | no_license | #!/usr/bin/ruby
#
# Intercept a PRF CSV and check against existing incidents
# If any incidents match then rewrite PRF message but save
# copy of the original CSV to {file}-orig
#
require 'net/http'
require 'uri'
require 'json'
require 'pp'
require 'csv'
require 'fileutils'
require 'set'
#
# Support for fetching pub... | true |
56ee664bb0d9c1b89a444e0ef815f3961c264195 | Ruby | rioyi/ruby_snake | /src/test.rb | UTF-8 | 377 | 3.5 | 4 | [] | no_license | class Calculator
def sum(a,b)
a + b
end
def substract(a,b)
a - b
end
end
# probar sin libreria
calc = Calculator.new
test_sum = {
[1,2] => 3,
[5,6] => 11,
[100,1] => 101
}
test_sum.each do |input, expect_result|
if !(calc.sum(input[0], input[1]) == expect_result)
raise "Test failed for ... | true |
086c262f38406e157a901144de9783753c807655 | Ruby | Meyanis95/Start_Ruby | /exo_18.rb | UTF-8 | 113 | 2.625 | 3 | [] | no_license | mails = []
i = 1
50.times do
mails.append("jean.dupont."+i.to_s+"@email.fr")
i = i + 1
end
puts mails | true |
9652635358f1245754595192e45ba408e1fc18d6 | Ruby | mpospelov/Soldat-1 | /lib/runner.rb | UTF-8 | 309 | 2.734375 | 3 | [] | no_license | class Runner
@@line = 0
def self.start
code_rows = File.read('sample.code').split("\n")
result = File.open("result.bin", "w+")
code_rows.each do |row|
result.puts(Command.new(row).full_code << "\n")
@@line += 1
end
result.close
end
def self.line
@@line
end
end
| true |
16b921dc9f832abc1adaf2b7c861012759d98775 | Ruby | winireis/ruby-interviews-codes | /elevator/passenger.rb | UTF-8 | 460 | 3.203125 | 3 | [] | no_license | class Passenger
attr_reader :arrival_time, :name, :destiny_floor
attr_accessor :boarding_time, :landing_time
def initialize(name, arrival, floor)
@name = name
@destiny_floor = floor
@arrival_time = arrival
@boarding_time = 0
@landing_time = 0
end
def waiting_time
@boarding_time - ... | true |
7634583cc4856eb57233eb5c1e273e859fa138d9 | Ruby | abinoam/dry-core | /spec/dry/core/constants_spec.rb | UTF-8 | 1,768 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'dry/core/constants'
RSpec.describe Dry::Core::Constants do
before do
class ClassWithConstants
include Dry::Core::Constants
def empty_array
EMPTY_ARRAY
end
def empty_hash
EMPTY_HASH
end
def empty_set
EMPTY_SET
end
def empty_strin... | true |
85cfaee0bcb3c3af014c040041b67c035c48534e | Ruby | taw/etwng | /tile_list/tile_list_unpack | UTF-8 | 2,100 | 2.765625 | 3 | [] | no_license | #!/usr/bin/env ruby
require "pathname"
require "pp"
class Float
def pretty_single
return self if nan?
begin
rv = (100_000.0 * self).round / 100_000.0
return rv if self != rv and [self].pack("f") == [rv].pack("f")
self
rescue
self
end
end
end
class TileList
def initialize... | true |
c837b1d8a71363afac46ace969748e24916ab3e5 | Ruby | properzads2/orm-update-lab-atlanta-web-career-031119 | /lib/student.rb | UTF-8 | 1,307 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative "../config/environment.rb"
class Student
attr_accessor :name, :id, :grade
def initialize(id = nil, name , grade)
@name = name
@id = id
@grade = grade
end
def self.create(name,grade)
newstudent = Student.new(name,grade)
newstudent.save
end
def self.new_from_db(array)
Student.n... | true |
92e12ee75a6e015d0fa60f47eb3fdc7a75f764af | Ruby | mru2/smoothier | /crawler/Rakefile | UTF-8 | 1,246 | 2.828125 | 3 | [] | no_license | require './lib.rb'
task :get_my_tracks do
my_tracks = track_ids(ME)
store :my_tracks, my_tracks
end
task :get_all_users do
my_tracks = read :my_tracks
# Get the users who liked them
users = {}
my_tracks.each do |track_id|
begin
# Get the likers
likers = get("/tracks/#{track_id}/favori... | true |
e3e9c16cfd147a46b91d8993c6aced7de30f6e68 | Ruby | ching-wang/programming-univbasics-3-methods-default-values-lab-london-web-100719 | /lib/meal_choice.rb | UTF-8 | 223 | 3.484375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def meal_choice(veg1, veg2, protein = "meat")
if meal_choice == veg1 + veg2
puts "What a nutritious meal!"
elsif (meal_choice == protein + veg1 + veg2)
puts "A plate of #{protein} with #{veg1} and #{veg2}."
end
| true |
f23d7ce1d195babccc5da4a09f8e5928c6253b70 | Ruby | ZeenLamDev/MakersBnB | /lib/space.rb | UTF-8 | 2,991 | 2.96875 | 3 | [] | no_license | require_relative 'user'
class Space
attr_reader :id, :name, :description, :price, :date_available_from, :date_available_to, :user_id
def self.all
result = DatabaseConnection.query("SELECT * FROM spaces;")
result.map do |space|
Space.new(
id: space['id'],
name: space['name'],
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.