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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
dca234dbfa5d29242d306532f9d6b9b41dd89e30 | Ruby | alliestehney/world_cup | /lib/Team.rb | UTF-8 | 545 | 3.609375 | 4 | [] | no_license | class Team
attr_accessor :country, :eliminated, :players
def initialize(country)
@country = country
@players = []
@eliminated = false
end
def add_player(player)
@players << player
return @players
end
def eliminated?
return @eliminated
end
... | true |
12c7f45051a0c14eaada05084a61fa41f5535006 | Ruby | tejasdev23/ruby-on-rails-course2 | /module4/i_reviewed/db/seeds.rb | UTF-8 | 791 | 2.6875 | 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | true |
f3b7f64d1374dd1638beb415bf225c9a296e99fb | Ruby | malak-dev/TwO-O-Player-Math-Game | /player.rb | UTF-8 | 215 | 3.203125 | 3 | [] | no_license | class Player
def initialize name
@name = name
@lives=3
end
def name
@name
end
def get
@lives
end
def lives(points)
@lives +=points
end
def dead?
@lives <= 1
end
end | true |
eaa2eb22387f34a36ada41a17c32f0e7873ff21a | Ruby | fadynaffa3/bitmap_editor | /lib/validator.rb | UTF-8 | 852 | 2.796875 | 3 | [] | no_license | module Validator
def validate_size!(constant, finish, direction)
valid = if direction == 'V'
@image.length > finish && @image[0].length > constant
else
@image.length > constant && @image[0].length > finish
end
raise ValidationError, 'out of bound' unless val... | true |
c6f4d950d9c1443b17a7c519f631910acfb7fd42 | Ruby | adamdawkins/mavenlink-ruby | /lib/mavenlink/list.rb | UTF-8 | 1,260 | 2.515625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Mavenlink
class List
include Enumerable
attr_accessor :data
attr_reader :page_number
attr_reader :page_count
def initialize(klass, response, options = {}, params = {})
@meta = response["meta"]
@klass = klass
@params = params
@page_nu... | true |
931ffd1e7c24a50644526a5c3d69d1e0979cd272 | Ruby | oguzpol/ruby-tutorial | /p-method.rb | UTF-8 | 105 | 2.859375 | 3 | [] | no_license | puts "POM"
p "Mehmet Oğuz POLAT"
puts "Hi there, this is a
big line break"
p "Hi there, this is a
big line break"
| true |
5bb6426e3c9eae281d7c43dd14d7968f9627ad5f | Ruby | hasandeveloper/ecommerce-code | /app/models/order.rb | UTF-8 | 1,163 | 2.578125 | 3 | [] | no_license | class Order < ApplicationRecord
has_many :order_line_items
belongs_to :address
belongs_to :user
validates_presence_of :order_number, :order_date, :user_id, :total, :address_id
before_validation :set_number_date_total
after_create :move_to_order_line_items
after_create :empty_cart_line_items
after_cr... | true |
e9b93cd160e684f402428e8b31ce62e48f548af8 | Ruby | darthdeus/ghc-modi-wrapper | /bin/ghc-modi-wrapper | UTF-8 | 2,339 | 2.921875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require "socket"
require "fileutils"
PID_FILE = ".ghc-modi-wrapper.pid"
SOCKET_FILE = ".ghc-modi-wrapper.sock"
def cleanup_temp
FileUtils.rm_f(PID_FILE)
FileUtils.rm_f(SOCKET_FILE)
end
def running_pid
if File.exists?(PID_FILE)
File.read(PID_FILE).strip.to_i
else
# TODO - do this i... | true |
4c395ed1552403787eb65ba7b14b8e09db9d95e5 | Ruby | STCTbone/tictactoe | /lib/tasks/generate_moves.rake | UTF-8 | 430 | 2.78125 | 3 | [] | no_license | task generate_moves: :environment do
game = Game.create
next_player = (game.player_turn == 'X' ? 'O' : 'X')
game.squares.each_with_index do |square, position|
unless square
next_squares = game.squares.dup
next_squares[position] = game.player_turn
next_game = Game.create(next_p... | true |
e29b882f2d95c21d21d775ae923750ba1cf00b46 | Ruby | dariocravero/pendragon | /lib/pendragon/engine/recognizer.rb | UTF-8 | 1,706 | 2.734375 | 3 | [
"MIT"
] | permissive | module Pendragon
class Recognizer
def initialize(routes)
@routes = routes
end
def call(request)
pattern, verb, params = parse_request(request)
raise_exception(400) unless valid_verb?(verb)
fetch(pattern, verb){|route| [route, params_for(route, pattern, params)] }
end
priv... | true |
1eb5fa4d512761a87e221bc3bae89a3fa6d47087 | Ruby | rafaj777225/Cursocodeacamp | /Newbie/conceptW.rb | UTF-8 | 5,798 | 3.390625 | 3 | [] | no_license | Inheritance
Es una relacion entre 2 clases y tienen una jerarquia en donde las
clases hijas heredan comportamientos(metodos y atributos ) de la clase padre y a su vez estas clases hijas pueden crear comportamientos propios
=begin
class Mamifero
def respirar
puts 'inspirar, espirar'
end
end
# el símbolo < i... | true |
48205f3778c673bda577396dd982b0642d189487 | Ruby | MaxMEllon/sandbox | /yukicoder/525.rb | UTF-8 | 141 | 2.890625 | 3 | [] | no_license | h, m = gets.chomp.split(':').map(&:to_i)
m += 5
if m >= 60
m %= 60
h += 1
end
if h >= 24
h %= 24
h = 0
end
printf "%02d:%02d", h, m
| true |
1d24575e5141d609fa20deaaf03720516499cf7c | Ruby | Lasiorhine/grocery-store | /lib/online_order.rb | UTF-8 | 3,709 | 3.203125 | 3 | [] | no_license | require 'csv'
require 'awesome_print'
require_relative '../lib/order'
module Grocery
class OnlineOrder < Grocery::Order
attr_reader :id, :customer_id, :status
attr_accessor :products
def initialize(id, products, customer_id, status)
super(id, products)
@customer_id = customer_id
@statu... | true |
e3572cea78ac1883966c2522c7ced56876f71f28 | Ruby | GuiMarcelino/onebitcode | /IteracaoEmCollections/select_each_hash.rb | UTF-8 | 167 | 3.34375 | 3 | [] | no_license | hash = {zero: 0, um: 1, dois: 2, tres: 3}
puts 'Selecione keys com valor maior que 0'
selection_key = hash.select do |key, value |
value > 2
end
puts selection_key | true |
9c2b7f02528033934ed2e8d16379f49d3bf0e778 | Ruby | ATung01/sinatra-nested-forms-web-060517 | /app/models/ship.rb | UTF-8 | 263 | 2.90625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Ship
attr_reader :name, :type, :booty
@@all = []
def initialize(stats)
@name = stats[:name]
@type = stats[:type]
@booty = stats[:booty]
@@all << self
end
def self.all
@@all
end
def self.clear
@@all.clear
end
end
| true |
570da22460455c410fdc9274454f1a197e03f728 | Ruby | davis-campbell/ruby | /web-projects/twitterbot.rb | UTF-8 | 2,285 | 3.140625 | 3 | [] | no_license | require 'jumpstart_auth'
require "bitly"
class MicroBlogger
attr_reader :client
def initialize
puts "Initializing MicroBlogger"
@client = JumpstartAuth.twitter
end
def run
puts "Welcome to the JSL Twitter Client!"
command = ''
while command[0] != 'q'
printf 'enter command: '
... | true |
8c018f9ef55557bb891478c03499837f9ed929f8 | Ruby | bencappello/Exercises | /minesweeper/minesweeper.rb | UTF-8 | 6,050 | 3.8125 | 4 | [] | no_license | require 'yaml'
class Tile
attr_accessor :flagged, :bomb, :revealed
# the tile needs to know its coordinates
# and calculate its number on the fly
def flagged?
@flagged
end
def initialize(board, position)
@flagged = false
@bomb = false
@revealed = false
@board = board
@position ... | true |
cb856128971e210745b21657b1135a77d12eb8a8 | Ruby | middledeveloper/Thinknetica | /lesson9/wagon.rb | UTF-8 | 1,121 | 2.953125 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'manufacturer'
require_relative 'accessors'
require_relative 'validation'
class Wagon
include Accessors
include Manufacturer
include Validation
attr_reader :number, :type
validate :manufacturer, :presence
validate :number, :presence
validate :type, :prese... | true |
e308e2414ac00d735a65790e0865a5c894f03d3a | Ruby | RobertoCarrilloAvila/maraton | /Modelo.rb | UTF-8 | 501 | 3.453125 | 3 | [] | no_license | class Game
attr_reader :cartas
def initialize
@cartas = []
@index=0
load_cards
end
private
def load_cards
arr_of_arrs = CSV.read("respuestas.csv")
arr_of_arrs.each do |array|
pregunta = array[0]
respuestas = array[1]
@cartas << Card.new(pregunta, respuesta)
end
end
end
class Card
at... | true |
ad235f5e6439f54d071553899468dd89b3318ce8 | Ruby | velaluqa/gitdeploy | /lib/gitdeploy/command.rb | UTF-8 | 502 | 2.578125 | 3 | [] | no_license | module Gitdeploy
class Command
class << self
def flags(flags = nil)
short = (flags || []).select { |a| a.to_s.length <= 1 }
long = (flags || []).select { |a| a.to_s.length > 1 }
short.map!(&:to_s)
long.map! { |flag| "--#{flag} "}
"#{'-' + short.join unless short.em... | true |
16f596726d2656f7de9e2c85a1762f2203991ba8 | Ruby | raffo1234/Ruby | /method.rb | UTF-8 | 48 | 2.859375 | 3 | [] | no_license | def double(val)
val * 2
end
puts double(2)
| true |
7fc943238615f5f8f5417e11ad9aefdd6b89c2da | Ruby | jbgutierrez/delicious_api | /lib/delicious_api/tag.rb | UTF-8 | 1,276 | 2.859375 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + '/base'
module DeliciousApi
class Tag < Base
# Tag name
attr_accessor :name
# An alias for the tag name
alias :tag :name
# Number of times used
attr_reader :count
##
# Tag initialize method
# ==== Parameters
# * <tt>name</tt> - Tag name
... | true |
56688f4484334b62f8e0bda47bd39c19fea4dfdf | Ruby | eva-barczykowska/Ruby | /Blocks_exercises.rb | UTF-8 | 319 | 4.03125 | 4 | [] | no_license | [3, 5, 7, 9].each { |number| puts number**2}
puts
evens = [2, 4, 6, 8, 10]
evens.each { |number| puts number**3}
puts
colors = ["magenta", "hazel", "turquoise"]
statements = colors.map { |color| puts "#{color} is a great color!"}
puts
5.times do |index|
puts index
puts "Let's move on to the next loop."
end
| true |
19a19f65924ca6ccd6808f0806463eea3025b538 | Ruby | daltonrenaldo/Developer-Applicant-Exercise | /simple_refactoring_exercise/template_spec.rb | UTF-8 | 614 | 2.78125 | 3 | [] | no_license | require_relative 'template'
describe Template do
include Template
before(:each) do
@alt = '56789-012'
end
it "should substitute %CODE% and %ALTCODE% in the template" do
# We only want this test to fail if the problem is with it,
# and not with a method that it's calling.
# So, we stub get_altco... | true |
419c85dd1c31177be1688a6f706ff4df80092ed7 | Ruby | adharmad/ruby-examples | /basics/string_methods.rb | UTF-8 | 1,658 | 4.3125 | 4 | [] | no_license | #!/usr/local/bin/ruby -w
# some useful methods on strings
# Run as:
# ruby string_methods.rb
# All string methods are documented here:
# http://corelib.rubyonrails.org/classes/String.html
#
# As with other ruby methods, a method ending in "!" is destructive
# and will alter the actual object state
puts "hello_wo... | true |
5d0047d908401bbe762b599048af90fa712fd52f | Ruby | fuvzn121/aoj-ruby | /introduction_to_programming/print_rectangle.rb | UTF-8 | 268 | 3.140625 | 3 | [] | no_license | # frozen_string_literal: true
h_arr = []
w_arr = []
loop do
h, w = gets.split.map(&:to_i)
break if h == 0 && w == 0
h_arr.push(h)
w_arr.push(w)
end
h_arr.zip(w_arr) do |h, w|
h.times do
w.times do
print '#'
end
puts ''
end
puts ''
end
| true |
0a004370034b5f4953547b617f85eb372a91a44a | Ruby | DigitPaint/roger_eslint | /test/lint_test.rb | UTF-8 | 3,066 | 2.84375 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + "/../lib/roger_eslint/lint.rb"
require "test/unit"
require "roger/testing/mock_project"
# Fake tester to pass into the linter plugin
class TesterStub
attr_reader :messages
attr_writer :files
def initialize
@messages = []
@files = []
end
def project
# Creating a ... | true |
51285d02bdbce7cac1b691a75da04e11cd41ded5 | Ruby | pockyhao518/AA_Homeworks | /W4D1/In class/KnightPathFinder/PolyTree.rb | UTF-8 | 1,672 | 3.703125 | 4 | [] | no_license | class PolyTreeNode
attr_accessor :value, :parent, :children
def initialize(value)
@value = value
@parent = nil
@children = []
end
def parent=(node)
if !node.nil?
if !self.parent.nil?
self.parent.children.delete(self)
en... | true |
6c6e6cb068f874924014dd933ef52646f24828b2 | Ruby | jsdelivrbot/Semaine-0 | /day5/exo_11.rb | UTF-8 | 192 | 3.734375 | 4 | [] | no_license | puts "Donne moi un nombre"
user_number = gets.chomp
u = user_number.to_i
puts "Je vais afficher 'Salut, ça farte?' #{user_number} fois"
while (u > 0)
puts "Salut, ça farte?"
u = u - 1
end | true |
932b924ea8efd7759b5760b6c47851f82b2e2a0b | Ruby | hooptie45/xiki | /menu/itunes.rb | UTF-8 | 2,300 | 2.84375 | 3 | [
"MIT"
] | permissive | module Xiki
class Itunes
MENU = "
- .play/
- .pause/
- .next/
- .previous/
- .artists/
- .songs/
- .current/
- .playlist/
- api/
> Play a song
@ Itunes.songs 'Thunderstorm'
|
- docs/
| Play specific song
@itunes/so... | true |
c7b171e121447e68308032735703e44eeacad049 | Ruby | kalebealvs/webmotors | /app/services/web_motors_request_api.rb | UTF-8 | 553 | 2.515625 | 3 | [] | no_license | class WebMotorsRequestAPI
URI_MANUFACTURERS = URI('https://www.webmotors.com.br/carro/marcas')
URI_MODELS = URI('https://www.webmotors.com.br/carro/modelos')
def self.get_makes
makes = JSON.parse Net::HTTP.post_form(URI_MANUFACTURERS, {}).body
makes.each { |make| makes.delete make if make['Nome'] == ''}
... | true |
c42915986c7df3fbc2eec6874962c61b09c5d91a | Ruby | nwsmith/pawnzilla | /engine/src/geometry/coord.rb | UTF-8 | 3,662 | 3.46875 | 3 | [] | no_license | #
# Copyright 2005-2009 Nathan Smith, Ron Thomas, Sheldon Fuchs
#
# 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 requi... | true |
11e29687b327b06b5ed4c4c167eb81600e9fb1fc | Ruby | pmichaeljones/eloquent_ruby | /document.rb | UTF-8 | 230 | 3.671875 | 4 | [] | no_license | # turn "The" into "ehT"
# turn "Patrick" into "kcirtaP"
def reverse_string(string)
new_string = ""
until string.length == 0 do
last_letter = string[-1]
string.chop!
new_string << last_letter
end
new_string
end
| true |
877ff7c97a35cea5abc8e938176a5565b088f0e0 | Ruby | JupiterLikeThePlanet/code_challenges | /ruby_todo/udacitask.rb | UTF-8 | 870 | 3.078125 | 3 | [
"MIT"
] | permissive | require_relative 'task_starter.rb'
require 'pp'
require 'date'
# Creates a new todo list
todo = TodoList.new('Stuff to do')
# Add four new items
todo.add_item('Buy Apples')
todo.add_item('Brush Teeth')
todo.add_item('Do Homework')
todo.add_item('Wash Car')
# Print the list
todo.print_list
# # Delete the first item
t... | true |
1331fedf3c463ef5acd429df3a20e1ed299c2b1b | Ruby | nickzaf95/ruby-oo-complex-objects-school-domain-london-web-021720 | /lib/school.rb | UTF-8 | 891 | 3.40625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # code here!
class School
@@all = []
def initialize(name)
@name = name
@@all << self
end
def roster
if @roster
return @roster
else
@roster = {}
return @roster
end
end
def add_student(name, x)
if @roster
... | true |
9868a56d3d6804da2ca3cfe52b49e611380da378 | Ruby | anoam/meeting_schedule | /spec/lib/schedule_spec.rb | UTF-8 | 1,889 | 2.578125 | 3 | [] | no_license | # frozen_string_literal: true
require 'rspec'
require 'schedule'
require 'meeting'
describe Schedule do
describe '#to_s' do
let(:first_room_morning_meetings) do
[
Meeting.new('All Hands meeting', 60),
Meeting.new('Marketing presentation', 30),
Meeting.new('Product team sync',... | true |
b0e88b0d5781d083522aebee2505fd69d0d5181c | Ruby | kkcook/ls_ruby_old | /small_problems/easy1/easy_1_prob_4.rb | UTF-8 | 896 | 4.09375 | 4 | [] | no_license | # frozen_string_literal: true
# Prob: write a method that counts the number of occurrences of each element in given array
# Input: array, output: hash
# Edge cases: empty array...
# Datastructure: array to hash
# Algorithm: iterate through each and see if key exists, if so, add one to count, otherwise create key and s... | true |
23791f5e9f6b907ae716d82decb3ef3518f1a5a8 | Ruby | Rexman17/oo-kickstarter-nyc-web-100818 | /lib/backer.rb | UTF-8 | 521 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Phong
require 'pry'
class Backer
attr_accessor :name, :backed_projects
def initialize(name)
@name = name
@backed_projects = []
end
def back_project(project)
@backed_projects << project
project.backers << self
end
# also adds the backer to the project's backers array
# adding an insta... | true |
9a01d9d3c1360bf709443e3035de78748ea24184 | Ruby | jleeman/blackjack-sinatra | /main.rb | UTF-8 | 4,870 | 3.171875 | 3 | [] | no_license | require 'rubygems'
require 'sinatra'
# require 'shotgun'
require 'pry'
set :sessions, true
# constants
BLACKJACK_VALUE = 21
DEALER_HIT_VALUE = 17
# define helper methods, can also use modules for this
helpers do
def init_deck
suits = ['Spades', 'Clubs', 'Diamonds', 'Hearts']
values = ['Ace', '2', '3', '... | true |
7b913d94782178779a4673ba587f9cdf97f255f5 | Ruby | marsh-sb/Ruby_practice | /Lesson13_03.rb | UTF-8 | 171 | 3.484375 | 3 | [] | no_license | class Student
def initialize(name)
@name = name
end
def avg(math, english)
p @name,(math + english) / 2
end
end
a001 = Student.new("Sato")
a001.avg(30,70) | true |
a211a7b45b610b46033aad985a38cf3472e8ca3f | Ruby | rubsav/learn_ruby | /01_temperature/temperature.rb | UTF-8 | 215 | 3.296875 | 3 | [] | no_license | def ftoc(fahrenheit)
(fahrenheit - 32)*(5/9.0)
# if farenheit ==212
# 100
# elsif farenheit ==98.6
# 37
# elsif farenheit==68
# 20
# else
# 0
# end
end
def ctof(celsius)
(celsius * 9/5.0)+(32)
end
| true |
6aff534784a97a74b9ed75acf2905eae5515eece | Ruby | Ohnao/pair_pro_class | /prac_test/t/year_converter_basic.rb | UTF-8 | 13,141 | 2.5625 | 3 | [] | no_license | $LOAD_PATH.push('lib')
require 'minitest/autorun'
require 'year_converter'
class YearConverterTest < Minitest::Test
def setup
@yc = YearConverter.new
end
# 令和テスト
def test_yc_1
assert_equal @yc.guess_ad_year("令和1年"), 2019, "令和1年は2019年"
end
def test_yc_2
assert_equal @yc.guess_ad_year("令和2年"), 202... | true |
fa232670a9df60984b27f2c1246098c437c1f018 | Ruby | ogz00/angularjs_with_rails | /app/helpers/user_scores_helper.rb | UTF-8 | 2,313 | 2.5625 | 3 | [] | no_license | module UserScoresHelper
def self.calculate_user_scores(*args)
year = Time.now.year
@all_answers = Answer.all
user_ids = []
this_year_answers = []
@all_puzzles = []
@all_answers.each do |answer|
if answer.puzzle.year == year
this_year_answers << answer
end
end
... | true |
27e72a1bdf9d523acdb75ba1f9726bd5fe77ce3c | Ruby | cheeseandpepper/euler_solutions | /euler_14.rb | UTF-8 | 1,318 | 3.96875 | 4 | [] | no_license | # The following iterative sequence is defined for the set of positive integers:
# n → n/2 (n is even)
# n → 3n + 1 (n is odd)
# Using the rule above and starting with 13, we generate the following sequence:
# 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
# It can be seen that this sequence (starting at 13 and finishing... | true |
7262fb2f42258e5baa933c76802b8e5354379d65 | Ruby | Yoshyn/interviews | /get_around/backend/level3/models/rental.rb | UTF-8 | 667 | 2.546875 | 3 | [] | no_license | # frozen_string_literal: true
require "active_record"
require_relative '../lib/extensions/active_record/jsonable_scope'
require_relative "../services/discouts/per_day"
require_relative "../services/commission"
class Rental < ActiveRecord::Base
jsonable_scope(only: :id, methods: [:price, :commission])
belongs_to... | true |
d87244fcdcacb0c5c0b1db092ff75c09a0936ad8 | Ruby | sma/rainbowsend | /entity.rb | UTF-8 | 614 | 2.796875 | 3 | [
"MIT"
] | permissive | # entity.rb - Rainbow's End is an empire building strategy PBEM game
# rules (C)2001 Russell Wallace, source code (C)2001 Stefan Matthias Aust
class Entity
attr_accessor :id, :name
attr_reader :orders, :events
def initialize
@orders = []
@events = []
end
def nameid
"#{@name} [#{@id}]"
end... | true |
e55d64af717dec3edba44b575ec3c7cfb622950c | Ruby | JennicaStiehl/road_race | /test/race_test.rb | UTF-8 | 5,007 | 2.8125 | 3 | [] | no_license | require './test/test_helper'
require './lib/race'
require './lib/team'
require './lib/racer'
class RaceTest < Minitest::Test
def test_it_exists
salida_crit = Race.new("Salida Criterium", "SW 3", 25, 5, 1, "60")
assert_instance_of Race, salida_crit
end
def test_it_has_attributes
salida_crit = Race.... | true |
e12ff81becebad3f78f301ab3dd9b09a6797c9a3 | Ruby | nanma80/mode-wca | /lib/local/tsv_file.rb | UTF-8 | 2,008 | 2.6875 | 3 | [] | no_license | module ModeWca
module Local
class TsvFile < LocalFile
def columns
return @columns_cache if @columns_cache
puts "Extracting columns from #{path}"
column_names = []
column_types = []
first_row = true
File.open(path).each do |line|
row = line.chomp.s... | true |
da9f6630021f3d1d4393c1b149d1d4ab5bc234c7 | Ruby | daxadax/quotes | /spec/services/kindle_importer_spec.rb | UTF-8 | 2,210 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
class KindleImporterSpec < ServiceSpec
let(:user_uid) { 23 }
let(:autotagger) { FakeAutotagService }
let(:input) { File.read("spec/support/sample_kindle_clippings.txt") }
let(:kindle_importer) do
Services::KindleImporter.new(user_uid, input, autotagger)
end
let(:result)... | true |
822c56436656eced60f5886339e231de1bf582ed | Ruby | Felipeandres11/desafioruby1 | /CLASES/company.rb | UTF-8 | 571 | 3.421875 | 3 | [] | no_license | require 'date'
class Company
def initialize(name, *payments)
@name = name
@payments = payments.map {|date| Date.parse(date)}
#print @payments
end
def payments_before(filter_date)
@payments.select {|date| date < filter_date}
end
def payments_after(filter_date)
@payments.select {|dat... | true |
0807b5be02478ae59dfa77636b977b2ea0585166 | Ruby | raphsutti/ZendeskTicketViewer | /authenticate.rb | UTF-8 | 637 | 2.96875 | 3 | [] | no_license | require 'net/http'
require 'uri'
require 'json'
require 'openssl'
def authenticate(username, password)
uri = URI.parse("https://firstorder.zendesk.com/api/v2/tickets.json")
Net::HTTP.start(uri.host, uri.port,
:use_ssl => uri.scheme == 'https',
:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|
requ... | true |
ac6fb20a53064897837ff2a0d51a8af146f31745 | Ruby | chris-ma/WDI_SYD_7_NEW | /chris/w01/d05/happytails/lib/shelter.rb | UTF-8 | 590 | 3.1875 | 3 | [] | no_license | module Shelter
# Define Animal as a class
require_relative = "animal"
require_relative = "client"
class Shelter
def relationship
Animal.new("Fido",2,"male","dog" )
end
puts "a | list animals"
puts "c | list clients"
puts "q | quit"
response = gets.strip
while response != 'q'
... | true |
81bba0e257ce7b263fc25aee75c694ac06f9d6eb | Ruby | dremerten/Ruby_Intro | /variable_constant_scope.rb | UTF-8 | 32,218 | 4.25 | 4 | [] | no_license | # to load into irb use: require './variable_constant_scope.rb'
CONSTANT_OUT = 9 # outer constant
class TestClass
attr_accessor :localVar, :iVar, :name, :email
CONSTANT_CLASS = 10
@@classVar = 11
def initialize
@iVar = 12 # initialized at creation of new class object
end
def meth1 # will setup localVar... | true |
2a4d1e4ec1e654f8bcbd9f3ede708e89ad981061 | Ruby | gonyolac/ls_ruby_course | /ruby_more_topics/weekly_challenges/binary_search_tree.rb | UTF-8 | 185 | 3.125 | 3 | [] | no_license | class Bst
def self.new(data)
[data]
end
def self.insert(data)
end
def self.data
end
def self.left
end
def self.right
end
end
four = Bst.new(4)
p four.data | true |
0390e3770999d681459838a08784c0f4a806d4f3 | Ruby | vy-labs/elasticsearch-dsl-builder | /lib/elasticsearch_dsl_builder/dsl/search/queries/term.rb | UTF-8 | 899 | 2.59375 | 3 | [
"MIT"
] | permissive | module ElasticsearchDslBuilder
module DSL
module Search
module Queries
class Term < Query
def initialize(field = nil, value = nil)
@type = :term
field(field) unless field.nil?
value(value) unless value.nil?
super()
end
de... | true |
b7faa0de1e6728ebfb5396d80b889c0ab4a14458 | Ruby | thegeekbrandon/rubyScripts | /Ruby-Scripts/exerciseOne.rb | UTF-8 | 162 | 2.734375 | 3 | [] | no_license | # Lesson 18: coding exercise one
puts "##########################"
puts "# Coded by Brandon Haulk #"
puts "# Ruby programming guru #"
puts "##########################" | true |
90135f3a813f07106757630d06312c7b07defac9 | Ruby | tebriel/aoc2020.rb | /test/day04/main_test.rb | UTF-8 | 2,077 | 2.6875 | 3 | [] | no_license | # frozen_string_literal: true
require 'minitest/autorun'
require_relative '../../lib/day04/main'
describe 'PassportPart1' do
def setup
@passport = PassportPart1.new
end
describe '#add_line' do
it 'adds a line to make a valid passport' do
@passport.add_line 'ecl:gry pid:860033327 eyr:2020 hcl:#ffff... | true |
7768f4e129a2e28c0b78641dca5c3bdf41567af7 | Ruby | michalberg/slibujeme | /spec/models/municipality_spec.rb | UTF-8 | 1,626 | 2.625 | 3 | [] | no_license | # encoding: utf-8
require 'spec_helper'
describe Municipality do
it "should form a tree" do
parent = create(:municipality)
children = []
3.times do
children << create(:municipality, :parent_id => parent.id)
end
parent.has_children?.should be_true
parent.children.should =~ children
... | true |
e1952ffce72ca771eb79f43de466884467799729 | Ruby | torresga/launch-school-code | /exercises/101-109_small_problems/easy_4/number_to_string.rb | UTF-8 | 2,871 | 4.75 | 5 | [] | no_license | # Convert a Number to a String!
# In the previous two exercises, you developed methods that convert simple numeric strings to signed Integers. In this exercise and the next, you're going to reverse those methods.
# Write a method that takes a positive integer or zero, and converts it to a string representation.
# Yo... | true |
eaf756c092869cac268cb7145a5fa97e17b39061 | Ruby | connectfoursome/connect_four | /lib/bot_interface.rb | UTF-8 | 1,419 | 3.46875 | 3 | [] | no_license | require_relative 'board.rb'
require_relative 'twitter_bot.rb'
class BotInterface
attr_reader :board
def initialize(board_string, opponent)
@board = Board.from_twitter(board_string)
p @board
@opponent = opponent
p @opponent
end
def tweet_message
bot_board
if game_over?
"#{reply} ... | true |
3c61e422ad2eda25b2d18265b7711bb0662e038b | Ruby | isabella232/viget-deployment | /lib/database/dump_file.rb | UTF-8 | 637 | 2.71875 | 3 | [
"MIT"
] | permissive | class Database
class DumpFile
def initialize(filename)
@filename = filename
end
def replace_extension(filename, extension)
filename.sub(/\.\w+/, ".#{extension}")
end
def archive_filename
replace_extension(@filename, 'zip')
end
def export_filename
replace_extensi... | true |
8e1c60b7d5372522cd485f111e32027ba149eb38 | Ruby | Tuxt/Ruby-Cipher-4 | /RC4.rb | UTF-8 | 685 | 3.34375 | 3 | [] | no_license | # Clase de RC4
class RC4
def initialize(key)
# Variables 'i' y 'j' para la salida (PRGA). Las de KSA son locales
@i = 0
@j = 0
# KSA ---------------------------------------: START
@key = key.bytes
@S = Array.new(256)
@S.each_index do |index|
@S[index] = index
end
key_len = @key.count
j =... | true |
46ab006b2593cd448a252b4cdaa474eb8853ee6d | Ruby | eva-barczykowska/Ruby | /arrays/slicing.rb | UTF-8 | 373 | 4.3125 | 4 | [] | no_license | #array/string slicing
#arr[startIndex..EndIndex] - includes the last element
#arr[startIndex...EndIndex] - ... excludes the last element
arr = ["ferrari", "fiat", "82-500", "opel", "toyota"]
print arr
puts
print arr[4] #it is not an array, just a string
puts
print arr[0..1]
puts
print arr[0...1]
puts
print arr[4]
put... | true |
1fe1ec109d9cec87d899c3abce2348be0e1b3d20 | Ruby | moneyadviceservice/cms | /spec/models/table_captioner_spec.rb | UTF-8 | 1,225 | 2.765625 | 3 | [
"MIT"
] | permissive | describe TableCaptioner do
context 'when there is no table' do
let(:source) { '<p>hello</p>' }
subject do
described_class.new(double, source)
end
it 'does nothing' do
expect(subject.call).to eql(source)
end
end
context 'when there is a table' do
context 'and there is a parag... | true |
ac8c12f2178ed00d9057bd1a2d597e798cd4f3b0 | Ruby | kallus/TrafficSim | /view/vector.rb | UTF-8 | 11,299 | 2.734375 | 3 | [] | no_license | require 'rvg/rvg'
include Magick
RVG::dpi = 144/8
class Vector
class << self
def draw!(cars, tile_grid, time)
return if File.exists?("output/#{("%06.2f" % [time]).sub(".", "")}.gif")
grid_size = [tile_grid[0].length,tile_grid.length]
size = [grid_size[0]*Tile.width,grid_size[1]*Tile.height]
... | true |
f4c08290cc9d4e93b549f0e0befb95fd827a5e6a | Ruby | robertleelittleiii/silverweb_cms | /app/uploaders/image_uploader.rb | UTF-8 | 6,562 | 2.609375 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require "image_tools"
class ImageUploader < CarrierWave::Uploader::Base
# Include RMagick or ImageScience support:
include CarrierWave::RMagick
# include CarrierWave::ImageScience
include ImageTools
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
... | true |
8eb7dbb92f67a99d745b90c37f51d92bce60930b | Ruby | jessiegibson/looping-break-gets-001 | /levitation_quiz.rb | UTF-8 | 214 | 3.421875 | 3 | [] | no_license |
def levitation_quiz
#your code here
loop do
puts "What is the spell that enacts levitation?"
answer = gets.chomp
break if answer == "Wingardium Leviosa"
end
puts "You passed the quiz!"
end
| true |
bc05e55e0294137bbc0b54cd5c4733095da64db2 | Ruby | Kojack8/Ruby_odin_projects | /binary_search_tree/node.rb | UTF-8 | 269 | 2.984375 | 3 | [] | no_license | # frozen_string_literal: true
# creates and modifies nodes to be used within the balanced binary search tree
class Node
def initialize(data, left = nil, right = nil)
@data = data
@left = left
@right = right
end
attr_accessor :left, :right, :data
end
| true |
39485ecc4419cb887602a9628a08e6a18014ac56 | Ruby | wojciech-stelmaszewski/projecteuler | /26.rb | UTF-8 | 2,573 | 3.34375 | 3 | [] | no_license | MAX_CYCLE_OFFSET = 10000
MAX_CYCLE_LENGTH = 1000 #For 1/p max cycle length cant be larger than (p-1)
MAX_ZERO_SECTION_LENGTH = 100
CYCLE_DETECTION_THRESHOLD = 7
class Integer
def only_2_or_5_are_proper_dividers?
n = self
while n > 1 do
previous_n = n
n /= 2 if n%2 == 0
n /= 5 if n%5 == 0
... | true |
6b8230d83f2be572e479b78867d9e619818a2a57 | Ruby | chef/chef | /chef-utils/lib/chef-utils/parallel_map.rb | UTF-8 | 4,756 | 2.796875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
#
# Copyright:: Copyright (c) Chef Software Inc.
# License:: Apache License, Version 2.0
#
# 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.apach... | true |
02525870d07d317b1f972f18d122b305a9ce9eb9 | Ruby | xflagstudio/zenform-rb | /lib/zenform/commands/apply/base.rb | UTF-8 | 2,420 | 2.703125 | 3 | [
"MIT"
] | permissive | module Zenform
module Commands
module Apply
class Base
attr_reader :client, :project_path, :new_contents, :shell
MESSAGE_SKIPPED = "Skipped to create %{count} %{content_name} because they are already created."
MESSAGE_SUCCESS = "Success to create %{content_name}(slug: %{slug})!"
... | true |
9ad7c36ed6ea063797c538e35b974947d2aaea97 | Ruby | ISABELLA888/kwk-l1-mothers-day-methods-kwk-students-l1-port-072318 | /mothers_day.rb | UTF-8 | 188 | 3.609375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | ## Define your method, mothers_day, below. Go through the README and update your method as needed!
def mothers_day
mom = gets.strip
puts "Happy Mother's day #{mom}"
end
mothers_day
| true |
a4f18bec27e4bc8ed12f78e8abff3ca26c3642ca | Ruby | Macro80-20/oo-counting-sentences-london-web-career-031119 | /lib/count_sentences.rb | UTF-8 | 460 | 3.390625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class String
def sentence?
self.end_with?(".")
end
def question?
self.end_with?("?")
end
def exclamation?
self.end_with?("!")
end
def count_sentences
nu_of_setence = self.split(/[.?!]/).reject {|string| string.empty?}.length
end
end
# def sentence?(string)
# if string[s... | true |
d77935462fd8e9541b7b18e93d7b65a56708f8f6 | Ruby | KerryKDiehl/test-first-ruby | /lib/14_array_extensions.rb | UTF-8 | 1,072 | 3.78125 | 4 | [] | no_license | class Array
def sum
sum_total = 0
self.each do |x|
sum_total += x
end
sum_total
end
def square
self.map do |x|
x * x
end
end
def square!
self.each_with_index do |x,i|
if x > 0
self[i] = x * x
end
end
end
def my_uniq
unique = []
sel... | true |
448537d785371f3f67e12db77055d215f52694a0 | Ruby | dot-Sean/src | /rb/array.rb | UTF-8 | 97 | 2.671875 | 3 | [] | no_license | #!/usr/bin/ruby
# -*- coding: utf-8 -*-
a = []
a.push("Hello")
a.push("World")
puts a, a.length
| true |
a981ac3428173d6b8963617829463aa9406f97b9 | Ruby | felkh/image_blur | /image_blur_2.rb | UTF-8 | 1,292 | 3.796875 | 4 | [] | no_license | class Image
def initialize(array)
@image = array
end
def output_image
@image.each do |row|
puts row.join
end
end
def get_ones
ones = []
@image.each_with_index do |img_array, img_array_index|
img_array.each_with_index do |img_array_item, img_array_item_index|
if img_ar... | true |
ef4e678dc9a0f557eaf36f86f92b98d2a40e761c | Ruby | SilverNightFall/Introduction-to-Programming-with-Ruby | /lab_in_word.rb | UTF-8 | 274 | 3.03125 | 3 | [] | no_license | def lab_in_word?(word)
if /lab/i.match(word)
puts "Lab is in the word #{word}"
else
puts "Lab is not in the word #{word}"
end
end
lab_in_word?("laboratory")
lab_in_word?("experiment")
lab_in_word?("Pans Labyrinth")
lab_in_word?("elaborate")
lab_in_word?("polar bear") | true |
ffa7bb7f1e84ba35057f08aa4c82fddfc730551b | Ruby | kamalpandey/phone_number_to_words_combinations | /lib/phone_number_to_words/phone_number_to_words.rb | UTF-8 | 2,406 | 3.546875 | 4 | [] | no_license | # frozen_string_literal: true
MIN_LENGTH = 3
MAX_LENGTH = 10
require_relative './dictionary_utils.rb'
require_relative 'exceptions.rb'
require_relative 'possible_combinations.rb'
class PhoneNumberToWords
def initialize
@phone_number = ''
@dictionary = load_dictionary
@final_result = []
@possible_co... | true |
f6c4143409b8052d9f9c065a92040176b0ecbfcf | Ruby | mickeysanchez/tour_planner | /vendor/plugins/temboo-ruby-sdk-1.77/lib/Library/Instapaper.rb | UTF-8 | 5,938 | 2.921875 | 3 | [] | no_license | require "temboo"
module Instapaper
##############################################################################
#
# AddURL
#
# Add a document to an Instapaper account.
#
##############################################################################
class AddURL < Choreography
####
# Cre... | true |
7eef3f3c96d8cee983f95f826beb07978881734d | Ruby | eduardopoleo/myflix | /app/models/stripe_wrapper.rb | UTF-8 | 1,779 | 2.890625 | 3 | [] | no_license | module StripeWrapper
#this is just a wrapper so no need to extend from Active Record Base
class Charge
attr_reader :response, :status
#This allows me this some_charge = Charge.new(some_response, some_status)
#some_charge.response = some_response
#some_charge.status = some_status
#We need this me... | true |
ecdb1dbbe1d74fff90b2c53154b64ac8a1d56580 | Ruby | ciihla/simple_tooltip | /lib/generators/simple_tooltip/install_generator.rb | UTF-8 | 3,609 | 2.515625 | 3 | [
"MIT"
] | permissive | module SimpleTooltip
module Generators
class InstallGenerator < ::Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)
desc "This generator installs all the files necessary for the simple_tooltip gem"
def copy_stylesheet_and_images
path = "public/styl... | true |
6e677772cc6822e75d4a00e19de87e50abf21538 | Ruby | thesyaf/rollcallatron | /attendance_app.rb | UTF-8 | 6,983 | 3.484375 | 3 | [] | no_license | <<<<<<< HEAD
=======
require "csv"
>>>>>>> bd5a3b6dae4a5a8687757456c30e65108ac4a02e
require "terminal-table"
require "artii"
# The hash array containing the students (Keys) and their answers (Values)
class_list = {
Terence: "",
Cindy: "",
Jonathan: "",
Ali: "",
Timothy: "",
Sophie: "",
Carmen: "",
Khal... | true |
992d24ac74777517386e9387b511bdaa28d9ebee | Ruby | ta1m1kam/Atcoder | /050/A.rb | UTF-8 | 116 | 3.296875 | 3 | [] | no_license | arr = gets.chomp.split
if arr[1] == '+'
puts arr[0].to_i + arr[2].to_i
else
puts arr[0].to_i - arr[2].to_i
end
| true |
fcf90c8d7c8d002e052f8231907e6d0a886d9be0 | Ruby | Pustelto/Bracketeer | /test/language_files/ruby.rb | UTF-8 | 725 | 4.28125 | 4 | [
"MIT"
] | permissive | def get_numbers_stack(list)
stack = [[0, []]]
output = []
until stack.empty?
index, taken = stack.pop
next output << taken if index == list.size
stack.unshift [index + 1, taken]
stack.unshift [index + 1, taken + [list[index]]]
end
output
end
s = "Hi there. How are you?"
print s.length, " ["... | true |
e122c24d15ab0b20e9cb792251b935b657cff0f9 | Ruby | wyhaines/iowa | /src/iowa/Mutex.rb | UTF-8 | 2,851 | 3.296875 | 3 | [
"MIT"
] | permissive | module Iowa
# Iowa::Mutex is a slight modification of the standard Ruby Mutex class.
# This class changes the array operations used to manage the queue of
# threads waiting for a lock in order to get better memory management
# behavior from the array. This mutex will also not block if the thread
# holding a lock... | true |
652e8d0cc5281f4da2970fc0081541d10a3f35d4 | Ruby | jywei/ruby-toys | /small_script5.rb | UTF-8 | 209 | 3 | 3 | [] | no_license | #逐一行印出
f = File.open("small_script1.rb")
while line = f.gets do
puts line
end
f.close
#逐一行顯示
File.open( "small_script2.rb" , "r" ) do |f|
while line = f.gets
puts line
end
end
| true |
83778cd8bc70d8a61dc9dcdc19797c6ea212ee21 | Ruby | tiagofoks/MentoriaLucas | /crud.rb | UTF-8 | 1,160 | 3.296875 | 3 | [] | no_license | require './post'
require './menu'
menu
action = gets.chomp
if action == '1'
puts 'Digite seu post:'
param_text = gets.chomp
post = Post.new
post.text = param_text
post.create
puts "Ultimo post cadastrado:"
post = Post.read_last_one
puts post.text
end
if action == '2'
puts 'Digite o Id referente ... | true |
a3997c4c8da3af8157220230225ac1d0c0fd53cf | Ruby | adamgriffis/code-eval-solutions | /DollarText/test.rb | UTF-8 | 2,273 | 4.03125 | 4 | [] | no_license | def get_single(num)
if num == 0
return "Zero"
elsif num == 1
return "One"
elsif num == 2
return "Two"
elsif num == 3
return "Three"
elsif num == 4
return "Four"
elsif num == 5
return "Five"
elsif num == 6
return "Six"
elsif num == 7... | true |
5519f45d7ceebb60e13f8021245ec2eb35c11c14 | Ruby | jvshahid/Android | /android.rb | UTF-8 | 3,024 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env ruby
require "term/ansicolor"
String.send :include, Term::ANSIColor
def script_name
File.basename $0
end
if ARGV.count != 1
puts "Usage: #{script_name} [setup | update | recover | [upload image_name]]".red
puts "where: "
puts " setup: sets up the android development kit (implies update)"
p... | true |
a499617269969ab4ec34856d31f7c2445f024cd5 | Ruby | Shidame/Terres-du-Nil | /app/models/city_creator.rb | UTF-8 | 336 | 2.578125 | 3 | [] | no_license | class CityCreator
def initialize(user)
@user = user
end
def create!
nb_cities = @user.cities.count
City.transaction do
city = City.new
city.user = @user
city.name = "#{@user.username}-#{nb_cities+1}"
city.save!
map = MapCreator.new(city)
map.create!
city
... | true |
c37ef48ee9c78687d8c53de47c032569802fc83b | Ruby | thomthom/shadow-catcher | /tt_shadowcatcher.rb | WINDOWS-1250 | 20,411 | 2.515625 | 3 | [] | no_license | #-------------------------------------------------------------------------------
#
# Thomas Thomassen
# thomas[at]thomthom[dot]net
#
#-------------------------------------------------------------------------------
require 'sketchup.rb'
require 'TT_Lib2/core.rb'
TT::Lib.compatible?('2.6.0', 'TT Shadow Catche... | true |
5b6df45346e909df517e0b34abf2749fae6c385e | Ruby | shogo-tksk/at_coder | /abc153/recursive.rb | UTF-8 | 502 | 3.484375 | 3 | [] | no_license | # 基本的な再帰関数
def func(n)
# ベースケース
# ベースケースに対して return する処理を必ず入れる
return 0 if n == 0
# 再帰呼び出しを行ったときの問題が、元の問題よりも小さな問題となるように再帰呼び出しを行い、
# そのような「より小さい問題の系列」が最終的にベースケースに辿り着くようにする
n + func(n - 1)
end
(0..10).each do |n|
puts "#{n} までの和は #{func(n)}"
end | true |
ca23cd847a45cee0b2173b11f1fe799341a0a354 | Ruby | cregg/slideshare-api | /lib/document_rater.rb | UTF-8 | 2,189 | 2.6875 | 3 | [] | no_license | require 'json'
class DocumentRater
@array_of_search_terms
@array_of_docs
@ranking_strategy
@key
def initialize(array_of_search_terms, array_of_docs, key, ranking_strategy)
@array_of_search_terms = array_of_search_terms
@array_of_docs = array_of_docs
@key = key
... | true |
4d84186e2e20698e4c9a26054e5fa46172105e52 | Ruby | jakenotjacob/ruby_basics | /compare_hashes.rb | UTF-8 | 484 | 3.65625 | 4 | [] | no_license | things = {
rock: 'heavy',
scissors: 'ok',
paper: 'light'
}
things.each do |thing, weight|
answer = weight.to_s == 'ok'
if answer == true
puts "The #{thing} fits!"
else
puts "We must aquit."
end
end
#!!!!!
#Bonus: Modify to use a conditional ("conditional expression")
#This will turn in the above... | true |
16727e45cc5b7bc04c29e72c6bcf3336ad39b41c | Ruby | emcooper/hashcards | /lib/round.rb | UTF-8 | 330 | 3.25 | 3 | [] | no_license | require 'pry'
class Round
attr_reader :deck, :guesses, :current_card
def initialize(deck)
@deck = deck
@guesses = []
@current_card = deck.cards.first
end
def record_guess(guess)
@guesses << Guess.new(guess, @current_card)
end
def number_correct
@guesses.count {|guess| guess.correct?}
... | true |
172ce1f5500415c05d85ec5a31502d8be737ed2c | Ruby | YujohnNattrass/ruby_small_problems | /easy1/sum_of_digits_2.rb | UTF-8 | 747 | 4.65625 | 5 | [] | no_license | =begin
input: Integer
output: new Integer
rules: returns the sum of adding all the individual digits in the integer
Data structure / Algorithm:
define method sum with 1 parameter variable num
split num into an array of individual digits
add digits together with sum method
=end
def sum(num)
num.digits.sum
end
puts... | true |
902015113d9eed2f5159f981d97c3ffd0c59b992 | Ruby | blevy115/ruby_fundamentals1 | /exercise4-3.rb | UTF-8 | 167 | 3.625 | 4 | [] | no_license | my_name = "Brandon"
puts "What's your name?"
your_name = gets.chomp
if my_name == your_name
puts "We have the same name!"
else
puts "Our names are different!"
end
| true |
dc052e1df49c50c16f7eb32dfe331e14d7a2b9fd | Ruby | Adrianjewell91/algo-work | /singlepointoffailure.rb | UTF-8 | 5,330 | 3.90625 | 4 | [] | no_license | require 'byebug'
def maximalSquare(matrix)
max = 0
squares = Hash.new(nil)
i = 0
while i < matrix.length
j = 0
length = 0
while j < matrix[i].length
if matrix[i][j] == '1'
length += 1
if max == 0
max = 1
... | true |
a4d802dac21ce2140b7a58a857a60d350726be88 | Ruby | timomitchel/black_thursday | /lib/invoice_repository.rb | UTF-8 | 1,246 | 2.859375 | 3 | [] | no_license | require_relative 'invoice'
require 'csv'
class InvoiceRepository
attr_reader :data, :parent
def initialize(data, parent)
@data = csv_load(data).map {|row| Invoice.new(row, self)}
@parent = parent
end
def csv_load(file_path)
CSV.open file_path, headers: true, header_converters: :symbol
end
def... | true |
9b1704b631527ac011131412a545776703b3085b | Ruby | Sigill/OggAlbumTagger | /lib/ogg_album_tagger/library.rb | UTF-8 | 19,037 | 3.203125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'ogg_album_tagger/version'
require 'ogg_album_tagger/tag_container'
require 'ogg_album_tagger/exceptions'
require 'set'
require 'fileutils'
require 'colorize'
module OggAlbumTagger
# A Library is just a hash associating each ogg file to a TagContainer.
# A subset of file can be selected in order to be tagged... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.