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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
59eb97306cc4435015f1bd658d24f470fd69a917 | Ruby | michaelchihuyho/Sproutify | /app/models/crop.rb | UTF-8 | 633 | 2.84375 | 3 | [] | no_license | class Crop < ActiveRecord::Base
attr_accessible :name
validates_presence_of :name
validates_uniqueness_of :name
has_many :supplies
has_many :demands
before_save :normalize
def number_supplied(users)
count = 0
users.each do |user|
user.supplies.each do |supply|
count += 1 if supply... | true |
9f1da5f08779a61e9339373ee2f42ebd3e90e2c8 | Ruby | RailsException/nashcode | /db/seeds.rb | UTF-8 | 1,756 | 2.5625 | 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 |
fb5d97a06fedaef500f970ce86ad704c9c6ea814 | Ruby | servidio/BEWD_Homework | /reddit.rb | UTF-8 | 1,857 | 3.984375 | 4 | [] | no_license | # reddit.rb
# requiring both json and rest-client in order to more easily access the
# reddit API
require 'json'
require 'rest-client'
# sets the post count to 0 (for an easier view) and brings in the current
# date and time to head the list of top reddit posts
count = 0
date = Time.new
# uses JSON via a RestClient ... | true |
22f8592927c77e678f33142d4ae5e54512b1128e | Ruby | chumbalum/sidescroller | /levelparser.rb | UTF-8 | 331 | 2.921875 | 3 | [] | no_license |
class Levelparser
def initialize
@level = []
@level_dir = Dir.entries("levels")
@level_dir.shift
@level_dir.shift
file = File.new("levels/"+@level_dir.shift)
file.each{|line| @level << line.strip.split(//) }
file.close
end
def next_wave
@level.shift
... | true |
c1972f4ffa287b8330c6d4db28f6aafec6570259 | Ruby | vladtischenko/post | /address.rb | UTF-8 | 450 | 3.640625 | 4 | [] | no_license |
class Address
attr_accessor :city, :street, :house, :apart
def initialize(data = {})
@city, @street, @house, @apart = data[:city], data[:street], data[:house], data[:apart]
end
def ==(other)
if @city == other.city and
@street == other.street and
@house == other.house and
@apart == other.apart
tru... | true |
265e1b043dc3d1440f115b3887ad09a7913fd485 | Ruby | johny-ger/labs | /lab6/lab6.1/main.rb | UTF-8 | 224 | 2.71875 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'func'
eps = [0.001, 0.0001]
2.times do |i|
result = square(eps[i])
puts "value with eps=#{eps[i]} =\t" + result[0].to_s + "\tnumber of iterations=\t" + result[1].to_s
end
| true |
8ec88e832beb14c7e760e0b87f37ff13bcfc43e3 | Ruby | lexus2727/tweet-shortener-online-web-prework | /tweet_shortener.rb | UTF-8 | 1,100 | 3.734375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
tweet = "Hey guys, can anyone teach me how to be cool? I really want to be the best at everything, you know what I mean? Tweeting is super fun you guys!!!!"
def dictionary
convert = {
"hello" => "hi",
"to" => "2",
"two" => "2",
"too" => "2",
"for" => "4",
"fo... | true |
403e57fcb803fa6c1199a5bbeaa0434bf22f9610 | Ruby | Keisuke-Awa/algorithm | /atcoder/beginners_selection/card_game_for_two.rb | UTF-8 | 214 | 3.03125 | 3 | [] | no_license | n = gets
cards = gets.split.map(&:to_i)
odds = []
evens = []
cards.sort.reverse.each.with_index(1) do |num, i|
if i.odd?
odds << num
else
evens << num
end
end
puts odds.inject(&:+) - evens.inject(&:+) | true |
44c3066a41927ec723953142169b52643bfc5a4e | Ruby | SciRuby/iruby | /lib/iruby/comm.rb | UTF-8 | 1,104 | 2.796875 | 3 | [
"MIT"
] | permissive | module IRuby
# Comm is a new messaging system for bidirectional communication.
# Both kernel and front-end listens for messages.
class Comm
attr_writer :on_msg, :on_close
class << self
def target; @target ||= {} end
def comm; @comm ||= {} end
end
def initialize(target_name, comm_... | true |
fbd2bb11f3b4e5e3670fc827b1d807d89a2defc7 | Ruby | runzezhang/MOOCs | /Coursera/Data Structure and Algorithm/Algorithmic Toolbox/week5_dynamic_programming1/5_longest_common_subsequence_of_three_sequences/by_learners/lcs3.rb | UTF-8 | 287 | 3.15625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby
# by Andronik Ordian
def lcs3(a, b, c)
# write your code here
[a.size, b.size, c.size].min
end
if __FILE__ == $0
data = STDIN.read.split().map(&:to_i)
n = data[0]
a = data[1..n]
m = data[n+1]
b = data[n+2..n+1+m]
c = data[n+3+m..-1]
puts lcs3(a, b, c)
end
| true |
e2fe859abe737250d42a2992e6b547d30f53ae51 | Ruby | aureliojargas/publisher | /lib/topic_changes/processor.rb | UTF-8 | 3,054 | 2.828125 | 3 | [
"LicenseRef-scancode-proprietary-license",
"MIT"
] | permissive | module TopicChanges
class Processor
def initialize(rows, logger = nil)
@rows = rows
@logger = logger || Rails.logger
end
def run
logger.info "Rows: #{rows.size}"
rows.each do |row|
process_row(row)
end
end
private
attr_reader :rows, :logger, :republish
... | true |
b79e1b1d4aaafe9525f4386e1a6abc408f4e2454 | Ruby | alex-metasploit/metasploit-clone | /zhiwenuil-metasploit/lib/packetfu/ipv6.rb | UTF-8 | 6,525 | 2.953125 | 3 | [
"BSD-3-Clause"
] | permissive | module PacketFu
# AddrIpv6 handles addressing for IPv6Header
#
# ==== Header Definition
#
# Int32 :a1
# Int32 :a2
# Int32 :a3
# Int32 :a4
class AddrIpv6 < Struct.new(:a1, :a2, :a3, :a4)
include StructFu
def initialize(args={})
super(
Int32.new(args[:a1]),
Int32.new(args[:a2]),
Int32.n... | true |
7a00bdb7b28e4df2890e42a625a5fe2be27187cb | Ruby | TurtleFeeder/Campgrounds | /campgrounds_backend/app/services/api_service.rb | UTF-8 | 1,634 | 2.625 | 3 | [] | no_license | module ApiService
def self.getFacilities(abbrev='NY')
base_url = 'https://ridb.recreation.gov/api/v1/facilities'
query_url = '?query=camping&limit=50&offset=0&full=true&activity=CAMPING&lastupdated=10-01-2018&state='
state = abbrev
full_url = base_url + query_url + state
header = {accept: "applica... | true |
da72f4a7909aedd5cae98947148a8a624226583b | Ruby | yuki3738/AtCoder | /abc/abc136/tasks/abc136_a.rb | UTF-8 | 91 | 3.015625 | 3 | [] | no_license | a, b, c = gets.split.map(&:to_i)
res = c - (a - b)
if res > 0
puts res
else
puts 0
end
| true |
9e317e151ede35d9ad165bcf6b6742354930efe9 | Ruby | GarrisonJ/simple_chat | /client/window.rb | UTF-8 | 4,009 | 3.3125 | 3 | [] | no_license | # Copyright © 2014 Garrison Jensen
# License
# This code and text are dedicated to the public domain.
# You can copy, modify, distribute and perform the work,
# even for commercial purposes, all without asking permission.
require "curses"
require "set"
require "./message"
class Window
include Curses
def initi... | true |
4c8163f6c0a3553831bf42d42a9c748c349013c0 | Ruby | hugginsc10/AppAcademy | /Ruby/W7D2/anagrams.rb | UTF-8 | 818 | 3.609375 | 4 | [] | no_license | str = "gizmo"
def first_anagram?(str)
str.chars.permutation.to_a.map(&:join)
end
p first_anagram?("gizmo")
def second_anagram?(str1,str2)
str2 = str2.chars
str1 = str1.chars.each do |char|
if !str2.index(char).nil?
str2[str2.index(char)] = ""
end
end
p str2
end... | true |
40f1d4ecc1fb54e13e9b6555e2abab655053e248 | Ruby | Winglu/Triplocal_landing_site | /v2/prelanuch_backend/app/controllers/suggest_hosts_controller.rb | UTF-8 | 960 | 2.546875 | 3 | [] | no_license | class SuggestHostsController < ApplicationController
def index
@hosts = params[:hosts]
if @hosts != nil
json = JSON.parse(@hosts)
json.each do |hostInf|
if hostInf["name"]!="" && hostInf["email"]!=""
if valid_email?(hostInf["email"])
@aHost = Suggesthost.find_b... | true |
479bfd13166208e2d46a499727747d0438363998 | Ruby | takaxyz/atcoder | /ABC086/A.rb | UTF-8 | 68 | 3.109375 | 3 | [] | no_license | a,b=gets.chomp.split.map(&:to_i)
puts (a*b).even? ? "Even" : "Odd"
| true |
7742b969ee83c02eb48ad230d09d33059b322c91 | Ruby | rock-core/tools-log_tools | /lib/log_tools/post_processing.rb | UTF-8 | 19,479 | 2.8125 | 3 | [] | no_license | require 'pocolog'
module LogTools
# Main class to build post-processing pipelines for log datasets
class PostProcessing
# A region in a log stream
class Region
# The start sample of the region
#
# @return [Integer]
attr_reader :start_time
... | true |
97f53c7d8f1cca9042464c66721b9f82c7f85244 | Ruby | IngramCapa/bank_tech_test | /spec/transaction_history_spec.rb | UTF-8 | 1,283 | 2.640625 | 3 | [] | no_license | require 'transaction_history'
describe TransactionHistory do
let(:subject) { TransactionHistory.new(transaction_class) }
let(:transaction_1) { double :transaction }
let(:transaction_2) { double :transaction }
let(:transaction_class) { double :transaction_class, new: transaction_1 }
before(:each) do
all... | true |
4ea7eef5519fd2c876d370447f035cbcefad837a | Ruby | nihilence/chess | /pieces/sliding_piece.rb | UTF-8 | 1,235 | 3.46875 | 3 | [] | no_license | class SlidingPiece < Piece
# returns a list of moves that represent squares that extend from the position
# to the edges of the board or until it reaches a piece.
def moves(pos = self.pos, directions)
legal_moves = []
pos_x, pos_y = pos
directions.each do |direction|
x, y = direction
edg... | true |
6e58ed82426ae3ad6ee247b8de52d868aa442fd5 | Ruby | mattbryce93/CodeClan-Course | /week_02/day_1/intro_to_oop/bank_account.rb | UTF-8 | 803 | 3.296875 | 3 | [] | no_license | class BankAccount
# attr_reader :holder_name, :balance, :type
# attr_writer :holder_name, :balance, :type
attr_accessor :holder_name, :balance, :type
def initialize(input_name, input_balance, input_type)
@holder_name = input_name
@balance = input_balance
@type = input_type
end
# def holder_nam... | true |
4496ec7b8ae42a44683e328e1ee234c66f26fdae | Ruby | EricaNichol/CodeCore- | /react-native/week_1/fizzbuzzclass.rb | UTF-8 | 467 | 3.828125 | 4 | [] | no_license |
class Fizzbuzz
attr_accessor :number
attr_accessor :number2
def initialize (number,number2)
@number = number
@number2 = number2
end
def run
array = []
array << new_value
array
print array
end
def new_value
array = (1..100).to_a
array.each do | x |
if x % @number == 0 && x % @number2 == 0
... | true |
f0dffca4bb1b526d2bf0e01a69a1e6c6a7dd2e57 | Ruby | IceDragon200/ruby-minil | /lib/minil/layout/functions.rb | UTF-8 | 3,126 | 2.96875 | 3 | [
"MIT"
] | permissive | require 'minil/image'
require 'minil/rect'
module Minil
module Layout
def slice_vert(r, func1, func2)
lambda do |image, rect, options|
rect1 = rect.dup
rect2 = rect.dup
rect1.height *= r
rect2.height -= rect1.height
rect2.y += rect1.height
func1.call(image, r... | true |
ac52a799c8e88c54d19df638cdea6d5d60e0fa31 | Ruby | passcod/blog | /bin/fanficline | UTF-8 | 5,071 | 2.703125 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | #!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'nokogiri'
require 'typhoeus'
class Fic
def initialize(url, star)
@url = URI url
@star = star
@doc = Nokogiri::HTML Typhoeus.get(@url, followlocation: true, accept_encoding: 'gzip,deflate,br').body
end
def fantag(dom)
case dom
whe... | true |
273c0a3e6faf0f21538156a01eb5d13e48743e01 | Ruby | 13um45/wyncode | /batman_live_coding.rb | UTF-8 | 1,888 | 3.96875 | 4 | [] | no_license | puts "After all of your hard work you've become Batman!"
# question 1
puts "Who will be your sidekick?"
puts "Options: Batgirl or Robin"
# canonicalization
sidekick = gets.chomp.downcase
# p response, response.class
if sidekick == "robin"
puts "Robin: Holy rusted metal, Batman!"
elsif sidekick == "batgirl"
puts "Ba... | true |
984f73ae70f38d2fb5263a5eada2c8c17401a12b | Ruby | gberger/codejam2014 | /qualification-b/solution.rb | UTF-8 | 738 | 3.03125 | 3 | [] | no_license | def minimize_time(time_elapsed, rate, cost, additional, goal)
# wait out
wait_time = time_elapsed + goal/rate
# buy
buy_time = time_elapsed + cost/rate
rate += additional
buy_and_wait_time = buy_time + goal/rate
if wait_time < buy_and_wait_time
wait_time
else
[
buy_and_wait_time,
... | true |
9061f9d5bcfcc6e0f354af6fc663a3812fd87ccb | Ruby | crayray/sinatra-basic-routes-lab-austin-web-102819 | /app.rb | UTF-8 | 281 | 2.515625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative 'config/environment'
class App < Sinatra::Base
get '/name' do
"My name is Rachel"
end
get '/hometown' do
"My hometown is Albuquerque, NM"
end
get '/favorite-song' do
"My favorite song is Malhuga by A-WA"
end
end
| true |
7bbd50bbad60a1428fe479b4b28bf3e608e42bc0 | Ruby | Calliari/coursework | /lab/starter-code/person.rb | UTF-8 | 999 | 3.25 | 3 | [] | no_license | class Person
def name
# create a name variable
name = "Osvaldo"
end
def age
# create age variable here
age = 30
end
def children
# create children array here
children = []
children.push "Jhon", "Anna", "Nick", "Clei"
end
def add... | true |
f89504b8e01b757d67ad8e205706d230d69b8c68 | Ruby | aitchiss/codeclan_caraoke | /specs/song_spec.rb | UTF-8 | 341 | 2.75 | 3 | [] | no_license | require ('minitest/autorun')
require_relative ('../song.rb')
class TestSong < MiniTest::Test
def setup
@born_to_run = Song.new("Bruce Springsteen", "Born to Run")
end
def test_song_has_title
assert_equal("Born to Run", @born_to_run.title)
end
def test_song_has_artist
assert_equal("Bruce Spr... | true |
04203b56fc30212bee3f046c424ccc444686bfda | Ruby | lamikae/ejb-dispatcher | /lib/ejbdispatcher/home_object.rb | UTF-8 | 2,874 | 2.875 | 3 | [
"MIT"
] | permissive | # Static class for lookup of a remote EJB Home.
class HomeObject
attr_reader :context
def initialize(ctx)
logger.debug 'Initializing HomeObject: %s' % ctx.inspect
self.class.validate_ctx(ctx)
@context = self.initial_context(ctx)
end
class << self
def logger
EJBDispatcher.logger
end
... | true |
a962e39f974b37705cf37ee9be3df5379d5bf177 | Ruby | katharinechen/point_of_sale | /lib/store.rb | UTF-8 | 257 | 2.671875 | 3 | [
"MIT"
] | permissive | class Store < ActiveRecord::Base
has_and_belongs_to_many :cashiers
validates :name, :presence => true
before_save :titleize_name
private
def titleize_name
self.name = self.name.split(" ").map { |word| word.capitalize}.join(" ")
end
end | true |
15b6194dbfec1096f7068a9dacf4cd07db0ca5be | Ruby | jahnavisen/kwk-l1-dance-instructions-kwk-students-l1-nyc-080618 | /steps.rb | UTF-8 | 82 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def two_step
puts "step to the right"
puts "step to the left"
end
two_step | true |
a219c5f5a88d76f82cbff822958060c20e871ecb | Ruby | EkispertWebService/ekispert-sdk-ruby | /lib/ekispert/error.rb | UTF-8 | 740 | 2.546875 | 3 | [
"MIT"
] | permissive | module Ekispert
class Error < StandardError
class ClientError < Error
def initialize(res)
@res = res
super(format_error_body)
end
private
def format_error_body
%(
status : #{@res.status}
URL : #{@res.env.url}
message : #{sp... | true |
b923343bd9c9233cf91bb53544b9616d68b49bb2 | Ruby | eemr3/linguagem-ruby | /emerson_moreira/ruby/mainData.rb | UTF-8 | 1,980 | 3.640625 | 4 | [] | no_license | require_relative 'data.rb'
result = Calc_Data.new
resposta = ''
loop do
puts "Resultado: #{resposta}"
puts "\nSelecione uma da opções"
puts '1 - Somar dias'
puts '2 - Subtrair dias'
puts '3 - Somar semana'
puts '4 - Subtrair semana'
puts '5 - Somar meses'
puts '6 - Subtrair meses'
puts '7 - Soma... | true |
0b7be710d33487b9f53afed9e9953c2e0d48ec42 | Ruby | aliceFung/project_tdd_minesweeper | /lib/player.rb | UTF-8 | 950 | 3.671875 | 4 | [] | no_license | class Player
attr_reader :difficulty
def initialize(board)
@board = board
end
def level
print "Select level (B)beginner, (I)intermediate, (A)advanced:"
selected_level = gets.chomp.upcase
@difficulty = selected_level[0]
end
def select_move
correct_input = false
move = nil
unti... | true |
cf2ae2f48839fd9f4be49f6dc27f69d2db119342 | Ruby | rsmith88/Ruby-Practice | /codecademy/CC_IsPrime.rb | UTF-8 | 219 | 4.03125 | 4 | [] | no_license | def is_prime(n)
is_prime = true
for integer in 2...n
if n % integer == 0
is_prime = false
end
end
if is_prime
puts "#{n} is prime!"
else
puts "#{n} is not prime."
end
end
is_prime(41)
is_prime(51) | true |
a677d2fd9008e485953fe6ff1814d95535cfacd0 | Ruby | philjdelong/book_club | /db/seeds.rb | UTF-8 | 1,048 | 2.53125 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
47411303751c389174dfbd35a7d7bd733bce326f | Ruby | mattjmorris/dvo | /spec/board_spec.rb | UTF-8 | 5,002 | 3.203125 | 3 | [] | no_license | require "spec"
require File.dirname(__FILE__) +"/../src/board"
require File.dirname(__FILE__) +"/../src/piece"
describe Board do
before(:each) do
@board = Board.new
end
it "contains all of the spaces on a dvonn board" do
@board.spaces.length.should == 49
@board.spaces.sort.map{|s| s.position}.should... | true |
999daf14331eedfdf358cf87d229d860f5683919 | Ruby | justinwang11/AppAcademy | /w4d2-99cats-part1-master/app/models/cat.rb | UTF-8 | 593 | 2.84375 | 3 | [] | no_license | class Cat < ActiveRecord::Base
has_many :cat_rental_requests
validates :birth_date, :name, :sex, :color, presence: true
validate :proper_color
validate :proper_sex
def proper_color
colors = ["white", "black", "red", "green", "blue", "purple"]
unless colors.include?(self.color.downcase)
errors[... | true |
3aaf7a74759d775cab5b53aebf312ee42cdcaed9 | Ruby | ranjan/tweet | /tweet.rb | UTF-8 | 372 | 3.015625 | 3 | [] | no_license | require './lib/twitter'
hashtag = ARGV.first
if hashtag.nil?
puts "Please provide tag you want to fetch. Example 'rails'"
exit
else
hashtag = '#'+hashtag
end
twitter = Twitter.new(hashtag)
puts "fetching tweets for hashtag : #{hashtag} ......"
twitter.search.each_with_index do |tweet, index|
index... | true |
a5beb8f9754cbd42b54f2c4497a200268383d4fd | Ruby | fschaeffler/mail_man | /mail_man.rb | UTF-8 | 3,677 | 2.734375 | 3 | [] | no_license | require 'rubygems'
require 'yaml'
require 'timeout'
require "#{File.dirname(__FILE__)}/pop_ssl"
require 'net/smtp'
require 'tmail'
class MailMan
TEMPFILE = "/tmp/MailMan"
TIMEOUT = 45
STUNNEL_PORT = 20000
def check
if File.exists?(TEMPFILE)
log "Already running. Delete #{TEMPFILE} if this is a mist... | true |
11a672bee553cdc3c86bf87ccdc9653d2a7d7749 | Ruby | fencedin/train_system | /spec/station_spec.rb | UTF-8 | 1,228 | 2.9375 | 3 | [] | no_license | require 'spec_helper'
describe 'Station' do
it 'initializes with a name' do
station = Station.new({:name => 'Beaverton Central'})
station.should be_an_instance_of Station
end
it 'gives back the station name' do
station = Station.new({:name => 'San Francisco'})
station.name.should eq 'San Francis... | true |
57432abed5683597f4a6c156844a796ce31d76d4 | Ruby | rockyboyyang/ruby_learning | /variables.rb | UTF-8 | 80 | 2.671875 | 3 | [] | no_license | # Variables
location = "SF"
puts location
my_num = 32
my_num += 10
puts my_num | true |
f6e6c4ad610d16457fde1e40cef2cca6e45eda77 | Ruby | flyeven/rSugar | /hash_default_value.rb | UTF-8 | 1,323 | 3.21875 | 3 | [] | no_license | #!/usr/bin/env ruby
#-*- coding: utf-8 -*-
h1, h2 = {}, Hash.new
puts "-" * 25
puts " {}[:a] => #{h1[:a].inspect}"
puts "Hash.new[:a] => #{h2[:a].inspect}"
puts
h3 = Hash.new 0
puts "-" * 25
puts " h = Hash.new 0"
puts " ... h[:a] => #{h3[:a].inspect}"
h3[:a] += 1
puts " h[:a] += 1"
puts " ... h[:a] => #... | true |
c9bf60d9a2bd6440a3a70fe6f81d338817b20163 | Ruby | gb23/ruby-music-library-cli-v-000 | /lib/concerns/concerns.rb | UTF-8 | 452 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | module Concerns
module Findable
def find_by_name(name)
self.all.detect{ |song|
song.name == name
}
end
def find_or_create_by_name(name)
result = find_by_name(name)
if result.nil?
self.new(name).tap{ |instance|
... | true |
2c54fb6186888b6794a10eb7491cb3e55d0af9fb | Ruby | busman84/atx-4-clone | /w03/d02/afternoon/instructor/dog/spec/dog_spec.rb | UTF-8 | 456 | 3.25 | 3 | [] | no_license | require_relative '../dog.rb'
describe Dog do
describe '#initialize' do
it 'creates a new dog object' do
expect(Dog.new("Spot").class).to eq(Dog)
end
it 'takes an argument name and sets the name of the dog' do
expect(Dog.new("Spot").name).to eq("Spot")
end
end
describe '#bark_name' d... | true |
3aa3e155fecf2dc4e3fcbea3a6d8c240b49eb096 | Ruby | PhilippePerret/bin-vite-faits | /lib/modules/operations/check.rb | UTF-8 | 2,641 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | # encoding: UTF-8
=begin
Module qui checke la validité des opérations définies
=end
class ViteFait
# Cette méthode s'assure que le fichier des opérations est conforme
# On peut l'appeler par 'vitefait check-operations' ou
# 'vitefait operations -c'
def check_operations_file
errors = []
clear
no... | true |
452384af0b8dc66ccbc1d0127cf1fbd0fb4ac09a | Ruby | whakapapa-HTML/pro-Ruby- | /hash.rb | UTF-8 | 82 | 3.21875 | 3 | [] | no_license | h = Hash.new{'hello'}
a = h[:foo]
b = h[:bar]
a.equal?(b)
puts a.upcase!
puts b | true |
0845610324b707dec0d1279d75116bdd56baec2b | Ruby | benamatare/activerecord-tvshow-web-012918 | /app/models/show.rb | UTF-8 | 442 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Show < ActiveRecord::Base
def self.highest_rating
Show.maximum(:rating)
end
def self.most_popular_show
self.find_by_rating(self.highest_rating)
end
def self.lowest_rating
minimum(:rating)
end
def self.least_popular_show
self.find_by_rating(self.lowest_rating)
end
def self.ratings_sum
sum(:rating)
... | true |
acf54713c755d6d1244d68201006e574573bf540 | Ruby | rurigrass/codeclancombat | /models/specs/battle_spec.rb | UTF-8 | 344 | 2.59375 | 3 | [] | no_license | require("minitest/autorun")
require("minitest/rg")
require_relative("../battle")
class TestBattle < Minitest::Test
def setup
options = {
"id" => 1,
"player1_id" => 1,
"player2_id" => 2,
"outcome" => 1
}
@battle = Battle.new(options)
end
def test_wins
assert_equal(1, @ba... | true |
8494c91e9f3047ee4669d2b447807e7225c8265b | Ruby | craigw/quill | /lib/quill/application.rb | UTF-8 | 1,230 | 2.828125 | 3 | [
"MIT"
] | permissive | module Quill
class Application
QUIT_COMMAND = "quit"
attr_accessor :execution_context, :input, :output
private :execution_context=, :input=, :output=
def initialize options = {}
self.input = options[:input] || STDIN
self.output = options[:output] || STDOUT
self.execution_context = ... | true |
b3bca120e4e03a3b7a8624c2a0a7a4189c4a34c6 | Ruby | tjnz/has-many-through-forms-rails-labs-v-000 | /app/models/post.rb | UTF-8 | 581 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Post < ActiveRecord::Base
has_many :post_categories
has_many :categories, through: :post_categories
has_many :comments
has_many :users, through: :comments
def categories_attributes=(atts)
atts.values.each do |att|
if !is_blank?(att)
category = Category.find_or_create_by(att)
self.categ... | true |
9bdea34c4530d412dfea4b0725fb1b2a882f7040 | Ruby | LisaHJung/programming-univbasics-4-intro-to-hashes-lab-denver-web-033020 | /intro_to_ruby_hashes_lab.rb | UTF-8 | 434 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def new_hash
new_hash = {}
end
def my_hash
my_hash = {"groceries":"eggs"}
end
def pioneer
pioneer= {:name=>"Grace Hopper"}
end
def id_generator
hash_id = {:id=> 7}
end
def my_hash_creator(key, value)
hash_creator = { }
hash_creator[key] = value
hash_creator
end
def read_from_hash(hash, key)
hash[ke... | true |
4385021e9c1ce4cfd686485f7f5b660e8ce37e13 | Ruby | waydeg/talentjunkie | /script/talentjunkie/feed_classify.rb | UTF-8 | 2,055 | 2.625 | 3 | [] | no_license | #!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require "#{RAILS_ROOT}/config/environment"
#require 'classifier' #monkey pachtes array, doesnt work with ActiveRecord
class Logger
def format_message(severity, timestamp, msg, progname)
"#{severity.upcase} [#{Time.now.strftime("%m-%d-%Y %H... | true |
b8e2893f546ed66868ad5f999ff0dd39761f026f | Ruby | covaithe/project_euler | /059/problem.rb | UTF-8 | 969 | 3.03125 | 3 | [] | no_license |
cipher = File.read("cipher1.txt")
cipher_chars = cipher.split(",")
possible_keys = Enumerator.new do |yielder|
'a'.upto('z').each do |a|
'a'.upto('z').each do |b|
'a'.upto('z').each do |c|
yielder << a+b+c
end
end
end
end
potentials = {}
possible_keys.each do |key|
# puts "testing... | true |
1d8e4986a711f1ddf6b5a92a86fb76d819961f42 | Ruby | averysoren/ls-core-curriculum | /exercises/rb101/easy_3/palindromic_strings.rb | UTF-8 | 955 | 4.5 | 4 | [] | no_license | # palindromic_strings.rb
# Part 1
=begin
def palindrome?(str)
str.reverse == str
end
puts palindrome?('madam') == true
puts palindrome?('Madam') == false # (case matters)
puts palindrome?("madam i'm adam") == false # (all characters matter)
puts palindrome?('356653') == true
# Further Exploration
def pa... | true |
ac15f66b9c7a0afaa80f6a252f207eca99249f27 | Ruby | yeti-detective/RubyChess | /queen.rb | UTF-8 | 255 | 2.8125 | 3 | [] | no_license | require_relative 'piece'
require_relative 'slideable'
class Queen < Piece
include Slideable
def initialize(color, board, pos)
super(color, board, pos)
@symbol = "\u2655 "
end
def move_dirs
horizontal_dirs + diagonal_dirs
end
end
| true |
b9b5113849ad14bd811f9e3078829e43d54336df | Ruby | anotherainaa/Ruby-Fundamental-Problems | /methods/getting_through_methods_part_2.rb | UTF-8 | 96 | 2.796875 | 3 | [] | no_license | def hello
'Hello'
end
def world
'World'
end
def greet
hello + " " + world
end
p greet
| true |
2a2fe91a79180b7516708dca16ca35d9484d12a0 | Ruby | stormruby/myruby | /str.rb | UTF-8 | 288 | 3.796875 | 4 | [] | no_license |
def concat_str(str1,str2)
# convert strings to arrays
arr1 = str1.unpack("C*")
arr2 = str2.unpack("C*")
# concat the arrays
arr = arr1 + arr2
# convert arrays back to string
arr.pack("C*")
end
str1 = 'a'
str2 = 'b'
str3 = concat_str(str1,str2)
puts str3
puts str3.length
| true |
c5468e0a0f2373ccb653f3c8eea37fc37aecaf57 | Ruby | theneutronchef/rails-proj2 | /app/models/car.rb | UTF-8 | 600 | 2.53125 | 3 | [] | no_license | # == Schema Information
#
# Table name: cars
#
# id :integer not null, primary key
# driver :integer
# number_of_seats :integer
# origin :string(255)
# created_at :datetime
# updated_at :datetime
#
class Car < ActiveRecord::Base
has_many :relations
# has_many... | true |
e7b81839655db6b5c02bbc82b88460f5e81e23ea | Ruby | MihailSergeenkov/ror_basic | /lesson_9/route.rb | UTF-8 | 1,014 | 3.359375 | 3 | [] | no_license | require_relative 'train.rb'
require_relative 'station.rb'
require_relative 'validation.rb'
class Route
include Validation
attr_accessor :stations
attr_reader :first_station, :finish_station
validate :first_station, :presence
validate :first_station, :type, Station
validate :finish_station, :presence
va... | true |
ae34052dee045e098a2e8fa4678671d7e2e09866 | Ruby | cmdalbem/redetrabalhosinf | /inf/app/models/course.rb | UTF-8 | 545 | 2.53125 | 3 | [] | no_license | class Course < ActiveRecord::Base
has_many :projects
validates :name, presence: true
validates :code, uniqueness: true
def self.search(search)
search.downcase!
if search
query = []
params = []
# Creates queries for each word of the input, and then join them with ANDs.
words = search.split(" ")
... | true |
1b29fbf3062c153e0c9810a7730509ff218e07ff | Ruby | yiyizym/biyu_tucao | /handler.rb | UTF-8 | 2,122 | 2.96875 | 3 | [] | no_license | require 'yaml'
require 'erb'
require 'logger'
class Handler
attr_reader :current_path, :logger, :timestamp, :all_content, :first_unshown_content
def initialize
@current_path = File.dirname(__FILE__)
@logger = Logger.new(File.join(current_path,'operation.log'))
@timestamp = Time.now
@all_content ... | true |
e87858b0cbdf4f369c9cf1278ec4e064bb411844 | Ruby | wulftone/goliath-heroku-postgres-example | /hello.rb | UTF-8 | 1,389 | 2.546875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'goliath'
require 'erb'
require 'uri'
require 'em-synchrony/activerecord'
require 'yajl'
db = URI.parse(ENV['DATABASE_URL'] || 'http://localhost')
if db.scheme == 'postgres' # This section makes Heroku work
ActiveRecord::Base.establish_connection(
:adapter => db.scheme == 'postgres'... | true |
4aa5765550443c37605abec6eb2d77e4ff4dabe7 | Ruby | dmhallahan/ssvp | /app/views/sandbox/test.pdf.prawn | UTF-8 | 713 | 2.5625 | 3 | [] | no_license | pdf.bounding_box [100,600], :width => 200 do
pdf.text "The rain in spain falls mainly on the plains " * 5
pdf.stroke do
pdf.line pdf.bounds.top_left, pdf.bounds.top_right
pdf.line pdf.bounds.bottom_left, pdf.bounds.bottom_right
end
end
pdf.bounding_box [100,500], :width => 200,... | true |
8248b7ab360248c9cb716bc3b475e6f58e935862 | Ruby | anaalta/lrthw | /lrthw/ex36/ex36.rb | UTF-8 | 2,453 | 3.953125 | 4 | [] | no_license | def start
puts "You wake up in your room, but there's a strange silence around. No one seems to be home, but you hear some noises in the hallway. Press 1 if you go and check, press 2 if you just stay in"
print "Your choice:"
path1 =$stdin.gets.chomp
if path1 == "1"
hallway
elsif path1 == "2"
room
el... | true |
db9e782d72f73b3218e3719024fd9590c705e598 | Ruby | cribbles/tiktak | /app/helpers/application_helper.rb | UTF-8 | 542 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'benchmark'
module ApplicationHelper
def benchmark_start
@benchmark ||= Time.now
end
def benchmark_result
(Time.now - benchmark_start).round(3)
end
def titleize(page_title)
page_name = (page_title.empty? ? "" : (" - " + page_title))
Settings.site_name + page_name
end
def sizei... | true |
78f1b250e2829a994c809a85b5bc765d19997c5a | Ruby | arunsatyarth/BlockAuth | /ms_login/app/helpers/users_helper.rb | UTF-8 | 3,597 | 2.8125 | 3 | [] | no_license | module UsersHelper
#Types of action that a person might wanna do
ACTION_ARTICLE=0#Needs RED badge
ACTION_DISCUSSION=1#Needs Yellow
ACTION_DISCUSSION_COMMENT=2#Needs Yellow
# including commenting in post,article,liking creating albums etc.
ACTION_OTHER=3#Needs Blue
ACCESS_ACCOUNT_BLOCKED=0
ACCESS_BADGE_NOTEARN... | true |
5a592a64d7c50a86561d52f1c2faee5ac775124e | Ruby | jack604/rc1 | /specific/hashes.rb | UTF-8 | 2,175 | 3.796875 | 4 | [] | no_license | #Hashes (in other languages also called dictionaries or maps)
#how, why, they are used.
#Silmilarity to blocks.
#important to master Hashes API!
#Documentation @ ruby-doc.org/core-2.2.0/Array.html
#indexed collections of object references
#created with either {} or Hash.new
#Also known as associative arra... | true |
b92e60d0a9b1413fc2ec2128ba1c8154d616d242 | Ruby | oieioi/circleci_crawler | /lib/circleci_crawler.rb | UTF-8 | 1,021 | 2.703125 | 3 | [
"MIT"
] | permissive | require "circleci_crawler/version"
require 'net/https'
require 'json'
module CircleciCrawler
class Crawler
def initialize(api_token:, project_path:, path:)
@api_token = api_token
@project_path = project_path
@path = path
end
def crawl
results = request("https://circleci.com/api/... | true |
55ea284b84b584d864e788d8df29fc1206166f34 | Ruby | DonHanna790/ror-class | /ruby-course/week2/beer_song_2.0.rb | UTF-8 | 431 | 4.28125 | 4 | [] | no_license | class Beer
def initialize(bottles)
@bottles = bottles
end
def song
@bottles = 99
while @bottles > 0
puts @bottles.to_s + " bottles of beer on the wall. " + @bottles.to_s +
" bottles of beer."
(@bottles -= 1).to_s
puts "Take one down, pass it around. " + @... | true |
050168620a01a16f80068031f4ae3a0cd8141a72 | Ruby | adamcarlile/wedding | /app/renderers/menu/link_renderer.rb | UTF-8 | 870 | 2.515625 | 3 | [] | no_license | module Menu
class LinkRenderer
attr_reader :title, :path
def initialize(context, title, path, &block)
@context = context
@title = title
@path = path
@sub_menu = Menu::ListRenderer.new(context, &block) if block_given?
end
def render
@context.content_tag(:li) do
... | true |
49c84d9e19fb9ec17fd3ad40862e17f14312d209 | Ruby | Harritone/Thinknetica | /lesson_4/lib/dialogs/station_creation_entry_dialog.rb | UTF-8 | 461 | 3.140625 | 3 | [] | no_license | require_relative 'dialog'
# require_relative '../station.rb'
class StationCreationEntryDialog < Dialog
private
def get_input
show_dialog_name 'station creation entry dialog'
puts 'To create station input the name'
@name = check_choice(gets.chomp)
end
def handle_choice
clear
station = Stat... | true |
0c4cc4c2e9848151d560cc308580d9cbc87bbf56 | Ruby | bimbram/launchschool | /100_programming_back_end_prep/01/codeacademy_rubytrack/05_blocks_and_sorting/01_methods,_blocks,_&_sorting/10_how_blocks_differ_from_methods.rb | UTF-8 | 1,201 | 4.625 | 5 | [] | no_license | # How Blocks Differ from Methods
#===============================================================================
#
# -There are some difference between blocks and Methods
# -In our case, the method can be called anytime while the block that we defined
# will only be called once and in the context of the array that we ... | true |
ca27d356d95ccbea6ef0eb6887af047d7726de20 | Ruby | jayngng/study_ruby | /basic/ProtectedInheritance.rb | UTF-8 | 188 | 3.0625 | 3 | [] | no_license | #!/usr/bin/ruby
class A
protected
def getProtected
"This is a protected method!"
end
end
class B < A
def printProtected
obj = A.new
obj.getProtected
end
end
| true |
69256217ab854a9da0bd3915911c9f31bdb11709 | Ruby | lucasjct/Ruby-Brief-Introdution | /estruturas-de-controle/while.rb | UTF-8 | 47 | 3.265625 | 3 | [] | no_license | x = 1
while x < 10
x = x +1
puts x
end | true |
ae0d02bb1cfb70bd741ebe465343c3c483ea2d54 | Ruby | mmrobins/fastly-ruby | /lib/fastly/settings.rb | UTF-8 | 1,505 | 2.65625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Settings Object
class Fastly
# Represent arbitary key value settings for a given Version
class Settings < Base
attr_accessor :service_id, :version, :settings
##
# :attr: service_id
#
# The id of the service this belongs to.
#
##
# :attr: version
#
# The number of the versi... | true |
ec622725a0e9e3a2412d684a352912ee6f1b2ee1 | Ruby | o-kot/Praca-dyplomowa | /nutrimngr/app/models/user_pg.rb | UTF-8 | 885 | 2.578125 | 3 | [] | no_license | class UserPg
def userExists? (email)
UserDbModel.where(Login:email).exists?
end
def saveUser (email, passwd)
if userExists? (email)
return 'Użytkownik o podanym mailu jest już zarejestrowany w bazie.'
elsif !passwd.match /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#... | true |
18bdba4e61cfadef5a726f7de728c62a17ca69aa | Ruby | samanthagongora/rails_engine | /app/models/merchant.rb | UTF-8 | 2,983 | 2.578125 | 3 | [] | no_license | require 'date'
class Merchant < ApplicationRecord
has_many :invoices
has_many :items
def revenue_by_date(date=nil)
if date.nil?
amount = invoices
.joins("INNER JOIN invoice_items
ON invoices.id = invoice_items.invoice_id")
.joins("INNER JOIN transactions
ON tran... | true |
bdda6a9898b6664b378890ab6ac4c63f8492badc | Ruby | pbruna/cartolify | /test/test_bank.rb | UTF-8 | 669 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'helper'
class TestBank < Test::Unit::TestCase
def setup
@bank = Bank.new("BCI", bank_account)
end
def test_new_bank_should_return_an_specfic_bank_Class_Instance
assert_equal(BCIBank, @bank.branch.class)
end
def test_url_should_return_and_https_url
assert_equal("https", URI(@bank.url).sch... | true |
7c09a02ce47a4b431ae86d9fe328bcccb995326c | Ruby | yuraksisa/ysd_md_cms | /lib/ysd_md_view_model.rb | UTF-8 | 1,360 | 2.953125 | 3 | [] | no_license | module Model
#
# It describes an entity(model) to retrieve data when creating views
#
class ViewModel
attr_reader :view_entity_model, :view_entity_description, :view_entity_model_class, :view_entity_render_template, :view_entity_fields
def initialize(view_entity_model, view_entity_description, vi... | true |
08173d9990e29730dbb8122916dbf42c228eb581 | Ruby | zeevex/scoped_search | /lib/scoped_search/query_conditions_builder.rb | UTF-8 | 8,636 | 2.703125 | 3 | [
"MIT"
] | permissive | module ScopedSearch
class QueryConditionsBuilder
# Builds the query string by calling the build method on a new instances of QueryConditionsBuilder.
def self.build_query(search_conditions, query_fields)
self.new.build(search_conditions, query_fields)
end
# Initializes the default class vari... | true |
ce5f1da4a9efdcd496f8423aec7009ee3083df14 | Ruby | zieglarnatta/rubyLearning | /math.rb | UTF-8 | 1,091 | 4.15625 | 4 | [] | no_license | puts "addition 3+4"
puts "Result: "
puts "#{3+4}"
#output formatting
puts""
puts""
puts "subtraction 7-3"
puts "Result: "
puts "#{7-3}"
#output formatting
puts""
puts""
puts "multiplication 3*4"
puts "Result: "
puts "#{4*3}"
#output formatting
puts""
puts""
puts "division 12/4"
puts "Result: "
puts "#{12/4}"
#ou... | true |
0609ee1a3dfbae27f010bb3e0891da0344b616fd | Ruby | weilandia/tic-tac-toe | /app/models/player.rb | UTF-8 | 183 | 3.109375 | 3 | [] | no_license | class Player
attr_reader :sym, :color, :mode
def initialize(sym, color, mode)
@mode = mode
@sym = sym
@color = color
end
def inspect
"#{self.sym}"
end
end
| true |
decaca0c0b839bbc4c75e7d60ad19d03b198d550 | Ruby | msynko/Dec10-RE | /exercise.rb | UTF-8 | 289 | 3.90625 | 4 | [] | no_license |
results = {}
(1..50).each do |value|
if value % 2 == 0 && value %7 == 0
results[value] = value * 2
elsif value % 2 == 0
results[value] = value + 1
elsif value % 7 == 0
results[value] = value - 1
else
results[value]
end
puts results
end
| true |
e1c31c40b409180e80c77cdee5cbff0d2979e078 | Ruby | Whynotski/intro-to-simple-array-manipulations-dc-web-060418 | /lib/intro_to_simple_array_manipulations.rb | UTF-8 | 2,811 | 4.28125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #using_push
#takes in two arguments, an array and a string and adds that string
#to the end of the array using the push method
def using_push(array, string)
array.push(string)
end
#using_unshift
#takes in two arguments, an array and a string and adds that string
#to the front of the array using the... | true |
3c1234d4530e0e680ae028825a245a84df283487 | Ruby | nice-okura/wcbtRuby | /utils/export_schesim.rb | UTF-8 | 4,983 | 2.6875 | 3 | [] | no_license | #! /usr/bin/ruby
# -*- coding: utf-8 -*-
#
# タスクをschesim用に変換するためのクラス
#
#$:.unshift(File.dirname(__FILE__))
class EXPORT_SCHESIM
def initialize(name)
# hoge/piyo/以下に
# piyo_task.json
# ...
#を作成する場合
# name = hoge/piyo/
# dirname = hoge/piyo
# filename = piyo とする
# name はfrozenなのでd... | true |
93c3bef2995de7bc3a028eac5db18adeb01576ff | Ruby | igor972/bullet_game | /main.rb | UTF-8 | 4,765 | 3.171875 | 3 | [] | no_license | require "gosu"
class Game
attr_accessor :window
def initialize window
@window = window
@player = Player.new self
@bullets = []
@enemies = []
@score = Score.new(self)
end
def update
@player.update
@enemies.each {|enemy| enemy.update}
@score.update
# generate some enemies
@enemies.push(En... | true |
f42024d295eab4ff92394598caf6c53daa71fdb2 | Ruby | rdesz920/ttt-7-valid-move-ruby-apply-000 | /lib/valid_move.rb | UTF-8 | 451 | 3.328125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def valid_move? (board,index)
def position_taken?(board, index)
if board[index] == " " || board[index] == "" || board[index] == nil
return false
else
return true
end
end
def on_the_board?(number)
if number.between?(0,8) == true
return true
else
return false
end
e... | true |
52fd359d310bea39e9c262023472a0fbbf045068 | Ruby | ollyholly/ruby-practice | /code-wars/reverse-words.rb | UTF-8 | 1,396 | 4.65625 | 5 | [] | no_license | # Complete the function that accepts a string parameter, and reverses each word in the string.
# All spaces in the string should be retained.
# Examples
# "This is an example!" ==> "sihT si na !elpmaxe"
# "double spaces" ==> "elbuod secaps"
# Problems:
# 1. Break string into words, separated by spaces -> array o... | true |
666ad6f48c682a0c2701227b61367b5b2b73c075 | Ruby | RubyCamp/rc2016w_g1 | /rubycamp1g/insectmeter.rb | UTF-8 | 498 | 2.9375 | 3 | [] | no_license | # coding: utf-8
class InsectMeter
PICSIZE = 96
INSECTMETER_X = 16
INSECTMETER_Y = 488
def initialize
@img = Image.load("images/insectgauge.png")
@count = 0
@rate = 0
@x1, @y1 = 0, 0
@x2, @y2 = 0, 0
end
def draw(count)
@count = count
@rate = (@count / 2).to_i
@x1 = PICSIZE * @rate
@y... | true |
ff48ce017d4ef163f29f3d0919a10c0f2f0dd7e1 | Ruby | ga-wolf/WDI13_Homework | /JennMaWhinney/week_04/monday/calc.rb | UTF-8 | 2,289 | 4.4375 | 4 | [] | no_license | # # Calculator
# # Explanation
# #
# # You will be building a calculator. A calculator can perform multiple arithmetic operations. Your function should allow the user to choose which operation is expected, enter in the values to perform the operation on, and ultimately view the result.
# # Specification:
# #
# # A user... | true |
7ebe184ae017980755bf20f5482482809f3cdb4e | Ruby | mikeyqq/Learning_Ruby | /ex2.rb | UTF-8 | 157 | 3 | 3 | [] | no_license | # TESTING TO SEE IF THIS IS COMMENT SECTION WHERE IT WILL NOT PRINT OUT
puts "I could have code like this", "HELLLOOOOOO", "TESTIN TEISNG"
puts "This will run" | true |
daf603cb7d78f6acfd9e0b33cbed91bfe39f9fbd | Ruby | the-hobbes/learning-ruby | /arrays.rb | UTF-8 | 4,179 | 4.5625 | 5 | [] | no_license | #!/usr/bin/ruby
arr = [9, 5, 1, 2, 3, 4, 0, -1]
puts arr[4]
puts arr.at(4)
puts arr[4] == arr.at(4)
arr[1..3] # .. indicates both indices are inclusive.
arr[1...3] # ... indicates the last index is excluded.
arr[1,4] # start index and length of the range
def element_at(arr, index)
# return the element of the Arr... | true |
8a8452eb54dd25b9aa4e97e69fde2cea866187a6 | Ruby | Dancorrea718/ruby-gets-input-nyc-fasttrack-020120 | /lib/hello_ruby_programmer.rb | UTF-8 | 97 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def greeting(John)
puts "Hi, #{John}! Welcome to the wonderful world of Ruby programming."
end
| true |
88ac7505737195a6169510ab8047b3eb3e14d3d9 | Ruby | Stupot83/coin_flip | /lib/coin.rb | UTF-8 | 484 | 3.703125 | 4 | [] | no_license | class Coin
attr_accessor :result, :heads_scored, :coin
def initialize
@result = []
end
def flip
puts "You are flipping a coin"
if rand.round == 0
coin = "heads"
else
coin = "tails"
end
puts "It is " + coin
@result << coin
... | true |
275bf96a193170ddcb4b670b0f17501f4cf2e2b0 | Ruby | emilianolowe/launch-school-exercises | /Ruby/easy/easy7/multiply_all_pairs.rb | UTF-8 | 257 | 3.765625 | 4 | [] | no_license | # Exercise 9
def multiply_all_pairs(array1, array2)
result = []
array1.map do |num1|
array2.map do |num2|
result << num1 * num2
end
end
result.flatten.sort
end
p multiply_all_pairs([2, 4], [4, 3, 1, 2]) == [2, 4, 4, 6, 8, 8, 12, 16]
| true |
9afea2727df09e538e80da5544f4f0676efa6b96 | Ruby | gloryahja/iXperience | /exercises/d2/strict_bouncer.rb | UTF-8 | 221 | 3.734375 | 4 | [] | no_license | puts "Welcome to da hip hoppin club. What's your age?"
age = gets.chomp.to_i
if age < 21
puts "Too young, fool!"
elsif age >= 65
puts "Go back to the nursing home!"
else age < 65
puts " Aw yeah c'mon in."
end
| true |
061a841c4e643b1eb31e491775b72f73ba06f98b | Ruby | hashrabbit/mirren | /lib/mirren/result_ext.rb | UTF-8 | 1,823 | 3.03125 | 3 | [
"MIT"
] | permissive | # ResultExt
# Provides a helpful method wrapper around Dry::Monad::Result objects
module ResultExt
include Dry::Monads[:result]
# ResultExt#fmap_left
# Takes two arguments:
# a result, Success(T) | Failure(U)
# a map function, Fn(U) -> V
# and returns:
# a result, Success(T) | Failure(V)
# Works ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.