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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
4aedecb7c8c1133bf9562c9ef327df47c7d2d787 | Ruby | kehra/Nattoku-Algorithm | /example/6_5.rb | UTF-8 | 529 | 3.328125 | 3 | [] | no_license | def seller?(name)
name[-1] == 'm'
end
graph = {}
graph['you'] = %w[alice bob claire]
graph['bob'] = %w[anuj peggy]
graph['alice'] = %w[peggy]
graph['claire'] = %w[thom jonny]
graph['anuj'] = []
graph['peggy'] = []
graph['thom'] = []
graph['jonny'] = []
queue = graph['you']
searched = []
until queue.empty?
person... | true |
3d0d8731b0d7c73a26a70e8ecb21dffd2e2bf33e | Ruby | taylor/learningtoprogram | /student/vegancarnivore/catalog_project/addbooks.rb | UTF-8 | 376 | 2.984375 | 3 | [] | no_license | require "date"
puts "Welcome to the Auxiliary Xanadu Edinburgh (AXE) catalog system. "
loop do
puts "Enter a book title or quit: "
title = gets.chomp
break if title == "quit"
puts "Enter author's name: "
author = gets.chomp
loan_stat = "Not Loaned"
File.open("booklistfile.txt","a") do |f|
f.puts "... | true |
045cc63f74ec839f27f17463390dbf40a5e80c88 | Ruby | DanielJWagener/app-academy-exercises | /ruby/reference/sudoku/game.rb | UTF-8 | 1,549 | 4.0625 | 4 | [] | no_license | require_relative 'board.rb'
class Game
def initialize
@board = Board.new('./puzzles/sudoku1_almost.txt')
end
def play
until @board.solved?
@board.render
self.prompt
end
return "You win!"
end
def prompt
user_input = []
puts "Enter three integers in the format: row ... | true |
434100cf73d5008f5228d00352123fbaba996833 | Ruby | OmairRaza9/9.20-main-Programming-Fundamentals-Collections-and-Iteration | /Ex1.rb | UTF-8 | 5,752 | 4.1875 | 4 | [] | no_license | ####Exercise 0 ####
#Create an array for each item below that contains the given information:
#your favourite colours
my_array = []
fav_colours = ['black', 'orange', 'yellow', 'green', 'brown']
#
# #the age of you and your siblings/cousins/friends
#
age = [ 28, 34, 37, 50, 100, 75]
#
# #flip a coin 5 times and recor... | true |
782210132077fac444e0aad836e0beae1b4d6622 | Ruby | raosushant/sunnin.es | /lib/Mongo_Extn.rb | UTF-8 | 2,702 | 2.6875 | 3 | [] | no_license | module MongoExtn
class MongoExtn
@conn
def initialize
@conn = MongoConfig.connection
end
@@instance = MongoExtn.new
def self.instance
return @@instance
end
def find_nearby center, i
r = @conn.db('sunny').command(
{:geoNear=>"locations",
:near... | true |
0a613362bae335b00fabca43b7290c2decd37107 | Ruby | kipcole9/rainbow | /lib/rainbow/color/wheel.rb | UTF-8 | 4,296 | 3.234375 | 3 | [
"MIT"
] | permissive | require 'rainbow/color/harmony'
module Rainbow
module Color
module Wheel
# Family name taken by splitting the wheel into 12 parts (seems common)
# Red is 0 degrees so take 15 degrees either side as "Red" and then work
# around the wheel in 30 degree segments
# http://www.paintwithapassion... | true |
4ba395581b668be598122a58d13d1036603d3892 | Ruby | Uthaeus/w3ruby | /arrays/14.rb | UTF-8 | 414 | 4.6875 | 5 | [] | no_license | # Write a Ruby program to compute the sum of the first 2 elements of a given an array of integers. If the array length is less than 2, just sum up the elements that exist, returning 0 if the length of the array is 0.
def summer arr
if arr.length < 2
return 0
else
return arr[0] + arr[1]
end
end
test1 ... | true |
af8e0250b7ca5ffafc60f84049e83eed61f59307 | Ruby | hanrattyjen/learn_to_program | /ch10-nothing-new/sort.rb | UTF-8 | 720 | 3.328125 | 3 | [] | no_license | def sort arr
recursive_sort(arr, [])
end
def recursive_sort unsorted_array, sorted_array
if unsorted_array.length < 1
return sorted_array
end
smallest = unsorted_array.pop
still_unsorted = []
unsorted_array.each { |tested_object|
if tested_object < smallest
still_unsorted << smallest
smallest = test... | true |
d31d8e9b11a87722d258d47a098c773ae6e1ef6a | Ruby | kkslider/poker | /lib/poker.rb | UTF-8 | 2,522 | 3.625 | 4 | [] | no_license | class Card
attr_accessor :rank, :suit
def initialize(rank, suit)
@rank = rank
@suit = suit
end
end
class Deck
attr_accessor :cards
def initialize
@cards = []
create_all_cards
end
def create_all_cards
suits = [:heart, :diamond, :spade, :club]
ranks = (1..13).to_a
suits.each d... | true |
f938f1f3d3e9fa4df208dfc3017613a40301dc24 | Ruby | drew-hart/RubyTHW | /ex39-eu.rb | UTF-8 | 3,679 | 2.84375 | 3 | [] | no_license | # create a mapping of state to abbreviation
states = {
'Alabama' =>'AL',
'Alaska' =>'AK',
'Arizona' =>'AZ',
'Arkansas' =>'AR',
'California' =>'CA',
'Colorado' =>'CO',
'Connecticut' =>'CT',
'Delaware' =>'DE',
'Florida' =>'FL',
'Georgia' =>'GA',
'Hawaii' =>'HI',
'Idaho' =>'I... | true |
863b675a78eb13bb2105908740ddeb2a90030560 | Ruby | root239/store | /app/controllers/pages_controller.rb | UTF-8 | 646 | 2.5625 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
class PagesController < ApplicationController
def about
#used to change the routing to /about
end
def label
# Nokogiri web scrape content from asos
url = "https://marketplace.asos.com/boutiques/independent-label"
doc = Nokogiri::HTML(open(url... | true |
08c83fc6e0f2134be840ef2907c2d386ca2f1636 | Ruby | sergeypedan/integral-text-helpers | /lib/integral/text_helpers/aspect.rb | UTF-8 | 501 | 2.53125 | 3 | [] | no_license | # frozen_string_literal: true
module Integral
module TextHelpers
module Aspect
# @geometry<Hash width: Numeric, height: Numeric>
def aspect_ratio_equal?(frame_geometry, img_geometry)
aspect_ratio(img_geometry).round(3) == aspect_ratio(frame_geometry).round(3)
end
# @geometry<Has... | true |
3d16d9fc4dcc0e01b185f46571e1dbfbd5c5cb08 | Ruby | terencezhao/meteorologist | /app/controllers/meteorologist_controller.rb | UTF-8 | 1,475 | 2.578125 | 3 | [] | no_license | require 'open-uri'
class MeteorologistController < ApplicationController
def street_to_weather_form
# Nothing to do here.
render("meteorologist/street_to_weather_form.html.erb")
end
def street_to_weather
@street_address = params[:user_street_address]
# ==========================================... | true |
b0acbc66fd0d82f784dd2cde677bf7bf8d78d11c | Ruby | square/ruby-rrule | /spec/frequencies/weekly_spec.rb | UTF-8 | 3,548 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
require 'spec_helper'
describe RRule::Weekly do
let(:interval) { 1 }
let(:context) do
RRule::Context.new(
{ interval: interval, wkst: 1 },
date,
'America/Los_Angeles'
)
end
let(:filters) { [RRule::ByWeekDay.new([RRule::Weekday.new(date.wday)], cont... | true |
bcb5d497a77bb737a7be18cfd3c63db66f3c194c | Ruby | patpersons87/introduction-to-programming | /the-basics/exercise-2.rb | UTF-8 | 170 | 3.765625 | 4 | [] | no_license | input = 1234
puts "Thousands:" + (input / 1000).to_s
puts "Hundreds:" + (input % 1000 / 100).to_s
puts "Tens:" + (input % 100 / 10).to_s
puts "Ones:" + (input % 10).to_s | true |
65267e6ee0ec6244d77023349edda827d19b8e90 | Ruby | sdickey/sws-on-rails | /spec/models/owner_spec.rb | UTF-8 | 2,121 | 2.6875 | 3 | [] | no_license | require 'rails_helper'
describe Owner do
it "is invalid without a first name" do
expect(Owner.new(first_name: nil)).to have(1).errors_on(:first_name)
end
it "is invalid without a last name" do
expect(Owner.new(last_name: nil)).to have(1).errors_on(:last_name)
end
it "is invalid without an email add... | true |
b8c5d86315b6af8957d246be9d220d1744825242 | Ruby | robertjosephwayne/assignment_oop_warmups_1 | /warmups_2_benchmarker.rb | UTF-8 | 148 | 2.96875 | 3 | [] | no_license | def my_benchmark(number_of_times)
puts start = Time.now
number_of_times.times { yield }
puts finish = Time.now
duration = finish - start
end | true |
6be5fdc4c8d194228ff139e74b1a9c70664a2420 | Ruby | cathjime/ruby-project-guidelines-nyc01-seng-ft-051120 | /app/store_app.rb | UTF-8 | 10,206 | 3.59375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "tty-prompt"
require "pry"
class StoreApp
def run
greeting
user_input = gets.chomp.downcase
if valid_user_array.include?(user_input)
puts " "
puts "Hi #{user_input.capitalize}! Here is the main menu: "
return main_menu
else puts "Access denie... | true |
a2763b46f7c737cc6ba1a19e51662f1e4c588dbf | Ruby | SeaRbSg/advent_of_code | /thagomizer/21B/runner.rb | UTF-8 | 152 | 2.9375 | 3 | [] | no_license | require "./scrambler.rb"
instructions = File.readlines(ARGV[0]).reverse
s = Scrambler.new String.new(ARGV[1]), instructions
s.unscramble
puts s.str
| true |
2c45457c536e36a033c0988a545e46f52d88d09f | Ruby | bmoises/ruby_play | /lib/player.rb | UTF-8 | 940 | 3.046875 | 3 | [] | no_license | class Player
attr_accessor :player, :thread, :process_pid, :current_file
def initialize
case RUBY_PLATFORM.downcase
when /darwin/
@player = "afplay -d"
when /mswin/
when /linux/
else
raise ":( no platform/os support at this time"
end
end
def to_s
"#{@player}"
end
de... | true |
7c966ba51e08fd2248dfe49ae0fcb86772342aa6 | Ruby | EvilJadeon/BlackJack | /interface.rb | UTF-8 | 3,150 | 3.25 | 3 | [] | no_license | # frozen_string_literal: true
# класс для ввода-вывода всей информации
class Interface
attr_reader :choose
@choose = 0
# метод для добавления карты игроку
def add_card_player(hand, deck)
hand.add_card(deck.delete_card)
sleep 1.5
end
# метод для добавления карты дилеру
def add_card_dealer(hand, ... | true |
53c44101a96a48b826c42419f2e99d259e225ba7 | Ruby | obadiahkopchak/obierubyproj | /multiples3and5.rb | UTF-8 | 185 | 3 | 3 | [] | no_license | #project Euler mutliples of 3 and 5
n = 1
target = 1000
tally = 0
until n >= target do
if (n%3 == 0) || (n%5 == 0)
tally += n
n += 1
else
n += 1
end
end
print tally | true |
30911fbfa7209226c7755c37cda9d4aa171b9a9d | Ruby | zapnap/dialtone | /dial_tone.rb | UTF-8 | 1,461 | 3.203125 | 3 | [
"MIT"
] | permissive | require "rack"
require "erubis"
class DialTone
attr_reader :request, :response
def initialize
@routes = {}
puts "Waiting for calls..."
end
# center of all things Rack...
def call(env)
@request = Rack::Request.new(env)
@response = Rack::Response.new
answer(@request.path_info)
@resp... | true |
04189881ca96b5d47c727c58231c60da4d206649 | Ruby | samueldowens/breaking_git_active | /break.rb | UTF-8 | 270 | 2.671875 | 3 | [] | no_license | 500.times do
a = rand(1..50).to_s
b = rand(1..50).to_s
c = rand(1..50).to_s
d = rand(1..50).to_s
e = rand(1..50).to_s
name = a+b+c+d+e
system "touch #{name}.rb"
system "git add ."
system "git commit -m 'lol'"
system "git push origin master"
system "echo 'another'"
end | true |
242c83c1c93556361cbc92bcde4b690ee16928df | Ruby | ficstar/cassandra_mocks | /lib/cassandra_mocks/statement/token.rb | UTF-8 | 698 | 2.671875 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | module Cassandra
module Mocks
class Statement
class Token < Struct.new(:type, :value)
def normalized_value
case type
when :int
value.to_i
when :float
value.to_f
else
value
end
end
def r... | true |
2991aab165ed841f7b5d06d77f4920b9b204e5f7 | Ruby | atulgolhar/class_2_example_code | /example.rb | UTF-8 | 216 | 3.203125 | 3 | [] | no_license | def return_hello_world
"hello world"
end
def print_working_directory
x = return_hello_world
puts x.revese
end
def pounds_to_kilos(pounds)
pounds/2.2
end
puts pounds_to_kilos(100)
puts pounds_to_kilos(250)
| true |
056d085d487559685e1910457a39547d9470b796 | Ruby | agsutter/intro-to-programming | /exercises/exercise3.rb | UTF-8 | 242 | 4.375 | 4 | [] | no_license | # Using the same array from exercise2, use the select method to extract all odd numbers into a new array.
array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
new_array = []
array.select { |num|
if num.odd?
new_array << num
end
}
p new_array | true |
93c37f218bdf3766eee9851cad14c36613ab73d5 | Ruby | meeke198/W4D5 | /exe_time_dif.rb | UTF-8 | 1,455 | 3.890625 | 4 | [] | no_license | require "byebug"
def my_min_1(arr)
# debugger#compare arr[idx] with all other arr(ele)
arr.each do |ele| #n
new_arr = arr.reject { |ele2| ele2 == ele } #n^2
# debugger
is_lowest = true
new_arr.each do |new_ele|
if new_ele < ele
is_lowest ... | true |
7709809e0a4ac097a25832914e4b201bb139a797 | Ruby | EricRicketts/LaunchSchool | /Ruby/RubyFoundationsMoreTopics/lesson_1_blocks/assignment_to_do_list/test/to_do/to_do_test.rb | UTF-8 | 656 | 2.71875 | 3 | [] | no_license | require_relative 'test_helper'
class ToDoTest < Minitest::Test
attr_accessor :to_do
def setup
@to_do = ToDo.new("Item One", "Finish Lesson")
end
def test_initial_attributes
expected = [false, "Item One", "Finish Lesson"]
result = [to_do.done, to_do.title, to_do.description]
assert_equal(expec... | true |
1b79dc1660d6383fadd5a9e160749a146f4a1176 | Ruby | allcentury/daily_programmer | /stackoverflow/set_test.rb | UTF-8 | 306 | 3.09375 | 3 | [] | no_license | require 'set'
require 'pry'
class Family
attr_reader :people
def initialize(people)
binding.pry
@people = people
end
end
class GrandParent
attr_reader :grandparents
def initialize(grandparents)
@grandparents = grandparents
end
def << (name)
@grandparents << name
end
end
| true |
1265d2e03d75cd2dd2a32a01ba2519090746c3c1 | Ruby | justenwalker/Cassagraphy | /lib/cassagraphy/render.rb | UTF-8 | 3,888 | 2.671875 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-public-domain",
"MIT"
] | permissive | require "cassagraphy/model.rb"
module Render
class Template
def initialize(filename)
@filename = filename
end
def render(params)
content = File.read(@filename)
params.each_pair do |k,v|
content = content.gsub(/\$\{#{k}\}/,params[k])
end
return content
end
end
... | true |
0e2a85e600c3a9ee687c7b0c4410dda2591a04e3 | Ruby | belenac/E8CP1A1 | /02/ejercicio02.rb | UTF-8 | 154 | 2.515625 | 3 | [] | no_license | def cuenta_lineas(filename)
file = File.open(filename, 'r')
data = file.readlines
puts data.length
file.close
end
cuenta_lineas('peliculas.txt')
| true |
c589ee1183ed8ae6bdc2bf7be2ab8aa95d006093 | Ruby | timsu/flower | /lib/flower.rb | UTF-8 | 2,795 | 2.515625 | 3 | [] | no_license | require "rubygems"
require "bundler/setup"
require 'typhoeus'
require 'json'
require 'rufus/scheduler'
class Flower
["session", "command", "job", "config"].each do |file|
require File.expand_path(File.join(File.dirname(__FILE__), file))
end
COMMANDS = {} # We are going to load available commands in here
J... | true |
1acb0580ee3ce4775378dae9af01b89597bc9c05 | Ruby | rtroncoso/spree_docker_boilerplate | /vendor/cache/ruby/2.2.0/gems/ffaker-1.32.1/lib/ffaker/name_nl.rb | UTF-8 | 929 | 2.890625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # encoding: utf-8
require 'ffaker/name'
module Faker
module NameNL
include Faker::Name
extend ModuleUtils
extend self
PREFIXES = %w(Dr. Drs. Ir. Ing. Prof.)
def name
case rand(30)
when 0 then "#{prefix} #{first_name} #{last_name}"
else "#{first_name} #{last_name}"
... | true |
990e50270021d69a7524576cd96eea3ddc7047fe | Ruby | dpoper/GS4 | /config/initializers/sass.rb | UTF-8 | 7,041 | 2.671875 | 3 | [] | no_license | # Make Sass use proper indentation in the generated CSS files.
# This is necessary so the diff between the original CSS file
# and the one generated by Sass is as short as possible.
# Why is that important? So you can check if the generation
# works correctly.
require 'sass/tree/visitors/to_css'
class Sass::Tree::Vis... | true |
c9582f5c945dd80cab8ae6e5dbdac0481b6c0932 | Ruby | xiantotikui/Keras.rb | /dddqn.rb | UTF-8 | 5,692 | 2.9375 | 3 | [
"MIT"
] | permissive | require 'pycall/import'
include PyCall::Import
require './lib/keras'
keras_import(['Models', 'Core', 'Optimizers'])
class Brain
attr_reader :online_value, :online_advantage
attr_accessor :target_value, :target_advantage
def initialize(states, actions, lr)
@states = states
@actions = actions
@lr = ... | true |
eb7c0b3c9549b801dfb58b21d8a29703cf792a2d | Ruby | mongodb/mongo-ruby-driver | /examples/create.rb | UTF-8 | 790 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
# rubocop:todo all
# Insert a document
require 'date'
result = client[:restaurants].insert_one({
address: {
street: '2 Avenue',
zipcode: 10075,
building: 1480,
coord: [-73.9557413, 40.7720266]
},
borough: 'Manh... | true |
916e38da7fa7216b7321a66d993a870cf53891b9 | Ruby | eashworth/battle-game-2 | /spec/player_spec.rb | UTF-8 | 453 | 2.71875 | 3 | [] | no_license | require 'player'
describe Player do
subject(:henry) { described_class.new('Henry') }
describe '#name' do
it 'returns its name' do
expect(subject.name).to eq('Henry')
end
end
describe '#hp' do
it 'returns its health points' do
expect(subject.hp).to eq 100
end
end
describe '#recei... | true |
d3f736393293b6d74d53ff2888965dfcdf4e5850 | Ruby | timurcatakli/phase-0 | /week-4/factorial/my_solution.rb | UTF-8 | 553 | 3.9375 | 4 | [] | no_license | # Factorial
# I worked on this challenge [by myself, with: ].
# Input - positive integer
# Process
# Check if integer is positive
# If negative return 0
# If positive
# Loop i * (i-1) * (i-2) * (i-3) until i = 0
# Output - factorial i*(i-1) until i = 0
# Your Solution Below
def factorial(number)
# Your code goes ... | true |
067112b787b896393055c3729521f1b29d180a00 | Ruby | loongluangkhot/ttt-6-position-taken-rb-bootcamp-prep-000 | /lib/position_taken.rb | UTF-8 | 336 | 3.484375 | 3 | [] | no_license | # code your #position_taken? method here!
require 'pry'
def position_taken?(board, index)
# if (board[index] == " ") || (board[index] == "") || (board[index] == nil)
# below makes use of short-circuit nature of evaluation in Ruby
if (!board[index]) || (board[index].strip == "")
false
else
true
end
... | true |
100b402bde5d5cc5d02a1da720fc021fa973536c | Ruby | JunzeHe/AdventOfCode | /2021/app/day2.rb | UTF-8 | 1,330 | 3.296875 | 3 | [
"Apache-2.0"
] | permissive | module Day2
module_function
class Password
attr_accessor :first_num, :second_num, :letter, :password
def initialize(first_num:, second_num:, letter:, password:)
@first_num = first_num
@second_num = second_num
@letter = letter
@password = password
end
def valid?
count... | true |
221d2b5e6a46f829834476a6e7f274c6e1f4b092 | Ruby | heidmotron/chrome-xhr-bug | /server.ru | UTF-8 | 884 | 2.546875 | 3 | [] | no_license | $eventmachine_library = :pure_ruby
require 'em/pure_ruby'
puts EM.library_type
class Runtime
def initialize(app, name = nil)
@app = app
@header_name = "X-Runtime"
@header_name << "-#{name}" if name
end
def call(env)
r = Rack::Request.new(env)
puts r.url
status, headers, body = @app.call(e... | true |
6213dc63f15e9e98cf61954c80bef19625df06b8 | Ruby | DarcyMcCartney/ttt-4-display-board-rb-wework-bc-000 | /lib/display_board.rb | UTF-8 | 383 | 4 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Define display_board that accepts a board and prints
# out the current state.
board = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
def display_board(space)
puts " #{space[0]} | #{space[1]} | #{space[2]} "
puts "-----------"
puts " #{space[3]} | #{space[4]} | #{space[5]} "
puts "-----------"
puts " #{spac... | true |
2a75b1b2192e7b01b944cbc0aaa60965d7c47987 | Ruby | dpholbrook/ruby_small_problems | /small_problems/easy_1/10.rb | UTF-8 | 1,061 | 5 | 5 | [] | no_license | # input: positive integer, boolean
# output: positive integer
#
# rules:
# - if true then return half of input integer
# - if false then return 0
#
# algorithm:
# - return 0 if boolean is false
# - otherwise, return num/2
# def calculate_bonus(num, boolean)
# boolean == false ? 0 : num/2
# end
# def calcula... | true |
d5581f52329c0ddaa628be779a11a7627c1a4285 | Ruby | luvtechno/atcoder | /abc082/d.rb | UTF-8 | 1,410 | 3.1875 | 3 | [] | no_license | s = gets.chomp.chars
x, y = gets.chomp.split(" ").map(&:to_i)
x_steps = []
y_steps = [y.abs]
x_first_move = true
x_move = true
f_count = 0
s << "T"
s.size.times do |i|
if s[i] == "F"
f_count += 1
else
if x_move
if x_first_move
x_steps << (x - f_count).abs
x_first_move = false
... | true |
c48b971becc9b294afed1a3e7e1e2af30720dab5 | Ruby | MatthewYiHe/w7d1 | /TwO-O-PlayerMathGame/main.rb | UTF-8 | 317 | 3.21875 | 3 | [] | no_license | require './number'
require './player'
require './game'
# Game!
newGame = Game.new
puts "Enter Player1 Name:"
p1Name = gets.chomp
puts "Enter Player2 Name:"
p2Name = gets.chomp
p1 = Player.new "#{p1Name}"
p2 = Player.new "#{p2Name}"
newGame.startGame(p1, p2)
newGame.gameResult(p1, p2)
newGame.gameOver()
| true |
3f1d20318ffadad9cdae8b0bff2428388e2631f3 | Ruby | WhiteShay/tests-ruby | /lib/00_hello.rb | UTF-8 | 103 | 3.3125 | 3 | [] | no_license | def hello
return "Hello!"
end
name = gets.chomp
def greet(name)
return "Hello, #{name}!"
end
| true |
aacf02b49fc16c77ff4005b951f7ee922ae52d37 | Ruby | harled/rails_bootstrap | /app/components/rails_bootstrap/container_component.rb | UTF-8 | 688 | 2.59375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
class RailsBootstrap::ContainerComponent < ApplicationComponent
FLUID_TYPES = [true, false, "sm", "md", "lg", "xl"].freeze
validates :fluid, inclusion: { in: FLUID_TYPES }
def initialize(fluid: false, **options)
@fluid = fluid
options.tap do |options|
@class_name... | true |
3e066b380df5a8705b1690a6c4a0b1e431b037a1 | Ruby | l-jdavies/ruby_small_problems | /ruby_foundations_problems/medium_1/passing_parameters_part_2.rb | UTF-8 | 600 | 4.03125 | 4 | [] | no_license | # Based on the examples shown above, write a method that takes an array as an argument. The method should yield the contents of the array to a block, which should assign your block variables in such a way that it ignores the first two elements, and groups all remaining elements as a raptors array.
def splat(arr)
yie... | true |
fd1cd5edb0ffdf46259ff69eafd09ad7813fa10e | Ruby | kmdsbng/youtube_my_list | /lib/ext.rb | UTF-8 | 166 | 3.34375 | 3 | [] | no_license | class String
def shorten(max=30)
letters = self.split(//)
if (letters.size > max)
letters[0..max].join + '...'
else
self
end
end
end
| true |
7b27c31048817d4049bd478f0fb3d26a853f622d | Ruby | wesleysilvaalves/api-cep | /features/step_definitions/step_definitions.rb | UTF-8 | 749 | 2.859375 | 3 | [] | no_license |
Dado('que eu faça uma requisição para API de CEPs com um cep valido') do
@consulta_cep.get_cep_valido
end
Quando('eu obtenho os dados retornados') do
@retorno = @consulta_cep.get_cep_valido
end
Então("espero que o codigo ibge seja exibido") do
expect(@retorno)
puts('IBGE: ' + @retorno['ibge'])
... | true |
709ae9714b583988e95dd2232819bd430e06e136 | Ruby | bskelty/the_hard_way | /ex31.rb | UTF-8 | 1,498 | 4.15625 | 4 | [] | no_license | def prompt
print "> "
end
puts "You enter a dark room with two doors. Do you go through door #1, door #2, or door #3?"
prompt; door = gets.chomp
if door == "1"
puts "There's a giant bear here eating a cheese cake. What do you do?"
puts "1. Take the cheese cake."
puts "2. Scream at the bear."
prompt; bear = g... | true |
3f09cb56f1c4c8b0429e8e9c4af4219d379372e7 | Ruby | alexandershakirov/homework2020 | /hwlesson3/chet.rb | UTF-8 | 422 | 3.546875 | 4 | [] | no_license | puts "Введите натуральное число и мы определим является ли оно чётным"
a = gets.chomp.to_f
if a % 2 == 0
puts "Это число является чётным!"
elsif a % 2 == 1
puts "Это число не является чётным!"
elsif a == 0
puts "Вы ввели ноль"
else
puts "Вы ввели не наутральное число"
end | true |
7f98dad5d1783f5fad06e651214e242c863a08df | Ruby | versus-systems/dry_todo | /app/transactions/components/common/page.rb | UTF-8 | 1,098 | 2.796875 | 3 | [] | no_license | # Page takes a required key and optional collection and destination
# `key` is the symbol key to use to store the paged results under in our standard paging hash result
# `collection` is the symbol key from `input` to pull the collection to page. Default `:collection`
# `destination` is the symbol key from `input` to p... | true |
5a0034e3012cf2c690d0ee78fb5ff0d8baad4692 | Ruby | Eclecticdynasty/ruby-objects-has-many-lab-v-000 | /lib/song.rb | UTF-8 | 213 | 3.1875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song
attr_reader :name, :artist
def initialize(name)
@name = name
end
def artist=(artist_name)
@artist = artist_name
end
def artist_name
self.artist && self.artist.name
end
end
| true |
070985d81f6412160345b571366ad0a3998d6460 | Ruby | Keefeef/Week-1-Weekend-Homework | /pet_shop.rb | UTF-8 | 1,118 | 3.21875 | 3 | [] | no_license | def pet_shop_name(name)
return name[:name]
end
def total_cash(cash)
return cash[:admin][:total_cash]
end
def add_or_remove_cash(cash, total)
return cash[:admin][:total_cash] += total
end
def add_or_remove_cash__remove(cash, total)
return cash[:admin][:total_cash] -= total
end
def pets_sold(pets)
r... | true |
7c26258b54fc0acccd463f08381a4f78af800334 | Ruby | lucanioi/exercism-ruby | /space-age/space_age.rb | UTF-8 | 628 | 3.40625 | 3 | [] | no_license | class SpaceAge
EARTH_YEAR = 31557600.0
SPACE_AGES = {
earth: 1.0,
mercury: 0.2408467,
venus: 0.61519726,
mars: 1.8808158,
jupiter: 11.862615,
saturn: 29.447498,
uranus: 84.016846,
neptune: 164.79132
}.freeze
SPACE_AGES.keys.each do |planet|
define_method("on_#{plane... | true |
59811872c240d7ab8623fc681e97ddbe9758fe46 | Ruby | vilyapilya/UI-New-York-Times | /karta.rb | UTF-8 | 679 | 3.40625 | 3 | [] | no_license | require "byebug"
class Karta
def initialize
@karta = Array.new(0)
end
def show
@karta.each {|ar| print "{#{ar[0]} => #{ar[1]}}"}
end
def remove(key)
@karta.each {|ar| @karta.delete(ar) if ar[0] == key}
end
def look_up(key)
@karta.each {|ar| return ar[1] if ar[0] == key}
nil
end
... | true |
49026dd4c0b283c406edad98707a9def48e9c0f0 | Ruby | MichaelKTHP/S3j2 | /app.rb | UTF-8 | 666 | 3.28125 | 3 | [] | no_license | require 'bundler'
Bundler.require
require_relative 'lib/game'
require_relative 'lib/player'
player1 = Player.new("José")
player2 = Player.new("Max")
puts "Voici l'état de chaque joueur : "
while player1.life_points > 0 && player2.life_points > 0
puts "#{player1.name} à #{player1.life_points} points de vie"
puts "#... | true |
af6dfdbabbc012330b94b261428adaa6e88d3a44 | Ruby | textmaster/minos | /lib/minos/utils.rb | UTF-8 | 676 | 2.9375 | 3 | [
"MIT"
] | permissive | module Minos
class Utils
# Flatten args as an array, hash or string into CLI args.
def self.to_args(args)
args.map do |key, value|
case value
when Array
value.map do |v|
"--#{key.underscore.gsub('_', '-')} #{v}"
end
when Hash
value.map do... | true |
22db33786d4b37ce1278eebd56065c35362450d0 | Ruby | qw3r/mars-rovers-kata | /lib/mission.rb | UTF-8 | 758 | 3.203125 | 3 | [] | no_license | require_relative './plateau'
require_relative './rover'
class Mission
def initialize(mission_config)
@config = mission_config.split("\n")
@plateau = build_plateau config[0]
@rovers = build_rovers config[1..-1]
end
def run
execute_commands
show_statuses
end
private
attr_reader :... | true |
27a0a6044af32591dce85b8cf5d9875c1455054e | Ruby | simonconway1979/bank_tech_test | /lib/account.rb | UTF-8 | 2,256 | 3.90625 | 4 | [] | no_license | require 'pry'
class Account
def initialize
@balance = 0
@transactions = []
@formatted_transactions
end
def balance
@balance
end
def deposit(amount)
@balance += amount
date = Time.now.strftime("%d/%m/%Y")
@transactions << [date, amount, balance]
end
def withdrawal(amount)
wit... | true |
6eebab6a912a5cd4e6d8b8a7a1904a6ef05ce67d | Ruby | joker1007/slides | /true_refinements/10.rb | UTF-8 | 349 | 3.09375 | 3 | [] | no_license | require_relative './main'
require_relative './ext'
class Context
def initialize(name = nil)
@name = name
end
def hello(str)
TrueRefinements.refining(Ext) do
str.hello
end
end
def hello2
TrueRefinements.refining(Ext) do
@name.hello
end
end
end
Context.new("joker1007").hell... | true |
d7255187bb8a8cbedc155ccfc56063db47aae9d7 | Ruby | deanmax/spinning_cursor | /test/test_cursors.rb | UTF-8 | 3,616 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'helper'
class TestSpinningCursorCursor < Test::Unit::TestCase
context "SpinningCursor::ConsoleHelpers.reset_line" do
# get the current shell width
cols = SpinningCursor::ConsoleHelpers.console_columns
regex = Regexp.new(Regexp.escape("#{ESC_R_AND_CLR}#{ESC_UP_A_LINE}"))
should "not clear lin... | true |
5b14466e8c60f1035cefce3d766ddc715326eb2f | Ruby | hyphenized/study-group-utils | /commands/mkgroups.rb | UTF-8 | 1,973 | 2.859375 | 3 | [
"MIT"
] | permissive | #
# BASIC COMMAND TEMPLATE
#
#
class StudyGroups < Command
NAME = "mkgroups"
DESCRIPTION = "Creates study groups"
def initialize
super
end
def run(**kwargs)
# @type [CLI]
cli = kwargs[:cli]
matrix = StudentMatrix.new(cli.students, cli.config["group_size"])
matrix.load_ocurrences(cli.past... | true |
f75a9e4591ff36f77c526ad2b1ab11e49157137f | Ruby | coolo/pull_request_package | /runner.rb | UTF-8 | 997 | 2.5625 | 3 | [] | no_license | require 'octokit'
require 'logger'
require 'yaml'
require_relative 'lib/obs_pull_request_package'
require_relative 'lib/github_status_reporter'
config = YAML.load_file('config/config.yml')
client = Octokit::Client.new(config[:credentials])
logger = Logger.new(STDOUT)
def line_seperator(pull_request)
'=' * 15 + " #... | true |
1152140cc1dbc6a3b62160f870c1e87af0128971 | Ruby | semmons99/ruby-euler | /prob009.rb | UTF-8 | 284 | 3.859375 | 4 | [] | no_license | def triplet?(a, b, c)
a**2 + b**2 == c**2
end
def find_triplet(limit)
1.upto(limit) do |a|
2.upto(limit - a - 1) do |b|
c = limit - a - b
break if a > c or b > c
return a, b, c if triplet?(a, b, c)
end
end
end
a, b, c = find_triplet(1000)
puts a*b*c
| true |
31b665fa274cc066df85dd849120a13c34d480e8 | Ruby | durierem/rgs | /src/couple.rb | UTF-8 | 1,310 | 2.921875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative 'assertion_error.rb'
require_relative 'individual.rb'
require_relative 'parameters.rb'
# A couple of two individuals that can reproduce.
# @inv
# members.length == 2 && members.each { |m| m.is_a?(Individual) }
# && 0 <= offsprings.length <= max_offsprings
# && offs... | true |
09ac6dde00e5d4452fa841e5cc3fcc6aaf23207b | Ruby | brentbrinkley/tealeaf-book-excercises | /ch6_arrays_excercises/arrayprogram.rb | UTF-8 | 84 | 3.234375 | 3 | [] | no_license | array_1 = [1,2,3,4,5,6]
array_2 = array_1.map {|num| num * 2}
p array_1
p array_2
| true |
7960b5968b2f6ee0d59cb7da9be1e756d2b261e2 | Ruby | MFahadUmer/Ruby-Linter | /bin/linter.rb | UTF-8 | 1,275 | 3.390625 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative '../lib/file_validation.rb'
require_relative '../lib/style_error.rb'
puts 'Welcome to Linter'
file_validation = false
while file_validation == false
print 'Please Enter the address of your file: '
file = gets.chomp
if file.empty?
puts 'Empty address! Please Provide a valid... | true |
518efb811cd54ae3f48d2a22c502b1504786dfc0 | Ruby | human7016/pictweet | /app/helpers/tweets_helper.rb | UTF-8 | 254 | 2.640625 | 3 | [] | no_license | module TweetsHelper
def tweet_lists(tweets)
html = ''
tweets.each do |tweeted|
html += render(partial:'tweet', locals:{tweeted: tweeted})
end
#HTMLを正常に表示するためのメソッドraw()
return raw(html)
end
end
| true |
2c9a0823191d654ffd9b7384b39d913e06d21be2 | Ruby | paige11/prime-ruby-001-prework-web | /prime.rb | UTF-8 | 157 | 3.578125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def prime?(n)
if n < 2
return false
end
array = (2..(n-1)).to_a
array.each do |x|
if (n % x) == 0
return false
end
end
true
end | true |
b1c4317258f2b0cbcf3c5257b79026865f05a611 | Ruby | dannybarrientos/learningruby | /operadoreslogicos.rb | UTF-8 | 273 | 3.421875 | 3 | [] | no_license | =begin
Y => Ambas condiciones se tiene que cumplir
O => Si ninguna condicion se cumple es FALSE
! => cambia el resultado
=end
#AND
puts 1<2 && 1==1 && 3!=6 && 5==4
#Dr
puts 1<2 || 1==1 || 3!=6 || 5==4
#!Negacion
condicion = (1<2 || 1==1 || 3!=6 || 5==4)
puts !condicion | true |
748da8da49f15af4c627e3c14c5308261719eca4 | Ruby | oxywtf/nitro | /script/lib/wrap.rb | UTF-8 | 4,003 | 2.71875 | 3 | [] | no_license | require "pp"
require "set"
begin
require "rubygems"
rescue LoadError
end
begin
require "systemu"
rescue LoadError
puts "Please install systemu for better-looking results"
# small drop-in replacement for systemu... far from perfect though, so please
# install the library
def systemu command
stdout = ... | true |
4c98e3b1152dedf9db65123669480065ffddc9db | Ruby | jonsnyder01/thesis_wikipedia | /lib/object_store.rb | UTF-8 | 869 | 2.859375 | 3 | [] | no_license | class ObjectStore
def initialize(marshal_helper, filename, default_value=nil, &block)
@marshal_helper = marshal_helper
@filename = filename
@default_value = default_value
@default_block = block
end
def [](id)
objects_by_id[id] || (@default_block ? @default_block.call : @default_value)
en... | true |
a2c24e0be22e61b565c0d2998593ff3fa1d2dec5 | Ruby | bdwain/rubytest2 | /lib/file_parser.rb | UTF-8 | 308 | 3 | 3 | [] | no_license | require_relative 'record'
class FileParser
def parse_file(file_path)
result_set = Array.new
File.open(file_path) do |file|
file.each_line do |line|
record = Record.new
record.parse(line)
result_set.push(record)
end
end
result_set
end
end | true |
928878b274f017184785a2544c0ac5b39c9e85d7 | Ruby | rasmar/concrete-constructions-calculators | /beam.rb | UTF-8 | 1,700 | 3.15625 | 3 | [] | no_license | require_relative 'constants.rb'
require_relative 'methods.rb'
require 'pry'
puts "\nWhat kind of excercise You have to solve?"
puts 'Type:'
puts '1 - I need to calculate given section resistance.'
state = gets.chomp.to_i
case state
when 1
steel_cl # Define steel
con_cover # Calculate cover
con_cl # Define and i... | true |
ae31d7784d643002bb874f9f881e426629eb843d | Ruby | jonallured/jonallured.com | /spec/lib/title_parser_spec.rb | UTF-8 | 2,984 | 2.8125 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../../lib/title_parser'
RSpec.describe TitleParser do
describe 'with a short title' do
it 'returns one title part' do
title = 'Dealing With Rotten Links'
parts = TitleParser.parse(title)
expect(parts).to eq(
[
'Dealing With Rott... | true |
ddf6a9f969baec3ad243699bd2dc5a8c233a9039 | Ruby | venj/myscripts | /myscripts/prepo | UTF-8 | 2,631 | 3 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | #!/usr/bin/env ruby
# Make icns file for Mac App Store from a large image file.
require "fileutils"
require "rmagick"
require "colorize"
include FileUtils
include Magick
class PPNotSquareShapeError < StandardError;end
class PPFileTooSmallError < StandardError;end
def resize(image, width)
image.scale(width, width)
... | true |
9a55cf731f59f2c09404fb6be5b1910285a77ab5 | Ruby | jackhardy1/learn_to_program | /ch14-blocks-and-procs/grandfather_clock.rb | UTF-8 | 193 | 3.0625 | 3 | [] | no_license | def grandfather_clock &block
hour = Time.new.hour
if hour == 0
hour = 12
end
if hour > 12
hour = hour - 12
end
hour.times(&block)
end
grandfather_clock do
puts 'DONG!'
end
| true |
fa228f50e72804c18ade5d29e0fe5c60f18851c3 | Ruby | wearit/dagnabit | /lib/dagnabit/graph.rb | UTF-8 | 6,116 | 2.984375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require File.join(File.dirname(__FILE__), %w(.. dagnabit))
module Dagnabit
##
# This class is a representation of a directed graph. It deviates from the
# definition of a directed graph in a few ways; here's a couple:
#
# * It represents the vertex and edge sets using data structures more akin to
# bags... | true |
ff8aa6329fcba00b3610d34e765f959d1f50fb00 | Ruby | CST-100/bda-remote | /lib/validation.rb | UTF-8 | 12,181 | 3.140625 | 3 | [] | no_license | module Validation
class Strategy
def apply(craft)
return true
end
def error_message
return ""
end
end
class NotCondition < Strategy
def initialize(strategy)
@strategy = strategy
end
def apply(craft)
return !strategy(craft)
end
end
class OrCondition < ... | true |
9ca7f4ec6646ea302ed2de0f82522883fd54c685 | Ruby | piplcom/piplapis-ruby | /code_snippets.rb | UTF-8 | 2,953 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | require_relative 'lib/pipl'
# Home page
response = Pipl::client.search email: 'clark.kent@example.com'
puts response.image.thumbnail_url width: 200, height: 100, favicon: true, zoom_face: true
puts response.name
puts response.education
puts response.username
puts response.address
puts response.person.jobs.map(&:to_s)... | true |
8569d680e3adc88d6de319645b9ccfb844d7f258 | Ruby | HenryDashwood/Hotel-Homework | /specs/hotel_spec.rb | UTF-8 | 581 | 2.9375 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative('../hotel.rb')
require_relative('../room.rb')
require_relative('../guest.rb')
require_relative('../chain.rb')
class TestHotel < Minitest::Test
def setup
@room1 = Room.new(1, 2)
@room2 = Room.new(2, 2)
@room3 = Room.new(3, 2)
@room4 ... | true |
ff68ee29a2d330d37f1eae0037328c67af7ade7e | Ruby | FBH037/Ruby-programs | /CH9_EX9.5_Modern_RN.rb | UTF-8 | 753 | 3.796875 | 4 | [
"Unlicense"
] | permissive |
#Old school roman numerals method
def Roman_Numeral number
rn = []
while number > 0
while (number/1000) >= 1
rn.push ('M')
number=number-1000
end
while (number/500) >= 1
rn.push ('D')
number=number-500
end
while (number/100) >= 1
rn.push ('C')
number=number-100
end
while (number/50) >= 1
rn.p... | true |
d5d27c8f5b00703ad570c5bc91c0c003eb1057c8 | Ruby | nigohiroki/ratio_maker | /lib/ratio_maker/command.rb | UTF-8 | 628 | 2.875 | 3 | [
"MIT"
] | permissive | require 'ratio_maker'
require 'thor'
module RatioMaker
class Command < Thor
desc "width height ratio", "get width"
option :round, type: :boolean, default: false
def width(origin_width, origin_height, height)
width = origin_width.to_i * (height.to_f/origin_height.to_f)
p options[:round] ?... | true |
337c320ab91e224985511394593fc796c4171dfe | Ruby | studentinsights/studentinsights | /app/importers/tools/analyze_students_export.rb | UTF-8 | 1,328 | 2.828125 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | require 'csv'
class AnalyzeStudentsExport < Struct.new :path
def contents
encoding_options = {
invalid: :replace,
undef: :replace,
replace: ''
}
@file ||= File.read(path).encode('UTF-8', 'binary', encoding_options)
.gsub(/\\\\/, '')
... | true |
8edb40d8ccb37697a4b2b7e57fe1b9831b26cd66 | Ruby | Aphinith/Ruby101 | /nested_iterators.rb | UTF-8 | 418 | 2.6875 | 3 | [] | no_license | cars = {
"Toyota" => {
"Prius" => "Small Size Sedan",
"Corolla" => "Small/Medium Size Sedan",
"Camry" => "Medium Size Sedan"
},
"Honda" => {
"Civic" => "Small Size Sedan",
"Accord" => "Mid Size Sedan",
"CRV" => "Mid Size SUV"
}
}
cars.each do |make, models|
puts make
models.each do ... | true |
49c86eaa45d439441192dc0bc76c412745013771 | Ruby | JakubowskiA/Adventures | /db/seeds.rb | UTF-8 | 1,894 | 2.75 | 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 |
dac0f4b9dfd641a5cdb2df95cbeeeb1bbf12746f | Ruby | ChewbaccaJerky/Ruby-Algorithms | /lru_cache/lib/p01_int_set.rb | UTF-8 | 2,149 | 3.421875 | 3 | [] | no_license | class MaxIntSet
def initialize(max)
@max = max
@store = Array.new(max){false}
end
def insert(num)
unless include?(num)
if is_valid?(num)
@store[num] = true
true
else
raise "Out of bounds"
end
else
false
end
end
def remove(num)
if includ... | true |
23e4c13af022485cc823a16978e65d65b88d639b | Ruby | robinrali/programming-univbasics-4-square-array-online-web-prework | /lib/square_array.rb | UTF-8 | 133 | 2.8125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def square_array(array)
[1,4,9])
new_numbers = [9, 10, 16, 25]
square_array(new numbers)
[81, 100. 256, 625]
end | true |
5e14c4291f303ae0cec2c17960ca6f145a34b486 | Ruby | RubyDaRosess/ruby-exo | /exo_07_a.rb | UTF-8 | 346 | 3.78125 | 4 | [] | no_license | puts "Bonjour, c'est quoi ton blase ?"
user_name = gets.chomp
puts user_name
=begin
La méthode gets sert à demander une infomartion à l'utilisateur,
la méthode chomp sert à supprimer le retour à la ligne quand
l'utilisateur appuye sur Enter pour valider sa réponse
C'est simple, sans le .chomp, le puts user_name don... | true |
faa8ebdd292d743fc0052c33b786bd24a148adbe | Ruby | olemanju/RubySelenium | /Cucu/Mixin_module_ansc.rb | UTF-8 | 640 | 3.34375 | 3 | [] | no_license | module Purchaseble
def purchase(item)
"#{item} has been Purchased"
end
end
class Bookstore
include Purchaseble
def purchase(item)
"User has purchased has textbook #{item}"
end
end
class SuperMarket
include Purchaseble
def purchase(item)
" #{item} Super market is opened and purchased"
en... | true |
4eb2a73a243bd28d39c6a8e171f448e1f2f0d2d7 | Ruby | CodeCoreYVR/class_demos_bootcamp_march_2021 | /ruby_basics/sum_to_exit.rb | UTF-8 | 243 | 3.625 | 4 | [] | no_license | sum = 0
puts "Enter a number to add up or type exit for the sum"
input = gets.chomp
until input == "exit"
puts "Enter a number to add up or type exit for the sum"
num = input.to_i
sum += num
input = gets.chomp
end
puts "sum is #{sum}" | true |
5dab716583d79b996b94da85a40f8906c2b611fc | Ruby | dpholbrook/ruby_small_problems | /small_problems/easy_4/2.rb | UTF-8 | 2,898 | 4.3125 | 4 | [] | no_license | =begin
input: integer
output: string
rules:
- return the century of the year
- use proper ending
- 'st', 'nd', 'rd', 'th'
- 20th is 1901 - 2000
algorithm:
- determine century
- subtract 1 from year to account for 2000 being 20th century
- centry is (year / 100) + 1
- add ending
- create ha... | true |
4ec3e77e4c4629faff4eec0996ad85e41cdf3abe | Ruby | shaqqour/ruby-music-library-cli-online-web-ft-090919 | /lib/concers/findable.rb | UTF-8 | 377 | 2.5625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | module Concerns
module Findable
def find_by_name(name_str)
self.all.find { |item| item.name == name_str }
end
def find_or_create_by_name(name_str)
if self.find_by_name(name_str)
self.find_by_name(name_str)
else
self... | true |
5bb2d5e2742b13d9c47f5b982483ef1246905263 | Ruby | ahs8w/sample_app | /app/models/micropost.rb | UTF-8 | 1,394 | 2.71875 | 3 | [] | no_license | class Micropost < ActiveRecord::Base
belongs_to :user
default_scope -> { order('created_at DESC') } # default is order by user_id
# rails version of an anonymous function: scope '->' criteria desired for scope
# 'Proc'(procedure) or 'lambda': scope need not be evaluated immediately; loaded later as-... | true |
6a636bc4ca7a89a3a5d40b5c1e719a6a84fc4ead | Ruby | testmunk/testmunk_gem | /lib/testmunk/calabash/application.rb | UTF-8 | 527 | 2.625 | 3 | [
"MIT"
] | permissive | require 'testmunk/calabash/logger'
module Testmunk
class Application
attr_accessor :driver
def initialize(driver)
@driver = driver
end
# No need to write getters for screens
# just require 'a_screen' and then use it like @app.a_screen
#
def method_missing(sym, *args, &block)
... | true |
404fd3f10c34d803475bff6bba95f0d3c2c42197 | Ruby | jonesandy/customer-preferences | /lib/display.rb | UTF-8 | 274 | 3.171875 | 3 | [] | no_license | class Display
def format(array)
array.each do |record|
output =
record[:day] + " " +
record[:mday].to_s + " " +
record[:month] + " " +
record[:date] + " - " +
record[:customer].join(", ")
puts output
end
end
end
| true |
a3ad7304175fa604dc0b61bf601b4c2b7a927cb2 | Ruby | rohandalvi/CLI | /Project CRUD/Project_CRUD.rb | UTF-8 | 3,031 | 2.703125 | 3 | [] | no_license | =begin
Class Name: Project_CRUD
Description: Allows to perform CRUD commands on the type Project. Read the README file for more information
on using this script.
Author: Rohan Dalvi (Rohan.Dalvi@emc.com)
Company: EMC Corporation
Date: 10/28/13.
=end
require 'rally_api_emc_sso'
class Project_CRUD
def initialize(... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.