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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ccd6d8a7fa16b83605cec0bb13b1fe380d73ff06 | Ruby | cw0/capstone | /app/controllers/users_controller.rb | UTF-8 | 3,927 | 2.640625 | 3 | [] | no_license | # This controller is responsible for all actions related to application Users, including creation of new users, editing existing users, and removing users.
# @author Ashley Childress
# @version 2.7.2014
class UsersController < ApplicationController
# Use default authorizations from CanCan gem for all actions excep... | true |
b21eb2fadb7671230ccb98804d80b65ba45d7298 | Ruby | kmoosman/nomad_tracker | /app/helpers/helpers.rb | UTF-8 | 396 | 2.75 | 3 | [
"MIT"
] | permissive | class Helpers
def self.current_user(session)
@current_user ||= User.find(session[:user_id])
# memoization
end
def self.is_logged_in?(session)
!!User.find_by_id(session[:user_id])
end
# redirect if not logged in
def self.redirect_if_not_logged_in(session)
if !is_l... | true |
d87b21167994186fe0b4fc78d4e2517c842ae83b | Ruby | Peter-Springer/hyde | /lib/post.rb | UTF-8 | 896 | 2.875 | 3 | [] | no_license | require './lib/build.rb'
require './lib/module.rb'
class Post
include BaseFile
def initialize(file_path, title)
@file_path = file_path
@title = title
end
def new_post
if Dir.exist?(base_file)
format_title
create_new_file
basic_content
else
Build.new(@file_path).setup.n... | true |
cb4acf6af5f4471e17eae742848d19f445b2d94e | Ruby | enfence/rb-stanza | /lib/Stanza/Stanza.rb | UTF-8 | 7,628 | 3.109375 | 3 | [] | no_license | #!/usr/bin/ruby
# Stanza Class
# This file is a part of rb-stanza library
#
# Author:: Andrey Klyachkin <andrey.klyachkin@enfence.com>
# Copyright:: Copyright (c) 2016 eNFence GmbH
# License:: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compl... | true |
c0b83c50c9a6e1632d07154b8f19909e71660012 | Ruby | agscode/chaskatalks | /platicas/2019/abril/DRY/ticket-1.rb | UTF-8 | 1,536 | 2.609375 | 3 | [] | no_license | class Ticket < ApplicationRecord
scope :by_date, ->(start_date, end_date) {
return if start_date.blank? || end_date.blank?
where(capture_date: Time.strptime(start_date, '%m-%d-%Y')..Time.strptime(end_date, '%m-%d-%Y'))
}
scope :current_month, ->{
beginning_of_month = Time.current.beginning_of_month... | true |
3a15f857aa45f1a74fddb1462fb315bc60248186 | Ruby | Cscharf91/chess | /lib/game.rb | UTF-8 | 13,745 | 3.359375 | 3 | [] | no_license | require 'pry'
require_relative 'board'
require_relative 'save_load'
class Game
include SaveLoad
attr_reader :players, :board, :current_player, :other_player
def initialize(players, board = Board.new)
@players = players
@board = board
@current_player, @other_player = players.shuffle
... | true |
f5a9c56571f7c7de27d348b989ab7f632c3d5b81 | Ruby | TaylorBeeston/ExercismAnswers | /ruby/minesweeper/minesweeper.rb | UTF-8 | 1,148 | 3.484375 | 3 | [] | no_license | class Board
def self.transform(input)
@input = sanitize(input)
input.map.with_index { |line, index| convert_line(line, index) }
end
private
VALID_CHARS = "+-| *"
# Checks for proper formatting
def self.sanitize(input)
correct_border = "+#{"-" * (input[0].length - 2)}+"
unless ... | true |
58f44d4bfb70858d256a62a872b93171a06ed173 | Ruby | johnnymugs/ffaker | /lib/ffaker/problem.rb | UTF-8 | 722 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Faker
module Problem
extend ModuleUtils
extend self
def problem
PREFIXES.rand + " " +
Faker::Product.brand + " " +
Faker::Product.product + " " +
Faker::Product.model + " " +
SUFFIXES.rand
end
PREFIXES = k [
"The ol'",
"The darn",
"My old",
... | true |
fd0c9e4f15271411c5cbde3adec61f72f55cf96a | Ruby | Fanny-R/advent-of-code-2019 | /point.rb | UTF-8 | 932 | 3.734375 | 4 | [] | no_license | class Point
attr_accessor :x, :y
def initialize(x, y)
@x = x
@y = y
end
def manhattan_distance(another_point)
(@x - another_point.x).abs + (@y - another_point.y).abs
end
def eql?(other)
@x == other.x and @y == other.y
end
def hash
[@x, @y].hash
end
def to_s
"x: #{@x} y:#... | true |
4dbc4d234878c220681ddd4febfd9d6639fd1d80 | Ruby | rubyforgood/casa | /app/notifications/base_notification.rb | UTF-8 | 935 | 2.53125 | 3 | [
"MIT"
] | permissive | class BaseNotification < Noticed::Base
# Require title, url and message methods to be implemented on children
def title
raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}"
end
def message
raise NotImplementedError, "#{self.class} has not implemented method '#{__method__... | true |
a850b75bd5df4190271ff42c398f8e5f28339e69 | Ruby | pragdave/dion | /util/Formatters.rb | UTF-8 | 2,085 | 3.03125 | 3 | [] | no_license | # ----
# Copyright (c) 2003, 2003 David Thomas (dba Thomas Consulting)
# All Rights Reserved.
# The right to use this software is granted by separate license
# between Destination Imagination, Inc and David Thomas.
#
# No part of this program may be reproduced, stored in a retrieval
# system, or transmitted, in any for... | true |
649a18cb5c6b7428ee03a7a5029aae53900fea6d | Ruby | davehassan/bombcrusher | /board.rb | UTF-8 | 1,260 | 3.390625 | 3 | [] | no_license | require_relative 'tile'
require 'byebug'
class Board
attr_reader :dim, :num_bombs
attr_accessor :grid
def initialize(dim = [9,9], num_bombs = 10)
# byebug
@dim = dim
@grid = Array.new(dim[0]) {Array.new(dim[1])}
@num_bombs = num_bombs
self.fill
end
def in_bounds?(pos)
(0...dim[0]).... | true |
f1fb17568d5250e84ef17e99623054a397f98673 | Ruby | joonas-fi/liikkuva-tampere | /heatmap/produce-trips-json.rb | UTF-8 | 2,991 | 3.15625 | 3 | [] | no_license | require 'json'
require './common.rb'
def createBusStopsHash(bus_stops)
ret = {}
bus_stops.each do |stop|
processed = {}
processed['stop_lat'] = stop["stop_lat"].to_f
processed['stop_lon'] = stop["stop_lon"].to_f
ret[ stop['stop_id'] ] = processed
end
ret
end
busStopsDatasource = '../itsfact... | true |
7f2426d3a84bed29ecea1e72f4f104700f3b6ac4 | Ruby | shocci1214/Ruby_Camp | /practice07/Scene/scene_gameover/Director.rb | UTF-8 | 733 | 2.703125 | 3 | [] | no_license | require_relative '../Lib/Button'
require_relative '../Lib/Info'
module GameOver
class Director
@@score = 0
def initialize
@button_next = Button.new(200,200,'次のステージへ',START_SOUND,to: "game")
@button_to_title = BackButton.new(200,300,'タイトルへもどる',EXIT_SOUND,to:'title')
... | true |
766b97a9d0d0c275ea19cb86a568f949556158a6 | Ruby | slimbach/RB-101 | /small_problems/easy_1/8_array_average.rb | UTF-8 | 609 | 4.71875 | 5 | [] | no_license | # Write a method that takes one argument, an array containing integers, and returns the average of all numbers in the array.
# The array will never be empty and the numbers will always be positive integers.
# Your result should also be an integer.
def average(arr)
arr.sum / arr.size
end
# Examples:
puts average([... | true |
6e6a38b74834cedb9f83184584d69690b082749b | Ruby | davidvgus/homework | /hello.rb | UTF-8 | 564 | 3.234375 | 3 | [] | no_license | require 'win32console'
=begin
This is a comment block
multiple lines
doctest: First doctest
>> "hello!"
=> "hello!"
doctest: I have another method here
>> hello
=> "hello"
doctest: I pass david to hello and get "Hello David!"
>> hello "David"
=> "hello David!"
doctest: If I forget to capitalize the name it will capita... | true |
3362993048087c41492544bce37c83682445c293 | Ruby | perryr16/food_truck_event_2003 | /lib/item.rb | UTF-8 | 172 | 3.28125 | 3 | [] | no_license | class Item
attr_reader :name
def initialize(details)
@name = details[:name]
@price = details[:price]
end
def price
@price.sub("$","").to_f
end
end
| true |
4201b68c6d895af21c9e791c04d19d7baa43670d | Ruby | pietia/ribs | /test/belongs_to_spec.rb | UTF-8 | 1,235 | 2.640625 | 3 | [
"MIT"
] | permissive | require File.join(File.dirname(__FILE__), 'test_helper')
class Owner
attr_accessor :id, :name, :blog_id
end
class Blog
attr_accessor :id, :owner, :name
Ribs! do |blog|
blog.belongs_to Owner
end
end
describe Blog do
describe "belongs_to" do
it "should include owner field when getting" do
b... | true |
c2f421542c84fc73fe6a9278443084f8de75bbe7 | Ruby | zisko/Ruby-Tools | /ipaddrtool.rb | UTF-8 | 449 | 3.421875 | 3 | [] | no_license | require 'open-uri'
require 'json'
ipinjson = open("http://ipinfo.io/json").read() #opens the uri object and then reads the string it sent
returnedinfo = JSON.parse(ipinjson) #ruby gem to parse out jshon into a hash
puts returnedinfo #print out the new hash object
puts "\n\n------------------------------------------... | true |
afe4c67fa27999537388f36212f657762d3d6715 | Ruby | apurvajajodia/rbnd-toycity-part3 | /lib/product.rb | UTF-8 | 1,198 | 3.375 | 3 | [
"MIT"
] | permissive |
#require_relative "lib/errors"
class Product
@@products = []
@@product_in_stock = []
attr_accessor :title, :price, :stock
def initialize(string = {})
@title = string[:title]
@price = string[:price]
@stock = string[:stock]
add_to_products
end
def self.all
@@products
end
def self.find_by_title(s... | true |
73afa31d7365cb5cbecd9987e1ac8f64c722ef36 | Ruby | jpalumickas/csstats | /lib/csstats/parser/reader/file_reader.rb | UTF-8 | 1,032 | 2.5625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # frozen_string_literal: true
require_relative 'file_streamer'
module CSstats
module Parser
module Reader
class FileReader
attr_reader :file_path, :limit
def initialize(file_path, options = {})
@file_path = file_path
@limit = options[:limit] || 0
raise CSsta... | true |
6da7722d9af8755fc8693a6b22db54710f1b1ff1 | Ruby | DougWelchons/war_or_peace | /test/turn_test.rb | UTF-8 | 9,730 | 3.15625 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/card'
require './lib/deck'
require './lib/player'
require './lib/turn'
class TurnTest < Minitest::Test
def test_turn_exists
deck1 = Deck.new([])
deck2 = Deck.new([])
player1 = Player.new("Megan", deck1)
player2 = Player.new("Aurora",... | true |
b77428010b149b534ad9548e588e9eab816cd981 | Ruby | ajtran303/codeacademy-ruby | /1/the-reverse-method.rb | UTF-8 | 98 | 3.046875 | 3 | [] | no_license | # The reverse method is a built-in method. It's one way to sort.
puts "woodstockthebird".reverse
| true |
5a382925c73f4605cd6580488fb97d4e6db72e71 | Ruby | katiepekarek/gCamp | /spec/model/user_spec.rb | UTF-8 | 1,053 | 2.671875 | 3 | [] | no_license | describe Project do
it "is valid with a full name email and password" do
user=User.new(first_name:'Name', last_name: 'Smith', email:'user@yahoo.com', password: '1234', password_confirmation: '1234' )
expect(user).to be_valid
end
it "is not valid without a first_name" do
user = User.new(first_nam... | true |
650475fd3d299df71622d94d9617896eb7108739 | Ruby | nicolasmuneram/FashionAdvisorBackEnd | /gems/FashionAdvisorCore/lib/FashionAdvisorCore/Entities/user.rb | UTF-8 | 715 | 2.734375 | 3 | [
"MIT"
] | permissive | module FashionAdvisorCore
module Entities
class User
attr_accessor :id
attr_accessor :email
attr_accessor :password
attr_accessor :token
attr_accessor :products
def initialize(email, password)
@password = password
@email = email
@products = {}
end... | true |
eb92aa6a920dacacefb9719dfb958b401230bcb4 | Ruby | iamwalker/groudashpon | /city.rb | UTF-8 | 276 | 2.5625 | 3 | [] | no_license | require 'net/http'
require 'json'
class City
URL = URI.parse("http://www.groupon.com/api/v1/divisions.json")
def self.all
response = Net::HTTP.start(URL.host, URL.port) do |http|
http.get(URL.path)
end
JSON.parse(response.body)["divisions"]
end
end
| true |
963c0c87aa77c22d9473cc62f90d945253437a23 | Ruby | ranjan/InterviewBit_ruby_week1 | /minStepsInInfiniteGrid.rb | UTF-8 | 689 | 3.34375 | 3 | [] | no_license | class Solution
# @param a : array of integers
# @param b : array of integers
# @return an integer
def coverPoints(a, b)
if a == nil || b == nil || (a.length != b.length)
return 0
end
if a.length < 2
return 0
end
count = 0
... | true |
93a06dcb799f31a113b4406ec73b00b18d480c57 | Ruby | aasmith/struggle | /lib/struggle/events/card_events/nato.rb | UTF-8 | 2,232 | 2.734375 | 3 | [
"MIT"
] | permissive | module Events
module CardEvents
# The NATO event is implemented using several mechanisms. This is the
# canonical list of them.
#
# NATO cannot be played as a card for the event until certain events have
# occured. This is enforced in the NatoPreventer class. It prevents the
# card from being... | true |
735cf30615bb50c951174477540d3e01b56a90f9 | Ruby | michaelveloso/breakable_recipes | /spec/features/ingredients/moderator_edits_ingredients_spec.rb | UTF-8 | 3,949 | 2.671875 | 3 | [] | no_license | require 'rails_helper'
feature 'moderator edits ingredient', %{
As a moderator
I want to edit an ingredient
To fix mistakes
Acceptance criteria:
[√] - Moderator can edit ingredients from ingredients index
[√] - Admin can edit ingredients from ingredients index
[√] - Form shows all fields
[√] - Succes... | true |
3533860ba9d12168734617563d691338699bb762 | Ruby | katy12032001/SOA2015_flip_flap | /flip_flap.rb | UTF-8 | 246 | 2.6875 | 3 | [] | no_license | require_relative 'tsv_buddy'
require 'yaml'
# a class that is able to transfer between YSML
class FlipFlap
include TsvBuddy
attr_accessor :data
def take_yaml(yml)
@data = YAML.load(yml)
end
def to_yaml
@data.to_yaml
end
end
| true |
65efe6119aa168fdb0c146ba253272a244bdd818 | Ruby | openactive/api-dashboard | /lib/datasets_cache.rb | UTF-8 | 2,707 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | class Datasets
DIRECTORY="http://dataset-directory.herokuapp.com/datasets"
#Returns a hash of datasets keyed on a unique id.
def self.list
results = JSON.parse(RestClient.get(DIRECTORY))
datasets = {}
results.each do |result|
begin
next unless result["publish"] && result["publish"] == ... | true |
0f239b63828ce4949dc6063c7d3406e0614803ce | Ruby | jamessom/fat-code-refactoring-techniques | /spec/models/concerns/emailable_spec.rb | UTF-8 | 2,668 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe User do
before do
@user = User.new(name: "Example User", email: "user@example.com",
password: "foobar", password_confirmation: "foobar")
end
subject { @user }
describe "#email_domain" do
it "should equal example.com" do
expect(@user.email_do... | true |
601fd2829e3de4a9190dccc0c70a880020f5eeea | Ruby | rock-core/gui-rock_widget_collection | /scripts/virtual_joystick.rb | UTF-8 | 1,913 | 2.515625 | 3 | [] | no_license | #!/usr/bin/ruby
##############################################
# Small script for the virtual joystick plugin
# Author: leif.christensen@dfki.de
# Date: 09/19/2014
##############################################
require 'vizkit'
require 'optparse'
include Orocos
options = {}
optparse = OptionParser.new do |opts|
... | true |
772aa22481e001c4737bd57d0a30528ffb91943e | Ruby | mbalsamo2/ttt-10-current-player-v-000 | /lib/current_player.rb | UTF-8 | 342 | 3.921875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # determine how many turns have been made
def turn_count(board)
counter = 0
board.each do |turn|
if turn == "X" || turn == "O"
counter += 1
end
end
return counter
end
# determine if it's X's or O's turn
def current_player(board)
if turn_count(board) % 2 == 0
"X"
elsif turn_count(board) % 2 == 1... | true |
21a5aaf7a266c58c81c5b4f116dcbdcd2d1aea87 | Ruby | orotemo/youmark | /app/helpers/users_helper.rb | UTF-8 | 748 | 2.53125 | 3 | [] | no_license | module UsersHelper
def login(user)
cookies.permanent[:remember_token] = user.remember_token
current_user = user
end
def logged_in?
!current_user.nil?
end
def current_user=(user)
@current_user = user
end
def current_user
@current_user ||= user_from_remember_token
end
def current... | true |
6566867e6bb711690b886815bdd9f8b72d17b349 | Ruby | nickjenvey/ar-exercises | /exercises/exercise_4.rb | UTF-8 | 876 | 2.96875 | 3 | [] | no_license | require_relative '../setup'
require_relative './exercise_1'
require_relative './exercise_2'
require_relative './exercise_3'
puts "Exercise 4"
puts "----------"
# Your code goes here ...
surrey = Store.create :name => 'Surrey', :annual_revenue => 224000, :mens_apparel => false, :womens_apparel => true
whistler = Stor... | true |
c880917d826dec4d46b6ad7f1aedfccb825b59a6 | Ruby | gerapeldoorn/puppet-pe_upgrade | /lib/puppet/parser/functions/pe_pkgname.rb | UTF-8 | 2,751 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | require 'puppet/error'
Puppet::Parser::Functions.newfunction(:pe_pkgname, :type => :rvalue, :doc => <<-EOD
Determine PE package name from facts
Given a set of client facts, determines the name of the pe upgrade package
appropriate for that machine.
Examples
--------
# On Debian 6 i386
notice(pe_pkgname('2.6.... | true |
113bbcd8d24da4d59bee981829d25a5fe5a79d4a | Ruby | feki/iv122 | /04/polygon_v2.rb | UTF-8 | 2,668 | 3.21875 | 3 | [] | no_license | module Polygon
class Point < Struct.new(:x, :y)
def self.new_by_array(arr)
self.new(arr[0], arr[1])
end
def ==(another_point)
x === another_point.x && y === another_point.y
end
end
class Vector < Struct.new(:x, :y)
# @param vector [Vector]
def ==(vector)
x === vector.x ... | true |
2a68f39ae9ccd988970d8a8b63e41370a5f789c6 | Ruby | telegraham/youtubs-id | /spec/converter_spec.rb | UTF-8 | 13,731 | 3.015625 | 3 | [] | no_license | require_relative 'spec_helper'
describe Converter do
describe ".stringify" do
it "converts numbers up to 63" do
expect(Converter.stringify(0)).to eq("0")
expect(Converter.stringify(1)).to eq("1")
expect(Converter.stringify(2)).to eq("2")
expect(Converter.stringify(3)).to eq("3")
e... | true |
cfb2936cc87c63d64829038a712eb5e8359a4db6 | Ruby | SViccari/FizzBuzzFun | /fizzbuzz_3.rb | UTF-8 | 152 | 3.796875 | 4 | [] | no_license | def fizzbuzz(int)
(1..int).map { |i|
(i%15).zero? ? "FizzBuzz" :
(i%5).zero? ? "Fizz" :
(i%3).zero? ? "Buzz" : i
}
end
puts fizzbuzz(100)
| true |
e8ee645cf90b868d93b3092fec51e9bc126fd818 | Ruby | lmbacelar/cs169-1x | /hw13.rb | UTF-8 | 364 | 3.703125 | 4 | [] | no_license | def combine_anagrams(words)
anagrams = []
until words.empty? do
anagrams << words.select { |word| word.is_anagram_of? words.first }
words -= anagrams.flatten
end
anagrams
end
class String
def is_anagram_of?(string)
self.downcase.sort_letters == string.downcase.sort_letters
end
def sort_lette... | true |
81fa2e62412565e587c9009d06d1856a12592197 | Ruby | Cryptofrye/Vegas_Video-Game | /roulette.rb | UTF-8 | 924 | 3.0625 | 3 | [] | no_license | def welcome_screen
puts ""
puts "Welcome to roulette, please choose a number 0-34"
@bet = gets.to_i
puts "your bet is on #{bet}."
end
def win_maybe
if @answer == bet
puts "you win"
win = Wallet.increase_money(35)
puts "your money in your wallet is: #{@Wallet}"
else
puts "you lose"
Money ... | true |
bdb8867053a9932179161eaeee08a7d3ddf32ef1 | Ruby | bryanluu/TOP_ruby | /hangman/lib/hangman.rb | UTF-8 | 2,838 | 4.03125 | 4 | [] | no_license | # frozen_string_literal: true
require 'set'
require 'yaml'
def affirmative?
input = gets.chomp.downcase
%w[y yes].include? input
end
# Hangman game class
class Game
DICTIONARY = '../5desk.txt'
def initialize
@word = get_word_from_dictionary(DICTIONARY)
@correct = Set.new
@incorrect = Set.new
... | true |
22d02cb59a9aa7da46b36fb2930624e0638e1113 | Ruby | iAmNathanJ/scratch | /test_life_3d.rb | UTF-8 | 1,163 | 2.8125 | 3 | [] | no_license | require 'test/unit'
require_relative 'game_of_life'
require_relative 'navigator'
require_relative 'rules'
class TestGameOfLife < Test::Unit::TestCase
attr_reader :life
def setup
nav = XYZ_Navigator.new
rules = Rules.new
@life = GameOfLife.new(nav, rules)
end
def test_generation
locations = [... | true |
1a8723af73c5a5a3a6ade6303e92b37c6669d5f7 | Ruby | adamdboudreau/carbuncle | /lib/csv_writer.rb | UTF-8 | 1,370 | 3.28125 | 3 | [] | no_license | class CsvWriter
attr_reader :filename
def initialize(filename)
@filename = filename || ""
end
def append_text(text)
if File.exist?(File.expand_path(@filename))
open(File.expand_path(@filename), 'a') do |f|
f.puts text
end
# existingFile = File.open(File.expand_path(@filename), "a")
# begin
... | true |
cd0ee66d776825febee17a3d5f5d1083590d74e2 | Ruby | epson121/Ruby | /clrs/scramble_search.rb | UTF-8 | 291 | 3.3125 | 3 | [] | no_license | require 'in_place_permutation'
require 'linear_search'
##
# Uses linear search and permutation to find value in array
# p scramble_search([1, 2, 3, 5, 4], 4)
# p scramble_search([1, 2, 3, 5, 4], 6)
#
def scramble_search(array, v)
linear_search(permute(array), v) != nil ? true : false
end | true |
6d91dee1433c52e4ecd7863d21756f3f5cd303a9 | Ruby | digitalh2o2/rails-amusement-park-v-000 | /app/models/ride.rb | UTF-8 | 963 | 2.734375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Ride < ActiveRecord::Base
belongs_to :user
belongs_to :attraction
def take_ride
if can_ride
begin_ride
elsif !has_enough_tickets && not_short
"Sorry. You do not have enough tickets the #{attraction.name}."
elsif !not_short && has_enough_tickets
"Sorry. You are not tall enough to ride t... | true |
2bf85fce0423a977fa03d170351997b86584a49d | Ruby | Growingplant3/intro-ruby | /test9.rb | UTF-8 | 85 | 3.09375 | 3 | [] | no_license | # for number in 0..10 do
# puts number
# end
10.times do
puts "Hello World"
end
| true |
833d3f31d16a6e9034a38f89dc76b3b524a968b7 | Ruby | riffraff/cli | /bin/rate | UTF-8 | 1,157 | 2.96875 | 3 | [] | no_license | #!/usr/bin/env ruby
# vim: syntax=ruby expandtab sw=2 sts=2
TIME_BETWEEN_SIGINTS=1
class Stage
def initialize
@count=0
@prev=0
end
def input(line)
@count+=1
@line = line
end
def output
@line
end
def report
ret= [@count, @prev]
@prev=@count
ret
end
end
def setup_interrup... | true |
1ecee60bc78b794de310e6c6106771391d798b73 | Ruby | othiym23/sc2calc | /lib/resource_model.rb | UTF-8 | 8,171 | 3.328125 | 3 | [
"BSD-2-Clause"
] | permissive | require 'consumer_model'
class ResourceModel < ConsumerModel
attr_accessor :logger
attr_reader :trip_time, :per_trip, :initial
COPIOUS_DEBUGGING = false
def initialize(type, trip_time, per_trip, start_harvesters = 0, start_amount = 0)
super({})
@type = type
@trip_time = trip_time
@per_t... | true |
d1d583cf86d82ba95d27d1ff40a9a560f0783746 | Ruby | george-carlin/abroaders | /spec/models/business_spec.rb | UTF-8 | 736 | 2.828125 | 3 | [] | no_license | require 'business'
RSpec.describe Business do
let(:spending_info_class) { Struct.new(:has_business, :business_spending_usd) }
example '.build' do
# when there is no business
spending = spending_info_class.new('no_business', nil)
expect(described_class.build(spending)).to be_nil
# business with ei... | true |
ae24031a0d3798da7f657e43e98999a720990b46 | Ruby | gnardinigh/parrot-ruby-nyc-web-062518 | /parrot.rb | UTF-8 | 59 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def parrot(message="Squawk!")
puts message
message
end
| true |
147496dce7ad2d183d30284180e9a240373b062b | Ruby | dannyshafer/phase-0-unit-1 | /week-3/exercises/10-leap-years/my_solution.rb | UTF-8 | 339 | 2.9375 | 3 | [] | no_license | # U1.W3: Leap Years
# I worked on this challenge [by myself, with: ].
<<<<<<< HEAD
# Your Solution Below
def leap_year?(year)
return true if year % 4 == 0 && year % 100 != 0
return false if year % 100 != 0
return false if year % 400 != 0
return false if year % 4 != 0
true
end
=======
# Your Solution Below
>>>>>... | true |
20b575660a251836ea872abc2827f145793d3f8d | Ruby | albertbahia/wdi_june_2014 | /w02/d02/sarit_levy/cars/lib/car.rb | UTF-8 | 848 | 3.734375 | 4 | [] | no_license | class Car
attr_reader(:horsepower, :fuel)
def initialize(horsepower, fuel)
@horsepower = horsepower
if fuel > 5
@fuel = 5
elsif fuel < 0
@fuel = 0
else
@fuel = fuel
end
end
def rev()
return "VROOM!"
end
def drive()
if @fuel > 0
@fuel -= 1
return true
else
return false
end
e... | true |
0c1161046ab4413e0f74688c5ada60217ce74b3d | Ruby | tatscru/badges-and-schedules-online-web-pt-102218 | /conference_badges.rb | UTF-8 | 452 | 3.828125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def badge_maker(name)
"Hello, my name is #{name}."
end
def batch_badge_creator(names)
names.collect {|name| badge_maker name}
end
def assign_rooms(names)
names.each_with_index.collect {|name, index| "Hello, #{name}! You'll be assigned to room #{index +1}!"}
end
def printe... | true |
96e4d59fd2805a2f622185cf93b45ab7c703fa94 | Ruby | nicholasmbogo/recipe | /lib/pantry.rb | UTF-8 | 1,443 | 3.546875 | 4 | [] | no_license | class Pantry
attr_reader :stock, :cook_book
def initialize
@stock = {}
@cook_book = []
end
def stock_check(ingredient)
if @stock[ingredient]
@stock[ingredient]
else
0
end
end
def restock(ingredient, amount)
#@stock[ingredient] = amount
if @stock[ingredient]
... | true |
cc7aa9f9dce0526567e2dc0b770b826ba821b5d4 | Ruby | keento0809/Renew_Japan_Been | /app/models/user.rb | UTF-8 | 4,254 | 2.625 | 3 | [] | no_license | class User < ApplicationRecord
# validatesはModelに記述する
# バリデーションとはDBに値を保存する際に何か値が抜けていると保存できなくするもの。簡単に言えばフィルターみたいなもの。
validates :name, presence: true, length: { minimum:3, maximum:50 }, uniqueness: true
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i
# VALID_EMAIL_REGEX = /\A[\w... | true |
1b2cd0ffff0f3d4087e43c51f1eaad4a670f074d | Ruby | mralexsatur/learn-to-program | /7-3.rb | UTF-8 | 172 | 3.765625 | 4 | [] | no_license | input = ' '
while input != 'bye'
puts input
input = gets.chomp
end
puts "come again soon!"
while true
input = gets.chomp
puts input
if input == 'bye'
break
end
end | true |
987f74e989089d92e164fa7addd03a9a336f4154 | Ruby | rongfengliang/ruby-learning | /second/users_module.rb | UTF-8 | 222 | 2.890625 | 3 | [] | no_license | module UserApp
class User
@@name ='classname'
def initialize(name)
@name = name
end
def printname
puts @name
end
def User.printname2
puts "#{@@name} call from"
end
end
end | true |
27e7d3deba2bb0317a76df52f1841bca3353644b | Ruby | kaganon/hotel | /spec/reservation_spec.rb | UTF-8 | 913 | 3.09375 | 3 | [] | no_license | require_relative 'spec_helper'
require 'pry'
describe "Reservation Class" do
let (:date_range) { Hotel::DateRange.new('2018-09-01', '2018-09-05') }
let (:reservation) { Hotel::Reservation.new(date_range, 1)}
describe "Initializer" do
it 'Is an instance of Reservation' do
expect(reservation).must_be_ki... | true |
6a23907f2987abc30aebdccf10e59fa16dc7e715 | Ruby | timothyshort/IntersectionsRubyTraining | /Day1/numbers.rb | UTF-8 | 1,224 | 4.625 | 5 | [] | no_license | def find_max(arr)
#Assume the max is the first element
maxN = arr[0]
#Iterate through the array to see if each element is larger than max
arr.each do | num |
if num > maxN
maxN = num
end
end
return maxN
end
def find_min(arr)
minN = arr[0]
arr.each do | num |
if num < minN
minN = num
end
end
re... | true |
7443092782ca7fb34082d79449087a8041cdb8c6 | Ruby | tebriggs4/bloccit | /app/controllers/posts_controller.rb | UTF-8 | 3,593 | 2.671875 | 3 | [] | no_license | class PostsController < ApplicationController
# There's no longer an index route for posts. This is because the posts index view is no longer needed.
# All posts will be displayed with respect to a topic now, on the topics show view. Remove the index action from the PostsController
# We use a before_action... | true |
cd0e7ad30fd0e8626811aedd6bec27345f8b4dce | Ruby | code-builders/far_mar | /daniel/lib/far_mar/base.rb | UTF-8 | 268 | 2.640625 | 3 | [] | no_license | class FarMar::Base
def initialize (attrs)
end
def read_file
"class needs to be defined in order to read file"
end
def self.all
@all ||= self.read_file.map {|x| self.new(x)}
end
def self.find (id)
self.all.find {|x| x.id == id}
end
end
| true |
41f6cd22f83a9332b9c2c59690e90fb33dee0844 | Ruby | 2019jrhee/FINAL | /playagegame.rb | UTF-8 | 164 | 2.546875 | 3 | [] | no_license | require "./agegame.rb"
bask_to_play_again = true
while bask_to_play_again == true
intro
ask_name
ask_age
age_res
bask_to_play_again = ask_to_play_again
end | true |
0dc33e51067f30b02ff4fe501f42d4258ec18303 | Ruby | nog/atcoder | /contests/abc183/a/main.rb | UTF-8 | 55 | 3.25 | 3 | [] | no_license | x = gets.to_i
if x >= 0
puts x
else
puts 0
end | true |
3db55b552d254295e6a52d01fc67a2f2cacfbc7e | Ruby | peterkrenn/apricot | /lib/apricot/ruby_ext.rb | UTF-8 | 1,826 | 3.3125 | 3 | [
"ISC"
] | permissive | class Object
def apricot_inspect
inspect
end
def apricot_call(*args)
call(*args)
end
end
class Array
# Adapted from Array#inspect. This version prints no commas and calls
# #apricot_inspect on its elements. e.g. [1 2 3]
def apricot_inspect
return '[]' if size == 0
str = '['
return ... | true |
67408fd1bf1b51efe83470738602307e28fa11ad | Ruby | plato721/head-first-design-ruby | /adapter/lib/turducken.rb | UTF-8 | 362 | 3.09375 | 3 | [] | no_license | class Turducken
def initialize(turkey_or_duck)
@turkey_duck = turkey_or_duck
end
def fly
turkey_duck.fly
end
def quack
turkey_duck.respond_to?(:quack) ? turkey_duck.quack : turkey_duck.gobble
end
def gobble
turkey_duck.respond_to?(:gobble) ? turkey_duck.gobble : turkey_duck.quack
end
... | true |
82c2763836d7562ee391ce0abce73bacee1d5f03 | Ruby | piisalie/the_persister | /lib/the_persister/base.rb | UTF-8 | 644 | 2.625 | 3 | [
"MIT"
] | permissive | module ThePersister
class Base
def self.table_name(name = nil)
@table_name ||= name
end
def self.attributes(*attributes)
@attributes ||= begin
attributes << :id
attributes.each do |attr|
attr_accessor attr
end
attributes
end
end
def in... | true |
005c985d71a60a739c64c3f0873788f01e318f2d | Ruby | kano4/troch | /spec/workers/get_page_rank_spec.rb | UTF-8 | 582 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | # -*- coding: utf-8 -*-
require 'spec_helper.rb'
describe GetPageRank do
describe "module GooglePageRank" do
it "m1 should return mix/power mod" do
GooglePageRank.m1(1, 2, 3, 4).should == 4294967288
end
it "c2i should convert char code to int" do
GooglePageRank.c2i("hello").should == 181904... | true |
c3a06f74a4bc9b963f17252d31f9e0f108a33459 | Ruby | benj2240/euler | /Ruby/euler034.rb | UTF-8 | 434 | 3.6875 | 4 | [] | no_license | module Enumerable
def product
inject :*
end
def sum
inject :+
end
end
class Integer
@@facts = [1]
def factorial
@@facts[self] ||= (1..self).product
end
def digits
to_s.chars.map &:to_i
end
def factorial_digit_sum
digits.map(&:factorial).sum
end
end
def euler034
# 7*9! <... | true |
6829fd1179a3a3c59995dae10b4f734d193fcfb4 | Ruby | bneb/advent_of_code_2017 | /d16.rb | UTF-8 | 770 | 3.59375 | 4 | [] | no_license | N = 16.freeze
def swap!(a, x, y)
t = a[x]
a[x] = a[y]
a[y] = t
a
end
def _d161_(chars = (0...N).map { |i| (97+i).chr }, instructions = gets.split(","))
instructions.each do |i|
t = i[0]
x, y = i[1..-1].scan(/\w+/)
case t
when "s"
chars = chars.pop(x.to_i) + chars
when "x"
sw... | true |
5c2552d06e816a6eebb869979c252adeabedf7ab | Ruby | wallywest/magnum | /perf/models.rb | UTF-8 | 4,186 | 2.59375 | 3 | [
"MIT"
] | permissive | def netflix_profile
@profile = Magnum::SP.new(
:time_zone => "UTC",
:status => "new",
:tree => {},
:labels => [],
:segments => [],
:allocations => []
)
@vlabels = FactoryGirl.build_list(:label, 200)
@segments = []
@allocations = []
@allocations2 = []
@s = 0
@e = 59
@allocatio... | true |
1496399f90346c63dd503c4ddadf746315c9e817 | Ruby | GonzSanch/Discovery-Piscine-Ruby | /Ruby01/ex01/name.rb | UTF-8 | 114 | 2.625 | 3 | [] | no_license | #!/usr/bin/ruby
first_name = 'Gonzalo'
last_name = 'Sánchez Silva'
whole_name = first_name+' '+last_name
puts whole_name
| true |
5faee5289d10271954d7499e57c3c66822b81f83 | Ruby | npinilla/schedule | /app/models/route.rb | UTF-8 | 731 | 2.65625 | 3 | [] | no_license | class Route < ActiveRecord::Base
def can_assign?(driver)
if driver.max_stops != nil && driver.max_stops < self.stops_amount
return false
end
if driver.drive_in?(self.cities) && driver.has_time?(self)
return true
end
return false
end
def assign_driver_and_vehicle(driver_id, vehicle... | true |
f21b0e0a3015297b9696aa6c18946a98be71c200 | Ruby | arturictus/fusu | /spec/try_spec.rb | UTF-8 | 1,858 | 2.96875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Fusu::Try do
let(:string) { 'Hello' }
it 'test_nonexisting_method' do
method = :undefined_method
expect !string.respond_to?(method)
expect(Fusu.try(string, method)).to be_nil
end
it 'test_nonexisting_method_with_arguments' do
method = :undefined_method
expec... | true |
1877b26e189c1248d3a38b844be0a247ed7cd135 | Ruby | bcgoss/battleship | /test/messages_test.rb | UTF-8 | 1,618 | 2.859375 | 3 | [] | no_license | require './test/test_helper'
require './lib/messages'
class MessagesTest < Minitest::Test
def test_greeting
assert_equal "Welcome to BATTLESHIP\n\n", Messages.greeting
end
def test_menu_message
assert_equal "Would you like to (p)lay, read the (i)nstructions, or (q)uit?", Messages.menu_message
end
de... | true |
59f6292e4b9885ac920cd0c0a0bc052787974e4e | Ruby | quocanh/decorated_graph | /lib/feature_graph.rb | UTF-8 | 4,764 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'prawn'
require_relative './decorated_graph'
pdf = Prawn::Document.new
points = [[4,2],[100,38], [150, 75], [270, 150]]
point_spec = {shape:'circle', size:6, color:'cc0000', y_value: [75, 950, 9300, 90000], y_width: 24, y_height: 7, text_size: 7,
text_color: '000000' , x_value: [4, 100, 150, 270], x_width: ... | true |
2239102c6405db76cdcdec7ded256c3f8fb1c2a6 | Ruby | murarisumit/logstash_compressor_plugin | /plugin/logstash/filters/compressor.rb | UTF-8 | 2,141 | 2.65625 | 3 | [] | no_license |
require 'java'
require "logstash/filters/base"
require "logstash/namespace"
require File.expand_path(File.dirname(__FILE__))<<"/lib/logstash plugin.jar"
require File.expand_path(File.dirname(__FILE__))<<"/lib/gzipPlugin.jar"
require File.expand_path(File.dirname(__FILE__))<<"/lib/SnappyAlgoritm.jar"
module Sample
i... | true |
5ccc02988b1d1d0e4f000f209d81ca7fee72fdad | Ruby | trueknightwhosayni/ni | /lib/ni/help.rb | UTF-8 | 2,242 | 2.578125 | 3 | [
"MIT"
] | permissive | #require 'colorize'
module Ni
module Help
extend ActiveSupport::Concern
module ClassMethods
def help(action=:perform, indent=0)
disp = -> (str) { puts '' * indent + str }
disp "#{'Interactor'.bold} #{('='*15).bold}> #{self.class.name.colorize(:blue)} <#{('='*15).bold} "
disp "... | true |
99023b88b141c2f19f61f9478463dda65d9f53b8 | Ruby | sugyan/genba-info | /test/models/idol_test.rb | UTF-8 | 724 | 2.6875 | 3 | [] | no_license | # coding: utf-8
require 'test_helper'
class IdolTest < ActiveSupport::TestCase
test "should not save without name, kana" do
assert_not Idol.new().save
assert_not Idol.new(name: "hoge").save
assert_not Idol.new(kana: "fuga").save
end
test "should not save duplicated name" do
assert Idol.new(name... | true |
935b7f8e441d8f27de172fba4b1467f89b3bba13 | Ruby | vivdash/bot_saves_princess | /lib/battle_field.rb | UTF-8 | 1,120 | 3.25 | 3 | [] | no_license | class BattleField
attr_accessor :size, :grid
def validate_size
unless size.is_a? Numeric
puts "Please enter integer only. Try again!"
abort
end
if size.even? || !size.between?(2, 100)
puts "Enter Odd Number Only between 3 and 100. Try again!"
abort
end
end
def validate
... | true |
56ba8cbc79c0af194223786cca7029e9c38d9aa3 | Ruby | IceDragon200/rm-macl | /lib/rm-macl/xpan/surface/surface3.rb | UTF-8 | 1,906 | 2.53125 | 3 | [
"MIT"
] | permissive | #
# rm-macl/lib/rm-macl/xpan/surface/surface3.rb
# by IceDragon
require 'rm-macl/macl-core'
require 'rm-macl/core_ext/module'
require 'rm-macl/xpan/surface/surface2'
require 'rm-macl/xpan/surface/msurface3'
module MACL
module Surface
class Surface3 < Surface2
include MACL::Mixin::Surface3
attr_re... | true |
d2fcc3dd9846c4329de84fe293a75f203355f3d9 | Ruby | jfryman/ruby-katas | /codekata/karate_chop/pass_1/game.rb | UTF-8 | 1,140 | 4 | 4 | [] | no_license | class Game
def chop(search, array)
return self.bSearch(search, array, 0, array.length - 1)
end
def bSearch(search, array, low, high)
return -1 if high < low
mid = (low + high) / 2
if array[mid] > search
self.bSearch(search, array, low, mid - 1)
elsif array[mid] < search
self.bSea... | true |
ec5f4da030a95b01ec6d4fa52845e9a00f1a2d8b | Ruby | siralomarahmed/100DaysOfCode | /SourceCode/Ruby/day041.rb | UTF-8 | 274 | 4 | 4 | [] | no_license | # Basic Artiemitic Methods
p 1.next()
puts
# Arthemetic Methods:
p 1.+(9)
p 2.-(8)
p 3.*(7)
p 4.**(6)
p 5./(5)
p 5.%(5)
puts
# Methods with the same functionality
# Division example
p 10 / 5
p 10./(5)
p 10.div(5)
puts
# Modulo example
p 10 % 3
p 10.%(3)
p 10.modulo(3)
| true |
c5da30bdf906556377ae4cfa1af61d5ddec49dfc | Ruby | rossta/montrose | /lib/montrose/rule/between.rb | UTF-8 | 515 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Montrose
module Rule
class Between
include Montrose::Rule
def self.apply_options(opts)
opts[:between].is_a?(Range) && opts[:between]
end
# Initializes rule
#
# @param [Range] between - timestamp range
#
def initialize(... | true |
705123fead69fbba8d5a5c62f515cbe8a2569dbd | Ruby | adrianwu8516/polo_bot | /lib/ticker_info.rb | UTF-8 | 692 | 2.984375 | 3 | [] | no_license | class TickerInfo
attr_reader :last, :lowestAsk, :highestBid, :percentChange, :baseVolume, :quoteVolume, :isFrozen, :high24hr, :low24hr, :percentChangeString
def initialize(ticker_json)
@last = ticker_json["last"].to_f
@lowestAsk = ticker_json["lowestAsk"].to_f
@highestBid = ticker_json["highestBid"].to_f
@p... | true |
70f2d2b3e4e62cac37cedd7403459fac695e06ac | Ruby | Zalachenka/THP-S1J3 | /00_hello.rb | UTF-8 | 196 | 3.671875 | 4 | [] | no_license | def say_hello
puts "Quel est ton prénom ?"
first_name = gets.chomp
return first_name
end
def salut(first_name)
puts "Bonjour, #{first_name}"
end
def perform
salut(say_hello)
end
perform | true |
e01e3ff34e9a28779fbcb010d38c8c0f77d063d6 | Ruby | zht14/D2 | /ruby_rush.rb | UTF-8 | 527 | 3.203125 | 3 | [] | no_license | require_relative 'main'
raise "There should have exactly three inputs!\n" unless ARGV.count == 3
seed = ARGV[0]
prospectors = ARGV[1]
turns = ARGV[2]
rs = RubyRush.new(seed, prospectors, turns)
rs.random(Integer(seed))
while rs.prospector <= rs.prospectors
rs.days = 0
rs.real_rb = 0
rs.fake_rb = 0
rs.city = 'E... | true |
2cad2601056f1ea6a5c87f084d45f7434b615642 | Ruby | JacobNinja/codeminer | /lib/codeminer/expressions/binary_expression.rb | UTF-8 | 395 | 3.0625 | 3 | [] | no_license | module CodeMiner
class BinaryExpression < Expression
attr_reader :left, :right
def initialize(token, left, right, src)
@token = token
@left = left
@right = right
@src = src
end
def each
[left, right]
end
def type
:binary
end
def value
@to... | true |
78ede6658af332d21fd6b6a8430d4d7cfb970532 | Ruby | huyuxin0429/sample_app | /app/models/address.rb | UTF-8 | 3,262 | 2.53125 | 3 | [] | no_license | class Address < ApplicationRecord
belongs_to :addressable, polymorphic: true
validates :addressable_id, presence: true
validates :addressable_type, presence: true
with_options if: :need_be_specific do |specific|
specific.validates :street_address, presence: true
specific.validates :city,... | true |
2b3778c67c1c94f330cb43bace8e5305a05fcabc | Ruby | itggot-hannes-skoog/standard-biblioteket | /lib/contains_char.rb | UTF-8 | 361 | 4.375 | 4 | [] | no_license | # Public: Checks if string contains char.
#
# str - Input string.
# char - Input character.
#
# Examples
#
# contains_char("hallå eller", "h")
# # => "h"
#
# Returns if string contains char.
def contains_char(str, char)
i = 0
while i < str.size
if char == str[i]
return true
end... | true |
8819c2669a5103f90763608578aa385ab9b1a4b5 | Ruby | heatseeknyc/heatseeknyc | /lib/tasks/articles.rake | UTF-8 | 7,279 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | namespace :articles do
desc "TODO"
task seed: :environment do
[
"http://observer.com/2014/08/heat-seek-nyc-the-app-set-to-protect-struggling-tenants-this-winter/",
"http://www.wired.com/2014/08/heat-seek-nyc/",
"http://www.engadget.com/2014/08/27/heat-seek-temperature-monitor-nyc-kickstarter/... | true |
4d8f6931ab83920560054ece778d83786e0d56ea | Ruby | wkang/toggl_api | /lib/toggl_api/request.rb | UTF-8 | 2,386 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'toggl_api/error'
module Toggl
module Request
ENDPOINT = "https://www.toggl.com"
attr_writer :user_agent, :connection_options
def user_agent
@user_agent ||= "Toggl Api Ruby Gem #{Toggl::VERSION}"
end
def connection_options
@connection_options ||= {
:headers => {
... | true |
7039ac894f96b847480427b61706da961fbfbe38 | Ruby | savelbl4/ruby_lessons | /lesson07/app2.rb | UTF-8 | 224 | 3.171875 | 3 | [] | no_license | # encoding: utf-8
print "Вы довольны своей зарплатой? (Y/N): "
answer = gets.chomp.upcase.strip.to_i
if answer == 1
print "заебись!\n"
end
if answer == 0
print "хуёво\n"
end
| true |
2324501221b58be14bd90bdd23018afae03e0780 | Ruby | scottmacphersonmusic/music_thurry | /careless_whisper.rb | UTF-8 | 974 | 2.78125 | 3 | [] | no_license | require 'music_theory'
require 'wavefile'
module CarelessWhisper
class PitchMap
MELODY = [[:E, 6], [:D, 6], [:A, 5], [:F, 5],
[:E, 6], [:D, 6], [:A, 5], [:F, 5],
[:C, 6], [:Bf, 5], [:F, 5], [:D, 5],
[:C, 6], [:Bf, 5], [:F, 5],
[:Bf, 5], [:A, 5], [:F,... | true |
f00cb5eaad70e29565c0d566a82cca5fa34a4bc8 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/0f5c9d64d4af4f2b9007f2461999485f.rb | UTF-8 | 435 | 3.6875 | 4 | [] | no_license | class DNA
def initialize(strand1)
@strand1 = strand1
end
def hamming_distance(strand2)
mutations(strand2).count
end
private
def mutations(strand2)
comparison_indices(strand2).find_all do |i|
@strand1[i] != strand2[i]
end
end
def comparison_indices(strand2)
(0..(min_strand_len... | true |
1627ef8da48f6b6d1e65d0419c6c4c3ea6f68982 | Ruby | xpsurgery/corner-shop | /ruby/lib/basket_actions/display_basket_command.rb | UTF-8 | 898 | 3.15625 | 3 | [] | no_license | module BasketActions
class DisplayBasketCommand
def initialize(basket)
@basket = basket
end
def run(cmd)
items = @basket.list
if items.empty?
puts "Your basket is empty"
return
end
items.each do |item|
leader = sprintf("£%8.02f %5dx ", item.price / 100.0, item.count)
poss_le... | true |
1c3739b79c677afa075abbcc3e270eb5e960d267 | Ruby | aiwilliams/ofxrb | /lib/type_casting.rb | UTF-8 | 2,346 | 3.09375 | 3 | [] | no_license | require 'parsedate'
module OFXRB
# This code is borrowed from Ruby on Rails' active_record/connection_adapters/abstract/schema_definitions.rb.
# It has been modified and reduced for use in this library.
module TypeCasting
# Determines whether to use Time.local (using :local) or Time.utc (using :utc) when p... | true |
a5c96df6057239f89999138b61957fbdd80e882b | Ruby | Jonesyd/programming_ruby | /05_loops/04_ex.rb | UTF-8 | 225 | 3.8125 | 4 | [] | no_license | require "pry"
def count_down(num)
puts num
num -= 1
if num < 0
puts "Blast Off!"
return
end
count_down(num)
end
puts "Give me a number?"
number = gets.chomp.to_i
puts "Okay here we go!"
count_down(number)
| true |
94addd49a666905a574dfa63ce00c5bb4d418f8a | Ruby | bennorris/bringing-it-all-together-v-000 | /lib/dog.rb | UTF-8 | 1,860 | 3.5 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Dog
attr_accessor :name, :breed, :id
def initialize(hash)
@name = hash[:name]
@breed = hash[:breed]
@id = nil
end
def self.create_table
sql = <<-SQL
CREATE TABLE IF NOT EXISTS dogs (
id INTEGER PRIMARY KEY,
name TEXT,
breed TEXT);
SQL
DB[:conn].execute(sq... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.