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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
cb1f8562d985f983718e340a6ff30651947dcec9 | Ruby | railsfactory-deepankar/mp1 | /swap_string/swap_string.rb | UTF-8 | 225 | 3.609375 | 4 | [] | no_license | puts "Enter the two strings"
i = gets.chomp.to_s
j = gets.chomp.to_s
puts "Strings before swapping"
puts "First string : #{i}"
puts "Second string : #{j}"
puts "After swapping: \n First String : #{j} \n Second String : #{i}"
| true |
c4543f460d895b0a66924dfa68681e4776b61d56 | Ruby | mauriballes/ruby-lessons | /ruby/numeros.rb | UTF-8 | 276 | 3.46875 | 3 | [
"MIT"
] | permissive | # Numeros
### Enteros
34
52
1
### Flotantes
20.0
25.54
2.52
# Para pasar de entero a float
10.to_f
# Para pasar de float a entero
12.2315.to_i
# Para valor absoluto
-10.abs
# Para saber si el valor es numero para
2.even?
# Para devolver el siguiente entero
3.next | true |
0b8d930a2ce81bbed1f01ccccc4ca120ada60fbe | Ruby | PeterCamilleri/fOOrth | /lib/fOOrth/library/duration/formatter.rb | UTF-8 | 7,160 | 2.84375 | 3 | [
"MIT"
] | permissive | # coding: utf-8
#* library/duration/formatter.rb - Duration formatting support library.
module XfOOrth
#Formatter support for the \Duration class.
class Duration
#Extend this class with attr_formatter support.
extend FormatEngine::AttrFormatter
##
#The specification of the formatter ... | true |
b22e014d1e616f1ed5bb2a9aeb825be53b3fd8f5 | Ruby | Maikell84/advent-of-code-2020 | /day_02/2.rb | UTF-8 | 1,549 | 3.59375 | 4 | [] | no_license | #!/usr/bin/env ruby
def find_occurances(haystack, needle, occurances = 0)
i = haystack.index(needle)
return occurances if i.nil?
occurances += 1
modified_haystack = String.new(haystack)
modified_haystack[i] = ''
find_occurances(modified_haystack, needle, occurances)
end
def part1_password_valid?(occurance... | true |
ee86c08246ed7fd82f21ee041c5a66caf8cf7f39 | Ruby | alexperez2160/ls_exercises | /loops/loops_2_9.rb | UTF-8 | 195 | 3.3125 | 3 | [] | no_license | number_a = 0
number_b = 0
loop do
number_a += rand(2)
number_b += rand(2)
puts number_a
puts number_b
next unless number_b == 5 || number_a == 5
puts "5 was reached"
break
end | true |
bce1fa0165edbc52cc32f548d746192740d79620 | Ruby | matthewpeak/ruby-oo-fundamentals-object-attributes-lab-nyc-web-021720 | /lib/dog.rb | UTF-8 | 244 | 3.203125 | 3 | [] | no_license | class Dog
def name
@name
end
def name= (name)
@name = name
end
def name
"#{@name}".strip
end
def breed
@breed
end
def breed= (breed)
@breed = breed
end
def breed
"#{@breed}".strip
end
end
| true |
6b093b6089dce6cec3a8c98fdba2e5cf72b0e289 | Ruby | LukVik/helloword | /app/models/oop_projects/student.rb | UTF-8 | 739 | 3.5 | 4 | [] | no_license | class Student
attr_accessor :first_name, :last_name, :email, :password
attr_reader :username
@first_name
@last_name
@email
# @username = "lukas1" # a da se to do def set_username 22
@username
@password
# def first_name=(name)
# @first_name = name
# end
# def first_name
# @first_name
#... | true |
121b7d2bac842931db2767eb338b26a856a2964e | Ruby | MedetaiAkaru/optional_exercises | /iterations_2.rb | UTF-8 | 397 | 4.34375 | 4 | [] | no_license | # Module: Iterations
# Write a method count_a(word) that takes in a string word
# The method returns the number of a's in the word.
# Note: The method should count both lowercase (a) and uppercase (A)
def count_a(word)
# Write your code here
end
puts count_a("application") # => 2
puts count_a("bike") # ... | true |
9244159a207c4a01a6d38520987f2854cd608def | Ruby | tmikeschu/the-spoken-tour-api | /app/services/inreach_service.rb | UTF-8 | 901 | 2.578125 | 3 | [] | no_license | class InreachService
def self.latest_coordinates
new.latest_coordinates
end
def latest_coordinates
{
location: {
lat: latitude(response_data), lng: longitude(response_data)
},
date: date(response_data)
}
end
def latitude(response_data)
Nokogiri.XML(response_data).cs... | true |
46f3a58f822983f1881e54860b45b9c385ef6157 | Ruby | mharris717/basketball_pbp | /lib/basketball_pbp/pbp_file/base.rb | UTF-8 | 783 | 2.5625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module BasketballPbp
module PBPFile
class Base
attr_accessor :path
include FromHash
fattr(:dir) do
path.split("/")[-2]
end
fattr(:short_filename) do
path.split("/")[-2..-1].join("/")
end
def each_row
CSV.foreach(path,:headers => true, :col_sep => d... | true |
e1f6e41e524c486eb37c4d123b8c7c05a957b17f | Ruby | billonrails/TeaLeaf_Submissions | /my_calculator.rb | UTF-8 | 620 | 4.03125 | 4 | [] | no_license | def say(msg)
puts "=> #{msg}"
end
say "Please enter your your first number:"
first_num = gets.chomp
say "Please enter your second number:"
second_num = gets.chomp
say "What operation would you like to do? Type 1)addition 2)subtraction 3)multiplication 4)division"
operation = gets.chomp
if operation == "1"
solut... | true |
42cc7b35abed9b18a7f4a628203a526d149daa2f | Ruby | tomas-stefano/rspec-i18n | /examples/i18n/de/german_spec.rb | UTF-8 | 634 | 2.59375 | 3 | [
"MIT"
] | permissive | # coding: UTF-8
require 'lib/spec-i18n'
Spec::Runner.configure do |config|
config.spec_language :de
end
class Person
end
# PLEASE - Replace with GOOD EXAMPLES
#
beschreibe Person do
vorher(:von_jeder) do
@vorher = 'Before Keyword!'
end
es 'wahr sollte wahr sein' do
true.sollte wahr_sein
end
... | true |
288e2748318408a8938b494ec2353eabcc37fe17 | Ruby | barbarian611/High-Card-Dealer | /game.rb | UTF-8 | 1,221 | 3.90625 | 4 | [] | no_license | require 'pry'
# Note: we only need `require_relative` if we end up calling a class by name in our file's logic. As such, you may have to add more `require_relative` statements accordingly.
require_relative "lib/hand"
require_relative "lib/deck"
#GAME START
# Your game logic here.
fifty_two_effing_cards = Deck.new
... | true |
480802c9326846e4ab2c656f8eef3a5cc9036b85 | Ruby | bbeaird/coding_challenges | /consecutive.rb | UTF-8 | 349 | 3.59375 | 4 | [] | no_license | def consecutive(arr)
arr.sort!
count = 0
prev = nil
arr.each do |num|
count += (num - prev - 1) unless prev.nil?
prev = num
end
count
end
def consecutive2(arr)
arr.sort!
min = arr[0]
max = arr[-1]
return max - min - arr.size + 1
end
arr = [5,10,15]
p consecutive(arr)
p consecutive([1,2,100... | true |
b18708ad429f35f3427f96c5979df50838788af8 | Ruby | ManageIQ/virtfs | /lib/virtfs/delegate_module.rb | UTF-8 | 1,118 | 2.609375 | 3 | [
"MIT"
] | permissive | require "delegate"
module VirtFS
module DelegateModule
def delegate_module(superclass)
mod = Module.new
methods = superclass.instance_methods
methods -= ::Delegator.public_api
methods -= [:to_s, :inspect, :=~, :!~, :===]
mod.module_eval do
def __getobj__ # :nodoc:
... | true |
e5f82e756cc258a804b1f1554390900aa348bd4f | Ruby | jociemoore/ruby_practice | /I2P_ch7_Hashes/exercise3.rb | UTF-8 | 188 | 3.296875 | 3 | [] | no_license | # hash
store = {jacket:"$50", shirt:"$20", hat:"$10"}
store.each_key{ |item| puts item }
store.each_value{ |price| puts price}
store.each{|item, price| puts "The #{item} costs #{price}."} | true |
392f3179c8677e610f1fc798892f4786b0ce7f49 | Ruby | alisajedi/mys3ql | /lib/mys3ql/s3.rb | UTF-8 | 2,757 | 2.625 | 3 | [
"MIT"
] | permissive | require 'mys3ql/shell'
require 'fog'
module Mys3ql
class S3
include Shell
def initialize(config)
@config = config
Fog::Logger[:warning] = nil
end
def store(file, dump = true)
key = key_for(dump ? :dump : :bin_log, file)
s3_file = save file, key
if dump && s3_file
... | true |
a155e13cdb141fb5e315a38b925841eb558f03a7 | Ruby | timsully/introduction_to_programming | /ruby_basics/user_input/print_something_01.rb | UTF-8 | 289 | 4.34375 | 4 | [] | no_license | =begin
Write a program that asks the user whether they want the program to
print "something", then print it if the user enters y. Otherwise, print nothing.
=end
puts "Do you want me to print \"something\"? (y/n)"
user_input = gets.chomp
if user_input == "y" || "Y"
puts "something"
end | true |
27335cee03da3c01eead0ede4bca3682502e6972 | Ruby | jsvensson/streamstatus | /lib/object_cache.rb | UTF-8 | 256 | 2.890625 | 3 | [] | no_license | class ObjectCache
def initialize(client, cache, ttl)
@cache = client.cache(cache)
@ttl = ttl
end
def get(object)
@cache.get(object)
end
def put(object, value, ttl = @ttl)
@cache.put(object, value, {expires_in: ttl})
end
end
| true |
e26ec7134505358dfe8d267a1dc12a4457f11ef8 | Ruby | tdeschamps/projet_perso | /gosu_game/player.rb | UTF-8 | 420 | 3.046875 | 3 | [] | no_license | require 'gosu'
class Player
attr_accessor :player_x, :player_y
def initialize(window)
@image = Gosu::Image.new(window, "media/pharrel.png", false)
@player_x, @player_y = 400, 400
@vel_y = 0
end
def accelerate
@vel_y -= Gosu::offset_y(1,0.1)
end
def move
@player_y += @vel_y unless pl... | true |
0e4f01958bdf846aaa83d7988133ef6bb72734d4 | Ruby | Scott2bReal/LS-ruby-basic-exercises | /debugging/multiply_by_five.rb | UTF-8 | 427 | 4.90625 | 5 | [] | no_license | # When the user inputs 10, we expect the program to print The result is 50!, but
# that's not the output we see. Why not
def multiply_by_five(n)
n * 5
end
puts "Hello! Which number would you like to multiply by 5?"
number = gets.chomp
puts "The result is #{multiply_by_five(number)}!"
# The program doesn't work be... | true |
7c543cc662a4112344d13f6f66d69cad67dd6b6f | Ruby | DWBayly/ar-exercises | /exercises/exercise_6.rb | UTF-8 | 763 | 3.046875 | 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'
puts "Exercise 6"
puts "----------"
# Your code goes here ...
@store1.employees.create(first_name: "Khurram", last_name: "Virani",... | true |
3310128c767e5a4eae545ab40ae5047b734502d6 | Ruby | carrot-u/assignments-2019 | /assignment-2-ruby/rborder/guessing_game.rb | UTF-8 | 4,608 | 3.734375 | 4 | [] | no_license | # same robot from the room-cleaner app
def robot
sleep 1
puts " _______ "
puts " _/ \\_ "
puts " / | | \\ "
puts " / |__ __| \\ "
puts " |--(( )| |( ))--| "
puts " | | | | "
puts " |\\ |_| /| "
puts " | \\ / | "
p... | true |
96e2f04f37d69fdf81ca2bab627e5c7a17b66bc6 | Ruby | xelex/brute-dict | /dictionary.rb | UTF-8 | 2,014 | 3.921875 | 4 | [
"Unlicense"
] | permissive | ##
# A simple brute dictionary class
class Dictionary
def initialize(opt = {})
@filters = []
@filters_negative = []
@power_cache = []
alphabet(opt[:abc])
length(opt[:len])
end
##
# Set alphabet
def alphabet(abc)
@alphabet = abc.to_s.chars.sort.uniq
return reset()
end
##
# S... | true |
a1d860765b96abf0d07625cbdf2a90d10e22c447 | Ruby | MichaelAldaba/random | /tictactoe/third_iteration/spec/board_spec.rb | UTF-8 | 6,803 | 3.234375 | 3 | [] | no_license | require 'spec_helper'
describe Board do
before :each do
@board = Board.new
end
describe ".new" do
it "should create a Board object" do
expect(@board).to be_an_instance_of Board
end
end
describe "#size" do
context "when :size is not given" do
it "size should return :size" do
... | true |
198506f3cdb29e1730815b050e51740c14c203b7 | Ruby | staunchRobots/lita-hipchat-extensions | /lib/lita/handlers/hipchat-extensions/timezone.rb | UTF-8 | 3,350 | 2.53125 | 3 | [
"MIT"
] | permissive | module Lita
module Handlers
class HipchatExtensions < Handler
# Handles Timezone shenanigans
class Timezone < Base
include RelativeDistances
route /^tz\s+(@\w+)/, :show, command: true
route /^tz\s+list/, :list, command: true
route /^tz\s+when\s+(.*)/, :when... | true |
77e5a2b9c34ea37a042fb4551fca550ff9d92bb8 | Ruby | zear/sdljava | /sdljava/src/org/gljava/opengl/native/ftgl/post-process.rb | UTF-8 | 2,289 | 3 | 3 | [] | no_license | #!/usr/bin/ruby -w
require "find"
require "ftools"
# temporary hack until I can figure out a better way to do this
# process the given files, change the methods names to start
# with lower case, remove the methods in remove_methods list
# then cat the contents of .post file to redefine or add new
# method... | true |
c62e4f395940b8a62427ea12b9570061c9b5b68d | Ruby | danielmontgomery/ruby-prac | /block_practice.rb | UTF-8 | 2,366 | 4.5625 | 5 | [] | no_license | #ENUMERABLE
#**TODO ENTER CODE**
# * Output all the methods of the Enumerable class to the console
puts Enumerable.methods
# **TODO ENTER CODE **
# * create a class called Persons that hand rolls an 'each' iterator method, inside of which you
# define some names, the each method will allow you to iterate over ... | true |
39661fdad9a63f407bc0df29ed04b65a40e96a94 | Ruby | noelrappin/foot_travel | /spec_fast/roles/friend_spec.rb | UTF-8 | 1,250 | 2.796875 | 3 | [] | no_license | require 'fast_spec_helper'
require 'roles/buyer'
describe Friend do
let(:me) { OpenStruct.new(:first_name => "Fred", :last_name => "Flintstone") }
let(:friend) { OpenStruct.new(:first_name => "Barney") }
let(:enemy) { OpenStruct.new(:first_name => "Spacely") }
before(:each) do
me.extend(Friend)
frien... | true |
fe08d48acea4953e54f93589fea406997b8dcf8a | Ruby | thiagoa/menu_maker | /lib/menu_maker/path.rb | UTF-8 | 638 | 3.1875 | 3 | [
"MIT"
] | permissive | module MenuMaker
class Path
Methods = %i[get post put patch delete]
def self.valid_method?(method)
Methods.include? method
end
attr_reader :method, :path
def initialize(method, path)
method = method.to_sym.downcase
unless self.class.valid_method? method
fail PathError... | true |
b5df2a6c7e26f178e89b22c9648017ef0dfd4548 | Ruby | PreetBhadana/Training | /Ruby/Ruby_Practice/FIle IO Practice Programs/Gets_statement.rb | UTF-8 | 65 | 2.6875 | 3 | [] | no_license | # Gets Statement
puts "Enter Input here : "
val1 = gets
puts val1 | true |
dcacc7d1ef0bfa41ab799803a4f9bc146ea739fb | Ruby | rejeep/evm | /lib/evm/command/config.rb | UTF-8 | 512 | 2.5625 | 3 | [] | no_license | module Evm
module Command
class Config
def initialize(argv, options = {})
key, value = argv
unless key
Evm.config.all.each do |k, v|
STDOUT.puts("#{k} => #{v}")
end
return
end
unless Evm::CONFIG_KEYS.include?(key.to_sym)
r... | true |
27ebfa68a3ef4584dc6a9d1dcada3890e3caa6cd | Ruby | SuzanneHuldt/robot-wars | /lib/action/action.rb | UTF-8 | 365 | 2.578125 | 3 | [] | no_license | class Action
def initialize
@move = Move.new
end
def new_action(timebank, info)
update_info(timebank, info)
@move.new_move(@my_id, @op_id, @info[:field], @timebank)
end
private
def update_info(timebank, info)
@info = info
@timebank = timebank
@my_id = @info[:your_botid].to_s
@... | true |
34c96edb5825103b2b71df765fabfd9414ff7e94 | Ruby | erik-krogh/ql | /ruby/ql/test/library-tests/dataflow/type-tracker/type_tracker.rb | UTF-8 | 211 | 3.171875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Container
def field=(val)
puts self.field
@field = val
end
def field
@field
end
end
def m()
var = Container.new
var.field = "hello"
puts var.field
end
| true |
68353e7c0eec5de04a26fd0ca61aa8eedb15a1be | Ruby | Arnaudboscq/rails-stupid-coaching | /app/controllers/coaching_controller.rb | UTF-8 | 668 | 3.109375 | 3 | [] | no_license | class CoachingController < ApplicationController
def answer
@query = params[:query]
coach_answer_enhance
end
def ask
end
def home
end
end
private
def coach_answer
if @query.include? "?"
@query = "Silly question, get dressed and go to work!"
elsif @query == "I am going to work right now!... | true |
9929170ce5e393c37d3cd84feb1ed9cbb1913c6e | Ruby | jessjchang/ruby-basics-exercises | /user_input/opposites_attract.rb | UTF-8 | 740 | 4 | 4 | [] | no_license | def valid_number?(number_string)
number_string.to_i.to_s == number_string && number_string.to_i != 0
end
num_1 = nil
num_2 = nil
loop do
loop do
puts ">> Please enter a positive or negative integer:"
num_1 = gets.chomp
break if valid_number?(num_1)
puts ">> Invalid input. Only non-zero integers ar... | true |
d018a4550f03504fd504f982af88fc4101d4b77a | Ruby | BaptPrn/tabata_genetator | /db/seeds.rb | UTF-8 | 12,019 | 2.875 | 3 | [] | no_license | puts "Creating exercises"
Exercise.create(
name: "Abdos complets",
exercise_type: "Abdos",
equipment: "Aucun",
initial_status: nil,
available: nil,
description: "Allongé sur le dos, remonter le buste et les genoux jusqu'à une position accroupie. Enchainer de manière dynamique."
)
puts "."
Exercise.crea... | true |
d697bf1fb650ea89b5f47a6ab4fbfb235d4f6940 | Ruby | hamza3202/repositext | /lib/repositext/services/extract_content_at_main_titles.rb | UTF-8 | 1,544 | 3.03125 | 3 | [
"MIT"
] | permissive | class Repositext
class Services
# This service extracts a file's main titles: The first level 1 header by
# default, and the first level 2 header if requested.
#
# Usage:
# main_title = ExtractContentAtMainTitles.call(content_at, :content_at).result
#
class ExtractContentAtMainTitles
... | true |
8e5736c854b456fad6b944f891ced50bb24e5a7e | Ruby | alekvuka/ttt-with-ai-project-v-000 | /lib/players/computer.rb | UTF-8 | 553 | 3.34375 | 3 | [] | no_license | module Players
class Computer < Player
def move(board)
@board = board
decision = move_to_make
puts "The computer has chosen to occupy cell #{decision}"
puts "Please examine the updated board below:"
decision
end
def move_to_make
if @board.turn_count == 0
dec... | true |
32a42db01781c232e08f377bd51d99f7b69711fe | Ruby | freddywaiganjo/rubySample | /condFile.rb | UTF-8 | 230 | 3.015625 | 3 | [] | no_license | class ConditionTest
def check_even(a)
if a < 0
puts('no less than 0')
elsif a == 0
puts('no is zero')
elsif a > 0 || a.even?
puts('even no')
else
puts('Odd number')
end
end
end
| true |
6fa7f35c52743cf840d555465a082d57a72d0600 | Ruby | bguthrie/speed_racer | /pkg/speed_racer-0.1.0/lib/speed_racer/comparison.rb | UTF-8 | 1,388 | 2.765625 | 3 | [
"MIT"
] | permissive | module SpeedRacer
class Comparison
attr_reader :baseline, :measurements, :times
def initialize(n)
@times = n
@measurements = []
end
def measure(name, &block)
@measurements << Measurement.new(name, times, *data, &block)
end
def against(name, &block)
@baseline = Measur... | true |
0df5bbf33706c40f6abe2fc1bca5237167ef647e | Ruby | ianberman/App-Academy-Open | /Intro to Programming/Hashes/hashes_lecture_notes_1.rb | UTF-8 | 909 | 4.28125 | 4 | [] | no_license | # arrays group data within a single variable with indices
# hashes have values indicated by keys
# hashes in Ruby use curly braces {} - organized by key and value pairs
my_hash = {
"name" => "App Academy",
"color" => "red",
"age" => 5,
42 => "hello"
}
my_hash["color"] = "pink" # manipulation of hashes is like ... | true |
5ef19475eebeb3c7deafd7ec57ac07ca2765ccff | Ruby | rspeicher/invision_bridge | /lib/authlogic/crypto_providers/invision_power_board.rb | UTF-8 | 1,627 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'digest/md5'
module Authlogic
module CryptoProviders
class InvisionPowerBoard
class << self
def encrypt(*tokens)
tokens = tokens.flatten
digest = tokens.shift
digest = filter_input(digest)
# Invision's hash: MD5(MD5(salt) + MD5(raw))
digest... | true |
61ae5e254578af6f41d58ad051025d2b682a74f7 | Ruby | khiav223577/ChineseCheckersBot | /lib/ruby/alpha_beta_ai.rb | UTF-8 | 2,344 | 2.765625 | 3 | [] | no_license | require File.expand_path('../ai_base', __FILE__)
class AI::AlphaBeta < AI::Base
MAX_DEEP = 3
def initialize(color_idx, players, board_states, goals, output)
pidx = players.index(color_idx)
[goals, players].each{|s| s.push(*s.shift(pidx)) } #rearrange the order of players
@player_size = players.size
... | true |
5e880629784529ba608280564898a189e874eaa6 | Ruby | harshitamukesh/ruby_set2 | /Polymorphism/polymorphism2.rb | UTF-8 | 1,133 | 4.375 | 4 | [] | no_license | # Create a class called Person.
# Define three other classes i.e student, teacher and parent which should have all the properties of Person.
# Define a method which introduces the person with his firstname, lastname, age, city and state.
class Person
def firstname(fname)
@fname = fname
end
def lastname(lname)
... | true |
63b4b750d3c7d66612286e383c4777e328f1c878 | Ruby | jensjap/curator2 | /archive/add_internal_id.rb | UTF-8 | 1,399 | 2.59375 | 3 | [] | no_license | #encoding: utf-8
require "./lib/environment.rb"
require "csv"
FILE_PATH = "./output/assignments.csv"
PROJECT_ID = 163
def main
data = CSV.table(FILE_PATH, { :encoding => "ISO8859-1", :col_sep => "\t" })
data.each do |row|
pmid = row[:pubmed_id]
refid = row[:internal_id]
primary_publications = _fin... | true |
51102ccae28c5fd57fb23f8c5ae5cd79662ba15b | Ruby | nataliemac81/phase_0_unit_3 | /week_8_and_9/4_Ruby/fibonacci_sequence/my_solution.rb | UTF-8 | 1,266 | 4.15625 | 4 | [] | no_license | # U3.W8-9:
# I worked on this challenge by myself.
# 2. Pseudocode
=begin
***A positive number is a fibonacci number if (5 * n**2 + 4) or (5 * n**2 - 4) is a perfect square.
create a method called perfect_sq that takes a number and tests whether it is a perfect square or not.
call the Math.sqrt method on number ... | true |
8ed117c7101f5230715de6ed3a66537722920499 | Ruby | aortbals/specs_watcher | /lib/specs_watcher/parsers/searcher.rb | UTF-8 | 985 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'nokogiri'
module SpecsWatcher
module Parsers
class Searcher
def self.parse(raw_html)
new(raw_html).parse
end
attr_reader :raw_html
def initialize(raw_html)
@raw_html = raw_html
end
def parse
doc = Nokogiri::HTML(raw_html)
rows = doc.c... | true |
39870d1cb02c78228faf4ffde176140166f98ae3 | Ruby | soutaro/steep | /smoke/enumerator/b.rb | UTF-8 | 264 | 2.78125 | 3 | [
"MIT"
] | permissive | # @type var b: Array[String]
# @type var c: Array[Integer]
a = [1]
b = a.each.with_object([]) do |i, xs|
xs << i.to_s
end
c = a.each.with_object([]) do |i, xs|
xs << i.to_s
end
# @type var d: String
d = a.each.with_object([]) do |i, xs|
xs << i.to_s
end
| true |
a1c93931b85f8164566bb18e2b62c4784e270522 | Ruby | prokizzle/sit_stand | /sit_stand.rb | UTF-8 | 607 | 2.953125 | 3 | [] | no_license | require 'timers'
require 'daemons'
Fixnum.class_eval do
def seconds
self
end
def minutes
self * 60
end
def hours
self * 60 * 60
end
end
class SitStand
def initialize
@timers = Timers::Group.new
@every_five_seconds = @timers.every(20.minutes) { notify }
@position = "sit"
not... | true |
df75633652402bda2c97cfbe6dcdeaeb0f4fd7be | Ruby | nathanworden/RB101-Programming-Foundations | /RB101-RB109_small_problems/06.easy_6/03.fibonacci_number_location_by_length.rb | UTF-8 | 2,807 | 4.75 | 5 | [] | no_license | #PEDAC
# Problem
# Write a method that calculates and returns the index of the first Fibonacci numbers that
# has the number of digits specified as an argument. (The first Fibonacci number has index 1)
# Example / Test Cases
# find_fibonacci_index_by_length(2) == 7 # 1 1 2 3 5 8 13
# find_fibonacci_index_b... | true |
92324a7a5208838edf6a5c3be560fcf47bb9b3cd | Ruby | hiro0911/NaganoCakeSlim | /app/helpers/application_helper.rb | UTF-8 | 160 | 2.53125 | 3 | [] | no_license | module ApplicationHelper
def total_price(cart_items)
price = 0
cart_items.each do |cart_item|
price += cart_item.subtotal
end
return price
end
end
| true |
b1ee10f0c6ce07644db539259140105594523c05 | Ruby | markryall/songbirdsh | /lib/songbirdsh/command/search.rb | UTF-8 | 736 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'songbirdsh/command'
class Songbirdsh::Command::Search
include Songbirdsh::Command
usage '*<word>'
help <<EOF
searches for tracks containing the specified words (in artist, title or album)
ids are placed on the clipboard for convenient use with +
EOF
execute do |text|
terms = text.split(/\W/)
m... | true |
d64c4fbaa7bbd556e84af43c67d223598d501bdf | Ruby | TaylorBeeston/ExercismAnswers | /ruby/pangram/pangram.rb | UTF-8 | 182 | 3.375 | 3 | [] | no_license | class Pangram
def self.pangram?(sentence)
pangram = true
for letter in 'a'..'z'
pangram = false if sentence.downcase.count(letter) == 0
end
pangram
end
end
| true |
03a44df63799de548dbbab7e5c049ad517b7b428 | Ruby | bartoszdyja/learn_ruby | /08_book_titles/book.rb | UTF-8 | 226 | 3.390625 | 3 | [] | no_license | class Book
attr_reader :title
def title=(title)
@title=title.split.map do |word|
%w(a an the in and of).include?(word) ? word : word.capitalize
end.join(' ')
@title[0] = @title[0].capitalize
end
end
| true |
a7b1cb6ff06f13181eae593531013b26fd4c4d15 | Ruby | TongCui/t_tools | /doc/ruby/rails/edgeguides/models/active-record-callback.rb | UTF-8 | 1,262 | 2.578125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
## Callback
class User < ApplicationRecord
validates :login, :email, presence: true
before_validation :ensure_login_has_a_value
protected
def ensure_login_has_a_value
if login.nil?
self.login = email unless email.blank?
end
end
end
or
class User < Applicatio... | true |
fcf8334647294cb77f96ec43e5106fc2b44c3042 | Ruby | azhang9328/ruby-enumerables-generalized-map-and-reduce-lab-seattle-web-120919 | /lib/my_code.rb | UTF-8 | 431 | 3.578125 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Your Code Here
def map(array)
newarray = []
i = 0
while i < array.length do
newarray.push(yield(array[i]))
i += 1
end
newarray
end
def reduce(array, starting_point = nil)
i = 0
if starting_point
total = starting_point
else
total = array[0]
i = 1
end
while i < array... | true |
000c66f21b84ca3cb9fead601e2e7b1682813e2c | Ruby | zstrick/battleship | /player.rb | UTF-8 | 383 | 3.046875 | 3 | [] | no_license | class Player
attr_reader :grid
def initialize
@grid = Grid.new
end
def ships
grid.ships
end
def record_hit(coordinates)
grid.hit_opponent(coordinates)
end
def record_miss(coordinates)
grid.miss_opponent(coordinates)
end
def fire_at_coordinates(coordinates)
grid.fire_at_coordi... | true |
b539c2ade9366e06f9dbed4903a53e3d055888e3 | Ruby | coconatsuki/ruby_spec_testing | /06_timer/timer.rb | UTF-8 | 1,233 | 3.875 | 4 | [] | no_license | class Timer
attr_accessor :seconds
def initialize seconds=0
@seconds = seconds
@hours_string = "00"
@minutes_string = "00"
@seconds_string = "00"
end
def time_string
if @seconds >= 3600
hours
elsif @seconds >= 60 && @seconds < 3600
minutes
elsif @seconds > 0
sec
... | true |
3a1981843273c2af4e64e9c332529f95e12303d1 | Ruby | tperdue321/sample_app | /ruby_solutions.rb | UTF-8 | 1,778 | 4.25 | 4 | [] | no_license | # original string
string = "This is a string in reverse"
# change to array to manipulate
array = string.split("")
index = 0
# new array to save reverse version
reverse_array = []
#until loop iterating through array starting with first item in array working up and saving it to reverse_array
until index == array.length
... | true |
25f1e37061eb4fb1a95afd2efff3b995e7223e46 | Ruby | JohnMahowald/potd | /mobile-6.rb | UTF-8 | 182 | 3.296875 | 3 | [] | no_license | #!/usr/bin/env ruby
x = 16
def shift_six num
num_str = num.to_s
num_str = num_str[-1] + num_str[0..-2]
num_str.to_i
end
until shift_six(x) == (x * 4)
x += 10
end
puts x
| true |
c03b7d40172ecefc3ee564de157a1b59fc5f6f15 | Ruby | swa-gitlab/documentation | /metrics/retrieve_github_issues.rb | UTF-8 | 1,992 | 3.078125 | 3 | [] | no_license | # encoding: UTF-8
require 'rubygems'
require 'httparty'
require 'pp'
require 'json'
##
# GitHub issue downloader
#
# Downloads the issues posted for a given project and writes the responses to a JSON file.
# Example dataset produced by this script can be obtained from https://dl.dropboxusercontent.com/u/710158/issue... | true |
5e723875d730ee430b3303dd9c020786dd17acea | Ruby | kat-siu/ruby-notes | /string_util.rb | UTF-8 | 351 | 3.515625 | 4 | [] | no_license |
def repeat(str, count)
result = ''
# Approach 1
#0.upto(count) do
# result = result + str
#end
# Approach 2
#count.downto 0 do
# result = result + str
#end
# Approach 3
#count.times { result += str }
#result
# Approach 4 (awesomeness!)
str * count... | true |
cf32ed53d9c169023e9d91298a1ebab52216209d | Ruby | ese-unibe-ch/ese2012-team1 | /trade/app/models/Messenger/message.rb | UTF-8 | 2,674 | 3.453125 | 3 | [] | no_license | module Models
##
#
# A Message stores a single message
#
##
class Message
@@message_count = 1
#unique id of the message
attr_reader :message_id
#message itself
attr_accessor :message
#sender of the message
attr_accessor :sender
#date when the message was c... | true |
7531ec9d9aa769ea4539583e8bdd846edca416ef | Ruby | kjferris/launch_school_101 | /lesson_3/exercises_easy_2.rb | UTF-8 | 727 | 3.046875 | 3 | [] | no_license | # Question 1
ages = { "Herman" => 32, "Lily" => 30, "Grandpa" => 402, "Eddie" => 10 }
ages.has_key?("Spot")
# Question 2
ages = { "Herman" => 32, "Lily" => 30, "Grandpa" => 5843, "Eddie" => 10, "Marilyn" => 22, "Spot" => 237 }
ages.value.inject(:+)
# Question 3
ages.keep_if { |name, age| age < 100 }
# Question 4
mun... | true |
24d55ece20906fb5d45008feddf9ae24ef6229c7 | Ruby | gvquiroz/aydoo2016-ruby | /factores-primos-ruby/spec/formateador_quiett_spec.rb | UTF-8 | 726 | 2.671875 | 3 | [] | no_license | require 'rspec'
require_relative '../model/formateador_quiett'
class FormateadorQuiettSpec
describe 'FormateadorQuiett' do
it 'should return 2\n2\n3\n5 when get contenido formateado' do
array_con_contenido = [2, 2, 3, 5]
expected_string = "2\n2\n3\n5"
formateador = FormateadorQuiett.new
e... | true |
ccd780f0f796a37dc007d961db4aaf5c6f59b090 | Ruby | tri-dang/anti-pattern-test | /lib/liar.rb | UTF-8 | 274 | 3.3125 | 3 | [] | no_license | class Liar
@@big_liar = true
def initialize(liar)
@liar = liar
end
attr_reader :liar
def self.big_liar
@@big_liar
end
def self.big_liar=(big_liar)
@@big_liar = big_liar
end
def to_s
liar ? 'You are liar' : 'You are not liar'
end
end
| true |
c6b0259a1a18406f4c26cdaee28059ad598d6be5 | Ruby | caneroj1/BlackjackRb | /lib/blackjack_rb/deck.rb | UTF-8 | 1,739 | 4.03125 | 4 | [] | no_license | module BlackjackRb
class Deck
# a deck will have 52 cards and it will have certain actions
# that it can do, such as give a card, or shuffle
attr_reader :cards
# this will initialize the deck by calling another method to create the cards
# in order to have a nice, proper deck, and then we shuffl... | true |
f7d843bd86416bc1f42866a23a284739d6e4bfec | Ruby | francomac/ruby-concepts | /inject.rb | UTF-8 | 184 | 3.984375 | 4 | [] | no_license | puts (1..10).inject {|memo, i| memo + i} # 55
array = [*1..10]
sum1 = array.inject {|memo, i| memo + i}
puts sum1 # 55
sum2 = array.inject(100) {|memo, i| memo + i}
puts sum2 # 155
| true |
ea1227513ef564adb9fa5b52592ebeeb3a1c6942 | Ruby | VincentFeildel/Backend-Drivy | /backend/level1/main.rb | UTF-8 | 6,807 | 3.15625 | 3 | [] | no_license | require 'json'
require 'date'
# Helpers
def simple_p_calc(car, distance, days)
price_per_km = car['price_per_km']
price_per_day = car ['price_per_day']
rental_price = price_per_km * distance + price_per_day * days
end
def prog_p_calc(car, distance, days)
price_per_km = car['price_per_km']
price_per_day = ca... | true |
cd92e587ffa90c3ba1cafe46feb332fa5aa43c6f | Ruby | VictorHolanda21/cursoRuby | /exercicios/exercicio01/quest13.rb | UTF-8 | 762 | 4.46875 | 4 | [] | no_license | =begin
13 Tendo como dados de entrada a altura e o sexo de uma pessoa, construa um algoritmo
que calcule seu peso ideal, utilizando as seguintes fórmulas: a. Para homens: (72.7*h) -
58 b. Para mulheres: (62.1*h) - 44.7 (h = altura) c. Peça o peso da pessoa e informe se
ela está dentro, acima ou abaixo do peso. 4
=end... | true |
096a3fc39bdff5587bb6fc601408a7de7f950afc | Ruby | nburkley/follower-maze | /spec/follower-maze/user_spec.rb | UTF-8 | 1,134 | 2.734375 | 3 | [] | no_license | require_relative '../spec_helper'
module FollowerMaze
describe User do
before do
@user = User.new(1, nil)
end
it "adds followers" do
@user.followers.size.should be(0)
fanboy = User.new(1, nil)
@user.add_follower(fanboy)
@user.followers.size.should be(1)
@user.followers... | true |
a8f9c057fe30afcf40a4e4bbcff3e5bd2481a27c | Ruby | ForeverZer0/open-image | /lib/open_image/colors.rb | UTF-8 | 34,529 | 3 | 3 | [
"MIT"
] | permissive |
module OpenImage
##
# Module containing convenience methods for defining, retrieving, and
# enumerating preset named {Color} objects.
module Colors
# @!group Helper Methods
##
# Dynamically defines a static method to return a named color.
#
# @param name [String, Symbol] The name of the ... | true |
9692e46146a0128db7ac9e37f5c17f2eaf3b5321 | Ruby | ykz1/LS_101_foundations | /0_exercises/easy_7/5_staggered_caps_1.rb | UTF-8 | 867 | 3.828125 | 4 | [] | no_license | # 5_staggered_caps_1.rb
# Start 12:31PM
# Finish 12:37PM
# Extras 12:46PM
# ARgument: string
# Return: new string
# Transformation: upcase every other char, downcase rest
def staggered_case(str)
str.chars.map.with_index { |char, idx| idx.even? ? char.upcase : char.downcase }.join
end
def staggered_case2(s... | true |
dc0a5079c6f379f65a42611426e95b3e27ab6a07 | Ruby | sherpc/cryptography | /lab3/main.rb | UTF-8 | 852 | 3.640625 | 4 | [] | no_license | #!/usr/bin/ruby
def make_sqrt_list
cache = { 1 => 1 }
last_key = 1
lambda { |x|
return cache if cache.has_value?(x)
while(last_key != x) do
last_key += 1
#p last_key
cache[last_key * last_key] = last_key
end
cache
}
end
Sqrt_list = make_sqrt_list
def is_sqrt? x, n
y2 = x * ... | true |
ac4ffdb96cee401115af582b1ca0037fd4f69836 | Ruby | need4spd/eulerproject | /need4spd/euler_21.rb | UTF-8 | 942 | 3.484375 | 3 | [] | no_license | def getDivisors(num)
divisors=Array.new(0)
startnum = 1
if num==1
divisors.push(1)
return divisors
end
while true
if num%startnum == 0
divisors.push(startnum)
end
startnum+=1
if num==startnum
break
end
end
return divisors
end
targetnum=1000... | true |
affc11649c01cba7e019dfd1ad2c457e46b5a39d | Ruby | DianaLuciaRinconBl/Ruby-book-exercises | /Arrays/ex_7.rb | UTF-8 | 447 | 4.25 | 4 | [] | no_license | #Write a program that iterates over an array and builds a new
#array that is the result of incrementing each value in the
#original array by a value of 2. You should have two arrays at
#the end of this program, The original array and the new array
#you've created. Print both arrays to the screen using the p
#method ins... | true |
327c9ed76c9c0a59664fd3cd7a0014783305be74 | Ruby | adellanno/Chris-Pine-s-Learn-to-Program | /ch8-arrays-and-iterators/ex8-0.rb | UTF-8 | 346 | 3.609375 | 4 | [] | no_license | # Arrays:
names = ['Ada', 'Belle', 'Chris']
puts names
puts
puts names[0]
puts names[1]
puts names[2]
puts names[3] # This is out of range
other_peeps = []
other_peeps[3] = 'beebee Meaner'
other_peeps[0] = 'Ah-ha'
other_peeps[1] = 'Seedee'
other_peeps[0] = 'beebee Ah-ha'
puts other_peeps
# Notice how [2] is automat... | true |
89b80ee7c29e05aad448b4def7b9136425c8df3d | Ruby | KyleBWilson49/Recusion_Practice | /exponent.rb | UTF-8 | 348 | 3.515625 | 4 | [] | no_license | def recursion1(number, exponent)
return 1 if exponent == 0
number * recursion1(number, exponent - 1)
end
def recursion2(number, exponent)
return 1 if exponent == 0
if exponent.even?
result = recursion2(number, exponent / 2)
result * result
else
exp = recursion2(number, (exponent - 1) / 2)
n... | true |
9418e539e3292fd25dca98f340c6cf9f5b3e05be | Ruby | kristianmandrup/jwt_auth | /lib/jwt_auth/token_validator.rb | UTF-8 | 568 | 2.6875 | 3 | [
"MIT"
] | permissive | module JwtAuth
class TokenValidator
attr_reader :token
def initialize(token)
@token = token
end
def valid_jwt_token?
user_identifier == token_identifier if decoded_data.present?
end
def user_identifier
user.email
end
def token_identifier
decoded_data.first[u... | true |
d333ce374575e00fb3c3bdbd41e23dc06bb49eed | Ruby | Theoonetj/cartoon-collections-online-web-ft-120919 | /cartoon_collections.rb | UTF-8 | 1,506 | 3.75 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(array) # code an argument here
i = 0 # Your code here
while i < array.length
puts "#{i + 1}. #{array[i]}"
i += 1
end
end
dwarvesName = ["Doc", "Dopey", "Bashful", "Grumpy"]
roll_call_dwarves(dwarvesName)
def summon_captain_planet(arr... | true |
e8a935c170d3df0de9c08ac9fc3e0b129f6e31e1 | Ruby | zekrullah97/scutiger | /test/template | UTF-8 | 240 | 2.875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'erb'
class Template
def name
@name ||= 0
@name += 1
"name_a#{@name}"
end
def erb(file)
ERB.new(File.read(file), nil, '-', name).result(binding)
end
end
puts Template.new.erb(ARGV[0])
| true |
d647daa3f28b470a5d6d27f57260399d23741033 | Ruby | c1iff/clock_angle | /lib/clock_angle.rb | UTF-8 | 397 | 3.0625 | 3 | [] | no_license | class String
define_method(:clock_angle) do
hands = self.split(":")
hour_hand = hands.at(0).to_f()
minute_hand = hands.at(1).to_f()
minute_degrees = minute_hand * 6
hour_degrees = ((hour_hand * 30) + (minute_hand/2))
degrees_apart = (hour_degrees - minute_degrees).abs
if (degrees_apart > 1... | true |
4a480f9dea6ced061862d6aef761057265e54dd2 | Ruby | vitaliel/push_chat | /script/comet-push-consume.rb | UTF-8 | 1,202 | 2.515625 | 3 | [] | no_license | require 'rubygems'
require 'em-http'
def subscribe(opts)
listener = EventMachine::HttpRequest.new('http://127.0.0.5/activity?id='+ opts[:channel]).get :head => opts[:head]
listener.callback {
# print recieved message, re-subscribe to channel with
# the last-modified header to avoid duplicate message... | true |
e36c373fc6f291e8fbfcb052b96b8f8eede21c01 | Ruby | agbaber/2018-advent-of-code | /day_01/day_1.rb | UTF-8 | 497 | 3.515625 | 4 | [] | no_license | @input = []
@value = 0
@new_vals = [0]
@i = 0
def read_file
File.open("input.txt", "r") do |f|
f.each_line do |line|
@input << line.chomp
end
end
end
def run
@input.each do |i|
# puts "sending #{i[0]} #{i[1..-1]} "
@value = @value.send(i[0], i[1..-1].to_i)
if @new_vals.include?(@value... | true |
7d733866fdfc1f019a81e08ade21438326334771 | Ruby | ballman/hoops | /app/models/cstv_team_game.rb | UTF-8 | 412 | 2.65625 | 3 | [] | no_license | class CstvTeamGame < TeamGame
def validate_player_total_for_stat(stat)
player_total = player_games.inject(0) { | total, player | total + player.send(stat) }
team_total = self.send(stat)
if (player_total != team_total)
"Team total of #{stat} does not sum. Players = #{player_total} Team = #{team_t... | true |
0f5c74f4cae4707e0e4f49535a4e9b5fbe9278a3 | Ruby | lpenzey/interview_exercises | /cracking_the_code_interview/chapter_1/1.2_check_permutation/lib/check_permutation.rb | UTF-8 | 266 | 3.53125 | 4 | [] | no_license | # frozen_string_literal: true
# Given two strings, write a method to decide
# if one is a permutation of the other.
class CheckPermutation
def check(thing1, thing2)
all_combos = thing1.chars.permutation.map &:join
all_combos.include?(thing2)
end
end
| true |
34a6c5a9ef4fb9d1b0aeb609dbd9fddbf7cc5ff1 | Ruby | greenygh0st/coursemology2 | /app/helpers/course/assessment/question/programming_helper.rb | UTF-8 | 2,328 | 2.59375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Course::Assessment::Question::ProgrammingHelper
# Displays the result alert for an import job.
#
# @return [String] If there is an import job for the question.
# @return [nil] If there is no import job for the question.
def import_result_alert
import_job = @programming... | true |
52a35cdc767c216beb5bea466c584d3e2257d3fe | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz36_sols/solutions/James Edward Gray II/chess/lib/chess.rb | UTF-8 | 365 | 2.53125 | 3 | [
"MIT"
] | permissive | #!/usr/local/bin/ruby -w
# chess.rb
#
# Created by James Edward Gray II on 2005-06-13.
# Copyright 2005 Gray Productions. All rights reserved.
#
# Require this file to gain access to the entire chess library.
require "chess/board"
require "chess/piece"
require "chess/pawn"
require "chess/knight"
require "chess/bis... | true |
646459252f16449b28bd457e693e12e595db4e5d | Ruby | hyphenized/c2-module2 | /week-1/day-3/reduce.rb | UTF-8 | 855 | 4.15625 | 4 | [] | no_license | def reduce(arr, initial)
for x in arr do
initial = yield initial,x
end
initial
end
test_array = [2, 3, 4, 5]
puts reduce(test_array, 0) { |total_sum, current_value| total_sum + current_value }
# Result: 14
# The execution of the method would be:
# First execution the block is provided the arguments... | true |
27ced908bdb2659e1b569ac5d694c16ae20d72b0 | Ruby | alexpapworth/fizzbuzz-app | /app/helpers/application_helper.rb | UTF-8 | 144 | 2.5625 | 3 | [] | no_license | module ApplicationHelper
def check_fizzbuzz(number)
"#{"fizz" if number.to_i % 3 == 0}#{'buzz' if number.to_i % 5 == 0}".capitalize
end
end
| true |
fa727ee1df93180325a9736741b2b45be8f78b86 | Ruby | ryanduchin/ActiveRecordLite | /lib/01_sql_object.rb | UTF-8 | 2,999 | 3.171875 | 3 | [] | no_license | require_relative 'db_connection'
require 'active_support/inflector'
class SQLObject
def self.columns
#get COLUMNS from TABLES (not just instance variables)
#returns array of symbols
DBConnection::execute2(<<-SQL).first.map { |val| val.to_sym }
SELECT
*
FROM
#{table_name}
S... | true |
ae7e3cd361e980ee2279b6fb8de0894d9b2daf74 | Ruby | thetauri/skystone | /SkyStone/plugin.rb | UTF-8 | 563 | 2.515625 | 3 | [] | no_license | module SkyStone
class Plugin
include Singleton
def setup(plugin)
@plugin = plugin
end
def debug(text)
broadcast "SkyStone: #{text}"
end
def event(*args)
@plugin.event(*args)
end
def public_command(*args)
@plugin.public_command(*args)
end
def broadca... | true |
5b69545c038de9f633610010432dab7a4161e281 | Ruby | da99/megauni.ruby | /models/Argumentor.rb | UTF-8 | 1,207 | 3.15625 | 3 | [
"MIT"
] | permissive |
class Argumentor
class Bag
def initialize hash
hash.each { |key, val|
eval %~
def self.#{key}
#{val.inspect}
end
~
}
end
end # === class Bag
def self.argue args, &blok
obj = new
obj.instance_eval {
@args = args
@all... | true |
4941aefd803e277f3445c8af86547518d25d9388 | Ruby | imogenmisso/oystercard-1 | /spec/journey_spec.rb | UTF-8 | 1,010 | 3 | 3 | [] | no_license | require 'journey'
require 'pry'
describe Journey do
let (:oyster) {double :oyster}
let (:station_1) {double :station_1, name: "Aldgate East", zone: 1}
let (:station_2) {double :station_2, name: "Waterloo", zone: 1}
it "has an entry station" do
journey = Journey.new(station_1)
expect(journey.entry_stat... | true |
eb59599d1c36043e00269b7c0df84451a9574e8b | Ruby | anytimesoon/sinatra-mvc-lab-v-000 | /models/piglatinizer.rb | UTF-8 | 808 | 3.625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class PigLatinizer
def piglatinize(text)
answer = text.split(' ').collect do |word|
if first_letter_helper(word) > 0
first_letter = word.slice!(0 .. first_letter_helper(word) - 1 )
word + first_letter + "ay"
else
word + "way"
end
end
answer.join(' ')
end
def ... | true |
24828d962915179a91a9ab3102a9db56a45e3fa2 | Ruby | ScStew/tic_tac_toe_app | /console_game_remake.rb | UTF-8 | 3,490 | 3.453125 | 3 | [] | no_license | require_relative "board.rb"
require_relative "player.rb"
require_relative "ai.rb"
def how_many_players
num = " "
p "how many players 1:2"
until num != " "
num = gets.chomp
# num = "0"
if num == "1"
num = "1"
elsif num == "2"
num = "2"
elsif nu... | true |
b65313ccf9ba0681376a6001c4ac439349dd78db | Ruby | olessiap/learningruby | /Weekly-Projects/week-1/part4.rb | UTF-8 | 142 | 3 | 3 | [] | no_license | require "CSV"
name = "COLIN"
CSV.foreach("/Users/Olie/coding/learningruby/part2.csv") do |row|
if row[0] == name
puts row[3]
end
end
| true |
8888d93887d2264aef3c25aa16eefb4b70268c2a | Ruby | gde-unicamp/gde | /app/crawlers/faculty_mech.rb | UTF-8 | 921 | 2.71875 | 3 | [
"MIT"
] | permissive | #
# A Mech to visit DAC's website and extract
# Faculty and a list of Course codes
#
class FacultyMech < GdeMech
attr_reader :term, :faculty
def initialize(term, faculty)
@faculty = faculty
@term = term
super()
get(dac_page)
end
def dac_page
"http://www.dac.unicamp.br/sistemas/horarios/gr... | true |
f2dba6ceb83dfe03b1b28608be196b150637afd8 | Ruby | travislavery/triangle-classification-v-000 | /lib/triangle.rb | UTF-8 | 908 | 3.3125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Triangle
attr_accessor :type
attr_reader :side1, :side2, :side3
def initialize(side1, side2, side3)
@side1 = side1
@side2 = side2
@side3 = side3
end
def kind
if (check_sides)
if (@side1 == @side2 && @side1 == @side3)
@type = :equilateral
elsif (@side1 == @side2 || @side1 == @s... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.