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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
9ca0b9215db85a09d1c6afaf350b4ab1eb804910 | Ruby | JuliaPrussia/BasicRuby | /Carriage.rb | UTF-8 | 962 | 3.328125 | 3 | [] | no_license | require_relative 'modules/manufacturer_company'
require_relative 'modules/instance_counter'
require_relative 'modules/validate'
class Carriage
include ManufacturerCompany
include InstanceCounter
include Validate
attr_reader :num,
:type
NUM_TEMPLATE = /^[a-z\d]{3}$/
def initia... | true |
3e3ba7356faa492c68f940ae338f6989804ced43 | Ruby | jhartwell/ironruby | /Tests/Experiments/Globals/Semicolon.rb | UTF-8 | 637 | 3.59375 | 4 | [] | no_license | puts "Initial value"
p $;
$x = "a"
$; = "b"
alias $old_slash $;
alias $; $x
p $;
puts "---"
p '123a456b789'.split # [123a456,789] -> ignores alias
puts "","---"
p $;.object_id == $;.object_id
alias $; $old_slash # restore $;
puts '-' * 20
$; = nil ... | true |
426e66101b5a38329ee52569f02e2f22deec580b | Ruby | marcwright/WDI_ATL_1_Instructors | /REPO - DC - Students/w03/d01/Jacob/superhero/superheroes.rb | UTF-8 | 3,845 | 3.53125 | 4 | [] | no_license | require 'pg'
superhero_conn = PG.connect(:dbname => 'superheroes_db', :host => 'localhost')
def answer_to(question)
puts question
answer = gets.chomp
end
def menu_options
puts "Please select an option from the menu:"
puts "(I) Index - List all Super Heros"
puts "(C) Add a Super Hero"
puts "(R) View all... | true |
ab29d45bb523f5d7f0ef1f55c21f36220253e8c3 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/raindrops/dfc8c6a660b94175a9a3c2bc8cbc274e.rb | UTF-8 | 330 | 3.265625 | 3 | [] | no_license | require 'prime'
class Raindrops
RAINDROPS = {
3 => 'Pling',
5 => 'Plang',
7 => 'Plong'
}
def self.convert(num)
primes = num.prime_division.collect {|f| f[0] }
str = ''
RAINDROPS.each do |key,raindrop|
str << raindrop if primes.include? key
end
str.empty? ? num.to_s : str
... | true |
64a14b02871a54c5a6011f84ad9dfa359dbf6532 | Ruby | aryazar86/ruby_fundamentals1 | /exercise4.rb | UTF-8 | 208 | 3.421875 | 3 | [] | no_license |
100.downto(1). each do |i|
multiple = false
if i%3 == 0
print "Bit"
multiple = true
end
if i%5 == 0
print "Maker"
multiple = true
end
if multiple == false
print "#{i}"
end
puts " "
end | true |
138c68beb2ac399bc2013bc2c98d90603074dfa3 | Ruby | cruessler/lafamiglia.rb | /lib/researches.rb | UTF-8 | 924 | 2.53125 | 3 | [
"MIT"
] | permissive | module LaFamiglia
class Research
def key
"research_#{id}".to_sym
end
def name
@name ||= I18n.t "researches.#{key}"
end
def requirements_met? villa
villa.building_2 > 0
end
attr_accessor :id
attr_accessor :maxlevel
attr_writer :research_time, :costs
def res... | true |
92d220546c9cfbf26f24ce474791303b738deece | Ruby | ivanternovyi/repo | /ts_shoulda.rb | UTF-8 | 1,224 | 3.03125 | 3 | [] | no_license | require 'test/unit'
require 'shoulda'
require_relative 'TennisScorer.rb'
class TennisScorerTest < Test::Unit::TestCase
def assert_score(target)
assert_equal(target, @ts.score)
end
context "Tennis scores" do
setup do
@ts = TennisScorer.new
end
should "start wit a score of 0-0" do
as... | true |
2f108a1c85f6dabb8a1f2418511f0c922b9997e2 | Ruby | makeitgo/didyou | /app/models/counter_group.rb | UTF-8 | 329 | 2.578125 | 3 | [] | no_license | class CounterGroup < ActiveRecord::Base
has_many :counter_items
def summary_count
counter_items.inject(0) { |value, item| value += item.count }
end
def item(name)
if !counter_items.exists?(name: name)
counter_items.create(name: name, count: 0)
end
counter_items.where(name: name)
e... | true |
0b23f930f30f4e5aebfde90c086db785a59a5f18 | Ruby | jessicadavey/ls_small_problems_exercises | /medium_2/exercise_7.rb | UTF-8 | 263 | 3.59375 | 4 | [] | no_license | require 'date'
MONTHS = (1..12).to_a.freeze
def friday_13th(year)
thirteenths = MONTHS.map do |month|
Date.new(year, month, 13)
end
thirteenths.count(&:friday?)
end
puts friday_13th(2015) == 3
puts friday_13th(1986) == 1
puts friday_13th(2019) == 2
| true |
7c8283088fa2d1e2093a219008f45b36c980492c | Ruby | jwoertink/shoes4 | /lib/shoes/swt/text_fragment.rb | UTF-8 | 1,207 | 2.578125 | 3 | [
"MIT"
] | permissive | module Shoes
module Swt
class TextFragment
include Common::Child
attr_accessor :style, :widget
# Need the widget or text element to apply this new style to
def initialize(dsl, parent)
@dsl = dsl
@parent = parent
@style = ::Swt::Custom::StyleRange.new
en... | true |
bd4018d9c45a07ce5055b086cca6b39bc4ee216c | Ruby | addisonmartin/AdventOfCode | /2020/1-1.rb | UTF-8 | 499 | 3.125 | 3 | [] | no_license | sum = 2020
def readInputsFromFile(path)
raw_inputs = []
File.readlines(path).each do |line|
raw_inputs << line.chomp.to_i
end
raw_inputs
end
inputs = readInputsFromFile('day_1_inputs.txt')
for input in inputs
for other_input in inputs
unless input == other_input
if input + other_input ... | true |
8c871f77761c0b223acc7049292d4d3b92246fb9 | Ruby | sonnym/array_decay | /lib/array_decay.rb | UTF-8 | 396 | 2.96875 | 3 | [
"MIT"
] | permissive | require_relative 'array_decay/version'
class Array
def decay!
ArrayDecay::Enumerator.new(self)
end
end
module ArrayDecay
class Enumerator
include Enumerable
attr_accessor :enumerator
def initialize(enumerator)
self.enumerator = enumerator
end
def each(&block)
until enumera... | true |
cb52e9b852aacc409951c98d23c44731cfa6117d | Ruby | shved270189/ya_metrika | /lib/ya_metrika/client.rb | UTF-8 | 1,643 | 2.875 | 3 | [
"MIT"
] | permissive | require 'ya_metrika/settings'
require 'net/http'
module YaMetrika
class Client
HOST = 'http://api-metrika.yandex.ru'
REST_METHODS = [:get, :post, :put, :delete]
def initialize(options = {})
options = YaMetrika::Settings.to_hash.merge(options)
@format = options[:format]
... | true |
02e7ce6397979a0f401b6f295ec184ee56011b82 | Ruby | ChernayaJuly/Ruby | /lb1_z5.rb | UTF-8 | 191 | 3.578125 | 4 | [] | no_license | numb = ARGV[0]
numb = numb.to_i
def last_digit(x,q=10)
x % q
end
def digits_sum(x,q=10)
sum = 0
while x > 0
sum+= last_digit(x,q)
x /= q
end
sum
end
puts digits_sum(numb) | true |
4df791615e81c60e7b20a6908ffdc1123d553d27 | Ruby | kennojc/online_arrays | /desafio1array.rb | UTF-8 | 807 | 4.375 | 4 | [] | no_license |
#con map sumarle 1 a los elementos
def plus_one(a)
sum = a.map {|x| x+1 }
print sum
end
#con map pasarlos a float
def to_float(a)
floats = a.map {|x| x.to_f}
print floats
end
#Utilizando select descartar todos los elementos menores a 5 en el array.
def discard(a)
clean = a.select {|x|... | true |
7e98fb37e78273acea45fdb0700b48ed964a5d41 | Ruby | intenex/aa-practice-test-generator | /problems/eight_queens.rb | UTF-8 | 686 | 4.03125 | 4 | [] | no_license | # Write a recursive method that generates the number of possible unique ways to
# place eight queens on a chess board such that no two queens are in
# the row, column, or diagonal. A skeleton for a possible solution is
# provided. Feel free to create your own solution from scratch.
class EightQueens
attr_accessor :... | true |
5b0b7c8259a8f09f4836d68c7e09d6a8b7bfd11f | Ruby | Eulers-Bridge/isegoriaweb | /app/controllers/tickets_controller.rb | UTF-8 | 11,516 | 2.59375 | 3 | [] | no_license | class TicketsController < ApplicationController
#Set the default layout for this controller, the views from this controller are available when the user is looged in
layout 'application'
=begin
-------------------------------------------------------------------------------------------------------------------------... | true |
597daf7fc9fe743281f314b6b52de1b952376ce6 | Ruby | zpalmquist/reunion | /test/reunion_test.rb | UTF-8 | 576 | 2.65625 | 3 | [] | no_license | require 'minitest'
require 'minitest/test'
require 'minitest/autorun'
require './lib/reunion'
require './lib/activity'
class ReunionTest < Minitest::Test
def test_attributes_of_reunion
reunion = Reunion.new('montana', 'hiking')
assert_equal 'montana', reunion.location
assert_equal ['hiking'], reunion.a... | true |
85c2af8c2bb3d367bc668d601c86183b050d9e2a | Ruby | cglorious/prework-videos-intro-to-tests-online-web-sp-000 | /conversions.rb | UTF-8 | 109 | 2.546875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | GRAMS_PER_OUNCE = 28.3495 #constant variable
def ounces_to_grams(ounces)
ounces.to_f * GRAMS_PER_OUNCE
end
| true |
4285af6f489cb7a570b3df49b5572d0d3622f359 | Ruby | vvj5/wk2day1 | /profile-info.rb | UTF-8 | 1,129 | 3.9375 | 4 | [] | no_license | puts "Would you like to play a game?"
enter = gets.chomp
if enter.include? "no"
puts "Please? I'm so lonely. Type 'k' to play a game with me."
else
puts "Oh good! Type 'k' to continue."
end
passcode = gets.chomp
if passcode.include? "k"
puts "Let's talk about you. "
else
puts "Try typing k again."
end
puts "What is you... | true |
ed86856e55e35e58c28d646637ffc0429be6a5db | Ruby | smoreau-tj/bowling_rspec | /spec/frame_spec.rb | UTF-8 | 913 | 2.71875 | 3 | [] | no_license | require 'frame'
describe Frame do
describe "#frame_over?" do
context "when I bowl twice" do
before do
2.times { subject.bowl(0) }
end
it "is true" do
expect(subject.frame_over?).to eq(true)
end
end
context "... | true |
29c23e0535f841f3699d4aa0b096aee8a4733ae1 | Ruby | ralphreid/WDI_LDN_3_Work | /ralphreid/w1d4/homework/happitails_animal_shelter/data.rb | UTF-8 | 299 | 2.53125 | 3 | [] | no_license | require_relative 'shelter'
require_relative 'client'
require_relative 'animal'
$shelter = Shelter.new( "Happitails", "Main Street")
# add all the initial data
###example below 2 is the number of childern.......this helps show the §
# $shelter.clients['bob'] = Client.new('Bob', 22, 'male', 2) | true |
da8f335b1037d35c9c77fcc3a62f3160cc06a2f7 | Ruby | upamune/itamae-osx | /common/formula.rb | UTF-8 | 174 | 2.921875 | 3 | [] | no_license | class Formula
attr_reader :package, :tap
def initialize(package, tap=nil)
@package = package
@tap = tap
end
def hasTap()
return !self.tap.nil?
end
end | true |
33e72f9b14db6baa7f6ab3bcb1466c5cb588744e | Ruby | freerange/mocha.methods | /Mocha/ParameterMatchers/Not/#matches?.rb | UTF-8 | 114 | 2.515625 | 3 | [] | no_license | def matches?(available_parameters)
parameter = available_parameters.shift
!@matcher.matches?([parameter])
end
| true |
fd03110db21c45822c17b833d46bddfe2d4f350b | Ruby | phamv21/stp_minesweeper | /game.rb | UTF-8 | 6,173 | 3.25 | 3 | [] | no_license | require_relative 'board'
require_relative 'keypress'
require 'yaml'
class Game
attr_reader :board, :saved_board, :size
def initialize(size = get_val("please put yours desire size"))
@size = size
@board = Board.new(size)
@saved_board = ""
@time_start = 0
@time_stop = 0
... | true |
4064519484777dcd6c6ee4d5ab6986180044cfb1 | Ruby | diegous/econocrawler | /renderer.rb | UTF-8 | 871 | 2.6875 | 3 | [] | no_license | require 'erb'
require 'json'
require 'byebug'
english = true
LANGUAGE = english ? 'english' : 'spanish'
BASE_URL = "http://economica.econo.unlp.edu.ar#{'/ing' if english}"
# Retrieve JSON
JSON_FILE = File.read("./result#{'_english' if english}.json")
publications = JSON.parse(JSON_FILE)
# Templates
PUBLICATION_TEMPL... | true |
99064be43a3904ef5d76080c569b02972d04e1c8 | Ruby | kurage0516/furima-30952 | /spec/models/user_spec.rb | UTF-8 | 4,781 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
before do
@user = FactoryBot.build(:user)
end
describe 'ユーザー新規登録' do
it 'nickname、email、password、password_confirmation、name、surname、name_ruby、surname_ruby、birthdayが存在すれば登録できる' do
expect(@user).to be_valid
end
it 'nicknameが空では登録でき... | true |
5aa5d6e6758edca11b04fa74dbace188ceb9a3c4 | Ruby | petrgazarov/Chess | /lib/sliding_piece.rb | UTF-8 | 520 | 3.1875 | 3 | [] | no_license | class SlidingPiece < Piece
def moves
result = []
deltas.each do |delta|
result += make_branch(delta)
end
result
end
private
def make_branch(delta)
result = []
1.upto(Board::SIZE - 1) do |idx|
pos = [(delta[0] * idx + position[0]), (delta[1] * idx + position[1])]
ret... | true |
58de46d7374507d2c07cfdc81be7248ff04039d6 | Ruby | flaco/Signed-Request-Parser | /parse_signed_request.rb | UTF-8 | 940 | 2.734375 | 3 | [] | no_license | # Parses Facebooks Signed Request Parameter and returns JSON
# Some borrowing from http://github.com/appoxy/mini_fb/blob/master/lib/mini_fb.rb && http://sunilarora.org/parsing-signedrequest-parameter-in-python-bas
require "openssl"
require "base64"
require "cgi"
require "yajl"
def base64_url_decode(st)
st = st + "=... | true |
047483c510bcf5034cc06f9431c838e53cc420fe | Ruby | sassani134/crypto_J_S6 | /app/service/scrapp_money.rb | UTF-8 | 1,360 | 3.171875 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
class Scrapp_money
# frozen_string_literal: true
attr_accessor :hash, :name
def initialize(name_money="" ,url = "https://coinmarketcap.com/all/views/all/")
@url = url
@page = Nokogiri::HTML(open(@url))
@hash = {}
@name = []
@money_name= name_money
# o... | true |
1c0dcd7442a0860384e06fecd10bcf705aa7319a | Ruby | ChristopherDurand/Exercises | /ruby/small-problems/advanced/e1.rb | UTF-8 | 967 | 3.078125 | 3 | [
"MIT"
] | permissive | TAG = /<(.+?)>/
WHOLE_TAG = /\<.+?\>/
WORDS = {"adjective" => %w(quick lazy sleepy ugly),
"noun" => %w(fox dog head leg cat tail),
"verb" => %w(spins bites licks hurdles),
"adverb" => %w(easily lazily noisly excitedly)}
def get_needed(text)
text.scan(TAG)
end
def prompt_user(... | true |
007dc15328b6ff2e18935c85da26d0ea24710c06 | Ruby | toptal/codeowners-checker | /spec/codeowners/reporter_spec.rb | UTF-8 | 2,077 | 2.625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'codeowners/checker'
RSpec.describe Codeowners::Reporter do
describe '::print_delimiter_line' do
it 'raises the exception if unknow error type' do
expect do
described_class.print_delimiter_line(:foobar)
end.to raise_exception(ArgumentError, "unknown erro... | true |
4e0a7e408a829ab639667a6b4a156145d6c62a8d | Ruby | sagarlekar/road_roller | /lib/road_roller.rb | UTF-8 | 4,732 | 3.546875 | 4 | [] | no_license | # Author - Sagar Arlekar
# Email - sagar.arlekar@gmail.com
require 'rgeo'
require 'rgeo/shapefile'
require 'road_roller_helper'
# * This class has methods to divide roads(RGeo::Feature::LineString) into points (RGeo::Feature::Point)
class RoadRoller
attr_accessor :shapefile, :filename, :id_field, :road_points
#
... | true |
80309ccaca89dc000ac2fe3a67cc6c82e63275c6 | Ruby | BC-MAY-21-ROR/kata-02-el-juego-de-la-vida-dia-04-team05-dia-3 | /spec/location_spec.rb | UTF-8 | 2,044 | 2.75 | 3 | [] | no_license | # frozen_string_literal: true
require 'rspec'
require './lib/location'
describe Location do
before :all do
@north_west = Location::NORTHWEST
@north_east = Location::NORTHEAST
@south_west = Location::SOUTHWEST
@south_east = Location::SOUTHEAST
@center = Location::CENTER
@north = Location::NORT... | true |
131cb7e2ee16d3a06215881da0c1cc74a7371f96 | Ruby | Elbakay/Exo_Ruby | /exo_09.rb | UTF-8 | 213 | 3.625 | 4 | [] | no_license | puts "Bonjour, quel est votre prénom ?"
print ">"
user_first_name = gets.chomp
puts "Quel est votre nom ?"
print ">"
user_last_name=gets.chomp
puts"Bonjour, "+user_first_name.capitalize+" "+user_last_name.upcase
| true |
f9f21380380e32d813caa95b098b4dac9aebc630 | Ruby | clothnetwork/cloth-ruby | /lib/cloth/client.rb | UTF-8 | 1,283 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'json'
require 'typhoeus'
module Cloth
class Client
attr_reader :api_key
def initialize(api_key = nil)
@api_key = api_key || Cloth.api_key
raise Exception, "An API key must be set before the Cloth client can be used. Set an API key with 'Cloth.api_key = ...'" unless @api_key
end
... | true |
e4e6dbc9eaa26a0ff61a04e5dacefd8e96982f54 | Ruby | naoki-k/Ruby-Cherry-Book | /chapter2/2.2.1.rb | UTF-8 | 498 | 4.1875 | 4 | [] | no_license | # to_sメソッド
# 数値や真偽値、正規表現もオブジェクトで、それぞれにメソッドを持つ
# 文字列に変換するメソッド
# 文字列
'1'.to_s
puts('1'.to_s)
# 数値
1.to_s
puts(1.to_s)
# nil
nil.to_s
puts(nil.to_s)
puts('_' + nil.to_s + '_')
# true
true.to_s
puts(true.to_s)
# false
false.to_s
puts(false.to_s)
# 正規表現
/\d+/.to_s
puts(/\d+/.to_s)
# to_sメソッドの引数
# 数値を16真数の文字列に変換する
10.to_s... | true |
ec9a272a10f0adbf1966c8502aa699aad0a7ed37 | Ruby | Cooky90/LaunchSchool | /ProgrammingFoundations-101/Small-Exercises/Easy-3/Exercise10.rb | UTF-8 | 208 | 3.234375 | 3 | [] | no_license | def palindromic_number?(number)
number.to_s.reverse == number.to_s
end
palindromic_number?(34543) == true
palindromic_number?(123210) == false
palindromic_number?(22) == true
palindromic_number?(5) == true | true |
97b8c5b3772a919291ada8a3adde82da1c89af1f | Ruby | Domitalk/OO-FlatironMifflin-dumbo-web-102819 | /lib/Manager.rb | UTF-8 | 776 | 3.578125 | 4 | [] | no_license | class Manager
attr_reader :name, :department, :age
@@all = []
def initialize(name, department, age)
@name = name
@department = department
@age = age
@@all << self
end
def self.all
@@all
end
def employees
Employee.all.select do |instance|
... | true |
4c43d58e290d126082bfee9bfaf432929384d8d0 | Ruby | oreills8/DistributedSystemsProject | /DirectoryServer/directoryClient.rb | UTF-8 | 1,599 | 2.78125 | 3 | [] | no_license | require './errors'
require './directory'
class Client
attr_accessor :connection, :ClientProxyJoinID, :ChatroomNumber, :error,
:updatingFile
def initialize(setJoinID, setConnection)
@joinID = setJoinID
@connection = setConnection
@Clie... | true |
6e16d7510a1f55d57ef227c8b798b142adae3f8f | Ruby | peel3r/till_kata | /spec/receipt_spec.rb | UTF-8 | 1,640 | 3.0625 | 3 | [] | no_license |
describe Receipt do
context 'Calculating line prices' do
let(:order_dbl){double :order}
let(:receipt){Receipt.new(order_dbl)}
it 'Returns a price for each item' do
expect(receipt.price_for('Cafe Latte')).to eq 4.75
end
it 'Returns a line price for an item and quantity' do
two_choc_... | true |
e8a62146ab701cdf912ec00ff02e2ce5a83f9100 | Ruby | yoshikyoto/twitch-clipper | /src/cliper/service.rb | UTF-8 | 1,812 | 2.78125 | 3 | [] | no_license | require 'date'
require 'twitch-api'
require 'twitch-clipr'
module Cliper
class Service
def initialize(config)
@config = config
@twitch = Twitch::Client.new(client_id: config["twitch"]["client_id"])
@clipr = Twitch::Clipr::Client.new()
end
def search_clip_and_download_with_broadcasters(... | true |
4f530c66b22f701b7c295b52134de7a930f6ec48 | Ruby | jsm125/triangle-classification-online-web-sp-000 | /lib/triangle.rb | UTF-8 | 816 | 3.484375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require_relative '../lib/triangle'
class Triangle
attr_accessor :length_a, :length_b, :length_c
def initialize(length_a, length_b, length_c)
@length_a = length_a
@length_b = length_b
@length_c = length_c
end
def kind
if (@length_a <= 0) || (@length_b <= 0) || (@length_c <= 0)
ra... | true |
9391921cca696e991705a9212db4edc7137dd675 | Ruby | ArayB/advent_of_code_2017 | /lib/day_one/problem_one.rb | UTF-8 | 440 | 3.234375 | 3 | [] | no_license | module DayOne
class Problem1
def initialize(input)
@arr = input.split('').map { |x| x.to_i }
@matches = []
end
def run
process(@arr)
@matches.sum
end
def process(arr, last = nil)
head, *tail = arr
if head == last
@matches << head
end
retur... | true |
164cdd7989b1d3566fff4e5710d39ef2424f8c73 | Ruby | loschtreality/Chess_Ruby | /board.rb | UTF-8 | 2,232 | 3.53125 | 4 | [] | no_license | require_relative "pieces"
class Board
attr_reader :grid
def initialize(grid = Array.new(8) { Array.new(8) { NullPiece.instance } })
@grid = grid
end
def grid
@grid
end
def [](pos)
x,y = pos
@grid[x][y]
end
def []=(pos, value)
x, y = pos
@grid[x][y] = value
end
def dup
... | true |
dc1d6676fc3abd359a9e942d1892db16a3db75ff | Ruby | tiltedlistener/NorthwestProgramming2016 | /assignments/2_Ruby_intro.rb | UTF-8 | 401 | 3.625 | 4 | [] | no_license | ###
# Copy each section separately and run through https://repl.it/languages/ruby
#
# When finished, try running the entire program through the REPL
###
########## Output
puts "Hello World!"
########## Assignment
a = 5
b = 6
########## Basic Math
a = 5
b = 6
a + b
########## Math Output
a = 5
b = 6
c = a + b
puts... | true |
555828e3397d64183c805735252924dc64f345df | Ruby | lao9/complete_me | /lib/complete_me.rb | UTF-8 | 6,294 | 3.59375 | 4 | [] | no_license | require 'pry'
class CompleteMe
attr_accessor :dictionary, :count
def initialize
@dictionary = Node.new("")
@count = 0
@selection_hash = {}
end
def insert(word)
@dictionary.insert(word)
@count += 1
end
def populate(entry)
entry.split("\n").each do |word|
@dictionary.insert(w... | true |
695fd7f5345ecca6b8fe92a857160a9454861091 | Ruby | am-team/luna_park | /lib/luna_park/http/request.rb | UTF-8 | 7,592 | 3.03125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'luna_park/http/send'
module LunaPark
module Http
class Request
# Business description for this request, help you
# make the domain model more expressive
#
# @example Get users request
# request = Request.new(
# title: 'Get users li... | true |
e50afea8b7b0cb298344b472bbfa886818adf5f7 | Ruby | illustriam/mail-gpg | /lib/hkp.rb | UTF-8 | 4,118 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'gpgme'
require 'openssl'
require 'net/http'
# simple HKP client for public key search and retrieval
class Hkp
class TooManyRedirects < StandardError; end
class InvalidResponse < StandardError; end
class Client
MAX_REDIRECTS = 3
def initialize(server, ssl_verify_mode: OpenSSL::SSL::VERIFY_P... | true |
9f88fe24bca948fd30f2e7e99f9cec01bdf2adbd | Ruby | cddurbin/tic_tac_toe | /app/models/move.rb | UTF-8 | 542 | 2.671875 | 3 | [] | no_license | class Move < ActiveRecord::Base
attr_accessor :player1
belongs_to :user
belongs_to :game
def self.find_mark(game_id)
game = Game.find(game_id)
if game.moves.present?
if game.moves.last.mark == "x"
"o"
else
"x"
end
else
"x"
end
end
def self.computer_mo... | true |
9b09b7a98a53837fe75f6bb1fc6c14d34bb3b844 | Ruby | KakeruYamamoto/peawork | /sample2.rb | UTF-8 | 3,642 | 3.34375 | 3 | [] | no_license | class VendingMachine
MONEY = [10, 50, 100, 500, 1000].freeze #0-1.10円玉、50円玉、100円玉、500円玉、1000円札を1つずつ投入できる。
def initialize
@slot_money = 0
@proceeds = 0
item = Item.new
@stock = [item.coke, item.redbull, item.water]
end
def current_slot_money #0-3.投入金額の総計を取得できる。
@slot_money
end
def slo... | true |
d7430d8ac9b4c0ae3c54a4c9170f798b23b9f092 | Ruby | wwit-atl/movie-archive | /bin/movie-archive | UTF-8 | 1,841 | 3.078125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'wwit/archive'
require 'colorize'
opt = WWIT::Archive::Options.parse(ARGV)
if opt.verbose
puts 'Source directories are'.light_white + " #{opt.source.join(', ').green}"
puts 'Destination directory is'.light_white + " #{(opt.dest ? opt.dest : 'same as source file').green}"
puts 'Files... | true |
feaf5224ca7c70bfdf08b03cf296b05a48618414 | Ruby | jecrockett/Turing_Homework | /1014_looping.rb | UTF-8 | 743 | 4.46875 | 4 | [] | no_license | # 1 Easy Looping
5.times do
puts "Line"
end
#2 Looping with a condition
5.times do |i|
if i.even?
puts "Line is even"
else
puts "Line is odd"
end
end
# 3 Three Loops
5.times do |i|
puts "This is my output line #{i + 1}"
end
line = 0
while line < 5
line += 1
puts "This is my output line #{l... | true |
36947b77daa437469d4fa11fbaac52a8323de165 | Ruby | Muriel-Salvan/ruby-serial | /lib/ruby-serial/_object.rb | UTF-8 | 1,355 | 3.234375 | 3 | [
"BSD-3-Clause"
] | permissive | # Instrument Object to get access to the list of instance variables to be serialized.
class Object
# Get the list of instance variables that are meant to be serialized
#
# Result::
# * <em>map<String,Object></em>: Set of instance variables, per name
def instance_vars_to_be_rubyserialized
# Compute the li... | true |
86838c1296a3ef8297a09c810a56e4a86c5cf92d | Ruby | CoopTang/mod_2_ruby_challenge | /lib/round.rb | UTF-8 | 700 | 3.671875 | 4 | [] | no_license | class Round
attr_reader :guess, :code, :correct_elements, :correct_positions
def initialize(guess, code)
@guess = guess
@code = code
@correct_elements = calculate_correct_elements
@correct_positions = calculate_correct_positions
end
def correct?
@code == @guess
end
private
def cal... | true |
75447feec8616e5ab665b13f0358dd1720cd8610 | Ruby | tkengo/algorithms | /ruby/algorithms/sort/bubble_sort.rb | UTF-8 | 218 | 3.421875 | 3 | [] | no_license | class Array
def bubble_sort
a = self
(1..a.size).each do |i|
(a.size - i).times do |j|
if a[j] > a[j + 1]
a[j], a[j + 1] = a[j + 1], a[j]
end
end
end
a
end
end
| true |
03ac323d4932f7fcaac40b03491f8ef9c70b474e | Ruby | FCSadoyama/api-oauth2-template | /app/services/authorizations/authenticators/password.rb | UTF-8 | 439 | 2.609375 | 3 | [] | no_license | module Authorizations
module Authenticators
class Password
def initialize(email:, password:)
@email = email
@password = password
end
def call
user if authenticated?
end
private
attr_reader :email, :password
def authenticated?
user.authe... | true |
250779f9ad3be59bc7ada18f1306af3416b92a2d | Ruby | diegoarvz4/rspec-tictactoe | /lib/board.rb | UTF-8 | 329 | 3.390625 | 3 | [
"MIT"
] | permissive |
require_relative 'ui.rb'
class Board
include UI
attr_reader :dimensions
def initialize
@dimensions= [0,1,2,3,4,5,6,7,8]
end
def set_cell(value, turn)
@dimensions[value] = turn
end
def is_full?
@dimensions.all? { |square| square.is_a?(String) }
end
... | true |
662b32660237ac565a1ea298c1fb249cce9c34b1 | Ruby | tksasha/vm | /app/models/coin.rb | UTF-8 | 702 | 3.109375 | 3 | [] | no_license | # frozen_string_literal: true
class Coin < ApplicationModel
self.database = 'db/coins.yml'
class << self
def available
all.select { |_, value| value.positive? }
end
def push(coin)
return unless all.key? coin
all[coin] = quantity(coin) + 1
end
def pop(coin)
return unl... | true |
5e2b115baa30a3bc7bec6fa5e97231f49523ac2b | Ruby | ojnunez/movie_rental_store | /app/controllers/admins/api_v1/movies_controller.rb | UTF-8 | 2,031 | 2.53125 | 3 | [] | no_license | # frozen_string_literal: true
module Admins
module ApiV1
class MoviesController < Admins::ApiV1Controller
before_action :set_item, only: %i[update destroy]
# GET /admins/api/movies
def index
# Get movies that are available
@movies = Movie.order(title: :asc)
# Simple se... | true |
af31f432bad80c2f580d97d98b95d260abb6ba51 | Ruby | chrislomaxjones/Ruby-programs | /snippets/methods/break_procs.rb | UTF-8 | 1,952 | 4.375 | 4 | [] | no_license | # Procs.new is the iterator that break would return from
# By the time we invoke the proc obj, the iterator
# has already returned
# therefore it never makes sense to have a top-level
# break statement in a proc created with Proc.new
def test
puts "Entering method"
p = Proc.new { puts "Entering Proc"; break }
begin ... | true |
e42be20f3eb291a5a6d94d9d456cb91b4f67bb4d | Ruby | makiton/portfolio | /lib/portfolio/asset_class.rb | UTF-8 | 631 | 3.15625 | 3 | [
"MIT"
] | permissive | module Portfolio
class AssetClass
attr_accessor :name
attr_reader :histdata, :equity, :variance, :mean
def initialize(name:, histdata:)
@name = name
@histdata = histdata
end
def mean
@mean ||= histdata.sum.to_f / histdata.count
end
def equity
mean / histdata.firs... | true |
336577c517ec5370eda21eea390132d581241a13 | Ruby | schambon/pleo | /app/models/word.rb | UTF-8 | 319 | 3.109375 | 3 | [] | no_license | # a word (actually a stem) found in the text input
class Word
attr_accessor :stem, :char_position, :word_position, :as_found
def initialize(text, char_position, word_position)
@stem = Stemmer.new.stem text
@char_position = char_position
@word_position = word_position
@as_found = text
end
end
| true |
2031163c77ff262a626132e6af4083eccc21e263 | Ruby | kyokucho1989/ruby-kyozai | /ch2-1-1.rb | UTF-8 | 260 | 3.5 | 4 | [] | no_license | # require 'pry'
puts <<-text
おみくじを引いてみよう!
press enter
text
gets
select_num = rand(1..3)
# binding.pry
if select_num == 1
puts '大吉!!!'
elsif select_num == 2
puts '吉です'
elsif select_num == 3
puts '凶……。'
end | true |
7d4353291ce393123e49b879894b8b19f7ba81d5 | Ruby | mugyu/algorithms | /ruby/list/queue.rb | UTF-8 | 976 | 3.84375 | 4 | [] | no_license | # リスト構造
# キュー
# First In First Out
# Singly-linked list
require 'pp'
class Queue
def initialize
@value = []
@next = []
@head = 0
@tail = -1
end
def enqueue(x)
p = @tail
@tail += 1
@value[@tail] = x
@next[@tail] = nil
@next[p] = @tail unless @head == @tail
end
d... | true |
f39b0ab6fbad7a23d4dedf9ee2b751d03ef421cb | Ruby | malachaifrazier/Beatstream | /test/api_test_helper.rb | UTF-8 | 626 | 2.515625 | 3 | [
"LicenseRef-scancode-other-permissive"
] | permissive | # API test helpers
def get_json(url)
get url, :format => :json
end
def post_json(url, data)
post url, data.to_json, { 'CONTENT_TYPE' => 'application/json' }
end
def put_json(url, data)
put url, data.to_json, { 'CONTENT_TYPE' => 'application/json' }
end
def delete_json(url)
delete url, :format => :json
end
d... | true |
d78d7117a37835ba8f85a5f389ab2ec3639f5994 | Ruby | cameronepstein/sam | /test.rb | UTF-8 | 427 | 3.859375 | 4 | [] | no_license | puts "hi, write something"
input = gets.chomp
if input.include?('0') || input.include?('1') || input.include?('2') || input.include?('3') || input.include?('4') || input.include?('5') || input.include?('6') || input.include?('7') || input.include?('8') || input.include?('9')
puts 'nice number bro'
if input.to_i <... | true |
e75aa1cbf1163c5e1a7e6a92a8afb1279b938bbf | Ruby | nachiket87/RubyAlgorithms | /13-Coin/main.rb | UTF-8 | 474 | 3.15625 | 3 | [] | no_license | # frozen_string_literal: true
# not solved by me - Dynamic Programming est pas bonne
def change_possibilities_bottom_up(amount, denominations)
ways_of_doing_n_cents = [1] + Array.new(amount, 0)
denominations.each do |coin| # 1
(coin..amount).each do |higher_amount|
higher_amount_remainder = higher_amou... | true |
628f8101c5937c9de55be3d1b1a4f02238a9987d | Ruby | Bhanditz/JS.coach | /project/test/helpers/time_helper_test.rb | UTF-8 | 1,133 | 2.71875 | 3 | [] | no_license | require "test_helper"
class TimeHelperTest < ActionView::TestCase
it "returns a relative time" do
relative_timestamp(Time.now).must_equal "today"
relative_timestamp(1.hour.ago).must_equal "today"
relative_timestamp(24.hours.ago).must_equal "yesterday"
relative_timestamp(1.day.ago).must_equal "yester... | true |
eb20bcf93ce0b71a8f3935ff525e014e0e81309b | Ruby | lwangenheim/WGrubyist | /stack.rb | UTF-8 | 325 | 3.453125 | 3 | [] | no_license | require_relative "stacklike"
class Stack
include Stacklike
end
s = Stack.new
s.add_to_stack("item one")
s.add_to_stack("item two")
s.add_to_stack("item three")
puts "Objects currently on the stack: "
puts s.stack
taken = s.take_from_stack
puts "removed this object: "
puts taken
puts "now on stack: "
puts s.s... | true |
a449530886a7940dbfe05ccc7a4410cbba057589 | Ruby | lroliphant/inject-challenge | /spec/injecty_spec.rb | UTF-8 | 391 | 2.984375 | 3 | [] | no_license | require 'injecty'
describe Array do
subject(:array) { [1, 2, 3] }
it { is_expected.to respond_to(:injecty).with(1).arguments }
describe '#injecty' do
# tests for the simplest thing array.inject will do
it 'kind of adds elements in the array and returns a single value' do
expect(array.injecty { |accu... | true |
e83f80037a3f4dd7c1888758203e52bcfc6c91e2 | Ruby | awochna/todotxt_rb | /spec/lib/todotxt_rb/list_spec.rb | UTF-8 | 2,529 | 3.0625 | 3 | [] | no_license | require 'spec_helper'
describe TodotxtRb::List do
def create_tasks
file = 'spec/todo.txt'
array = []
File.open(file) do |file|
file.each_line do |line|
array.push(TodotxtRb::Task.new(line.chomp))
end
end
array
end
it "takes an array of tasks" do
task = TodotxtRb::T... | true |
ecdcac9ff942c9380ae7e500e13eef5f14a362c5 | Ruby | modular-magician/magic-modules | /build/presubmit/perc_bar.rb | UTF-8 | 1,982 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | #!/bin/ruby
# Copyright 2017 Google 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 |
18136c7b5f5decb494b24c5f138c413208dc9ca0 | Ruby | brendanwb/exercises_for_programmers | /tip_calculator/ruby/tip_calc/lib/tip_calc.rb | UTF-8 | 434 | 3.4375 | 3 | [] | no_license | class TipCalc
attr_reader :tip, :total
def initialize(bill_amount, tip_rate)
@bill_amount = bill_amount
@tip_rate = tip_rate
@tip = 0
@total = 0
end
def process
@tip = process_tip
@total = process_total
end
private
def process_tip
(@bill_amount * (@tip_rat... | true |
5a1b8a8b6c16ee19182712633c9f31f2f991678c | Ruby | imanaa/rprojects | /bin/sudoku.rb | UTF-8 | 926 | 2.984375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
#encoding: utf-8
###############################################################################
# sudoku.rb -- Solve a sudoku game
# Arguments:
#
#
# Copyright (C) 2012 Imad MANAA
# Last Modified : 13th, September 2012
# Version : 1.0
#############################################################... | true |
93f2ecfbd69e45ed6eb6df209c79846bb4390a67 | Ruby | JoeG21/houston-se-071320 | /04-object-relations-many-many/run.rb | UTF-8 | 839 | 2.96875 | 3 | [] | no_license | require 'pry'
require_relative './user'
require_relative './tweet'
require_relative './like'
naruto = User.new("Naruto")
sasuke = User.new("Sasuke")
sakura = User.new("Sakura")
t1 = naruto.post_tweet("This class is 🔥")
t2 = sasuke.post_tweet("First tweet ever!!")
t3 = sasuke.post_tweet("Objects...Classes...Methods.... | true |
662bda4d95cff867ab8cd25ba7a18ce091e7f361 | Ruby | joan2kus/ChartDirector | /railsdemo/app/controllers/colorbar_controller.rb | UTF-8 | 1,622 | 2.609375 | 3 | [
"IJG"
] | permissive | require("chartdirector")
class ColorbarController < ApplicationController
def index()
@title = "Multi-Color Bar Chart"
@ctrl_file = File.expand_path(__FILE__)
@noOfCharts = 1
render :template => "templates/chartview"
end
#
# Render and deliver the chart
#
def g... | true |
2b06e1c79fc6e97e803bf136728897628c1a8ef1 | Ruby | Joanne0330/student-directory | /directory_exercises.rb | UTF-8 | 3,343 | 3.40625 | 3 | [] | no_license | # students = [
# {name: "Dr. Hannibal Lecter", cohort: :november},
# {name: "Darth Vader", cohort: :november},
# {name: "Nurse Ratched", cohort: :november},
# {name: "Michael Corleone", cohort: :november},
# {name: "Alex DeLarge", cohort: :november},
# {name: "The Wicked Witch of the West", cohort: :november},
# {name:... | true |
2d1362821e977722064a976adc252c8e48765309 | Ruby | nachoal/pragmatic_studio | /studio_game/game_turn.rb | UTF-8 | 383 | 3.296875 | 3 | [] | no_license | require_relative 'die'
require_relative 'player'
require_relative 'treasure_trove'
module GameTurn
def self.take_turn(player)
die = Die.new
case die.roll
when 1..2
player.blam
when 3..4
puts "#{player.name} was skipped"
else
player.w00t
end
item = TreasureTrove.random
puts "#{pl... | true |
d04ddfde042cf0f5845503ebf9f0c7935c03e410 | Ruby | OmarMAbbasi/Metaprogramming-Project | /lib/00_attr_accessor_object.rb | UTF-8 | 452 | 2.96875 | 3 | [] | no_license | require 'byebug'
class AttrAccessorObject
def self.my_attr_accessor(*names)
names.each do |ivar|
define_method("#{ivar}"){instance_variable_get("@#{ivar}") }
define_method("#{ivar}="){ |i| instance_variable_set("@#{ivar}", i) }
end
end
end
# class AnimalConstructor
# def self.be_a_god(spe... | true |
9f61fac2a8d2adf51cb77130810401c5db471ff9 | Ruby | mugenup/html-pipeline-bungo | /lib/html/pipeline/bungo/dash_filter.rb | UTF-8 | 250 | 2.5625 | 3 | [
"MIT"
] | permissive | module HTML
class Pipeline
class DashFilter < TextFilter
def call
dash_filter(@text)
end
private
def dash_filter(text)
text.gsub(':--', "<span class='dash'>――</span>")
end
end
end
end
| true |
20751e6480280ec91822fbbe088e7021abf721c2 | Ruby | dtinth/codehew2016 | /qualification_day2/01_review2[refactored].rb | UTF-8 | 500 | 3.53125 | 4 | [] | no_license | # NOTE: Refactored version
# Uses Array#reduce instead of imperative code and
# always use a Range in the reduction array.
def cont? x, y
y == x.end + 1
end
def succ x, y
(x.begin..y)
end
gets.to_i.times do
data = gets.split[1..-1].map(&:to_i).sort
out = data.reduce [ ] do |a, x|
if !a.empty?... | true |
3f01786e03821e3661072fb2a064030782d50ac7 | Ruby | mh-o/resume | /Undergrad CS1632 Software Quality Assurance/Deliverable 3/transaction_checker.rb | UTF-8 | 1,799 | 3.640625 | 4 | [] | no_license | class TransactionChecker
attr_accessor :people
def initialize
@people = {}
end
def check_transaction(arr)
i = 0
for x in arr
seperate_transactions = split_transactions(x)
if perform_transaction(seperate_transactions, i) == 1
return 1
end
i += 1
end
displa... | true |
432b43921fd78c9c390104b13993940f43e30c43 | Ruby | usman-tahir/rubyeuler | /happy_numbers.rb | UTF-8 | 510 | 3.984375 | 4 | [] | no_license | # http://rosettacode.org/wiki/Happy_numbers
def happy?(number)
while (number != 1) && (number != 89)
number = sum_square_digits(number)
end
number == 1
end
def sum_square_digits(number,accumulator=0)
number < 10 ? accumulator + (number ** 2) : ((number % 10) ** 2) + sum_square_digits(number/10,accumulator... | true |
cfdc5d73660a9a01ef6c7e65712a1f6e8ad7e4bb | Ruby | piloulac/advent-code-2020 | /day_1/part_2.rb | UTF-8 | 420 | 2.953125 | 3 | [] | no_license | # frozen_string_literal: true
file = File.join(File.dirname(__FILE__), 'input.txt')
input = File.open(file).readlines.map(&:chomp).map(&:to_i)
hash = {}
input.each do |val1|
input.each do |val2|
reste = 2020 - val1 - val2
hash[reste] = [val1, val2] if reste.positive?
end
end
input.each do |val|
if hash... | true |
d40070f6fe04dc60adba936affc406dcf2eb5b78 | Ruby | Catamarander/Chess | /board.rb | UTF-8 | 4,129 | 3.640625 | 4 | [] | no_license | require_relative 'pieces/pieces.rb'
class Board
attr_accessor :chess_board, :cursor
def initialize(setup = true)
set_up_game(setup)
@cursor = [0, 0]
end
def self.on_board?(pos)
pos.all? { |coord| (0..7).cover? coord }
end
def move_piece!(from_pos, to_pos)
piece = self[from_pos]
self[... | true |
37baa1dd9b1ed4666125b5a3f65f5f8204a80ec4 | Ruby | artursmolin/Thinknetica-BlackJack | /message_panel.rb | UTF-8 | 1,366 | 3.21875 | 3 | [] | no_license | class MessagePanel
def new_game
p 'D you want to play a new game? Put yes, if you want to continue'
input = gets.chomp
if input != "yes"
p 'Thanks for game!'
exit
end
system('clear')
end
def player_name
p 'Please introduce yourself.'
end
def stop(player, dealer)
p '**... | true |
37ca4175a1cb687e95f10b741e7c91e8d39d9006 | Ruby | NiketaJen/reading-errors-and-debugging-using-pry-hou01-seng-ft-060120 | /lib/pry_debugging.rb | UTF-8 | 66 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def plus_two(num)
(num + 2)
end
binding.pry
| true |
748ec13bbaf69d83be7dce85b740f1c57d9e0d18 | Ruby | usernam3/meta_commit | /features/support/meta_commit_world.rb | UTF-8 | 1,265 | 2.515625 | 3 | [
"MIT"
] | permissive | module MetaCommitWorld
@git_repo_name
@configuration_name
def git_repo_name(repo_name)
@git_repo_name=repo_name
end
def configuration_name(config_name)
@configuration_name=config_name
end
def directory_option
repository_fixtures = File.join(File.dirname(File.dirname(__FILE__)), 'tmp', 'repo... | true |
5d445f6f049fb15c56af0ba1cbb5c151f8d86264 | Ruby | Drewbie345/Library | /my-library.rb | UTF-8 | 2,776 | 3.84375 | 4 | [] | no_license | class Library
attr_accessor :name
# create new library
def initialize(name)
@name = name
@books = []
@book_status = Hash.new
@who_has_book = Hash.new
end
# add new books to library
def add_book(book)
@books << book
@book_status[book.title] = book.get_status
end
# get list of current books
def b... | true |
6db89eeff6a3231683f372c5c5eef8d230fa2b7e | Ruby | rramsden/dev-null-api | /app/models/key.rb | UTF-8 | 219 | 3.265625 | 3 | [] | no_license | require 'prime'
class Key
attr_reader :value
def initialize(value)
@value = value
end
def very_interesting?
primes.include?(@value.to_i)
end
private
def primes
Prime.first(1000)
end
end
| true |
45cd9f433dab65e1a281522eea75511af3b9b024 | Ruby | JBrabson/tee_vee | /lib/character.rb | UTF-8 | 209 | 3.046875 | 3 | [] | no_license | class Character
attr_reader :name,
:actor,
:salary
def initialize(name_pay)
@name = name_pay[:name]
@actor = name_pay[:actor]
@salary = name_pay[:salary]
end
end
| true |
84ea821c1fb6518403af867fee184da1417371a4 | Ruby | yuki3738/codility | /lessons/2-arrays/cyclic_rotation.rb | UTF-8 | 100 | 2.9375 | 3 | [] | no_license | def solution(a, k)
return a if a.empty?
k.times do
i = a.pop
a.unshift(i)
end
a
end
| true |
506a3a4c18d765305de347956102042f20246ac1 | Ruby | kierrakay/activerecord-tvshow-online-web-pt-081219 | /app/models/show.rb | UTF-8 | 616 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Show < ActiveRecord::Base
def self.highest_rating
self.maximum(:rating)
end
def self.most_popular_show
#self.where(rating: highest_rating).first
#self.where(rating: highest_rating) returns aray but we want one instance thats why we have .first above
self.find_by(rating: highest_rating)
end
def sel... | true |
61cfecc8a1937c1db7abb5736bfba1bd2310985b | Ruby | njch5/linked-lists | /lib/linked_list.rb | UTF-8 | 1,399 | 3.671875 | 4 | [
"MIT"
] | permissive | require_relative "node"
class LinkedList
attr_reader :head
def initialize
@head = nil
end
# Time complexity - O(1)
# Space complexity - O(1)
def add_first(data)
@head = Node.new(data, head)
end
# Time complexity - O(1)
# Space complexity - O(1)
def get_first
return @head if @head.nil... | true |
3388d18fda849fe63435bc102214919f22e7d06b | Ruby | schonfeld/middleman-hashicorp | /lib/middleman-hashicorp/releases.rb | UTF-8 | 757 | 2.578125 | 3 | [
"MIT"
] | permissive | require "open-uri"
class Middleman::HashiCorp::Releases
RELEASES_URL = "https://releases.hashicorp.com".freeze
class Build < Struct.new(:name, :version, :os, :arch, :url); end
def self.fetch(product, version)
url = "#{RELEASES_URL}/#{product}/#{version}/index.json"
r = JSON.parse(open(url).string,
... | true |
1b4636fdcfddc9fe398bb2470babf0759ee39b96 | Ruby | shullmb/odin_oop | /mastermind/mind.rb | UTF-8 | 1,878 | 3.484375 | 3 | [] | no_license | module Mastermind
class Board
attr_accessor :pattern, :proposed, :guess
@@options = ["R","G","B","Y","W"]
@@screen_width = 100
def initialize
@pattern = Array.new(4)
@guess = 0
set_pattern
display_obscured_code
puts "Pattern Set!".center(@@screen_width)
puts "\n\n\n\n"
end
... | true |
1b6e940b4c3c6b62f2fe29bc73f6c8dc0e969422 | Ruby | PinkDeer/ruby | /rubyschool/lesson06/app6.rb | UTF-8 | 1,948 | 4.03125 | 4 | [] | no_license | # Какую сумму будем откладывать в месяц:
# Сколько месяцев будем отклыдвать:
# Вывод:
# Накопления за 1 месяц:
# Накопления за 2 месяц:
# Мой вариант:
print "Какую сумму будем откладывать в месяц: "
sum = gets.chomp.to_i
print "Сколько месяцев будем отклыдвать: "
mm = gets.chomp.to_i
1.upto(mm) do |x|
puts "Нако... | true |
b9595fb33c20693a2c307b94c53ad73ca8b2ed37 | Ruby | deanwilson/puppet-ipv4_octet | /lib/puppet/parser/functions/ipv4_octet.rb | UTF-8 | 1,265 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | module Puppet
module Parser
module Functions
newfunction(:ipv4_octet, type: :rvalue, arity: 2, doc: <<-EOD
Returns the given octet of an IP Address.
$first = ipv4_octet('10.11.12.13', 0) # returns 10
$last = ipv4_octet('10.11.12.13', 3) # returns 13
This function does ... | true |
49d36f54b5ef9dee143f50b8de1b99ba29342b6c | Ruby | luanaAlm/Atividades-faculdade | /Ruby/EX2_F.rb | UTF-8 | 200 | 3.734375 | 4 | [] | no_license | puts "Digite o primeiro valor"
a = gets.chomp.to_i
puts "Digite o segundo valor"
b = gets.chomp.to_i
puts "Digite o terceiro valor"
c = gets.chomp.to_i
soma = a + b + c
if soma >= 100
puts soma
end
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.