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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ba2653a03a6e66c6c3b8753b9de85c8807191b76 | Ruby | AteroConfigs/tracknowledge | /vendor/plugins/country_codes/lib/country_codes.rb | UTF-8 | 3,421 | 2.9375 | 3 | [
"MIT"
] | permissive | module CountryCodes # :nodoc:
def self.method_missing(name, *args)
if match = /find_([^_]*)_by_([^_]*)/.match(name.to_s)
raise "1 argument expected, #{args.size} provided." unless args.size == 1
required = match[1]
request = match[2]
if valid_attributes.include?(request) && valid_a... | true |
b1f8ece1d406e018a5c0d05b3169365ce8fece8b | Ruby | arlington6988/shame | /lib/wizard.rb | UTF-8 | 579 | 2.546875 | 3 | [] | no_license | module Wizard
module Review
STEPS = %w(step1 step2 step3).freeze
class Base
include ActiveModel::Model
attr_accessor :review
delegate *::Review.attribute_names.map { |attr| [attr, "#{attr}="] }.flatten, to: :review
def initialize(review_attributes)
@rev... | true |
8b77a28079a136e1a9753e2d11d15dfac78b782b | Ruby | ms919/rubybook | /chapter11/11-1/original_exception.rb | UTF-8 | 735 | 3.921875 | 4 | [] | no_license | class MinusAgeError < StandardError
def initialize(msg="おいおい、年齢がマイナスだよ")
super(msg)
end
end
class UnderageError < StandardError
# attr_reader :status
def initialize(msg="こらこら、未成年でしょ", status="補導")
super(msg)
@status = status
end
attr_reader :status
end
def buy_alcohol(age)
puts "処理スタート"
puts age
if ... | true |
1d8a02b6fb8774fb9fd401ccf918c827deb0ad3f | Ruby | rubberyuzu/tree_implementation | /BFS/BFS.rb | UTF-8 | 596 | 3.84375 | 4 | [] | no_license | class BFS
def initialize(list)
@list = list
end
def search(first, target)
queue = [first]
visited = { first => true }
p first
while !queue.empty?
node = queue.shift
@list[node].each do |child|
unless visited[child]
p child
if child == target
p "search done"
exit
end
... | true |
361b020e5a4be76e958cfe5838233c67626c1c62 | Ruby | k-nowicki/Imgur_random_downloader | /bin/imgur_random_downloader.rb | UTF-8 | 2,728 | 3.21875 | 3 | [
"MIT"
] | permissive | ######################################################
# Imgur_random_downloader
#
# © KNowicki 2012
######################################################
# encoding: utf-8
require 'rubygems'
require 'open-uri'
require 'fileutils'
# Statistics for better randomization setup
class Stat
def initialize
... | true |
a529049ec18c2d95d39b51a4a0367b62f2388a28 | Ruby | norbertnytko/scraper | /app.rb | UTF-8 | 2,344 | 3.25 | 3 | [] | no_license | require 'httparty'
require 'pry'
require 'nokogiri'
require 'ostruct'
require 'csv'
class Speaker < OpenStruct; end
class ExpoClient
include HTTParty
BASE_URL = 'https://eu.augmentedworldexpo.com'
def speakers_page
self.class.get("#{BASE_URL}/speakers/").body
end
def speaker_page(slug)
self.class.... | true |
9fffd51ee2faf0b3ae4e5826e5e7158bb45a778e | Ruby | mirubenstein/run-length-encoding | /run_length_encoding.rb | UTF-8 | 493 | 2.8125 | 3 | [] | no_license | class RunLengthEncoding
def self.encode(input)
input.scan(/((.)\2*)/).each_with_object('') do |(group, letter), output|
output.concat("#{group.length unless group.length == 1}#{letter}")
end
end
def self.decode(input)
input.scan(/(\d*(.))/).each_with_object('') do |(group, letter), output|
... | true |
0714b78e6b0d4654d7a22aed4816cd25f3e0c268 | Ruby | mattbrand/campconquer | /app/models/gear.rb | UTF-8 | 4,790 | 2.75 | 3 | [] | no_license | # == Schema Information
#
# Table name: gears
#
# id :integer not null, primary key
# name :string
# display_name :string
# description :string
# health_bonus :integer default("0"), not null
# speed_bonus :integer default("0"... | true |
e5267e8dd1fe70127629175802be6b42a21f969f | Ruby | mzt2/2_4 | /question_4.rb | UTF-8 | 110 | 3.421875 | 3 | [] | no_license | =begin
uptoを使って数字の0から9までを出力するプログラム
=end
0.upto(9) do |i|
p i
end
| true |
a25a9edae9049aca5ab522520232de42669d2928 | Ruby | XiwayB/livecode-SZ-Cookbook-Day-2 | /controller.rb | UTF-8 | 1,688 | 3.34375 | 3 | [] | no_license | require_relative "view"
require_relative "recipe"
require_relative "parsing"
class Controller
def initialize(cookbook)
@cookbook = cookbook
@view = View.new
end
def list
display_recipes
end
def create
# 1. Ask user for a name (view)
name = @view.ask_user_for("name")
# 2. Ask user fo... | true |
2e962e56d0de6970392d13f0a044fc6ea482340e | Ruby | ajtran303/codeacademy-ruby | /9/inheriting-a-fortune.rb | UTF-8 | 292 | 3.4375 | 3 | [] | no_license | # Review of inheritance
class Message
@@messages_sent = 0
def initialize(from, to)
@from = from
@to = to
@@messages_sent += 1
end
end
class Email < Message
def initialize(subject)
@subject = subject
end
end
my_message = Message.new("The Future", "The Past")
| true |
37ae77b30676d58f4f836313788c4122a99ef84e | Ruby | WordsPerMinute/cli-applications-jukebox-denver-web-010620 | /lib/jukebox.rb | UTF-8 | 2,197 | 4.125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
# # Add your code here
# def say_hello (name)
# "Hi #{name}!"
# end
# puts "Enter your name:"
# users_name = gets.strip
# puts say_hello(users_name)
def help
puts "I accept the following commands:"
puts "- help : displays this help message"
puts "- list : displays a list of songs you can play"
puts "- pl... | true |
7191aebc4e833797b739f2d9ba58eecf4c630d15 | Ruby | jwshinx/SubscriptionCircus | /lib/customer_rating.rb | UTF-8 | 239 | 2.71875 | 3 | [] | no_license | class CustomerRating < Rating
def self.from_amount_due( invoice )
if invoice.amount_due == 0
new("A")
elsif invoice.amount_due >= 1000
new("F")
elsif invoice.amount_due >= 100
new("D")
else
new("C")
end
end
end
| true |
439bc75b5958c7d5ae2d02e19093b2ab577f1f0a | Ruby | yani82/prime-ruby-onl01-seng-pt-072720 | /prime.rb | UTF-8 | 186 | 2.9375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Add code here!
def prime?(number)
start = 2
if number > 1
range = (start..number-1).to_a
range.none? do |num_to_test|
number % num_to_test == 0
end
else false
end
end
| true |
dacdd0bd0e16da6ef444d223f05d6fe24cb4b442 | Ruby | kafunk/learn_ruby | /10_temperature_object/temperature.rb | UTF-8 | 750 | 3.78125 | 4 | [] | no_license | class Temperature
def initialize(options = {})
@options = options
end
def f
@f
end
def c
@c
end
def in_fahrenheit
if @options.key?(:f)
@options[:f]
else
(@options[:c]) * 9.0 / 5 + 32
end
end
def in_celsius
if @options.key?(:c)
@options[:c]
else
... | true |
808797769054408e6e53602ba343c5a803733a5c | Ruby | cheokman/geminabox | /specs/gem_file_factory.rb | UTF-8 | 772 | 2.65625 | 3 | [] | no_license | require 'pathname'
require 'tempfile'
class GemFileFactory
DEFAULT_GEMS = [{:name => "rails", :version => "3.2.4"},{:name => "bundler"}]
def initialize()
@path = Dir.tmpdir
@dest_file_name = File.join(@path, "Gemfile")
end
def gem_file(options=[])
gem_files = options.map do |e|
gem_config = ... | true |
b6865ec6bb9c47a71b9c3f8258fd861c1e35fdc5 | Ruby | ag-sc/QALD | /5/scripts/xml2json.rb | UTF-8 | 2,060 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'nokogiri'
require 'json'
require 'mustache'
require 'uri'
#################################################################
inputXML = ARGV[0]
#################################################################
outputJSON = { "dataset" => {}, "questions" => [] }
doc = Nokogiri::XML(File.read(inputXML))
do... | true |
fec666e1def998a71a4d215f51913a9713270fd5 | Ruby | ArturT/team-scheduler | /app/helpers/application_helper.rb | UTF-8 | 1,264 | 2.734375 | 3 | [] | no_license | module ApplicationHelper
# @param title:string
# @param path:string
# @param options:{}
# @return string link to path
def menu_item(title, path, options = {})
options.reverse_merge!(:class => '')
#puts request.path
if (request.path.match(/#{path}/) && path != "/") || (request.path == "/" && path =... | true |
82f98f0ef298540bf896b74c0f4420130f9c221f | Ruby | famished-tiger/Macros4Cuke | /spec/macros4cuke/templating/placeholder_spec.rb | UTF-8 | 2,001 | 2.65625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
# File: placeholder_spec.rb
require_relative '../../spec_helper'
# Load the classes under test
require_relative '../../../lib/macros4cuke/templating/placeholder'
module Macros4Cuke
module Templating # Open this namespace to get rid of module qualifier prefixes
describe Placeholder do
... | true |
6604bdedc90e029daf947eec38a2daee6202ad06 | Ruby | imGurpreetSK/Ruby-playground | /authenticator.rb | UTF-8 | 784 | 3.421875 | 3 | [] | no_license | fake_db = {
"one" => '12345678',
"two" => 'Gurpreet'
}
puts 'Welcome to Authenticator!'
25.times { '-' }
puts "\n"
puts 'The program will take input from user and compare passwords'
attempts = 0
while attempts < 3
print 'Username: '
username = gets.chomp
print 'Password: '
password = gets.chomp
a... | true |
c4df1e5dbe3ca2d0ad75e54de2d232d64fab5788 | Ruby | zacck-zz/learning_ruby | /hashes.rb | UTF-8 | 752 | 4.1875 | 4 | [] | no_license | #Hashes
#these are data structure that stores values in a key value state
my_details = {'name' => 'Zacck', 'age' => 26 , 'favcolor' => 'valeyellow'}
#getting data
#whole hash
puts my_details
#parts
puts my_details["name"]
#hashes with symbols
myhash = {a:1, b:2, c:3}
#using symbols to access data
puts myhash[:c]
#... | true |
89326a965e9fa87bd70f91cbad1ead67e2cd9caa | Ruby | laushinka/emoticon-translator-web-0616 | /lib/translator.rb | UTF-8 | 1,009 | 3.34375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'yaml'
def load_library(filepath)
lib = {
"get_meaning" => {},
"get_emoticon" => {}
}
emoticon_file = YAML.load_file(filepath)
emoticon_file.map do |key, value|
lib["get_meaning"][value[1]] = key.to_s
lib["get_emoticon"][value[0]] = value[1]
end
return lib
end
def get_japa... | true |
7148f72f7d5c0f0447a9fd59d626eda22fe5044d | Ruby | cercomp/cranelift | /test/unit/project_test.rb | UTF-8 | 971 | 2.65625 | 3 | [] | no_license | require 'test_helper'
class ProjectTest < ActiveSupport::TestCase
fixtures :projects
test "project with name validation" do
assert projects(:one).valid?
end
test "rename directory on file system" do
project = projects(:one)
project.update_attribute :name, "12345teste"
new_slug = "12345new-pro... | true |
c05ef15d735e25f09923717a4c9cac16d8c3178f | Ruby | dammitBrandon/barhop | /db/seeds.rb | UTF-8 | 991 | 2.625 | 3 | [] | no_license | #user = User.new(firstname: "brandon", lastname: "bailey", email: "bbailey@bbailey.com", password: "1234", password_confirmation: "1234")
#user.save
#post = Post.new(title: "new post", body: "Boy this is wack")
#dates = []
#15.times {dates.push(rand(-35..0).days.ago.strf("%m-%d-%Y"))}
#b = User.create(
# ... | true |
c86c032e9bd167dde52e2c174939bf481b6030dd | Ruby | fab-ian/planning-poker | /app/models/game.rb | UTF-8 | 831 | 2.515625 | 3 | [] | no_license | class Game < ActiveRecord::Base
has_many :game_users, dependent: :destroy
has_many :users, through: :game_users
belongs_to :user
validates :name, :content, presence: true
accepts_nested_attributes_for :game_users, allow_destroy: true
scope :my_games, -> (p){where("user_id = ?", p).order("created_at des... | true |
a665332cb17ff9cbb80254af1d9429913fd2530d | Ruby | whb/ruby-warrior-solution | /beginner-tower/level-006/player.rb | UTF-8 | 731 | 3.578125 | 4 | [] | no_license | class Player
def initialize
@rush = false
@health = 0
end
def play_turn(warrior)
@direction = :forward unless @direction
if warrior.health < @health && warrior.feel(@direction).empty? && !@rush
@direction = :backward
end
if warrior.feel(:backward).wall?
@direction = :forward
... | true |
8e8c3f3242d0cfafb8feda438179b988e32b3fdf | Ruby | cep104/cli_build_show_group3 | /lib/show_cli_group3/cli.rb | UTF-8 | 1,394 | 3.578125 | 4 | [] | no_license | class CLI
def start
puts "Welcome to TV Maze! Enter your name please."
input = user_input
greeting(input)
end
def user_input
gets.strip
end
def greeting(name)
puts "Nice to meet you #{name}. Enter a TV show or keyword to see a list of shows. If you would ... | true |
4532a21860c6691030a6211d0f52d5981ecc5007 | Ruby | microsoftgraph/msgraph-sdk-ruby | /lib/models/event_message_response.rb | UTF-8 | 3,418 | 2.8125 | 3 | [
"MIT"
] | permissive | require 'microsoft_kiota_abstractions'
require_relative '../microsoft_graph'
require_relative './models'
module MicrosoftGraph
module Models
class EventMessageResponse < MicrosoftGraph::Models::EventMessage
include MicrosoftKiotaAbstractions::Parsable
##
# The proposedN... | true |
e86280315d3c9165f5c37a5d6269f5dfc4f7ec20 | Ruby | dmantilla/pingpong | /app/models/score.rb | UTF-8 | 1,406 | 2.921875 | 3 | [] | no_license | class Score < ActiveRecord::Base
belongs_to :created_by, class_name: 'User'
belongs_to :opponent, class_name: 'User'
validates :date_played, presence: true
validates :opponent_id, :created_by_id, presence: true
validates :score, :opponent_score, numericality: { greater_than: 0, less_than_or_equal_to: 21 }
... | true |
20b9e191e39f1170254e253b4423d8323bdafce0 | Ruby | Runefire32/crypto-display | /app/services/start_scrap.rb | UTF-8 | 608 | 2.609375 | 3 | [] | no_license | require 'rubygems'
require 'nokogiri'
require 'open-uri'
class StartScrap
def initialize
@all_cours = []
@all_name = []
end
def perform
page = Nokogiri::HTML(open("https://coinmarketcap.com/all/views/all/"))
courscryp = page.css("a.price").each do |cours|
cours = cours.text
@all_cours << cours
... | true |
1e1657b68b140e983686bdd833d1c4fe92a73057 | Ruby | AllPurposeName/ideabox | /test/models/idea_test.rb | UTF-8 | 1,455 | 3 | 3 | [] | no_license | require 'test_helper'
class IdeaTest < ActiveSupport::TestCase
test "Idea's status is made into a funny quality" do
swill = Idea.find_by(status: 0)
hooch = Idea.find_by(status: 1)
cordial = Idea.find_by(status: 2)
assert_equal "Scallywag's Swill!", swill.quality
assert_equal "Powder Monkey's Hoo... | true |
57afc0c0a9169e47c681980b972905a04d79847e | Ruby | ricardoalmeida/functional-principles-presentation | /slide03-functional-refactorings.rb | UTF-8 | 348 | 3.203125 | 3 | [] | no_license |
# Functional Refactorings
#NO
length = 0
["milu", "rantanplan"].each do |dog_name|
length += dog_name.length
end
puts length # => 14
#YES
length = ["milu", "rantanplan"].map(&:length).inject(0, :+) # 14
# init-empty + each + push = map
# init-empty + each + conditional push -> select/reject
# initialize + e... | true |
10c7728d470ef4db460effba3f51a484d8edc89e | Ruby | dfrezell/dfrezell | /code/projecteuler/p0025_fibodigit.rb | UTF-8 | 198 | 3.046875 | 3 | [] | no_license | #!/usr/bin/ruby
fn_1, fn_2 = 1, 1
fn = fn_1 + fn_2
cnt = 2
while fn.to_s.length < 1000 do
fn = fn_1 + fn_2
fn_2, fn_1 = fn_1, fn
cnt += 1
end
print "cnt = ",cnt,", len = ",fn.to_s.length,"\n"
| true |
80e8184480d241a6e5b4db22a8353b2215af3e18 | Ruby | tvfb85/fire-bug | /app.rb | UTF-8 | 1,381 | 2.65625 | 3 | [] | no_license | require 'sinatra/base'
require './lib/player'
require './lib/game'
class Firebug < Sinatra::Base
enable :sessions
get '/' do
erb(:index)
end
post '/player_names' do
player_one = Player.new(params[:player_one_name])
player_two = Player.new(params[:player_two_name])
@game = Game.create(player... | true |
e5fa93c6874d82eea3e73c5d583156e06823297c | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/anagram/2bb9528c9d884aad95df01570ecd7d59.rb | UTF-8 | 1,027 | 3.359375 | 3 | [] | no_license | class Anagram
attr_accessor :subject
def initialize(word="")
@subject = word.downcase
end
def match(possible_anagrams)
matches = possible_anagrams.select { |possible_anagram| anagram?(possible_anagram.downcase) }
end
private
def anagram?(possible_anagram)
unidentical_word?(possible... | true |
d749cf09bebf25c1eeb416b22789c8f482caeb38 | Ruby | HighwayofLife/advent-of-code | /day1/fuel.rb | UTF-8 | 2,571 | 3.890625 | 4 | [] | no_license | require "test/unit/assertions"
include Test::Unit::Assertions
def calculate_fuel(mass)
# Fuel required to launch a given module is based on its mass.
# Specifically, to find the fuel required for a module,
# take its mass, divide by three, round down, and subtract 2.
return (mass / 3).floor - 2
end
def modu... | true |
b619067c13553732c00a8cb8eec412e4f1eb6cac | Ruby | JiriKrizek/MI-RUB-HW1 | /src/Vertex.rb | UTF-8 | 273 | 2.625 | 3 | [] | no_license | class Vertex
attr_reader :status, :connections
:st_open
:st_close
:st_fresh
def initialize
@connections = Hash.new
@status = :st_fresh
end
def addConnection(i)
puts " Add connection #{i}" if Parser.DEBUG
connections[i] = true
end
end | true |
343a41929e16b56164eaf6b38da71077cfd28894 | Ruby | xiaji/cs446 | /src/unit10/pets/app/models/cat.rb | UTF-8 | 1,134 | 2.671875 | 3 | [] | no_license | # validation
class Cat < ActiveRecord::Base
has_many :line_items
before_destroy :ensure_not_referenced_by_any_line_item
#The field’s name, breed, age, gender, description, and image URL are not empty.
validates :name, :breed, :age, :gender, :description, :image_url, presence: true
#The name cannot ha... | true |
3949dd67947e0bf1c9da52b1d08b054d152a9e9a | Ruby | jsus/jsus | /spec/jsus/util/watcher_spec.rb | UTF-8 | 4,224 | 2.59375 | 3 | [
"Unlicense",
"LicenseRef-scancode-public-domain"
] | permissive | require 'spec_helper'
require 'fileutils'
# Until I figure out how to test this stuff better, here is what is going on:
# * main thread is set as a timeout thread. it launches some child threads
# and goes to sleep until woken up or timed out
#
# * FSSM thread watches for filesystem updates
# Note: the... | true |
4f7439894560f0da38bfe3d8cb0b0aed5ba53ef5 | Ruby | eaglerockdude/rubylearningdotorg | /scratchpad/readwrite.rb | UTF-8 | 369 | 3.375 | 3 | [] | no_license | # p027readwrite.rb
# Open and read from a text file
# Note that since a block is given, file will
# automatically be closed when the block terminates
File.open('txt1.txt', 'r') do |f1|
while line = f1.gets
puts line
puts line.class
end
end
# Create a new file and write to it
File.open('txt1.txt', 'w') do |... | true |
2ae2ffca379ce4f355ef6117eb2cc23fd7a03c54 | Ruby | Kinstantly/mvp2 | /lib/tasks/import_categories_subcategories_services.rake | UTF-8 | 2,493 | 2.515625 | 3 | [] | no_license | namespace :kinstantly_import do
desc 'Load the import data.'
task :load_lines do
@import_file = ENV['import_file']
@lines = File.open(@import_file, "r").read
end
desc 'Parse the categories, subcategories, and services import data.'
task parse_lines: :load_lines do
@names = {}
@lines.strip.split("\n").eac... | true |
b169aad920a3151a7b212343dd34e6cb20bf757f | Ruby | jtruman88/Ruby-Small-Problems | /Medium_02/matching_parentheses.rb | UTF-8 | 2,309 | 4.375 | 4 | [] | no_license | # Write a method that takes a string as argument, and returns true if all parentheses in the string are properly balanced, false otherwise. To be properly balanced, parentheses must occur in matching '(' and ')' pairs.
# Further Exploration - There are a few other characters that should be matching as well. Square bra... | true |
d6bbcdbf32cf6a88fa64255bc5c01411d29fdc62 | Ruby | hubert/strong_password | /lib/strong_password/strength_checker.rb | UTF-8 | 2,049 | 3.125 | 3 | [
"MIT"
] | permissive | module StrongPassword
class StrengthChecker
BASE_ENTROPY = 18
attr_reader :base_password
def initialize(password)
@base_password = password.dup
end
def is_weak?(opts={})
min_entropy = opts[:min_entropy] || BASE_ENTROPY
use_dictionary = opts[:use_dictionary] || false
... | true |
2b59d68a2c0d993efd7c878ef09df6cce5f490f1 | Ruby | ATBBENJA/tests_ruby | /lib/04_simon_says.rb | UTF-8 | 639 | 3.828125 | 4 | [] | no_license | def echo(hello)
return "#{hello}"
end
def shout(sh)
return "#{sh}".upcase!
end
def repeat(txt, nb)
nb_es=nb-1
if nb > 0
return (txt+" ")*nb_es+txt
else
return txt
end
end
def start_of_word(text, b)
x=txt[0...b]
return x
end
def first_word(phrase)
x=phrase.spli... | true |
36c3dc5a177f6f0fa14be61182b8906882e2cef6 | Ruby | timchipperfield/Battle | /spec/player_spec.rb | UTF-8 | 555 | 2.78125 | 3 | [] | no_license | require 'player'
describe Player do
subject(:dave) { described_class.new('Dave') }
subject(:harry) { described_class.new('Harry') }
describe "#name" do
it "returns the name" do
expect(dave.name).to eq "Dave"
end
end
describe "#hit_points" do
it "returns the hit points" do
expect(da... | true |
bf530e66fec9588ab92c7666dc5ff018646465ec | Ruby | Jozefw/Garage-Guys--Project-2- | /spec/models/sale_spec.rb | UTF-8 | 1,944 | 2.609375 | 3 | [] | no_license | require 'spec_helper'
describe Sale do
before :each do #instantiates a new sale before each test
@sale = Sale.create(user_id: 1, title: "Moving Sale", address: "123 Main St.", city: "Alameda", zipcode: 94501, date:"June 1, 2014", time_start: "7 am", time_end: "2 pm", description: "Moving out of state. Tons of ... | true |
7407b8b11694ecd56d4270177af56155986e279b | Ruby | luopio/lauri.sokkelo.net | /_plugins/exif_tag.rb | UTF-8 | 535 | 2.609375 | 3 | [] | no_license | # Title: Jekyll Exif tag
# Authors: Lauri Kainulainen @laurikainulaine
#
# Description: Quick hack to extract Exif information from photos. Didn't really work with my
# FujiFilm cam, so left to rot..
#
require 'exifr'
module Jekyll
class Exif < Liquid::Tag
def render(context)
filename, ex... | true |
2aa575c1866b1e3119091362adb77d09dd95a91b | Ruby | Lykos/cube_trainer | /lib/cube_trainer/scraping/expertf2l_scraper.rb | UTF-8 | 8,944 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'cube_trainer/training/alg_hint_parser'
require 'cube_trainer/training/case_solution'
require 'cube_trainer/scraping/f2l_case_description'
require 'cube_trainer/anki/cube_mask'
require 'json'
require 'net/http'
require 'twisty_puzzles'
require 'uri'
module CubeTrainer
module Sc... | true |
8e3f5a2cfa602205c1101149450cf5e40551cdee | Ruby | ryhorowitz/ruby_basics | /exercise_chapter/exer8.rb | UTF-8 | 84 | 2.828125 | 3 | [] | no_license | hash1 = {chocolate: 'flavor'}
hash2 = {:vanilla => 'flavor'}
puts hash1[:chocolate] | true |
d321a9546ae0da37f626e10fc9602b3b34fa5740 | Ruby | masenmatthews/Ruby_CoinCombinations | /spec/coincount_spec.rb | UTF-8 | 889 | 2.828125 | 3 | [] | no_license | require('rspec')
require('pry')
require('coincount')
describe('#coincount') do
it("takes 25 cents and returns 1 quarter") do
change_return = Change.new(25)
expect(change_return.calc()).to(eq("1 quarters and 0 dimes and 0 nickels and 0 pennies"))
end
it("takes 35 cents and returns 1 quarter and 1 dime"... | true |
d2f453fbeae9b1f2d5fad7a77485bff1751a7539 | Ruby | cheeeya/algorithms-and-data-structures-practice | /graphs/Samuel_Chia/lib/graph.rb | UTF-8 | 664 | 3.28125 | 3 | [] | no_license | class Vertex
attr_accessor :value, :in_edges, :out_edges
def initialize(value)
@value = value
@in_edges = Array.new
@out_edges = Array.new
end
def to_s
value
end
end
class Edge
attr_accessor :from_vertex, :to_vertex, :cost
def initialize(from_vertex, to_vertex, cost = 1)
@from_vertex... | true |
8e176b50628e47635d894c64eadbe681bd1bb11e | Ruby | CrossRef/tinypub | /vendor/bundle/ruby/1.9.1/gems/backports-3.3.3/lib/backports/1.9.1/array/sample.rb | UTF-8 | 519 | 2.71875 | 3 | [
"MIT"
] | permissive | unless Array.method_defined? :sample
require 'backports/tools'
class Array
def sample(n = Backports::Undefined)
return self[Kernel.rand(size)] if n == Backports::Undefined
n = Backports.coerce_to_int(n)
raise ArgumentError, "negative array size" if n < 0
n = size if n > size
resul... | true |
2880daf4c5935c7f17406352c2cc429cdef05564 | Ruby | kdavh/ultimate_tic_tac_toe_terminal | /view.rb | UTF-8 | 1,063 | 3.390625 | 3 | [] | no_license | class View
SQUARES = {
nil => "\u24FF",
ToeGame::PLAYER1 => "\u2460",
ToeGame::PLAYER2 => "\u2461"
}
def initialize(game)
@game = game
end
def game
board = ""
3.times do |big_row|
3.times do |small_row|
3.times do |big_col|
3.times do |small_col|
s... | true |
67f028d96d75f77f4d87ca83a2e95f14528993e7 | Ruby | filaone/codewars | /ruby_wars/016_rsic_5k.rb | UTF-8 | 1,642 | 3.0625 | 3 | [] | no_license | def search_substr( fullText, searchText, allowOverlap = true)
if searchText == ''
0
else
fullText.scan(allowOverlap ? Regexp.new("(?=(#{searchText}))") : searchText).size
end
end
def search_substr(fullText, searchText, allowOverlap)
return 0 if searchText.empty?
count, offset = 0, 0
while idx = fullText.inde... | true |
d007f77acbe2539784b326ebec0ef29bd6d12de0 | Ruby | kaseymccormick/tabs_database | /models/products.rb | UTF-8 | 823 | 2.921875 | 3 | [] | no_license |
require_relative "../database_class_methods.rb"
require_relative "../database_instance_methods.rb"
class Products
extend DatabaseClassMethods
include DatabaseInstanceMethods
attr_reader :id
attr_accessor :general_info, :technical_specs, :where_to_buy
#initalize a new responder object
def initial... | true |
f39ddad883720ed2e4e8f4cdf8aff73e66bee2cb | Ruby | michelgrootjans/ruby-head-first-design-patterns | /example.rb | UTF-8 | 184 | 2.734375 | 3 | [] | no_license | Dir["lib/*.rb"].each {|file| require_relative file }
ducks = [RedheadDuck.new, MallardDuck.new]
ducks.each do |duck|
puts duck.display
puts duck.swim
puts duck.quack
puts
end
| true |
6b38fec032275600cfd47b6ae9e1ed212b7db0c5 | Ruby | TyMazey/museum | /test/museum_test.rb | UTF-8 | 4,436 | 2.875 | 3 | [] | no_license | require_relative 'test_helper'
class MuseumTest < Minitest::Test
def test_it_exsist
dmns = Museum.new("Denver Museum of Nature and Science")
assert_instance_of Museum, dmns
end
def test_it_has_name
dmns = Museum.new("Denver Museum of Nature and Science")
assert_equal "Denver Museum of Nature ... | true |
53d1df8b3c3d700375f8e28025b3d61f2a3417d1 | Ruby | androidgrl/algorithms | /recursion/recursive_powers.rb | UTF-8 | 212 | 3.578125 | 4 | [] | no_license | def powers(x, n)
if n == 0
return 1
elsif n % 2 == 0
return powers(x, n/2) * powers(x, n/2)
elsif n < 0
return 1.0/powers(x, n)
else
return x * powers(x, n-1)
end
end
puts powers(2, 4)
| true |
143de591a9392a00c111d35df65b54f2c06d27ae | Ruby | stubblyhead/advent2015 | /day9/salesman.rb | UTF-8 | 1,095 | 3.1875 | 3 | [] | no_license | # require 'pry'
# binding.pry
lines = File.readlines('./input', :chomp => true)
distances = lines.length
city_hash = {}
city_count = 0
while distances > 0
distances -= city_count
city_count += 1
end
city_distance = Array.new(city_count) { Array.new(city_count) { 0 } }
lines.each do |i|
cities, distance = i.spl... | true |
73c3dceaf4ec6acc6c7a7ada90c23de80b3d4af4 | Ruby | mackdalton/key-for-min-value-v-000 | /key_for_min.rb | UTF-8 | 315 | 3.3125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash)
min = 0
key = nil
name_hash.each do |name, age|
if min == 0
min = age
key = name
end
if age <= min
key = name
end
end
key
end
| true |
4e45e1bbc3a3bd48080d9b9dabcd20c8b8bb1904 | Ruby | kseastman/grocery-store | /lib/order.rb | UTF-8 | 1,952 | 3.140625 | 3 | [] | no_license | require 'pry'
require 'csv'
require 'awesome_print'
module Grocery
# begin
# rescue Grocery::FindError > e
# end
# custom error for the Order.find class method
class FindError < ArgumentError
def initialize(msg="Error: Order has not been created yet")
super
# rescue
end
end
class O... | true |
5d4c2a8945e55be0d4189b1e5fb564dea7a643f7 | Ruby | modular-magician/magic-modules | /products/compute/helpers/provider_target_pool.rb | UTF-8 | 1,633 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | # Copyright 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, so... | true |
b440aab6ad9c02edb29e72179066c8428c3a2f34 | Ruby | Jhodges007/autotraining | /hello_world_ruby/tic_tac_toe.rb | UTF-8 | 552 | 3.0625 | 3 | [] | no_license | class TicTacToe
def next_move(move)
move['board'].sub!(/\*/, move['piece'])
move['board']
end
end
# def next_move(move)
# move['board'].split
# move['board']
# # winning_triplets: [[1, 2, 3], [4, 5, 6],
# [7, 8, 9], [1, 5, 9], [2, 5, 8], [3, 5, 7],
# [1, 4, 7], [3, 6, 9]]
# # board_... | true |
bc98a64155518b3eff598c57a203ac5dbbc856dd | Ruby | ptorrestr/evanu | /test/models/state_test.rb | UTF-8 | 909 | 2.734375 | 3 | [] | no_license | require 'test_helper'
class StateTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
def setup
@country = Country.new(name: "Ireland")
@country2 = Country.new(name: "England")
@state = State.new(name: "Galway",
country: @country)
end
test "should be valid" do
... | true |
b6d9e87e80dbf4a4d419acdd7068a38298d4716d | Ruby | omarkhan2270/takeaway-challenge-1 | /spec/takeaway_spec.rb | UTF-8 | 696 | 3.0625 | 3 | [] | no_license | require 'menu'
require 'order'
describe Menu do
subject(:menu) { described_class.new }
it 'checks for menu prices' do
expect(menu).to respond_to(:price).with(1).argument
end
describe '#list' do
it 'responds to list' do
expect(subject).to respond_to(:list)
end
it 'prints the menu' do ... | true |
ef0fcac796ee5ab2e95c2c495543db7c47597237 | Ruby | learn-co-students/chicago-web-033020 | /active-record-intro/app/models/tiger.rb | UTF-8 | 666 | 2.84375 | 3 | [] | no_license | class Tiger < ActiveRecord::Base
belongs_to :oasis
# attr_accessor :name, :age, :breed
# def self.all
# # Going to database table tigers, getting hashes, turning to Ruby objects
# end
# def initialize(args = {})
# self.name = args[:name]
# self.name = args[:age]
# self.name = args[:breed]
... | true |
1d9c3c7f526842df8e48776ea27f58503f090116 | Ruby | AnnaKL/Fizzbuzz-with-Ashleigh | /spec/fizzbuzz_spec.rb | UTF-8 | 347 | 2.96875 | 3 | [] | no_license | require 'fizzbuzz'
describe 'Fizzbuzz' do
it 'returns "fizz" when passed 3' do
expect(fizzbuzz(3)).to eq "fizz"
end
it 'returns "buzz" when passed 5' do
expect(fizzbuzz(5)).to eq 'buzz'
end
it 'returns "fizzbuzz" when passed 15' do
expect(fizzbuzz(15)).to eq "fizzbuzz"
end
it 'returns 7 when passed 7' do
expect(f... | true |
f06eeaec689369f4850104552908329d30326df4 | Ruby | bjh/katas | /src/chop.rb | UTF-8 | 1,676 | 3.8125 | 4 | [] | no_license | # http://codekata.pragprog.com/2007/01/kata_two_karate.html
require 'test/unit'
# data = (0...3037)
# needle = 3 #Random.rand(data)
# haystack = [] #Array[*data]
def chop(needle, haystack)
return -1 if haystack.empty? or haystack.nil?
chop_algo(needle, haystack, left=0, right=haystack.size-1)
end
def chop_al... | true |
dfbdbc322cf5b27f1b842f4bd8a6e435901d1e8b | Ruby | SJay90/bort | /vendor/plugins/administrate_me/lib/rspec_matchers.rb | UTF-8 | 1,753 | 2.53125 | 3 | [] | no_license | module Spec
module Rails
module Matchers
# Validates that a controller using administrate_me has set the search option for a given field.
#
# == Example:
#
# On the controller:
#
# class ProductsController < ApplicationController
# administrate_me do |a|
... | true |
744766b4fceef7cec74ca96f7985931c2aa24444 | Ruby | PeterWuMC/file_server | /models/user.rb | UTF-8 | 1,406 | 2.625 | 3 | [] | no_license | require 'digest/sha1'
class User < ActiveRecord::Base
has_many :devices, :dependent => :destroy
has_many :projects, :dependent => :destroy
has_secure_password
validates_uniqueness_of :user_name
validate :validate_user_name
after_create :create_initial_projects_and_folder
after_destroy :remove_private_... | true |
cd44f6713000c343aae06df7a390d746e76a273d | Ruby | dorrit/zen-eight-ball-with-thomas | /app/models/in_note.rb | UTF-8 | 564 | 2.625 | 3 | [] | no_license | class InNote
attr_reader :from, :text, :sender, :subject
LOCAL_URL = "http://zengun.fwd.wf"
def initialize(attributes)
@from = attributes["from"]
@text = attributes["body-plain"]
@sender = attributes["sender"]
@subject = attributes["subject"]
end
# def respond
# #post to a url/outnotes,... | true |
a95de03250c5477ff2d01927f72c47cb7a86e559 | Ruby | rocky/rb8-trepanning | /processor/command/next.rb | UTF-8 | 2,305 | 2.625 | 3 | [] | no_license | # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
require 'rubygems'; require 'require_relative'
require_relative '../command'
class Trepan::Command::NextCommand < Trepan::Command
ALIASES = %w(n n+ n- next+)
CATEGORY = 'running'
NAME = File.basename(__FILE__, '.rb')
HELP ... | true |
67b45d1e80b0b5f2a22a4704c9bba82a973c8348 | Ruby | aahmad94/W2D3-poker | /poker/lib/card.rb | UTF-8 | 441 | 3.15625 | 3 | [] | no_license | class Card
CARDS = {
2 => :one,
3 => :three,
4 => :four,
5 => :five,
6 => :six,
7 => :seven,
8 => :eight,
9 => :nine,
10 => :ten,
11 => :jack,
12 => :queen,
13 => :king,
14 => :ace
}
attr_reader :face, :value, :suit
def initialize(value, suit)
@value = value
@suit = suit
@face ... | true |
49cda80590789e4b4c129ab03b614a77bf321158 | Ruby | iantonik/TicTacToe_Final | /TicTacToe_IA.rb | UTF-8 | 2,581 | 3.859375 | 4 | [] | no_license | spaces = {'a1' => '', 'a2' => '', 'a3' => '', 'b1' => '', 'b2' => '', 'b3' => '', 'c1' => '', 'c2' => '', 'c3' => ''}
winning_combos = [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3'],['a1', 'b1', 'c1'], ['a2', 'b2', 'c2'], ['a3', 'b3', 'c3'], ['a1', 'b2', 'c3'], ['a3', 'b2', 'c1'] ]
user_sign = 'X'
compute... | true |
2ab7210d4072aec4887ba94b0849d92aae708e58 | Ruby | robotex82/code_matrix | /lib/service_hooks/base.rb | UTF-8 | 1,074 | 2.75 | 3 | [] | no_license | module ServiceHooks
class Base
# Holds the data from the service provider
attr_accessor :data
# project identifier
attr_accessor :identifier
# constructor
def initialize(identifier)
self.identifier = identifier
@data = nil
end
# Should return a badge from the... | true |
f5cb8a607a70b5b5f5a2e04d3d9943d9a8aad2e0 | Ruby | H1D/saas-class-assignments | /hw1/part5.rb | UTF-8 | 816 | 3.40625 | 3 | [] | no_license | class Class
def attr_accessor_with_history(attr_name)
attr_name = attr_name.to_s # make sure it's a string
attr_reader attr_name # create the attribute's
attr_reader attr_name+"_history" # create bar_history
class_eval %Q{
def %{n}=(new_value)
if !@%{n}_history
... | true |
5eab55931dcb8d4075a2b3fe034a4bdab1f95447 | Ruby | wasmerio/wasmer-ruby | /examples/exports_global.rb | UTF-8 | 2,386 | 3.484375 | 3 | [
"MIT"
] | permissive | require_relative "prelude"
# A Wasm module can export entities, like functions, memories, globals
# and tables.
#
# This example illustrates how to use exported globals. They come in 2
# flavors:
#
# 1. Immutable globals (const),
# 2. Mutable globals.
#
# You can run the example directly by executing in Wasmer roo... | true |
8c05f6afa37da9f02033cb46f2603b4aaa427614 | Ruby | szabokaroly/RB101 | /Lesson2-5/Lesson_2_only/rps_bonus_features.rb | UTF-8 | 2,721 | 4.09375 | 4 | [] | no_license | VALID_CHOICES = {
r: 'rock',
p: 'paper',
sc: 'scissors',
l: 'lizard',
sp: 'spock'
}
WINNING_FORMULA = {
'rock' => %w(lizard scissors),
'paper' => %w(rock spock),
'scissors' => %w(paper lizard),
'lizard' => %w(paper spock),
'spock' => %w(rock scissors)
}
MAKE_YOUR_CHOICE = <<-MSG
Choose one of the ... | true |
225d63336677e61db795072e93cca4be5ff778ef | Ruby | Mikazukittp/yoshinani | /script/migration_payment.rb | UTF-8 | 2,796 | 2.5625 | 3 | [] | no_license | #
# Migrate Payment Data From Heroku Application
#
# Usage:
# bundle exec rails r ./script/migration_payment.rb migrate -f=#{path}
#
# Example:
# bundle exec rails r ./script/migration_payment.rb migrate -f ./lib/tasks/input.json
class MigrationPayment < Thor
require 'json'
ID_MAPPING_TABLE = {
'54d30a520b0add0... | true |
10540f75614363f1dcf287b2ccf3e864d2fb095c | Ruby | aasmith/iron-tank | /app/models/account.rb | UTF-8 | 887 | 2.53125 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | # == Schema Information
# Schema version: 20091019043039
#
# Table name: ledgers
#
# id :integer not null, primary key
# type :string(255)
# name :string(255)
# user_id :integer
# keychain_id :integer
# adapter_id :integer
# external_id :string(255)
# created_at :datetime
# ... | true |
dd899209bda7c13e79692311ba997cf1c9bb74ae | Ruby | eskimosoup/nl_group | /app/models/timesheet_report.rb | UTF-8 | 426 | 2.515625 | 3 | [] | no_license | class TimesheetReport < Report
def to_csv
attributes = %w{ full_name time }
CSV.generate(headers: true) do |csv|
csv << attributes.map(&:titleize)
member_timesheets.each do |login|
csv << attributes.map{ |attr| login.send(attr) }
end
end
end
private
def member_timesheet... | true |
a3df689cff3a2849352fe4aa523c0d7d2adb928b | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/anagram/23a51c5705844aa2ad0499c597e0ec51.rb | UTF-8 | 703 | 3.9375 | 4 | [] | no_license | class Anagram
def initialize(word)
@analyzer = Analyzer.use_as_base(word)
end
def match(words)
words.select do |word|
@analyzer.match? word
end
end
class Analyzer
attr_accessor :base_word
def self.use_as_base(word)
analyzer = Analyzer.new
analyzer.base_word = word.down... | true |
fcbac176ef85169e9fa3c44065c1c0c97fb47392 | Ruby | IgorMilosavljevic2644/learn_ruby | /01_temperature/temperature.rb | UTF-8 | 116 | 3.390625 | 3 | [] | no_license | #write your code here
def ftoc number
(number - 32) * 5.0 / 9.0
end
def ctof number
((9.0/5.0) * number) + 32
end | true |
0623936d7a8d4a58e31aca7e93eef11e59a62092 | Ruby | midhunkrishna/muskrat | /lib/muskrat/configuration/loader.rb | UTF-8 | 1,683 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'muskrat'
require 'muskrat/configuration/guard'
module Muskrat
module Configuration
class Loader
CONFIG_FILE_NOT_FOUND = "Configuration file not found. Muskrat will fallback to default configurations".freeze
def initialize(options)
@options = options
end
def config_file=... | true |
38a3b031e740b33f035bf0554c7ba3393f7dcb75 | Ruby | mikejihbe/project_euler | /src/main/rb/5.rb | UTF-8 | 906 | 3.78125 | 4 | [] | no_license |
=begin
DIVISIBLE BY
2: last digit even, 0,2,4,8 - we can increment natural numbers (NN) by 2 finding possibilities
3: sum of digits divis by 3
4:
5: last digit 0 or 5, combined with 2 we can increment NN by 10
6:
7:
8:
9:
10: last digit == 0
11:
12: given by 3 and 4
13:
14: given by 2 and 7
15: given by 3 and 5
16... | true |
24730ef8b87d26b8dffcfdf8d4e58e1e3134cdf8 | Ruby | AdamJacobson/Algorithms-Practice | /arrays/adam_jacobson/lib/ring_buffer.rb | UTF-8 | 1,706 | 3.609375 | 4 | [] | no_license | require_relative "static_array"
require 'byebug'
class RingBuffer
attr_reader :length
def initialize
self.length = 0
self.capacity = 8
self.start_idx = 0
self.store = StaticArray.new(capacity)
end
# O(1)
def [](index)
check_index(index)
i = (self.start_idx + index) % capacity
s... | true |
69e18c2569552435b30469629aea8b3dc19107d9 | Ruby | snltd/aur | /lib/aur/stdlib/numeric.rb | UTF-8 | 180 | 2.78125 | 3 | [
"BSD-2-Clause"
] | permissive | # frozen_string_literal: true
# Extensions to stdlib Numeric
#
class Numeric
# @return [String] number, prefixed with leading zero
def to_n
format('%02d', self)
end
end
| true |
25296fc2dca020363338505310aa848a47c5e7de | Ruby | Em-Arce/fox | /fox/fox.rb | UTF-8 | 581 | 3.96875 | 4 | [] | no_license | #check input type if a number
def is_number(n)
if n.is_a? Numeric
FooBar(n.to_i)
else
puts "#{n} is not a number. FooBar will not execute for this input."
end
end
def FooBar(n)
puts "Executing FooBar function for n = #{n}:"
(1..n).each do | var |
if var % 3 == 0 && var % 5 == 0
... | true |
798fe9356dea01045b30426f5adcf5694e398226 | Ruby | 3ll3n/pet_shop-homework | /start_point/pet_shop.rb | UTF-8 | 1,541 | 3.40625 | 3 | [] | no_license | def pet_shop_name(pet_shop)
return pet_shop[:name]
end
def total_cash(pet_shop)
return pet_shop[:admin][:total_cash]
end
def add_or_remove_cash(pet_shop, cash)
return pet_shop[:admin][:total_cash] += cash
end
def pets_sold(pet_shop)
return pet_shop[:admin][:pets_sold]
end
def increase_pets_sold(pet_shop, so... | true |
36d9303178d6a837213b91b4cf8e3615d0086969 | Ruby | internetroger/ruby-oo-object-relationships-collaborating-objects-lab-seattle-web-030920 | /lib/artist.rb | UTF-8 | 927 | 3.640625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Artist
attr_accessor :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def songs
result = []
Song.all.select do |song|
if song.artist == self
result << song
... | true |
d99bd2f81ea9636efb8fd694964864264aca8509 | Ruby | nahi/ff_foaf_graph | /graph.rb | UTF-8 | 4,823 | 2.515625 | 3 | [] | no_license | require 'ff'
require 'store'
require 'graphviz'
id = ARGV.shift or raise
class Graph
def initialize(viz, limit = 200)
@id_counter = 0
@id_map = {}
@viz = viz
@limit = limit
@nodes = {}
@edges = {}
end
def node(id, name, opt = {})
return unless id and name
if mapped = map_id(id)
... | true |
23fa16c4eca3128e87a1b9686975bf2e61c299d6 | Ruby | rocking42/Ruby-fun | /class_test/student.rb | UTF-8 | 324 | 3.875 | 4 | [] | no_license | class Student
attr_reader :rank, :grade
attr_accessor :name
def initialize(name, grade, rank)
@name = name
@grade = grade
@rank = rank
end
def grade_up()
@grade += 1
end
def rank_up(n)
@rank -= n
end
def to_s
"I'm #{@name} in Grade #{@grade} with a rank of #{@rank}"
end
... | true |
f270b0c9400afd392bae0e6f0d54f30c5db65102 | Ruby | think41c/forex_trader | /trade_creator.rb | UTF-8 | 620 | 3.859375 | 4 | [] | no_license | class TradeCreator
attr_reader :percentage
# Just use probabilities to calculate the win or loss for that trade.
def trade_gen(percentage_winners)
answers = []
15.times do
a = rand(1..100)
if a < percentage_winners # Percentage of winning trades.
trade = 1
else
trade = -1
end
answers... | true |
7fe5d6748b04c76dd3d689da5bb3e35bf7cbc8b1 | Ruby | besmith43/Solving-Mazes | /maze.rb | UTF-8 | 525 | 2.609375 | 3 | [] | no_license | def maze
require 'chunky_png'
require 'pp'
require 'ruby-progressbar'
require 'highline'
require 'thread'
require_relative 'functions'
require_relative 'graph'
require_relative 'node'
require_relative 'edge'
maze_filename = select_maze
maze, rows, cols = read_image(maze_filename)
graph, num_nodes = get_n... | true |
5a4d7487d05688fc72fb30c0a11d9841f1dc7ae9 | Ruby | adambray/iron_horse | /lib/iron_horse/board.rb | UTF-8 | 1,891 | 3.09375 | 3 | [] | no_license | module IronHorse
class Board
attr_reader :cities, :route_owners
def initialize
@route_cost = [ [ nil, 10, nil, nil, nil, 20, 30 ],
[ 30, nil, 20, nil, nil, nil, 10 ],
[ nil, 20, nil, 30, nil, nil, 25 ],
... | true |
3f66e3b7fd04d20084ec2a06111c3b549bdb5d93 | Ruby | jayelle0/programming-univbasics-2-statement-if-end-nyc01-seng-ft-091420 | /lib/if_else_end.rb | UTF-8 | 138 | 3.265625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Write your solution here
current_time =Time.now
time_str = current_time.to_i
if time_str % 2 == 0
puts "Even!"
else
puts "Odd!"
end | true |
92f485babce0f976c7da1ba09772e08bed9d7960 | Ruby | simont/MCW-RDF | /RGD/RgdRecord.rb | UTF-8 | 3,924 | 2.671875 | 3 | [] | no_license | require 'cgi'
class RgdRecord
attr_reader :raw_data, :data, :headers
# quick references table for the standard taxons we have to deal with at RGD.
TAXON = {'rattus norvegicus' => '10116',
'rat' => '10116',
'homo sapiens' => '9606',
'human' => '9606',
'mus musculus' ... | true |
d08d63e1d07e1c3fb2ce82db343c7cf4e0fd5ec1 | Ruby | chriserin/Predators-OLD | /spec/models/show_spec.rb | UTF-8 | 3,406 | 3.03125 | 3 | [] | no_license | require 'spec_helper'
describe Show do
describe 'getting upcoming shows' do
it 'should get todays show but not yesterdays' do
today_date = DateTime.now.strftime('%m/%d/%y')
yesterday_date = DateTime.now.next_day(-1).strftime('%m/%d/%y')
show1 = Show.new_from_post("show xxx #{today_date} ... | true |
66417f22616ba1fc9f1d38fe247bfce74cd29894 | Ruby | Yukaii/SchoolAgent | /lib/course_api.rb | UTF-8 | 2,042 | 2.65625 | 3 | [] | no_license | require 'httpclient'
module CourseAPI
class << self
# 先隨便串一下
def import course_codes: nil, user_id: nil
user = User.find(user_id)
organization_code = user.organization_code
courses_taken = JSON.parse(clnt.get_content("https://colorgy.io:443/api/v1/user_courses.json?filter[user_id]=#{user_... | true |
f6c2ea7ac86fdab01fd897b416147d2353d64c96 | Ruby | ReLearnDeveloper/Ironhack-Web-Development | /week1/day1/ex-game.rb | UTF-8 | 1,690 | 4.03125 | 4 | [] | no_license | require "pry"
class Finding_number
#attr_accessor(:attemp, :total_attemps, :live, :total_lives)
def initialize
@attemp = 1
@total_attemps = 5
@live = 1
@total_lives = 3
end
def start_game
puts "Hello! What's your name?"
@name = gets.chomp
game
end
def game
@attemp = 1
@... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.