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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
7d631ca997390a948978de2049ee580f6c2fd8e2 | Ruby | zerowidth/iphone_data | /lib/iphone_data/iphone.rb | UTF-8 | 4,180 | 2.625 | 3 | [
"MIT"
] | permissive | module IPhoneData
class IPhone
class << self
def iphones
@iphones ||= base_dir.children.map do |child|
next unless child.directory?
new(child)
end.compact
end
private
def base_dir
Pathname.new(File.expand_path("~/Library/... | true |
7254bc92a9ae246afb6981ad79b9d539e17283ab | Ruby | KL-TML/112417-ReinEx | /ex1.rb | UTF-8 | 906 | 3.421875 | 3 | [] | no_license | ballots = [{1 => 'Smudge', 2 => 'Tigger', 3 => 'Simba'},
{1 => 'Bella', 2 => 'Lucky', 3 => 'Tigger'},
{1 => 'Bella', 2 => 'Boots', 3 => 'Smudge'},
{1 =>'Boots', 2 => 'Felix', 3 => 'Bella'},
{1 => 'Lucky', 2 => 'Felix', 3 => 'Bella'},
{1 => 'Smudge', 2 => 'Simba', 3... | true |
d961cc1f36543264b9daa57e84d54024fb065496 | Ruby | breycarr/ruby-practice | /Makers 5 - Iterations - Clap your hands.rb | UTF-8 | 168 | 2.71875 | 3 | [] | no_license | default = "clap your hands"
special = "and you really want to show it"
[default,default,special,default].each do |x|
puts "if you're happy and you know it, #{x}"
end
| true |
56e7756b21a5b0aff8c8a47a960c05d8effbcdf3 | Ruby | katharinechen/tic_tac_toe_ruby | /user_interface.rb | UTF-8 | 2,372 | 3.765625 | 4 | [
"MIT"
] | permissive | require './lib/space'
require './lib/board'
require './lib/player'
require './lib/game'
def static_board_holder
@static_board = "
█ █
1 █ 2 █ 3
▄▄▄▄▄▄█▄▄▄▄▄█▄▄▄▄▄▄
█ █
4 █ 5 █ 6
▄▄▄▄▄▄█▄▄▄▄▄█▄▄▄▄▄▄
█ █
7 █ 8 █ 9
█ █
"
@active_bo... | true |
1613e33436e10e6120d71e32f94cb41f7c7386e6 | Ruby | crossroads/ffcrm_mailchimp | /lib/ffcrm_mailchimp/list_subscription.rb | UTF-8 | 2,026 | 2.890625 | 3 | [] | no_license | #
# A list subscription encapsulates a specific instance of a contact and
# the list he/she is subscribed too. It is useful for serializing individual
# subscription data to be stored on the contact object itself.
require 'ostruct'
require 'active_support/core_ext/object'
module FfcrmMailchimp
class ListSubscriptio... | true |
f409ee9de1d98643b91c83a65826436abfdf8d2a | Ruby | seattlerb/hoe | /lib/hoe/rake.rb | UTF-8 | 1,648 | 2.625 | 3 | [
"MIT"
] | permissive | module Rake
class Task
# Used to name the source of a given task
attr_accessor :plugin
# :stopdoc:
alias :old_comment :comment
# :startdoc:
##
# Overrides the default #comment to provide the plugin name.
def comment
"%-#{$plugin_max}s # %s" % [plugin, old_comment] if old_comment... | true |
33dcacce31b767644baa6b02650e3af9cd4e0a74 | Ruby | Will-Meighan/backend_module_0_capstone | /day_4/exercises/methods.rb | UTF-8 | 930 | 4.65625 | 5 | [] | no_license | # In the exercises below, write your own code where indicated
# to achieve the desired result. You should be able to run this
# file from your terminal with the command `ruby day_4/exercises/methods.rb`
# example: Write a method below that, when called will print your name
def print_name
puts "Will Meighan"
end
pri... | true |
c63959793ce2812166895ceb218d50310ebf6ea0 | Ruby | nside/Joybox | /template/joybox-osx-example-repl/files/app/layers/actions_layer.rb | UTF-8 | 520 | 2.53125 | 3 | [
"MIT",
"Zlib"
] | permissive | class ActionsLayer < Joybox::Core::Layer
def on_enter
layout_characters
end
def layout_characters
@first_character = Sprite.new file_name: 'sprites/character_horn_girl.png',
position: [773, 100]
self << @first_character
@second_character = Sprite.new file_name: 'sprites/character_pink_girl.... | true |
6411c712a0871ccd98073b0bcc85ac48fefb819c | Ruby | rposborne/overpass-api-ruby | /lib/overpass_api_ruby.rb | UTF-8 | 2,403 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'httpi'
require 'diskcached'
require 'open-uri'
require 'json'
require 'nokogiri'
class OverpassAPI
VERSION='0.1.2'
DEFAULT_ENDPOINT='http://overpass-api.de/api/interpreter?data='
def initialize(args={})
bbox = args[:bbox]
bbox(bbox[:s],bbox[:n],bbox[:w],bbox[:e]) if bbox
cache_expiration_t... | true |
af710b601d96ad6291022cf0a12f8da34da87aa4 | Ruby | bomymo/rails_project_c | /spec/models/product_spec.rb | UTF-8 | 2,247 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
describe Product do
context "when the product has comments" do
let (:product) { Product.create!(name: "Batman Movie DVD", description: "test", colour: "black", price: 1.00, image_url: "test") }
let (:user) { User.create(email: "jtest@email.com", password: "moonstone") }
befor... | true |
5a2b78e95a46ef403623522948d7096eb3d12db7 | Ruby | mailgun/huboard | /lib/use_cases/fetch_board.rb | UTF-8 | 677 | 2.515625 | 3 | [
"LicenseRef-scancode-generic-cla",
"MIT"
] | permissive | module UseCase
class FetchBoard
include SolidUseCase
attr_accessor :client
def initialize(client)
@client = client
end
steps :repo_exists?, :board_exists?, :issues_enabled?
def repo_exists? params
board = client.board params[:user], params[:repo]
if board.repo_exists?
... | true |
4c16156eb60e4117f4b975e0d6f862c4889a368c | Ruby | fffear/learn_ruby | /06_timer/timer.rb | UTF-8 | 1,581 | 3.640625 | 4 | [] | no_license | class Timer
#write your code here
def initialize
@timer = 0
end
def seconds=(number)
@timer = number
end
def seconds
@timer
end
def padded number
if number >=0 && number <= 9
number = "0" + number.to_s
else
number = number.to_s
end
number
end
def time_stri... | true |
f80e0ece6f3a8e0ef0b88595a9b484df1e16b908 | Ruby | EcksZA/fizzbuzz | /spec/fizzbuzz_spec.rb | UTF-8 | 499 | 3.5625 | 4 | [] | no_license | require 'rspec'
require 'fizzbuzz'
describe "fizzbuzz" do
it "returns the number" do
fizzbuzz(1).should eq([1])
end
it "returns the word 'fizz' if the number is divisible by 2" do
fizzbuzz(2).should eq([1, "fizz"])
end
it "returns the word 'buzz' if the number is divisible by 3" do
fizzbuzz(3).should eq([1,... | true |
7e3f81562082a0c2af893b52baead7787324dda5 | Ruby | Marissab13/phase-0-tracks | /ruby/iteration_fiddlercrabs.rb | UTF-8 | 1,429 | 4.25 | 4 | [] | no_license | animals = ["porcupine", "platypus", "capybara", "liger"]
pets = {'dog' => 'Daeny', 'cat' => 'Zero', 'horse' => 'Margo', 'turtle' => 'Sheldon'}
#using .each on the array and the hash
puts animals
animals.each do |animal|
puts "The #{animal} is a very interesting animal."
end
puts pets
pets.each do |pet, name|
put... | true |
94318be10095555e75bda8c9f580d113c63712db | Ruby | randomorganizer/BackEndDevelopment | /lesson_2/rpsls.rb | UTF-8 | 2,442 | 4.15625 | 4 | [] | no_license | VALID_CHOICES = %w(rock paper scissors lizard Spock).freeze
def prompt(message)
Kernel.puts("=> #{message}")
end
def rock_wins?(first, second)
(first == 'r' && second == 'l') ||
(first == 'r' && second == 's')
end
def paper_wins?(first, second)
(first == 'p' && second == 'r') ||
(first == 'p' && second... | true |
196c18c4d00dae382fe41d2a4a82716fea02a535 | Ruby | nathanbwright/exercism-exercises | /ruby/sum-of-multiples/sum_of_multiples.rb | UTF-8 | 381 | 3.53125 | 4 | [] | no_license | class SumOfMultiples
def initialize(*factors)
@factors = factors
end
def to(max)
multiples = @factors.flat_map do |num|
get_multiples(num, max)
end
sum_uniq(multiples)
end
def sum_uniq(multiples)
multiples.uniq.reduce(:+)
end
def get_multiples(count_by, max)
(0...max).ste... | true |
604579de03e072b050c09ce14bbf54bcd26d371a | Ruby | gjmorale/pdf-reader | /dev/lib/Line.rb | UTF-8 | 3,779 | 3.09375 | 3 | [] | no_license | class MultiMatchData
attr_accessor :offset
attr_accessor :width
def initialize
@offset = []
end
def offset index = 0
@offset
end
end
class Multiline < String
attr_reader :line_size
attr_reader :strings
def self.generate str, remove_n = true
if str.is_a? Array
str = str.map {|s| s = s.delete("\n")... | true |
40ebf1314b6b297c04072cd138c9c55cbacc735d | Ruby | dastinnette/Chisel | /lib/chunk_formatter.rb | UTF-8 | 920 | 3.4375 | 3 | [] | no_license | require './lib/header_processor'
require './lib/paragraph_processor'
require './lib/unorder_list_processor'
require './lib/order_list_processor'
class ChunkFormatter
attr_reader :string, :paragraph_processor, :header_processor
def initialize(chunk)
@string = chunk
@paragraph_processor =... | true |
ace3d2cbf2b0f96f63de1a2cceac7754a2ffc908 | Ruby | EdwardAndress/DebugBookmarkManager | /spec/bookmark_spec.rb | UTF-8 | 1,049 | 2.9375 | 3 | [] | no_license | require 'bookmark'
describe Bookmark do
describe '.all' do
it 'returns all bookmarks in an array' do
# Add the test data
bookmark_1 = Bookmark.create(title: 'Makers Academy', url: "http://makersacademy.com")
bookmark_2 = Bookmark.create(title: 'Destroy All Software', url: "http://destroyallsoft... | true |
0cd1ea1b769dbb65433426359690ed89a5e8dd25 | Ruby | trentlarson/P2P-Docs | /Resources/ruby/gedcom-ancestry.rb | UTF-8 | 4,554 | 2.953125 | 3 | [] | no_license |
#require 'gedcom'
#require File.join(File.expand_path(File.dirname(__FILE__)), "lib", "gedcom.rb")
#require File.join(File.expand_path(File.dirname(__FILE__)), "p2pdocs_utils.rb")
class Individual
attr_accessor :id
attr_accessor :name
attr_accessor :birth_date
def initialize( id = nil, name = nil, birth_date... | true |
02ce7b202fc25bff67fde8b79de5d3ba25120dc1 | Ruby | furtivesock/rubyworkshop | /sinatra-api/app/table.rb | UTF-8 | 2,439 | 2.703125 | 3 | [] | no_license | module FileDb
class Table
:table
:database
def initialize(table, database)
@table = table
@database = database
end
def select(where: nil)
ntable = []
@table.each { |el|
pass = true
if where != nil
where.keys.each { |k|
if where[k] ... | true |
a8f901eb4a2cb747a6794f9e81b2db7e4768d4c2 | Ruby | achatelugabbi/looneytales | /app/models/movie.rb | UTF-8 | 2,469 | 2.578125 | 3 | [] | no_license | class Movie
include Mongoid::Document
include Mongoid::Timestamps
field :video_ids, :type => Array, :default => []
field :title, :type => String
field :year, :type => Integer
field :cast, :type => Array, :default => []
field :title_slug, :type => String
field :desc, :type => String
field :thumbnails,... | true |
c5890a5faac47de7176e1a705db499540208d7ed | Ruby | SuLoBoro/boris_bikes_project | /spec/docking_station_spec.rb | UTF-8 | 1,070 | 2.8125 | 3 | [] | no_license | require 'docking_station'
describe DockingStation do
it 'should respond to the method release_bike' do
expect(subject).to respond_to(:release_bike)
end
it 'releases working bikes' do
bike = Bike.new
subject.dock(bike)
subject.release_bike
expect(bike).to be_working
end
it 'should relea... | true |
0e48d6146f1c0f3df947c86e85f683ee1fa174d7 | Ruby | TheMaxta/JobFinder | /web_scraper.rb | UTF-8 | 724 | 2.875 | 3 | [] | no_license | require 'HTTParty' #sends request to page
require 'Nokogiri' #places xml info into ruby object
require 'JSON'
require 'Pry' #debugging gem
require 'csv'
#this requests a craigslist page for, pets for scraping
page = HTTParty.get('https://newyork.craigslist.org/search/pet?s=0')
#pass html string into nokogir... | true |
92e6e37e791d5a13683a1022ebc89cc33cedc72a | Ruby | soliverit/ollieml | /examples/simple_linear_regression.rb | UTF-8 | 4,364 | 2.71875 | 3 | [] | no_license | Lpr.p """
##
# Load the sample data and split into train/test.
#
# If the input data doesn't exist log and exist
#
# NOTE:
# If a second argument is passed to the command line it will be used
# as the input data file name. File must be in ./data/ and doesn't include
# the ./data/ part, just the file name.
#
# ADDITION... | true |
d6af7329a3f72e3cc6d8ed8e9d35031095ee23a8 | Ruby | dlaststark/machine-learning-projects | /Programming Language Detection/Experiment-2/Dataset/Train/Ruby/universal-turing-machine-2.rb | UTF-8 | 478 | 2.6875 | 3 | [] | no_license | incrementer_rules = {
:q0 => { 1 => [1, :right, :q0],
:b => [1, :stay, :qf]}
}
t = Turing.new([:b, 1], # permitted symbols
:b, # blank symbol
:q0, # starting state
[:qf], # terminating states
... | true |
d8febb9c46beb400d5f716014c4b9d750fc4a362 | Ruby | LeEnno/schlagzeilen | /plugins/youtube_tag.rb | UTF-8 | 1,079 | 2.8125 | 3 | [
"MIT"
] | permissive | # Title: Enno's YouTube Tag for Jekyll
# Author: Enrico Schlag
# Description: Easily generate iframe code for embedding youtube videos.
#
# Syntax {% youtube id width height %}
#
# Example:
# {% youtube rrkrvAUbU9Y 1120 630 %}
#
# Output:
# <iframe width="1120" height="630" src="http://www.youtube.com/embed/rrkrvAUbU9Y... | true |
ff73a917157d28db01172c7c6ea2597d7524191d | Ruby | madhusudhan1234/ruby_basics | /lambdaandproc.rb | UTF-8 | 126 | 3.359375 | 3 | [] | no_license | # lambda = -> (name) { puts "Hello #{name}" }
proc = Proc.new { |name| puts "Hello #{name}" }
# lambda.call();
proc.call(); | true |
75f6f4c28d2af525f2594798ddbda3217a0999a8 | Ruby | RSRBX07/old-exo-donovan | /exercices_pierre/loto.rb | UTF-8 | 2,369 | 3.28125 | 3 | [] | no_license | #init variables
cagnote = 0
benefice = 0
nb_joueurs = 1
nb_essais = 0
#Config -----------
prix_billet = 2
rand_nb_joueurs = true
rand_tirage_joueur = true
tirage_auto = false
#------------------
stop = false
while stop == false
#nombre de joueurs aléatoire
if rand_nb_joueurs == true
nb_joueurs = ... | true |
6c3c3938ec35b3d241e4ff3052955dbeb54bb574 | Ruby | ssapra/No-Limit-Code-Em | /spec/split_pot_spec.rb | UTF-8 | 1,525 | 2.5625 | 3 | [] | no_license | require 'spec_helper'
describe 'Split Pot' do
it 'should split the pot and consider both the players as winners for equal hands' do
player_ids = setup_player
tables = setup_tables_for_test(player_ids)
tables.each do |t|
t.begin_play
setup_hands(t.player_ids)
pot = t.round.determine_win... | true |
e91d16b53925ae206fd85347f8eb46d5d290351d | Ruby | ChaoticBoredom/nhl_stats | /lib/nhl_stats/franchise.rb | UTF-8 | 1,128 | 2.609375 | 3 | [
"MIT"
] | permissive | module NHLStats
class Franchise
attr_reader :id, :team_name, :location, :most_recent_team_id, :first_season, :last_season
def initialize(franchise_data)
@id = franchise_data[:id] || franchise_data["franchiseId"]
@most_recent_team_id = franchise_data["mostRecentTeamId"]
@location = franchise... | true |
0213f3048df3133837d26f684316e1149ec6f478 | Ruby | GeorgesLorre/AoC | /day5/ruby/day5.rb | UTF-8 | 501 | 2.90625 | 3 | [] | no_license | ls = File.read('input/inputday5.txt')
def part1(input)
pos = 0
count = 0
while pos < input.size
jump = input[pos]
input[pos] += 1
pos += jump
count += 1
end
count
end
def part2(input)
pos = 0
count = 0
while pos < input.size
jump = input[pos]
jump > 2 ? input[pos] -= 1 : input[... | true |
f44edca3398d4bbc25eb023c6ad20212f5ffee2e | Ruby | zeled3813/04-oxford-comma-lab | /lib/oxford_comma.rb | UTF-8 | 229 | 3.5625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(arr)
if arr.length == 2
arr.join(" and ")
elsif arr.length >= 3
last_ele = arr.pop
arr << "and "
arr.join(", ") + last_ele.to_s
else
arr.join(", ")
end
end | true |
a224f6ff3296bff6d6f07219bb5d3ef3980354ed | Ruby | yzguy/yzguy-sandbox | /ruby/utilities/ldaplook | UTF-8 | 1,634 | 2.9375 | 3 | [] | no_license | #!/usr/bin/ruby
require 'net/ldap'
require 'colorize'
# Variables
environment = ARGV[0]
option = ARGV[1]
item = ARGV[2]
# Print Usage
def usage
puts 'Usage: ldaplook <test|prod> <user|group|name> <username|name>'
end
# Set Environment specific variables
case environment
when 'test'
server = ''
base = ''
when ... | true |
180d4cbc3041fa9b75c5f191ccd893d4cba20ef4 | Ruby | jah2488/justinherrick_com | /lib/posts.rb | UTF-8 | 271 | 3.015625 | 3 | [] | no_license | class Posts
include Enumerable
def initialize(*args)
@posts = Array.new(*args)
end
def each(*args, &block)
posts.each(*args, &block)
end
def reverse
posts.reverse
end
def last
reverse.first
end
protected
attr_reader :posts
end
| true |
4e9b83815689e400c7d393c6959e459f18cf1160 | Ruby | seabre/chugalugdigest | /spec/models/list_digests_spec.rb | UTF-8 | 9,766 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe ListDigest do
before :each do
@list_digest = ListDigest.new "test@example.com", "Some Title", "A bunch of text"
end
describe "#new" do
it "takes title and digest_text arguments and returns a ListDigest object" do
@list_digest.should be_an_instance_of ListDigest
... | true |
c44996c753d21a53747681857dc5f11eec247b53 | Ruby | NQuinn27/LRTHW | /ex5.rb | UTF-8 | 501 | 3.65625 | 4 | [] | no_license | my_name = "Niall Quinn"
my_age = 26
my_height = 178 #cm
my_weight = 68 #kg
my_eyes = "Brown"
my_teeth = "White"
my_hair = "Brown"
puts "Lets talk about #{my_name}"
puts "He is #{my_height}cm tall"
puts "He weighs #{my_weight}kg"
puts "He's got #{my_eyes} eyes and #{my_hair} hair"
puts "His teeth are usually #{my_teeth... | true |
e29b378d1c181f62eb0d4a5542315637d5428057 | Ruby | athio92/launchschool | /courses/101/L06/tic_tac_toe_bonus.rb | UTF-8 | 4,568 | 3.609375 | 4 | [] | no_license | MOVES_LIST = ["Choose", "Player", "Computer"]
FIRST_MOVE = MOVES_LIST[0]
INITIAL_MARKER = " "
PLAYER_MARKER = "X"
COMPUTER_MARKER = "O"
WINNING_LINES =
[
[1, 2, 3], [4, 5, 6], [7, 8, 9], # rows
[1, 4, 7], [2, 5, 8], [3, 6, 9], # columns
[1, 5, 9], [3, 5, 7] # diagonals
]
def prompt(msg)
... | true |
25740e084a6ba30d81f1e13663be74127740c270 | Ruby | hazthompson/jungle-rails | /spec/models/user_spec.rb | UTF-8 | 3,525 | 2.515625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
describe 'validations' do
user1 = User.new(first_name: "Any name", last_name: "Any lastname", email: "test@test.com", password: "password", password_confirmation:"password")
it "is valid with valid attributes" do
user1 = User.new(first_name:... | true |
4c6b6e181cb39079715bd29231db87607c1967a0 | Ruby | mk2/hyalite-todomvc-redux | /app/application.rb | UTF-8 | 3,656 | 2.65625 | 3 | [
"ISC"
] | permissive | require 'hyalite'
require 'browser/interval'
class TodoView
include Hyalite::Component
def initial_state
@last_id = 0
@todos = [{id: @last_id, completed: false, content: "何かの予定"}]
{todos: @todos, show_completed: false}
end
def on_change_task(e, id)
@todos = @todos.map do |todo|
if todo[... | true |
08085ca52b794ef7815ad17a4c240525a12792ce | Ruby | nick-stebbings/ruby-rb101-109 | /lesson_5/p_p_8.rb | UTF-8 | 320 | 3.5 | 4 | [] | no_license | hsh = {first: ['the', 'quick'], second: ['brown', 'fox'], third: ['jumped'], fourth: ['over', 'the', 'lazy', 'dog']}
# write some code to output all of the vowels from the strings
hsh.map {|_,v|
p v.map { |val|
val.chars.select {|chr|
chr.match(/[aeiou]/)
}.join('')
}.join('')
}.join('') | true |
1181e25f9fe6d3e2fcc72599f1b4710c48a91c3b | Ruby | monfil/codea | /Fase1/POO1/seccion1/scope.rb | UTF-8 | 1,245 | 3.84375 | 4 | [] | no_license | $global_var = "This is a global variable"
CONSTANT = 3.1416
class DummyClass
@@class_variable = "This is a class variable"
def initialize
local_var = "this is my local var"
end
def return_my_local_var
# local_var = "This is not the original value of my local var"
@instance_var = "This is an instance var"
... | true |
5016d959d4b5fc19d6e7fb35ee8530a18c69983c | Ruby | alu0100697414/prct11 | /test/tc_matriz.rb | UTF-8 | 1,374 | 2.875 | 3 | [
"MIT"
] | permissive | require "./lib/prct09.rb"
require "test/unit"
class Test_M < Test::Unit::TestCase
def test_1
@m1 = Prct09::Matriz_Densa.new(2,2)
@m2 = Prct09::Matriz_Densa.new(2,2)
@m3 = Prct09::Matriz_Densa.new(2,2)
@m1.set(0,0,1)
@m1... | true |
76115a8736af0e99ae9e4cf57cd9ef1f22a650e5 | Ruby | lancelotbeer/S6E1 | /3_ciclos_anidados/ejercicio2.rb | UTF-8 | 617 | 2.9375 | 3 | [] | no_license | =begin
Generar el código para imprimir la siguiente tabla:
<table>
<tbody>
<tr>
<td> 1 </td>
<td> 2 </td>
<td> 3 </td>
<td> 4 </td>
</tr>
<tr>
<td> 5 </td>
<td> 6 </td>
<td> 7 </td>
<td> 8 </td>
</tr>
<tr>
<td> 9 </td>
<td> 10 </td>
<td> 11 </td>
<td> 12 </td... | true |
94cc75292b8f26b4813f1b3fabd6acf990fcb742 | Ruby | asif-meer/school_admin | /app/models/batch.rb | UTF-8 | 1,072 | 2.578125 | 3 | [] | no_license | # == Schema Information
#
# Table name: batches
#
# id :integer not null, primary key
# batch_name :string(255)
# start_date :date
# end_date :date
# course_id :integer
# created_at :datetime
# updated_at :datetime
#
class Batch < ActiveRecord::Base
# associations
belongs_to :course
ha... | true |
0b50599b823906d7dab2a371e4f3681c95ad0979 | Ruby | Israelistic/reinforcement-exercise_api_calls2 | /reinforcement-exercise_api_calls2.rb | UTF-8 | 407 | 2.984375 | 3 | [] | no_license | require 'httparty'
random_passwords_response = HTTParty.get('https://makemeapassword.org/api/v1/alphanumeric/json?c=12&l=12&sym')
parsed_response = JSON.parse(random_passwords_response.body)
passwords =[]
p "generating 12 passwords with length of 12"
parsed_response["pws"].each_with_index do |password, index|
p "#... | true |
6d2a0dd8581879693b238c8dfdd816deacecc455 | Ruby | violetaria/too-done | /lib/too_done/task.rb | UTF-8 | 406 | 2.53125 | 3 | [
"MIT"
] | permissive | module TooDone
class Task < ActiveRecord::Base
belongs_to :todo_list
has_many :todo_tags,:dependent => :destroy
has_many :tags, through: :todo_tags
# overwrites the to_s function so it prints out nicely
def to_s
"ID: #{self.id} - Name: #{self.name} - Due: #{self.due_date.nil? ? 'n... | true |
8c1df5cc716d9034367075f88957a685297fd484 | Ruby | topofocus/standard_deviation | /spec/standard_deviation/standard_deviation_spec.rb | UTF-8 | 3,235 | 2.703125 | 3 | [
"MIT"
] | permissive | require "spec_helper"
describe Array do
shared_examples_for "a serie calculation" do
context "when called on a empty array" do
let(:values) { [] }
it { lambda { subject }.should raise_exception ZeroDivisionError, "not enough elements" }
end
context "when called on a array with only one eleme... | true |
e5afe5c602f23436c77d4e4d0e621e9f48d751c5 | Ruby | schacon/git-db | /lib/git-db/objects/base.rb | UTF-8 | 534 | 2.765625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class GitDB::Objects::Base
attr_reader :data
def initialize(data)
@data = data
end
def inspect
%{#<#{self.class} #{inspect_properties}>}
end
def properties
[:data]
end
def raw
data
end
def sha
Digest::SHA1.hexdigest(raw)
end
private ######################################... | true |
955e655ecad007f273d5c03a40945f6d8157abd7 | Ruby | vic8722/phase-0 | /week-5/acct_groups.rb | UTF-8 | 5,082 | 4.21875 | 4 | [
"MIT"
] | permissive | #
=begin
inputs: array of names
outputs: an array of arrays, each sub-array contains names of members in each accountability group
steps:
define a method called accountability_groups that takes one argument, name_array that is an array of strings
define a variable, num_people as the length of name_array
define a var... | true |
127018cb5ceb66fb374a9798368404d810088059 | Ruby | riqwan/bitmapper | /lib/commands/vertical_line.rb | UTF-8 | 1,045 | 2.984375 | 3 | [] | no_license | module Commands
class VerticalLine < Base
attr_reader :x, :y1, :y2, :c
def initialize(command_string, bitmap = nil)
super(command_string, bitmap)
@x = command_chars[1]
@y1 = command_chars[2]
@y2 = command_chars[3]
@c = command_chars[4]
end
def execute!
raise Comm... | true |
07c7f04d80c0301d6ecc1a69ab2654fb652b1229 | Ruby | mabako/AdventOfCode2015 | /18/animation.rb | UTF-8 | 863 | 3.1875 | 3 | [] | no_license | @input = IO.readlines('input.txt')
@size = @input.count
def neighbors(x, y)
([0, x-1].max .. [x+1, @size-1].min).map { |xx|
([0, y-1].max .. [y+1, @size-1].min).map { |yy|
(xx != x or yy != y) ? @state[xx][yy] : false
}.count(true)
}.reduce(:+)
end
def step
@state = @state.each_with_index.map { |e... | true |
2865e0260e32b594bc99c6f5ac649fec5a4514a1 | Ruby | firewood/topcoder | /gcj_2017/QR_B.rb | UTF-8 | 273 | 3.203125 | 3 | [] | no_license | #!/usr/bin/ruby
# Google Code Jam 2017 Qualification Round
# Problem B. Tidy Numbers
T = STDIN.gets.to_i
(1..T).each do |t|
n = STDIN.gets.to_i
ans = 1
(1..n).each do |i|
ans = i if i.to_s.split('').sort.join('').to_i == i
end
puts "Case ##{t}: #{ans}"
end
| true |
a0bd28ac9b365969442b92dd52e9d070e47972cd | Ruby | golo-lang/golo-jmh-benchmarks | /src/main/resources/snippets/jruby/fibonacci.rb | UTF-8 | 73 | 3.21875 | 3 | [
"Apache-2.0"
] | permissive | def fib(n)
if n <= 2
1
else
fib(n - 1) + fib(n - 2)
end
end | true |
b6708d6c0305628ff3fc8e35746c1d0cd3eb8e6d | Ruby | benhawker/learn_to_program | /ch09-writing-your-own-methods/old_school_roman_numerals.rb | UTF-8 | 443 | 3.5625 | 4 | [] | no_license | def old_roman_numeral number
numbers = [1000,500, 100, 50, 10, 5, 1]
numerals = ["M", "D", "C", "L", "X", "V", "I"]
roman_numeral = " "
x = 0
while x <= 6
while number >= numbers[x]
number = number - numbers[x]
roman_numeral = roman_numeral + numerals[x]
end
x = x + 1
end
rom... | true |
936a8d6fc6cf825e3e2812453568641b85a1cdf3 | Ruby | mbburch/chisel | /ordered_list_parser_test.rb | UTF-8 | 2,017 | 3.015625 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './ordered_list_parser'
class OrderedListParserTest < Minitest::Test
def test_it_correctly_recognizes_an_ordered_list
ordered = OrderedListParser.new("1. Sushi\n2. Barbeque\n3. Mexican")
expected = true
result = ordered.ordered_list?
assert... | true |
0f9623a8d7bb05b1a81424b832d8e0ce8f0a2f87 | Ruby | kehlynch/kr-rails | /app/presenters/bids/bids_presenter.rb | UTF-8 | 978 | 2.578125 | 3 | [] | no_license | class Bids::BidsPresenter < Bids::BidsBasePresenter
def self.names_for(bids)
bids.map do |bid|
Bids::BidPresenter.new(bid.slug).name
end
end
private
def stage
Stage::BID
end
def finished?
Stage.finished?(@game, Stage::BID)
end
def finished_message
"#{@game.declarer.name} wi... | true |
13e9f5b2bb3863066ed2ed26c0a7f3281b146f00 | Ruby | BioInterchange/BioInterchange | /lib/biointerchange/registry.rb | UTF-8 | 2,138 | 2.921875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module BioInterchange
# A registry of Reader and Writer subclasses that also keeps track which
# Reader/Writer combinations can be used together. The registry makes it
# possible to implement readers and writers without the need to modify
# other BioInterchange framework code.
class Registry
def self.register_reade... | true |
5f51371ca9f4d50532bed72f4a6a4a77031dc7ee | Ruby | alexwebgr/shopping_cart | /app/printer.rb | UTF-8 | 499 | 3.296875 | 3 | [] | no_license | class Printer
attr_reader :cart
def initialize(items)
@cart = ShoppingCart.new(items)
end
def print_receipt
return 'No items' if cart.empty_cart?
[
print_items,
print_total_tax,
print_total
].join(' ')
end
private
def print_items
cart.list_items.map { |item| "#{it... | true |
cd611510c10298045e8f6d61e11355db538675e0 | Ruby | deeseert/oxford-comma-london-web-career-031119 | /lib/oxford_comma.rb | UTF-8 | 362 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(array)
if array.length == 1
simp_arr = ""
simp_arr << array.join(", ")
return simp_arr
elsif array.length == 2
two_arr = ""
two_arr << array.join(" and ")
return two_arr
elsif array.length >= 3
empty_arr = ""
empty_arr << [array[0...-1].join(", "), array.last].join... | true |
7b90da2a29c849ef17a9158f8641f8fdbb936877 | Ruby | echo1006/gitfile | /TEST IOS UIAutomation/09-Stubbing/step05/bin/rubygems/tilt-1.3.3/lib/tilt/rdoc.rb | UTF-8 | 1,132 | 2.53125 | 3 | [] | no_license | #---
# Excerpted from "Test iOS Apps with UI Automation",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# ... | true |
0b005026b57add7385e1aa7c6ddaf25cf492f723 | Ruby | Elronia/Mod3_Project_Gallery_Rails_Backend | /db/paintings_image/file_system_script.rb | UTF-8 | 933 | 3.03125 | 3 | [] | no_license | require 'fileutils'
require 'csv'
#shift off the first element to get rid of the column names
def parse_csv_file
csv_data = CSV.read("../artists_for_seed_data.csv")
csv_data.shift
# iterate over each element and send back a hash
# need to shift again at the beginning to get rid of id on the row
pain... | true |
cd812bea66f76bdc4a827501d4e34fe1ad499d81 | Ruby | Vterebenin/Tea-time-with-ruby | /patterns/Command.rb | UTF-8 | 6,212 | 3.15625 | 3 | [] | no_license | =begin
Описание:
Есть какой то объект с которым производятся манипуляции.
Нужно предоставить функционал ставить действия по манипуляции в очередь,
логировать их или откатывать. В таких случаях полезен паттерн Команда так как
он превращает операцию в самостоятельный объект.
Пример задачи:
Приложение по манипу... | true |
1d81732e8bfb30bbb98835dbc35a227c5d9123a6 | Ruby | leahwho/slack-cli | /lib/workspace.rb | UTF-8 | 1,431 | 2.921875 | 3 | [] | no_license | require 'httparty'
require_relative 'user'
require_relative 'channel'
class Workspace
attr_reader :users, :channels, :selected
def initialize
@users = User.list_users
@channels = Channel.list_channels
@selected = nil
end
def select_channel(user_channel)
if channels.find { |channel| c... | true |
bb96ca72047d0e5086cdcc8c0a7476892075edb5 | Ruby | Apmyp/pricewatcher_bot | /app/services/links/attach_link_item.rb | UTF-8 | 760 | 2.546875 | 3 | [] | no_license | # frozen_string_literal: true
module Links
class AttachLinkItem
def self.call(*args)
new.call(*args)
end
def call(link, parser_item)
ActiveRecord::Base.transaction do
reset_active_status(link)
attach_link_item(link, parser_item)
end
end
private
def reset_a... | true |
6cdc76b5251e968cf8fee4d2e7ee73623b0700e6 | Ruby | orderedlist/solidus | /core/app/models/spree/calculator/returns/default_refund_amount.rb | UTF-8 | 1,117 | 2.53125 | 3 | [
"BSD-3-Clause"
] | permissive | require_dependency 'spree/calculator'
require_dependency 'spree/returns_calculator'
module Spree
module Calculator::Returns
class DefaultRefundAmount < ReturnsCalculator
def compute(return_item)
return 0.0.to_d if return_item.part_of_exchange?
weighted_order_adjustment_amount(return_item.in... | true |
55ca544e6fc7d70a7310cd844379049c788a8bcc | Ruby | kbehnfeldt/ruby_intro_book_exercises | /flow_control/true_false.rb | UTF-8 | 75 | 3.125 | 3 | [] | no_license | a = 0
if a then puts "how can this be true?"
else puts "it is not true"
end | true |
d1fedaec529f102c4cd452dec414549018ed5627 | Ruby | RGolun/Ruby | /spec/1.NWD/NWD_spec.rb | UTF-8 | 378 | 2.609375 | 3 | [] | no_license | require 'rspec'
require_relative 'NWD'
describe '#NWD' do
it 'nalezy definiowac' do
expect { NWD(190,52) }.not_to raise_error
end
it 'Te testy powinny byc poprawne' do
expect(NWD(26,26)).to eq(26)
end
it 'Te testy nie powinny być poprawne' do
expect(NWD(19,26)).not_to eq(25)
end
it 'Nietypowa... | true |
4f5403426099a76c6e786fd12834aa7e493c70fa | Ruby | grzesiek/git_compound | /lib/git_compound/repository/remote_file/git_archive_strategy.rb | UTF-8 | 754 | 2.515625 | 3 | [
"MIT"
] | permissive | module GitCompound
module Repository
class RemoteFile
# Git archive strategy
#
class GitArchiveStrategy < RemoteFileStrategy
def initialize(source, ref, file)
super
opts = "--format=tar --remote=#{@source} #{@ref} -- #{@file} | tar -O -xf -"
@command = GitCo... | true |
4910d153410d2739bb1e1740a9a3ab1ab3802102 | Ruby | Alex808r/game_black_jack | /hand.rb | UTF-8 | 727 | 3.25 | 3 | [] | no_license | # frozen_string_literal: true
class Hand
attr_accessor :scores, :cards, :total_scores
def initialize
@cards = []
end
def clear_hand
@cards.clear
end
def get_card(card)
@cards.push(card)
end
def scores
total_scores = 0
without_aces = @cards.reject { |card| card.rank == 'A' }
... | true |
b179f793dd911197e73aa4c96bdbbbfb9c1adf3a | Ruby | cedange32/rails-longest-word-game | /app/controllers/games_controller.rb | UTF-8 | 813 | 3.171875 | 3 | [] | no_license | require 'json'
require 'open-uri'
class GamesController < ApplicationController
def new
@letters = []
r = Random.new
10.times do
@letters << r.rand(65..90).chr
end
# raise
end
def score
@word = params[:word]
@letters = params[:letters]
if word_not_in_the_grid?(@word, @lette... | true |
5001b5ece03e3e228633d8dea61e7b67005ca6b8 | Ruby | calculist/calculist-web | /app/services/item_stats_manager.rb | UTF-8 | 1,219 | 2.671875 | 3 | [
"MIT"
] | permissive | class ItemStatsManager
def self.get_item_count_histogram_data(start_date, end_date = nil)
end_date ||= start_date + 1.day
format = '%Y-%m-%d 00:00:00'
start_date_string = start_date.strftime(format)
end_date_string = end_date.strftime(format)
query = "
select
count(*) as items_creat... | true |
3fb9bc42f90099922915a12b30169257fa58bdf6 | Ruby | manchester-codejo/Codejo8-TDD-as-CI | /src/Money.rb | UTF-8 | 103 | 3.046875 | 3 | [] | no_license | class Money
attr_reader :amount
def initialize(parameters)
@amount = parameters[:amount]
end
end | true |
aaff512befd4053f6ddadc96ed7eda4b52d5bbb0 | Ruby | dlethcoe/Progress | /dbinspect.rb | UTF-8 | 618 | 3.015625 | 3 | [] | no_license | require 'sequel'
#used to check my data base information if I have some errors can test to see if data behaves properly
DB = Sequel.sqlite('blog.db')
test =DB[:blogdata]
data = test.where[:id => 1] #data = test.first
#data = test.map([:title, :content, :date])
puts data.inspect
text = data[:title]
puts text #tets to... | true |
936246e02a338e916c7b530811fa9772e858689b | Ruby | steph089/card-games | /FTD.rb | UTF-8 | 2,715 | 3.140625 | 3 | [] | no_license | class FTD
DEALER_DRINKS = 5
MAX_GETS = 3
MAX_GUESSES = 2
attr_accessor :table, :deck, :players
attr_reader :complete, :gets, :guess_count
def initialize
start_fresh
end
def start_fresh
@deck = Deck.new
@deck.add_deck
@deck.shuffle
@table = Deck.new
@players = Player_Bench.new
... | true |
d86b05a0a33ab6d152be479926e5178bf3ac3dd2 | Ruby | iroshiva/airbnb_rails | /db/seeds.rb | UTF-8 | 1,333 | 2.734375 | 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 |
f4b98f62b2cd20fff2597500e6d25590b30eecbf | Ruby | ehawk823/prework-ruby-assessment-web-0715-public | /lib/004_object_orientation.rb | UTF-8 | 633 | 3.546875 | 4 | [] | no_license | #Class Methods
class School
@@instances = []
@@count = 0
attr_accessor :name, :school, :location, :students, :instructors
attr_reader :ranking
def initialize (name, location, ranking)
@name = name
@location = location
@ranking = ranking
@students = []
@instructors = []
@@instances << self
@@c... | true |
812894dbb43f86a4c29e8c3138fa7f6a62f8660d | Ruby | cha63506/ruby-archipel-api | /lib/archipel/api/vm/vm_info.rb | UTF-8 | 1,073 | 3 | 3 | [
"MIT"
] | permissive | require 'ostruct'
require 'active_support/core_ext/numeric/bytes'
class VmInfo
class State
attr_accessor :value, :name
@@index = {}
def initialize value, name
@value, @name = value, name
@@index[value] = self
end
STARTED = new 1, 'started'
STOPPED = new 5, 'stopped'
class ... | true |
76fa0f8e7b9cf26391a835663113c9f0b26c3fd5 | Ruby | jvans1/swaptrack | /spec/models/swap_spec.rb | UTF-8 | 1,850 | 3 | 3 | [] | no_license | require 'spec_helper'
describe Swap do
before :each do
@u = create(:user)
@u1 = create(:user)
@p = create(:prize)
@p1 = create(:prize)
@s1 = create(:swap,:user=>@u1, :receiver=> @u, :receiver_prize=> create(:prize), :user_prize=> create(:prize))
@s2 = create(:swap, :user=>@u, :receiver=> @u, ... | true |
b9c7b33d491ef21ef2440d438456a13140519677 | Ruby | watermarkchurch/wcc-contentful | /wcc-contentful/lib/wcc/contentful/simple_client/response.rb | UTF-8 | 4,541 | 2.59375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative '../instrumentation'
class WCC::Contentful::SimpleClient
class Response
include ::WCC::Contentful::Instrumentation
attr_reader :raw_response, :client, :request
delegate :status, to: :raw_response
alias_method :code, :status
delegate :headers, to: ... | true |
37cddc894a2a0e4d928cb3397f7150daf9afe5ae | Ruby | fog/fog-aws | /tests/requests/storage/acl_utils_tests.rb | UTF-8 | 9,217 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'fog/aws/requests/storage/acl_utils'
Shindo.tests('Fog::AWS::Storage | ACL utils', ["aws"]) do
tests(".hash_to_acl") do
tests(".hash_to_acl({}) at xpath //AccessControlPolicy").returns("", "has an empty AccessControlPolicy") do
xml = Fog::AWS::Storage.hash_to_acl({})
Nokogiri::XML(xml).xpath(... | true |
403d022f4b94c7b1300bbe10584654ed29a0be8b | Ruby | brettbuller/phase-0-tracks | /ruby/alias_manager.rb | UTF-8 | 1,157 | 4.03125 | 4 | [] | no_license |
# take a name as a string.
# make it an array and split the two names
# create a new string with the first name and the last name
# make them all lower case
# change the vowels and the consonants to the next one. save as new string
# join the two together as new string
# print the new alias
puts "we need to... | true |
da3ad0e971b01a72f70a9572078c28804e2e64bb | Ruby | nathanworden/RB130-Ruby-Foundations-More-Topics | /05.Ruby Foundations More Topics Small Problems/02.easy2/05.drop_while.rb | UTF-8 | 1,444 | 4.78125 | 5 | [] | no_license | # Problem
# Write a method called drop_while that takes an array as an argument, and a block. It should return all the elements of the Array, except those elements at the beginning of the Array that produce a truthy value when passed to the block.
# Algorithm
# Define a method which takes an array
# initialize an em... | true |
cf075d8e6fe3e9ea3d43df578493ba6fd91b570c | Ruby | jon-proulx/alphasign | /lib/alphasign.rb | UTF-8 | 4,488 | 2.96875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class AlphaSign
# Require 'serialport' gem
require 'serialport'
#We have a relatively large number of potocol and formatting constants
require 'alphasign/protocol'
require 'alphasign/format'
include AlphaSign::Protocol
include AlphaSign::Format
# @param [String] device the serial device the sign is ... | true |
e9d76ca6a59c815e88a9bfe6b865f12dec7bae34 | Ruby | tenesami/square_array-onl01-seng-ft-061520 | /square_array.rb | UTF-8 | 101 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
n = []
array.each do |numbers|
n << numbers **2
end
n
end
| true |
1833b3dc42bbb8bcb93ce487758e169ed5c17639 | Ruby | chibakoo0130/CourseManagement-rb | /app/models/course_create_form.rb | UTF-8 | 795 | 2.75 | 3 | [] | no_license | class CourseCreateForm
include ActiveModel::Model
attr_accessor :course_no, :course_name, :the_date, :year, :month, :date,
:start_time, :start_hour, :start_minute,
:end_time, :end_hour, :end_minute, :capacity
validates :course_no, presence: true, length: { maximum: 4 }
validates :c... | true |
38779ef2ab163186ea571a1e6637866ae1ffe123 | Ruby | vbrazo/algorithms-archives | /arrays/is_strobogrammatic.rb | UTF-8 | 1,841 | 4.34375 | 4 | [] | no_license | # Given a string num which represents an integer, return true if num is a strobogrammatic number.
#
# A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).
#
# Example 1:
#
# Input: num = "69"
# Output: true
#
# Example 2:
#
# Input: num = "88"
# Output: true
#
# Exa... | true |
b9e2b0ce6995c35261570e46ec542019ad6f23ee | Ruby | hyphenized/c2-module2 | /week-2/day-1/two_fer.rb | UTF-8 | 157 | 3.765625 | 4 | [] | no_license | def two_fer(name: "you")
puts "One for #{name}, one for me."
end
print "who? "
name = gets.strip.capitalize
name.empty ? two_fer() : two_fer(name)
| true |
ba5ec66d3683133d7678212be267ebc205645b95 | Ruby | TheWildParamecium/Biomodules | /MachineLearning/MachineLearning.rb | UTF-8 | 2,106 | 3.96875 | 4 | [] | no_license | #K-Nearest Neighbor Algorithm. It classifies new data according to the k_number of nearest neighbors points.
#Parameters are the following:
#-training is an array of arrays with each subarray being a data (with all of his numeric variables) and the last
#item in the array being the response/category;
#-prediction i... | true |
2948053e310329752fed05c498eb794d9ef7cadb | Ruby | MrBadge/Project | /app/models/g_answer.rb | UTF-8 | 14,016 | 2.640625 | 3 | [] | no_license | #coding: utf-8
class GAnswer < ActiveRecord::Base
belongs_to :task
Not_name = ["C", "Н", "ВС", "П"]
Question = "Предложение типа вопрос"
Order = "Предложение типа команда"
Message = "Предложение типа сообщение"
G = "G"
def exist_pairs(first, second)
flag = true
first.each do |line_in_first|
... | true |
856dcfe10c0cc0223bad14d6bf4df288bd32b118 | Ruby | miros/new_albums | /lib/last_fm.rb | UTF-8 | 2,910 | 2.71875 | 3 | [] | no_license | require 'rubygems'
require 'net/http'
require 'cgi'
require 'uri'
require 'pp'
require 'ap'
require 'json'
class LastFm
class LastFmException < Exception; end
def initialize(api_key, proxy = nil)
@api_key = api_key
@proxy = proxy
end
API_URL = "http://ws.audioscrobbler.com/2.0/"
ERROR_LIBRARY_NO_... | true |
43814583717755b72f2003f687aaf511fb1cb39b | Ruby | StephenVNelson/Auto-Ad-Post | /Building.rb | UTF-8 | 974 | 3.03125 | 3 | [] | no_license | require_relative 'Company'
require_relative 'ApartmentRanking'
class Building < Company
include ApartmentRanking
attr_reader :name, :apartments, :amenities, :city, :zip_code, :cross_street_1, :cross_street_2, :close_to, :distance_to_UCLA, :state, :address
attr_accessor :company
def initialize(name:... | true |
eda0ba7024970a5aa89a5b611806d4459c473582 | Ruby | SebastianSzturo/jp_post | /lib/jp_post/tracking.rb | UTF-8 | 2,618 | 2.890625 | 3 | [
"MIT"
] | permissive | require "open-uri"
require "nokogiri"
require "chronic"
module JpPost
class Tracking
# Create a new Tracking object.
#
# tracking_number - tracking number of the package to lookup.
#
# Returns an instance of JpPost::Tracking.
def initialize(tracking_number)
raise ArgumentError unless tr... | true |
5bd5ad98417250e2d8c1ba8726ff6a331c859eec | Ruby | wanfamilia/arcticbots | /spec/component_spec.rb | UTF-8 | 2,694 | 2.890625 | 3 | [] | no_license | require_relative '../poro/component'
describe Component do
let(:component) {Component.new}
describe 'component_for' do
it 'ape sinew' do
expect(component.component_for 'As the usefulness of cured ape sinew ends, it suddenly disappears.').to eq 'cured ape sinew'
end
it 'musk gland' do
... | true |
029b22fe2e3e688a91282ad76b2eeec7c6d40167 | Ruby | Jwarholic/phase-0-tracks | /ruby/puppy_methods.rb | UTF-8 | 833 | 4.15625 | 4 | [] | no_license | class Puppy
def initialize
puts "Initializing new puppy instance ..."
end
def fetch(toy)
puts "I brought back the #{toy}!"
toy
end
def speak(n)
(1..n).each {puts "Woof!"}
end
def roll_over
puts "roll over"
end
def dog_years(n)
n = n * 10
n
end
def jump(n)
puts "The dog jumped #{n} time... | true |
1b4b08e0faea3c69f50f24c71f2b865fbe522e3c | Ruby | ochlupin/ruby-collaborating-objects-lab-nyc-web-100818 | /lib/mp3_importer.rb | UTF-8 | 859 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MP3Importer
attr_accessor :path
def initialize(path)
@path = path
end
# load mp3s from a directory and removes the directory path, using Dir.glob to check directory with specified path and file extension and collect to store them into a new array
def files
Dir.glob("#{path}/*.mp3").collect do
... | true |
491da2d4e5f673466c284a79a4665700f05d952c | Ruby | doctordeep/arachni | /plugins/beep_notify.rb | UTF-8 | 1,413 | 2.53125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | =begin
Copyright 2010-2014 Tasos Laskos <tasos.laskos@gmail.com>
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 requi... | true |
ae831a2cc163c8a421eb2ec68be290b681b32601 | Ruby | nofxx/run-a-log | /ral/model/Container.rb | UTF-8 | 8,039 | 2.9375 | 3 | [] | no_license | class Container
require "Timestamp.rb"
attr_accessor :_timestamps
$allowed_container_data=[
:filename,
:start,
:end,
:comment,
:weather,
:distance,
:duration,
:speed_avg,
:speed_max,
:elevation,
:hr_max,
:hr_avg
]
def initialize
@_data = Hash.n... | true |
3b8f2012eaf4c08c61c4ecddb0fcf1d7d9ad4c10 | Ruby | ghaki/ghaki-app | /lib/ghaki/app/mixable.rb | UTF-8 | 1,781 | 2.671875 | 3 | [
"MIT"
] | permissive | module Ghaki #:nodoc:
module App #:nodoc:
module Mixable #:nodoc:
# ==== Examples
#
# require 'ghaki/app/plugin'
# require 'ghaki/app/mixer'
#
# class Duck
# attr_accessor :quack
# end
#
# class DuckApp < Ghaki::App::Plugin
# app_plugin_accessor Duck, :... | true |
2e3c3cbfa31e2e546edacf1f9e6e526733eaeb49 | Ruby | hasandeveloper/advanced-ruby | /combination-of-comprehensive-and-advance-ruby-from-udemy-handpicked-ruby-practice/01-boolean-conditions/then_condtional_statement.rb | UTF-8 | 118 | 3.125 | 3 | [] | no_license | x = 5
y = 20
# if x == 5 then y = 25 end
# p y
if x == 10 then y = 35
elsif x == 12 then y = 8
else y = 30
end
p y | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.