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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ac461daa82d6ea9b2c01997f7ca63a7c870472a0 | Ruby | hussyvel/ruby | /VideoAulaOreally/default_or_Optional_Parameters.rb | UTF-8 | 192 | 2.75 | 3 | [] | no_license | # frozen_string_literal: true
def make_phone_call(number, international_code = 1, area_code = 646)
puts "Calling #{international_code}-#{area_code}-#{number}"
end
make_phone_call(123_456)
| true |
7e2d0104ff5cbfa036d4fa56494c15107267b0d7 | Ruby | vidyasagarpogiri/Scheduler | /lib/employee.rb | UTF-8 | 508 | 3.234375 | 3 | [] | no_license | class Employee
#for now, the employees will just be a .txt file, separated by columns
def load_employees
employees = []
path = "employees.txt"
fd = File.open(path, "r")
fd.each_line do |line|
emp = {}
a = line.split
name = a[0]
emp[:name] = name
emp[:mon] = a[1]
e... | true |
b9420621173032bb05e34b404721ceb621addd3f | Ruby | MIKEALGEE/Homework_week2_day2 | /spec/fish_class_spec.rb | UTF-8 | 300 | 2.625 | 3 | [] | no_license | require_relative("../fish_class.rb")
require("minitest/rg")
require("minitest/autorun")
class FishTest < MiniTest::Test
def setup
@fish = Fish.new("Sir Swims Alot")
end
def test_make_fish() #checks to see if the class is set up properly
assert_equal(Fish,@fish.class())
end
end
| true |
ce7c0d786563cab52af214986c811f764db8abfb | Ruby | IamIpanda/DataEditor | /DataEditor.Arce/bin/Debug/Tests/DrawLine.rb | UTF-8 | 575 | 3.109375 | 3 | [] | no_license | class Bitmap
# 直线: ax + by + c = 0
# 起点与终点: x1,x2
# 宽度:d
# 颜色:color
def draw_line_base(a,b,c,x1,x2,d,color)
# 约定: |k| < 1
t = Math.sqrt(a * a + b * b)
wy = d / t * y
dy = (wy / 2).ceil
for x in x1..x2
y = ((-c - a * x) / b).round
for j in (y-dy)..(y+dy)
dis = distance(a,b,c,x+0.5,y... | true |
ddbfad5c5648cf655c9d25837584b6b612be2444 | Ruby | cmaher92/launch_school | /coursework/books/intro_to_programming/review/number_checker.rb | UTF-8 | 442 | 4.5 | 4 | [] | no_license | # program
# takes a number from the user between 0 and 100
# lets user know if the number is beween 0 and 50, 51 and 100, or above 100
puts ">> Please enter a number"
num = gets.chomp.to_i
case
when num < 50 && num > 0 then puts "you entered a number between 0 and 50"
when num >= 50 && num <= 100 then puts "you e... | true |
839e5f4241f43d802ce31a4097ede08151765b16 | Ruby | smcintosh/bee | /lib/bee/loader/Loader.rb | UTF-8 | 915 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'logger'
module Bee
class Loader
include LogUtils
def initialize(fname, config)
beedb = config.get(:beedb)
@writer = beedb ?
Bee.const_get(config.get(:writer)).new(beedb) :
Bee.const_get(config.get(:writer)).new
@fname = fname
@config = config
@logger =... | true |
d4ef6adcd2caf597d4812ce3f8dc2c1d12b58a8a | Ruby | linkworks/invoices | /test/unit/invoice_test.rb | UTF-8 | 2,133 | 2.640625 | 3 | [] | no_license | require 'test_helper'
class InvoiceTest < ActiveSupport::TestCase
setup do
@invoice = {
:terms => 'Phasellus molestie magna non est bibendum non venenatis nisl tempor. Suspendisse dictum feugiat nisl ut dapibus. Mauris iaculis porttitor.',
:notes => 'Phasellus molestie magna non est bibendum non vene... | true |
9479dffc0a679b12319fec75db5cd175c1bd9cd5 | Ruby | MrFreeman13/bitmap_editor | /lib/commands/command_error.rb | UTF-8 | 215 | 2.75 | 3 | [] | no_license | module Commands
class CommandError < StandardError
attr_reader :exec_line
def initialize(msg='Command Error', line)
@exec_line = line
super("#{msg} in line: '#{exec_line}'")
end
end
end
| true |
8d84878889e33aadb41f59403b3872eaa9cc2b46 | Ruby | dcrosby42/galaga | /lib/hud.rb | UTF-8 | 1,355 | 2.765625 | 3 | [] | no_license | module Galaga
def new_hud
{
player_blink_state: true,
player_name: "",
player_score: 0,
player_reserve_ships: 0,
stage: 0,
high_score: 0,
credits: 0,
show_credits: true,
}
end
def update_hud(state, input)
hud = state.hud
hud.player_name = "#{state.p... | true |
47985a008f29824ac87972b7b573fc0190b124cd | Ruby | armandolew/bedsonline | /lib/bedsonline.rb | UTF-8 | 6,086 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'bedsonline/version'
require 'bedsonline/hotel_service'
require 'bedsonline/purchase'
require 'bedsonline/pagination_data'
require 'bedsonline/response_error'
require 'ostruct'
require 'httparty'
require 'uri'
require 'nokogiri'
module Bedsonline
class Client
include HTTParty
base_uri 'https://testap... | true |
cebc738a93cdef208d2f455d77f97f705cb5ce3c | Ruby | kellysomerville/phase-0-tracks | /ruby/shout_fiddler_crabs.rb | UTF-8 | 1,589 | 3.640625 | 4 | [] | no_license | module Yell
def scream(yell)
puts "Holy shit she can ......#{yell}"
end
end
class Grandma
include Yell
end
class School_teacher
include Yell
end
grandma = Grandma.new
grandma.scream('WHAT DID YOU SAAAAYYYYY! ')
school_teacher = School_teacher.new
school_teacher.scream(' SIT DOWN AND SHU... | true |
290720f0f508475471e81f624c4097d7de3926ff | Ruby | clreddy21/Laundry-Services | /app/helpers/status_helper.rb | UTF-8 | 461 | 2.59375 | 3 | [] | no_license | module StatusHelper
def alternate_statuses(user)
alternate_statuses = []
if user.status == 'active'
alternate_statuses = ['Blacklist', 'Suspend']
elsif user.status == 'balcklisted'
alternate_statuses = ['Activate', 'Suspend']
elsif user.status == 'suspended'
alternate_statuse... | true |
0fcf6ca79a0b44d124b1a99b10c64232a9410689 | Ruby | nasa/GMSEC_API | /ruby/gmsec5/dox/TimeUtil.rb | UTF-8 | 3,411 | 3.171875 | 3 | [] | no_license | # Copyright 2007-2023 United States Government as represented by the
# Administrator of The National Aeronautics and Space Administration.
# No copyright is claimed in the United States under Title 17, U.S. Code.
# All Rights Reserved.
# This file is used for generating Ruby documentation; it only contains
# stubs of ... | true |
5df1f277a925d45ad729605e772035a5a7e0f035 | Ruby | MIPT-ILab/cpp-lects-rus | /other_lects/informatics/code/greedy/testgens/schedule_intervals_gentest.rb | UTF-8 | 1,636 | 2.96875 | 3 | [] | no_license | #!/usr/bin/ruby
# test generator
# idea of generation:
ARGV << '-h' if ARGV.empty?
require 'optparse'
require 'ostruct'
def random_int(min, max)
rand(max - min) + min
end
# --- options parser ---
options = OpenStruct.new
options.findex = "001"
options.maxintv = 10
options.maxlen = 10
options.lenall = 20
opt... | true |
993f495a4e7e3266381666792f1fa7be4e42d57d | Ruby | 4xposed/Challenges | /Maths/01-Fibonacci-Sequence/solutions/jaeming-fibonacci.rb | UTF-8 | 479 | 3.875 | 4 | [] | no_license | def fibonacci
p "Enter a number and I'll compute the fibonacci sequence up to that number:"
num_input = gets.to_i
n1 = 0
n2 = 1
sum = 0
ary = []
while below_input?(sum, num_input)
ary << n1 if below_input?(n1, num_input)
ary << n2 if below_input?(n2, num_input)
sum = n1 + n2
ary << sum if... | true |
7afc4c9c648daa7d6b950a117a8af14d4aed5c4d | Ruby | MarkOates/fullscore | /.removed/maker/test/chromatic/lily_converter_test.rb | UTF-8 | 5,535 | 2.84375 | 3 | [] | no_license | require_relative '../../lib/chromatic/lily_converter'
require_relative '../test_helper'
require 'ostruct'
module Chromatic
class LilyConverterTest < Minitest::Test
class NoteWithPitches
attr_reader :pitches
def initialize(pitches: 3)
@pitches = pitches
end
end
class NoteWithA... | true |
af0597d204b078addb5f8631892e4efd588a9ce9 | Ruby | shortthirdman/code-eval-challenges | /moderate/flavius_josephus.rb | UTF-8 | 446 | 3.15625 | 3 | [
"MIT"
] | permissive | Node = Struct.new(:value, :next)
def list_push(value, node)
Node.new(value, node)
end
File.open(ARGV[0]).each_line do |line|
n, m = line.split(',').map(&:to_i)
tail = Node.new(n - 1, nil)
list = tail
(n - 2).step(0, -1) { |x| list = list_push(x, list) }
tail.next = list
list = tail
s = []
n.times d... | true |
3e1aa894ef20d6e7607a6b505e6069a8e244b5e7 | Ruby | kjjgibson/Eper-su-Rcrets-e-Ocoderen | /spec/lib/eper-su-rcrets-e-ocoderen_spec.rb | UTF-8 | 3,142 | 2.796875 | 3 | [] | no_license | require 'eper-su-rcrets-e-ocoderen'
require 'support/eper_shared_examples'
describe 'encoding' do
let(:seed) { 1 }
let(:fake_word_frequency) { 3 }
let(:encoder) { EperSuRcretsEOcoderen.new(seed, fake_word_frequency) }
describe 'a whole sentence' do
context 'a large sentence' do
let(:phrase) { "This i... | true |
c361121e0a608ecd64a683cc9c338899b1401670 | Ruby | cpjobling/proman_mmxii | /spec/models/user_spec.rb | UTF-8 | 10,821 | 2.578125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | require 'spec_helper'
describe User do
before(:each) do
@attr = {
:email => "hector.somebody@swansea.ac.uk",
:password => "foobar",
:password_confirmation => "foobar",
:first_name => "Test",
:last_name => "Tester"
}
end
# User name and email validations (see Chapter 6)
i... | true |
a944bdf12e96442fafe23de62e2faaa73c729038 | Ruby | HishamElmorsi7/word_chain | /word_chain.rb | UTF-8 | 1,303 | 3.578125 | 4 | [] | no_license | # require "byebug"
class Word_chainer
DICTIONARY = 'dictionary.txt'
WORDS = File.readlines(DICTIONARY).map { |word| word.chomp }
def initialize(starting_word, ending_word)
@starting_word = starting_word
@ending_word = ending_word
@chain_word = starting_word
@length = startin... | true |
772d1ebeb9adb34b236268d7b8f9d6a6c4ac9816 | Ruby | castor4bit/leetcode | /0200/231.Power_of_Two/test_231.rb | UTF-8 | 432 | 2.78125 | 3 | [] | no_license | require 'test/unit'
require './231'
class LeetCodeSolutionTest < Test::Unit::TestCase
def test_231
assert_equal true, is_power_of_two(1)
assert_equal true, is_power_of_two(8)
assert_equal true, is_power_of_two(16)
assert_equal false, is_power_of_two(218)
assert_equal false, is_power_of_two(50000... | true |
5fd1747c818be67bc1ecec06c11685bdaad74bec | Ruby | hermesalexis/ruby | /test.rb | UTF-8 | 2,861 | 3.671875 | 4 | [] | no_license | #puts "Me gusta" + " El pastel de manzana"
#puts "parpadeo " * 4
#puts 12 + 12
#puts "12" + "12"
#puts "12 + 12"
#puts "12" + 12
#puts "2" * "5"
#puts 'Mi nombre es "HERMES"'
#myString = "..Puedes decir eso de nuevo"
#puts myString
#puts myString
#name = 'Patricia Roxana Jesica Alexandra'
#puts 'M... | true |
6c9e1d9aecfe59bfedd9e0b4637e04cb3cabf326 | Ruby | louisbemberg/batch-658-lausanne | /reboot-jour-1/3-instacart/instacart_pseudocode.rb | UTF-8 | 752 | 3.3125 | 3 | [] | no_license | # créer une (constante) hash du magasin (prix, article)
# créer un shopping cart / panuier (array?)
# WELCOME MESSAGE
#hello
# créer variable qui permet d'entrer dans le loop (nil)
# LOOP COMMENCE ICI "jusqu'à ce qu'on me dise 'quit'"
# message pour dire ce qu'il y a dans le store
# itérer sur le hash pour montrer... | true |
b59f2ab9da716cd70671d6327de66177b4a3904f | Ruby | bTspm/stock-track | /lib/core_ext/string.rb | UTF-8 | 335 | 2.828125 | 3 | [
"MIT"
] | permissive | class String
def to_float
return if blank?
delete(',').scan(/[+-]?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?/)&.first&.to_f
end
def to_integer
return if blank?
scan(/\d/).join.to_i
end
def to_floats
return if blank?
delete(',').scan(/[+-]?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?/).map(&:to_fl... | true |
9f5ef221ceda11afb21825b579cdefacba491d24 | Ruby | yoda-yoda/ruby-dive-in | /prime.rb | UTF-8 | 327 | 3.78125 | 4 | [
"MIT"
] | permissive | def is_prime(x)
if x == 1
return false
end
if (x % 2) == 0
return (x == 2)
end
start = 3
while (start * start) <= x
if (x % start) == 0
return false
end
start += 2
end
return true
end
x = 1
while x <= 20
if is_prime(x)
print x
puts " is prime"
x = x.next
end
x = x.next
end
puts is_p... | true |
1e8beaaa8bc98aaf530dd29c4c554bb80f43075b | Ruby | welaika/wordmove | /lib/wordmove/guardian.rb | UTF-8 | 1,027 | 2.65625 | 3 | [
"MIT"
] | permissive | module Wordmove
class Guardian
attr_reader :movefile, :environment, :action, :logger
def initialize(options: nil, action: nil)
@movefile = Wordmove::Movefile.new(options[:config])
@environment = @movefile.environment(options).to_sym
@action = action
@logger = Logger.new(STDOUT).tap { ... | true |
b265f6af4430513bd4cd976dfef83bf9f3b11dff | Ruby | whychooseaname/sinatra-basic-routes-lab-atx01-seng-ft-082420 | /app.rb | UTF-8 | 328 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative 'config/environment'
class App < Sinatra::Base
get '/' do
"Hello, World!"
end
get '/name' do
"My name is Eddie"
end
get '/hometown' do
"My hometown is Chino Hills"
end
get '/favorite-song' do
"My favorite song is 'Breaking the Habit'"
... | true |
dc9cf00d1e69feacb75e5d8e4d6d1d836483c55f | Ruby | zverok/bloxl | /examples/02-2tables.rb | UTF-8 | 843 | 2.828125 | 3 | [] | no_license | require 'bundler/setup'
$:.unshift 'lib'
require 'bloxl'
MARKS1 = [
%w[A F B+],
%w[B+ C- D+],
%w[A- A B+]
]
MARKS2 = [
%w[D+ B- A ],
%w[B+ A C+],
%w[A- B A-]
]
STUDENTS = ['Bob', 'Ann', 'Kate']
CLASSES = ['Math', 'Phisics', 'Art']
BloXL.open('examples/output/2tables.xlsx') do |b|
b.bar{
b.st... | true |
d4c4b053be6ba1bbce14bafe2920c3a92071eb72 | Ruby | poshea48/Launch-School-Exercises | /course_101/lesson_3/Easy_2.rb | UTF-8 | 1,551 | 3.40625 | 3 | [] | no_license | # #1.
# ages = { "Herman" => 32, "Lily" => 30, "Grandpa" => 402, "Eddie" => 10 }
# p ages.include?('Spot')
# p ages.has_key?('Spot')
# p ages.key?('Spot')
#2.
# ages = { "Herman" => 32, "Lily" => 30, "Grandpa" => 5843, "Eddie" => 10, "Marilyn" => 22, "Spot" => 237 }
# combo_age = 0
# ages.each do |key, value|
# com... | true |
d9edc296e662a5c16a5deb6a7756b22551268413 | Ruby | timnans/arranger | /arranger.rb | UTF-8 | 2,241 | 3.21875 | 3 | [] | no_license | # frozen_string_literal: true
# class Arranger
class Arranger
require 'fileutils'
FOLDERS = %w[Video Audio Document Images].freeze
def create_folders_not_existing
FOLDERS.each do |folder|
if Dir.exist?(folder)
puts "#{folder} already exists"
else
Dir.mkdir(folder)
end
en... | true |
98d93be755036623cfe273083c73e3b433dabafe | Ruby | ty-porter/image-blur-solutions | /imageblur2.rb | UTF-8 | 1,407 | 4.1875 | 4 | [] | no_license | class Image
attr_accessor :array
def initialize(array)
@array = array
end
def output_image
@array.each do |row|
puts row.join(' ')
end
end
def blur
blur_coords = Array.new
@array.each_with_index do |row, y_index| # find all the 1s in the array
row.each_with_index do... | true |
2a491cb66d7acaede71c92a3d0b1e6a8d8a6a1d3 | Ruby | Abidzar16/gg-final-project | /app/models/post.rb | UTF-8 | 1,568 | 2.828125 | 3 | [] | no_license | require 'mysql2'
require './config/db_client'
require 'json'
class Post
attr_accessor :id, :content, :attachment, :user_id
attr_reader :errors
def initialize(attributes)
@id = attributes.fetch(:id, Nanoid.generate(size:11))
@content = attributes.fetch(:content)
@attachment = attributes.fetch(:attach... | true |
7ab53840bcbb7e86abdae765f4f4424e776dccec | Ruby | alexandersdickinson/go_fish | /lib/hand.rb | UTF-8 | 179 | 3.125 | 3 | [] | no_license | class Hand
attr_reader(:cards)
def initialize()
@cards = []
end
def add(card)
@cards.push(card)
end
def remove(card)
@cards.delete(card)
end
end | true |
17ec0885e299f807293e72ba295d1b8e42b70087 | Ruby | DannyCoop/programming-univbasics-4-simple-looping-lab-wdc01-seng-ft-042020 | /lib/simple_loops.rb | UTF-8 | 520 | 3.921875 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Write your methods here
def loop_message_five_times message
counter = 0
number = 5
while counter < number do
puts message
counter += 1
end
end
def loop_message_n_times message, n
n.times {puts message}
end
def output_array array
counter = 0
while counter < array.length do
puts array[count... | true |
0631f0527f1e1fd203d0868feb3c4eb1c6d4a93b | Ruby | SViccari/blackjack | /blackjack.rb | UTF-8 | 2,735 | 4.125 | 4 | [] | no_license | #!/usr/bin/env ruby
# encoding: UTF-8
SUITS = ['♠', '♣', '♥', '♦']
VALUES = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
def build_deck
deck = []
SUITS.each do |suit|
VALUES.each do |value|
deck.push(value + suit)
end
end
deck.shuffle
end
def deal_player
@card_dealt = @deck.pop
... | true |
5572e4f7f325c32ddbaa6640d13a4e13a4b6556c | Ruby | LondonBishop/ruby-intro-to-arrays-lab-london-web-career-021819 | /lib/intro_to_arrays.rb | UTF-8 | 432 | 3.34375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def instantiate_new_array
return []
end
def array_with_two_elements
return [0,0]
end
def first_element(arrIn)
return arrIn.first
end
def third_element(arrIn)
return arrIn[2]
end
def last_element(arrIn)
return arrIn.last
end
def first_element_with_array_methods(arrIn)
return arrIn.first
end
def last_el... | true |
d98f21ae74b605f1c4edb9a7244f82c8317e6fe6 | Ruby | AlexanderCode/Launch_School | /foundations/scrabble_score.rb | UTF-8 | 1,100 | 4.15625 | 4 | [] | no_license | # I am calculating a scrabble score where I am given at the start a string.. I then have
# values for each letter which i will add up to the final sum.
# first I will take the string of letters and convert them into an array. Then i will take
# a hash of letters to values and translate the array of letters into numbe... | true |
ceab6b881607eace0d39dfc95f2db5ea835e9fe8 | Ruby | fossabot/Decider | /spec/unit/clustering/bk_tree_spec.rb | UTF-8 | 6,993 | 2.875 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
require File.dirname(__FILE__) + "/../../spec_helper"
describe Clustering::BkTree::Node do
it "should give the correct nodes within a specified range" do
node = Clustering::BkTree::Node.new(nil, nil)
dummy_child_nodes = {1 => :one, 2 => :two, 3 => :three, 4 => :four, 5 => :five, 6 => :six, ... | true |
ec5be382e54134a852314865fd0021c04c4efc6b | Ruby | eamsc/jets | /lib/jets/resource/api_gateway/rest_api/routes.rb | UTF-8 | 4,195 | 2.515625 | 3 | [
"MIT"
] | permissive | class Jets::Resource::ApiGateway::RestApi
class Routes
extend Memoist
include Jets::AwsServices
def self.changed?
new.changed?
end
def changed?
deployed_routes = build
deployed_routes.each do |deployed_route|
new_route = find_comparable_route(deployed_route)
if ... | true |
7e7d714170bb807bed0959e3c8f100ddfec13534 | Ruby | sakanario/Programming-Knowledge | /Ruby/array.rb | UTF-8 | 2,931 | 3.90625 | 4 | [] | no_license | DECLARING ARRAY
DECLARE EMPTY ARRAY
foo = []
foo = Array.new
DECLARE ARRAY WITH SET OF VALUE
fop = [1,2,3,"a","b","c"]
DECLARE ARRAY OF STRING
foo = %w[aku ganteng] # return ["aku", "ganteng"]
or
foo = Array.new(3, "abc")
DECLARE ARRAY USING BLOCK
foo = Array.new(3) {"abc"} #["a... | true |
880a493d8c206c00c4d6440890e23d8bb8b2fb94 | Ruby | toshiya-horie/ja_address_detector | /lib/ja_address_detector/download.rb | UTF-8 | 569 | 2.78125 | 3 | [
"Unlicense",
"MIT"
] | permissive | require 'download'
class JaAddressDetector::Download
attr_accessor :url, :path
def initialize(url, path)
@url = url
@path = path
end
def uri_file_name
@uri_file_name ||= URI.parse(url).path.to_s.split('/').last
end
def file_path
File.directory?(path) ? File.join(path, uri_file_name) : p... | true |
45dc211db56d067daadc8d303a8c186fecc802be | Ruby | HSalomon86/oxford-comma-online-web-sp-000 | /lib/oxford_comma.rb | UTF-8 | 454 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(array)
if array.length == 2
x = array.join(" and ")
return x
elsif array.length == 1
return array[0]
elsif array.length == 3
arr_2 = []
array.each do |x|
arr_2 << x + ","
end
arr_2[2] = "and " + array[2]
return arr_2.join(" ")
elsif array.length > 3
arr... | true |
a0a1b62bdc98f2b1cef0bdc86e217667b7db2218 | Ruby | RSoph/euler_project | /087_prime_power_triples.rb | UTF-8 | 2,250 | 4.40625 | 4 | [] | no_license | # The smallest number expressible as the sum of a prime square, prime cube, and prime fourth power is 28.
# In fact, there are exactly four numbers below fifty that can be expressed in such a way:
# 28 = 2^2 + 2^3 + 2^4
# 33 = 3^2 + 2^3 + 2^4
# 49 = 5^2 + 2^3 + 2^4
# 47 = 2^2 + 3^3 + 2^4
# How many numbers below fift... | true |
dbe668474fc0c3755a3625a1ea074eea87e48715 | Ruby | dfriedm/gitbo | /app/models/repo.rb | UTF-8 | 3,151 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-public-domain"
] | permissive | class Repo < ActiveRecord::Base
extend FriendlyId
friendly_id :name, :use => :slugged
attr_accessible :description, :name, :open_issues, :owner_name,
:watchers, :issues, :git_updated_at, :bounty_total
has_many :issues, :dependent => :destroy
accepts_nested_attributes_for :issues
vali... | true |
ee9902f833003707a7111e716a81c33590f85b7d | Ruby | karthikeyhegde/c2 | /cement/script/method_actions.rb | UTF-8 | 1,469 | 3.03125 | 3 | [] | no_license |
def check_for_subject_syntax(cnf,subject)
action = nil
obj = nil
subject_tokens = subject.to_s.split(" ").collect{|str| str.downcase unless str.strip.blank?}
cnf["Object"].each{|key,val|
subj_arr = val["subject"].split(",")
action_index = subj_arr.index("action")
obj_index = subj_arr.index(key... | true |
1828e4854038baf8d47a00cc7a66142638c9411c | Ruby | mmottola24/VendettaMobile | /app/controllers/application_controller.rb | UTF-8 | 1,132 | 2.640625 | 3 | [] | no_license | class ApplicationController < ActionController::Base
protect_from_forgery
require 'httparty'
def get_hockey_data filename
json = HTTParty.get 'http://bhocks.michaelencode.com/BHI-Data/data/' + filename + '.json'
data = JSON.parse json.body
end
def get_dates data
dates = Array.new
unless ... | true |
2555b40ae078058582b59431a033b6251028a56d | Ruby | benseligman/chess | /piece.rb | UTF-8 | 3,566 | 3.578125 | 4 | [] | no_license |
class Piece
attr_accessor :position
attr_reader :color
def initialize(board, color)
@color = color
@board = board
end
def available_square?(destination, color)
@board.on_board?(*destination) &&
(@board.empty?(*destination) || (@board[*destination].color != color))
end
def into_check?... | true |
2e060e774a26db39703f805e735347aa82a330e0 | Ruby | maiha/ircbot_admin | /lib/gcal/calculate/events.rb | UTF-8 | 855 | 2.5625 | 3 | [] | no_license | class Gcal::Calculate::Events
include Ccp::Commands::Core
def execute
@events = []
data[:icss].each do |ics|
create_event(ics)
end
data[:events] = @events
end
def create_event(ics)
cal = Icalendar.parse(ics, true)
cal.events.each do |event|
st = calculate_st(event)
... | true |
b64685521a772d02c923718fd0ab5a3924ffb5e9 | Ruby | juliomilla/reminders | /lib/reminder.rb | UTF-8 | 458 | 2.828125 | 3 | [] | no_license | class Reminder
def initialize( reminder_rules )
@reminder_rules = reminder_rules
end
def on( date, estates )
date = Date.parse(date)
reminders = []
estates.each do |estate|
estate.update_due_dates(date)
rule = @reminder_rules.detect { |r| r.description == estate.service_charge_period... | true |
b40bfd86b8f1eca63392539ed3a4eb75cd9ec429 | Ruby | Yuripac/Robots | /main.rb | UTF-8 | 329 | 2.796875 | 3 | [] | no_license | require './lib/world_object'
require './lib/robot.rb'
require './lib/screen.rb'
require './lib/engine.rb'
#TODO: Todos os objectos devem ser uma herança de WorldObject
50.times do |n|
Robot.new(n)
end
screen = Screen.new(80, 40, WorldObject.objects[:all])
engine = Engine.new(WorldObject.objects[:all], screen)
en... | true |
e7eeaf5b7dcb091fed26de1865c0a404eaadcbf0 | Ruby | Triketos/SHRIFT-Translation | /Patch/Gaijinizer/Plugins_0.2.5/8_Weapon_Fix.rb | UTF-8 | 478 | 2.75 | 3 | [] | no_license | =begin
Translates the CE 760 weapon names and "Equipped" state.
LP: 0
=end
class Game_Variables
# Constants.
MARION_WEAPONS = ["Musket", "Flintlock", "Tetsuhau", "Cannon", "Hand Grenade", "Heirloom Spear"]
# Assigns a variable.
alias :ex4ce760p_array_assign :[]=
def []=(index, value)
value = MARION_WEAPONS[@d... | true |
039ea6f2ac55cab9d460acb89b2a750dc23852ee | Ruby | katesroad/ruby_on_rails | /ruby/if.rb | UTF-8 | 87 | 3.1875 | 3 | [] | no_license | if 1 > 0 and true
puts("1 is larger than 0")
else
puts('you are visiting else')
end | true |
e97d2dcebc70c231febe0fcba90a7832c485284e | Ruby | souki1103/ruby_novice | /lib/tatsuya/2/3/3_1.rb | UTF-8 | 82 | 2.75 | 3 | [
"MIT"
] | permissive | num1 = ARGV[0].to_i
num2 = ARGV[1].to_i
print num1,"+",num2,"=",num1 + num2,"\n"
| true |
e9e42e941f228bc5ddc0c6c067ccc9fc597bd4d5 | Ruby | Maxwell-Baird/futbol | /test/game_test.rb | UTF-8 | 682 | 2.8125 | 3 | [] | no_license | require_relative 'test_helper'
require './lib/game'
class GameTest < Minitest::Test
def setup
@game = Game.new({
game_id: '2015030226',
season: '20152016',
type: "Postseason",
away_team_id: 15,
home_team_id: 5,
away_goals: 3,
home_goals: 2
})
end
def test_it_... | true |
d11972eace4657340d130939dea2e19ce4c4f9be | Ruby | mikemackintosh/ruby-vectra | /lib/vectra/api.rb | UTF-8 | 1,355 | 2.546875 | 3 | [
"MIT"
] | permissive | module Vectra
class API
class InvalidResponse < RuntimeError ; end
include HTTParty
def self.pull(url)
# Set the endpoint
unless Vectra::Config.endpoint.include? "/api"
Vectra::Config.endpoint = "#{Vectra::Config.endpoint}/api"
end
base_uri Vectra::Config.endpoin... | true |
6aae6323a96a08bc7d6e32be92e1055066eac5c6 | Ruby | wehman/mca_scheduler | /sorting.rb | UTF-8 | 8,053 | 3.453125 | 3 | [] | no_license | student1 = { "1" => 5, "2" => 2, "3" => 1, "4" => 3, "5" => 4 }
student2 = { "1" => 2, "2" => 1, "3" => 3, "4" => 5, "5" => 4 }
student3 = { "1" => 1, "2" => 2, "3" => 3, "4" => 4, "5" => 5 }
student4 = { "1" => 4, "2" => 2, "3" => 1, "4" => 3, "5" => 5 }
student5 = { "1" => 1, "2" => 3, "3" => 2, "4" => 5, "5" => 4 }
... | true |
6f3660bddb8883c3aa268b555a54bbcea8fe3c6f | Ruby | jplethier/meu-projeto | /config/initializers/dinheiro.rb | UTF-8 | 221 | 3.46875 | 3 | [] | no_license | class Dinheiro
attr_accessor :valor
def initialize(valor)
@valor = valor
end
def to_s
if @valor.nil?
""
else
@valor.to_currency
end
end
end
| true |
a9ab33dc94a7ba41b90637d944acce78ac9a8bcd | Ruby | daphnedarwish/DAY1_4 | /Day_4/labs/calculator.rb | UTF-8 | 585 | 3.984375 | 4 | [] | no_license | puts "Hello! What did you eat today?"
nothing = gets.chomp
puts "That sounds yummy! Was your server good? (Yes or No)"
answer = gets.chomp
if answer == "Yes"
puts "Great, we recommend you tip somewhere between 25 and 30 percent"
elsif
puts "Ah, we're sorry your server was bad. We recommend you don't tip more than... | true |
9db7f7ab9635df932aeb486fa882317e4978d07e | Ruby | kaacun/newshack-server | /config.ru | UTF-8 | 6,262 | 2.53125 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
require 'server'
require 'json'
require 'pp'
require 'open-uri'
require 'openssl'
require 'rss'
require "rexml/document"
require 'aws-sdk'
set :environment, :production
class Bread < Sinatra::Base
get '/show' do
articles = select_article(crawl_data)
api_data = s... | true |
0e59e926ec5e82a2d6e955ab46111163ecaa3c6b | Ruby | stovermc/classroom_exercises | /exploring_each.rb | UTF-8 | 106 | 2.625 | 3 | [] | no_license | require 'pry'
doubles = []
[1,2,3,4,5,6].each do |number|
number * 2
end
puts doubles
binding.pry
""
| true |
129fc52f5bbed094f9ced870e5baeb6bc7138d1e | Ruby | Chalash8/QBE_Rollup | /Program Files/Expenses.rb | UTF-8 | 15,733 | 2.578125 | 3 | [] | no_license | #Stages Expense info
#make sure expenses and Expenses Reporex are sorted correctly
require 'rubygems'
require 'roo'
require 'write_xlsx'
require_relative 'Methods.rb'
require 'date'
def stageExpenses
eraseFile(getFile('st_ex'), "Expenses")
#open files, set defult sheet
ex = Roo::Excelx.new(getFile('ex'))
m... | true |
1da5e654c60076d737eb93c931ea06544b7aeb2e | Ruby | ministryofjustice/hmpps-job-feed-parser | /lib/wcn_scraper/prison.rb | UTF-8 | 923 | 3.0625 | 3 | [] | no_license | module WcnScraper
class Prison
class PrisonNotFoundError < StandardError
end
class NoPrisonsFoundError < StandardError
end
def self.find(prison_name)
prison = PRISONS.find { |p| p[:name] == prison_name }
raise self::PrisonNotFoundError, "#{prison_name} not found" if prison.nil?
... | true |
ed9473a23e15b76dcd492642e306066ff7c8f1a3 | Ruby | tkbeili/august_2016_fundamentals | /ruby_3/oreo.rb | UTF-8 | 625 | 3.296875 | 3 | [] | no_license | require "./cookie.rb"
# We define a class named `Oreo` in here that inherits from the `Cookie` class
# We call Oreo: child class or subclass
# We call Cookie: parent class or superclass
# the Oreo cookie will have all the methods and attributes defines in it as if
# you copied everything from the `Cookie` class
class ... | true |
c2365d20352f73aae984b4f2a0d27058aa6e5918 | Ruby | Sameer164/ToDo-Board | /to_do_board.rb | UTF-8 | 3,715 | 3.5 | 4 | [] | no_license | require_relative './item.rb'
require_relative './list.rb'
class TodoBoard
def initialize()
@label_hash = {}
end
def get_command
puts "Enter a Command"
cmd, cmd2, *args = gets.chomp.split(' ')
case cmd
when 'mklist'
@label_hash[cmd2] = List.new(c... | true |
c3c98800cb50c3130b1a125b91c96194c2eb9d21 | Ruby | alkarimlalani/email-server | /lib/email/email.rb | UTF-8 | 1,059 | 2.984375 | 3 | [] | no_license | require 'nokogiri'
require 'json'
require 'rest-client'
require_relative 'adapters/mailgun'
require_relative 'adapters/mandrill'
class Email
def initialize(email_hash)
@email_hash = email_hash
set_email_content!
@email_adapter = case ENV['EMAIL_PROVIDER']
when 'mailgun' then Email::A... | true |
39b2841fafa96a2ad1f53c5ba9456ca96b420155 | Ruby | Natalia-Kotreleva/dz9 | /train.rb | UTF-8 | 1,716 | 3.0625 | 3 | [] | no_license | # frozen_string_literal: true
load 'name_company.rb'
load 'instance_counter.rb'
class Train
include NameCompany
include InstanceCounter
attr_reader :route, :speed, :wagon, :name_train, :station, :number
attr_accessor :wagons
@@trains = []
def initialize(name_train, number)
@name_train = name_train
... | true |
8b0b71e65fd1255fa8356490a32d31e0770db6bc | Ruby | christianmendoza/BEWD_NYC_5_Homework | /Christian_Mendoza/midterm/runner.rb | UTF-8 | 1,409 | 3.828125 | 4 | [] | no_license | require_relative 'YahooWeatherApi'
require_relative 'forecast'
# hello
puts "\n"
puts "Welcome to the Weather Center."
puts "\n"
puts "Enter a location for a look at the 5 day forecast."
puts "Example: [10014] or [new york, ny] or [honolulu] or [manila]"
puts "\n"
# get input location
location = gets.chomp
# creat... | true |
81379600115cdeabf7a56f952c2fabfe9dc797de | Ruby | Cheng0315/ttt-5-move-rb-online-web-sp-000 | /lib/move.rb | UTF-8 | 362 | 3.703125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def display_board(board)
puts " #{board[0]} | #{board[1]} | #{board[2]} "
puts "-----------"
puts " #{board[3]} | #{board[4]} | #{board[5]} "
puts "-----------"
puts " #{board[6]} | #{board[7]} | #{board[8]} "
end
def input_to_index(num)
if num.to_i
num.to_i - 1
else
-1
end
end
def move(board,... | true |
029a7796206a7ff57440fc65077347ec609e83a7 | Ruby | MelizzaP/makersquare | /ruby_files/cookbook.rb | UTF-8 | 2,885 | 4.21875 | 4 | [] | no_license | #cookbook class
#created cookbook class should take a title input
class Cookbook
attr_accessor :title #will allow user to set and get cookbook title
attr_accessor :recipes #will allow user to set and get recipes
def initialize(title) # initilize method will allow user to name cookbook
@title = title # us... | true |
922bbe1e9f44aa38984344e4c68688981edca115 | Ruby | datagoil/tictactoe | /tictactoe.rb | UTF-8 | 4,507 | 3.828125 | 4 | [] | no_license | class TicTacToe
include Enumerable
@@empty_board = ["\n | | ", "-----------", " | | ", "-----------", " | | \n\n"]
@@map_hash = {TL: " ", TC: " ", TR: " ", CL: " ", CC: " ", CR: " ", BL: " ", BC: " ", BR: " "}
def initialize
puts "\nWelcome to TicTacToe, players!\n\n"
player_setup
... | true |
a9916b7b7b8da00fb14ffc6bc7d66bc35a1abe3e | Ruby | d-atkins/Battleship | /test/board_test.rb | UTF-8 | 4,824 | 3.25 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require_relative '../lib/board'
require_relative '../lib/ship'
class BoardTest < Minitest::Test
def test_it_exists #1
board = Board.new
assert_instance_of Board, board
end
def test_it_has_required_number_of_cells #2
board = Board.new
assert_eq... | true |
767c127cab5be3a2d04c1caca06ccaf9ebfbfb9c | Ruby | mtchavez/al_papi | /lib/al_papi/http.rb | UTF-8 | 2,178 | 2.65625 | 3 | [
"MIT"
] | permissive | module AlPapi
class Http # @private
HANDLED_CODES = [200, 204, 401, 403]
attr_accessor :errors, :response, :success, :config, :over_limit, :suspended
def initialize(config)
@config, @errors, @success, @over_limit, @suspended = config, [], false, false, false
end
def get(path, params = {})
... | true |
057a15ac42523c863d9b5358e9064c0565894ca8 | Ruby | McNeill2019/sei35-homework | /jamie-mcneill/week5/games-on-rails/app/controllers/rps_controller.rb | UTF-8 | 2,173 | 3.015625 | 3 | [] | no_license | class RpsController < ApplicationController #inherits from ApplicationController class.
def play
@users_choice = params[:throw]
outcome = ["rock","paper","scissors"]
@computer_choice = outcome[rand(3).floor]
# if @users_choice == @computer_choice
# @result = "User Wins!"
# else
# ... | true |
3f50d9edcb0b5903bd5eb95ab2d89f974ddb0159 | Ruby | Georgy5/ruby_stuff | /30.days.of.code/Day9_Recursion.rb | UTF-8 | 165 | 3.765625 | 4 | [] | no_license | # Enter your code here. Read input from STDIN. Print output to STDOUT
N = gets.chomp.to_i
def factorial(n)
n == 0 ? 1 : n * factorial(n-1)
end
puts factorial(N) | true |
2339fc0a38c4e86ad876ae674c1dc737c23bd596 | Ruby | rstuckless/playlistEngine | /chrishelp.rb | UTF-8 | 3,147 | 2.765625 | 3 | [] | no_license |
require 'csv'
require 'pry'
require './engineStuff/gseRank.rb'
require './engineStuff/ytapi.rb'
require './engineStuff/lastfm.rb'
# g = GoogleSearchHelper.new
@yt = YoutubeApi.new
lastFM = LastFMHelper.new
newTracks = []
playlists = {}
# chartJson = lastFM.getChart
# tracks = lastFM.getChart
# binding.pry
# CSV.op... | true |
da053cd6444d0367b100654bfb2f6471fc3e88a5 | Ruby | omokun/furima-36222 | /spec/models/user_spec.rb | UTF-8 | 5,838 | 2.640625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
before do
@user = FactoryBot.build(:user)
end
describe 'ユーザー新規登録' do
context '新規登録できるとき' do
it 'nicknameとemail、passwordとpassword_confirmation、last_nameとfirst_name、last_name_kanaとfirst_name_kana、birthdayが存在すれば登録できる' do
expect(@user... | true |
105fdebfc29f5b6b982db35034dc0b4b40467d20 | Ruby | mschuerig/picture_frame | /test/stencil_test.rb | UTF-8 | 1,064 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'test_helper'
require 'picture_frame/stencil'
class StencilTest < Minitest::Test
def setup
@corner_stencil = PictureFrame::Stencil.new(
"abcde\n" +
"12@45\n" +
"qrstu\n" +
"vwxyz\n"
)
end
def test_position
assert_equal [1, 2], @corner_stencil.position('@')
end
de... | true |
ba715f741e10c912db3ffc4f46a2b4ca2fb38cd1 | Ruby | haritsrm/Hackerrank-Solutions | /Data Structures/ruby/01-Array-DS.rb | UTF-8 | 325 | 3.078125 | 3 | [
"MIT"
] | permissive | #!/bin/ruby
require 'json'
require 'stringio'
# Complete the reverseArray function below.
def reverseArray(a)
return a.reverse
end
fptr = File.open(ENV['OUTPUT_PATH'], 'w')
arr_count = gets.to_i
arr = gets.rstrip.split(' ').map(&:to_i)
res = reverseArray arr
fptr.write res.join " "
fptr.write "\n"
fptr.clo... | true |
c206749383399e8e977210aa17b6fed23e234a2f | Ruby | trejoramiro/ruby-cloud9-workspace | /acltc/song_list.rb | UTF-8 | 658 | 3.6875 | 4 | [] | no_license | class List
def initialize
@songs = []
end
def add_song(song)
@songs << song
end
def play
@songs.each do |song|
`say #{song.lyrics}`
end
end
def shuffle
min = @songs.length
max = min + 1
songs_in_random_o... | true |
a5590e41e55b409665329513a62b547a6ef25a81 | Ruby | DanielLChang/AppAcademy | /w2/w2d1/chess/board.rb | UTF-8 | 1,529 | 3.640625 | 4 | [] | no_license | require 'byebug'
require_relative 'piece'
class Board
COLORS = [:black, :white].freeze
attr_accessor :grid
def initialize
# debugger
make_starting_grid
end
def [](pos)
x, y = pos
@grid[x][y]
end
def []=(pos, val)
x, y = pos
@grid[x][y] = val
end
# def dup()
#
# end
... | true |
5c9103753ac959ee48f21f27a2f1aedfbd5b43d0 | Ruby | rosskinney/ruby | /blog2.rb | UTF-8 | 1,411 | 3.734375 | 4 | [] | no_license | class Blog
attr_accessor :title, :all_blog_posts, :total_blog_posts
def initialize
@created_at = Time.now
puts "Give your blog a name:"
@title = gets.chomp
@all_blog_posts = []
@total_blog_posts = 0
puts "end initialize method in blog class"
puts "the name of the blog is #{@title}"
end
def create... | true |
7b1e052a1b905b582853ec7c4ced21ecee8a2e66 | Ruby | CLXNetworks/ruby-api | /examples/get_price_entries_by_gateway_id.rb | UTF-8 | 412 | 2.5625 | 3 | [
"MIT"
] | permissive | begin
clx = CLX::API.new('username', 'password')
prices = clx.get_price_entires_by_gateway_id(6)
prices.each do |price|
puts price.price
puts price.gateway
puts price.operator
puts price.expireDate
end
rescue CLX::CLXAPIException => e
puts e.clx_error_message
puts e.clx_erro... | true |
df68621c90dec2485c5b3c1fb218c53d435ac4f7 | Ruby | mindwiki/mindwiki | /lib/mindwiki/validations.rb | UTF-8 | 2,399 | 2.5625 | 3 | [
"MIT"
] | permissive | # The MIT License
#
# Copyright (c) 2009 Sami Blommendahl, Mika Hannula, Ville Kivelä,
# Aapo Laitinen, Matias Muhonen, Anssi Männistö, Samu Ollila, Jukka Peltomäki,
# Matias Piipari, Lauri Renko, Aapo Tahkola, and Juhani Tamminen.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of ... | true |
324dd4a7125697979fe8537c5554bfc41b5794f2 | Ruby | stevecj/map_with_indifferent_access | /spec/map_with_indifferent_access/normalization_spec.rb | UTF-8 | 4,402 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
module MapWithIndifferentAccess
module NormalizationSpec
class HashAnalog < Struct.new(:to_hash )
def each_pair ; end
end
class ArrayAnalog < Struct.new(:to_ary )
end
describe Normalization do
def build_given_hash
{
'a' => 1,
:b ... | true |
15cc0f16c724a097cfad955102f615c9d6b3f568 | Ruby | aasmith/struggle | /lib/struggle/instructions/prevent_play_of_event.rb | UTF-8 | 544 | 2.53125 | 3 | [
"MIT"
] | permissive | module Instructions
class PreventPlayOfEvent < Instruction
fancy_accessor :card_ref, :reason
needs :engine, :cards
def initialize(card_ref:, reason:)
self.card_ref = card_ref
self.reason = reason
end
def action
preventer = Modifiers::Permission::CardPlayEventPreventer.new(
... | true |
a2b09dfb23a2b9828bd4d61ca284a242356dbb4b | Ruby | aaronhumerickhouse/selenium-tests | /utilities/soft_asserts.rb | UTF-8 | 4,487 | 2.953125 | 3 | [] | no_license | require 'rspec'
# A single soft assert that holds an exception and a screenshot location
class SoftAssert
#The exception to handle and output later
attr_accessor :exception
#The screenshot file string
attr_accessor :screenshot
#The url at point of failure
attr_accessor :url
#A custom message to be includ... | true |
f96e41b97374498afe1f6b1c28e2e7e6479aeede | Ruby | NyxinU/BobaGuide | /app/models/drink.rb | UTF-8 | 758 | 2.6875 | 3 | [] | no_license | # == Schema Information
#
# Table name: drinks
#
# id :integer not null, primary key
# name :string not null
# created_at :datetime not null
# updated_at :datetime not null
# store_id :integer not null
#
class Drink < ApplicationRecord
validates :store... | true |
ad7fecc6cb25ad6439e5f926f19cec99329e0aae | Ruby | lythesia/pat | /a/1102/1102.rb | UTF-8 | 553 | 3.078125 | 3 | [] | no_license | #!/usr/bin/env ruby
n = gets.chomp.to_i
chd = Array.new(n) { [nil, nil] }
fa = Array.new(n, true)
n.times do |i|
lr = gets.chomp.split
lr.each_with_index do |x, j|
if x != '-'
x = x.to_i
chd[i][1 - j] = x; fa[x] = false
end
end
end
root = fa.index true
ans = []
q = Queue.new; q << root
until... | true |
6a01d4a9916cf8ae9bef8340c90693da4936af57 | Ruby | RichardDenton/linked_lists | /lib/tests.rb | UTF-8 | 1,247 | 3.5625 | 4 | [] | no_license | require_relative 'LinkedList.rb'
list = LinkedList.new
list.append(1)
list.append(2)
list.append(3)
list.append(8)
list.prepend(0)
contains = 8
insertIndex = 1
insertValue = 50
removeIndex = 1
puts list.to_s
puts "head: #{list.head}"
puts "tail: #{list.tail}"
puts "Size: #{list.size}"
puts "At: #{list.at(2)}"
puts "... | true |
61f9c44c77e1cdae2d462daac76cb75336ab3951 | Ruby | Demeugaliyev/viselitsa | /result_printer.rb | UTF-8 | 1,173 | 3.4375 | 3 | [] | no_license | class ResultPrinter
def initialize
@status_image = []
current_path = File.dirname(__FILE__)
counter = 0
while counter <= 7 do
file_name = current_path + "/img/#{counter}.txt"
if File.exist?(file_name)
f = File.new(file_name, "r:UTF-8")
@status_image << f.read
... | true |
9eb9aa7a0a37d9d2aa97f3554ca60f949d44257f | Ruby | dankomong/ruby-objects-has-many-lab-dumbo-web-career-031119 | /lib/artist.rb | UTF-8 | 437 | 3.171875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Artist
attr_accessor :name
@@artists = []
def initialize(name)
@name = name
@@artists << self
end
def songs
Song.all.select do |song|
self == song.artist
end
end
def add_song(song)
# songs.push(songArg)
song.artist = self
end
def add_song_by_name(songName)
... | true |
4a825395374670f3afda416fe98dd75fad6b0392 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/f0e86914857e4aa68e1d8847bee2c7a4.rb | UTF-8 | 923 | 4.125 | 4 | [] | no_license | # Bob
# Bob is a lackadaisical teenager. In conversation, his responses are very limited.
# Bob answers 'Sure.' if you ask him a question.
# He answers 'Woah, chill out!' if you yell at him.
# He says 'Fine. Be that way!' if you address him without actually saying anything.
# He answers 'Whatever.' to anything else.
c... | true |
c664fb5f93df057805022fc5e5ac9eeb44cab501 | Ruby | opendocs-adoc/suisinfar | /scripts/lib_publish.rb | UTF-8 | 5,954 | 2.78125 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | require 'asciidoctor'
require 'fileutils'
require 'htmlentities'
require 'optparse'
require 'rubypants'
require 'yaml'
def insert_sidenote(id, text)
":#{id}: pass:[<label for=\"#{id}\" class=\"margin-toggle sidenote-number\"></label><input type=\"checkbox\" id=\"#{id}\" class=\"margin-toggle\"><span class=\"sidenote... | true |
583e65d574b90e106903e330a05cad1df26ea92a | Ruby | hernanwilkinson/PortfolioExample-Maglev | /account.rb | UTF-8 | 2,115 | 3.15625 | 3 | [] | no_license | require "set"
require "./measure"
require "./account_transaction"
require "./subclass_responsibility"
class Account
def number
raise SubclassResponsibility
end
def name
raise SubclassResponsibility
end
def isIdentifiedAs?(aNumber)
self.number==aNumber
end
def isPortfolio?
raise Subclas... | true |
4f1f86a0b1476797fb8a3cc1dbf12c3217e116e4 | Ruby | mustafayusuf01/twenty-questions | /20 Questions/twenty_questions.rb | UTF-8 | 1,286 | 3.890625 | 4 | [
"MIT"
] | permissive | class Game
def initialize
@file = File.new("boris_johnson.dat")
@question = []
@question_match = false
@questions_count = 20
@person = @file.readlines.first.chomp
rawwords = @file.readlines("/n")
@keywords = rawwords.each{|a| a.chomp}
end
def take_question
puts "Ask a question: ... | true |
87a33d8d90a5c1bed2a09226f462e6fb488238a1 | Ruby | Austin-dv-Evans/scheme_discovery | /appium_test.rb | UTF-8 | 2,028 | 2.828125 | 3 | [] | no_license | # This is just a shell, I need to decide how I want the phone to get the schemes
# This should run a new instance with each app/csv
# Have one method that loops through the csv's then calls another method to try the links on that csv - that way we can loop through the entire directory AND individual csv's if needed
#
#... | true |
e22d44eadf38bafd68910caf7d70e71cc65557df | Ruby | blakerego/mappd | /app/models/location.rb | UTF-8 | 1,022 | 2.609375 | 3 | [] | no_license | ###################################################
# create_table "locations", force: :cascade do |t|
# t.string "address"
# t.float "latitude"
# t.float "longitude"
# t.string "name"
# t.string "type"
# t.datetime "created_at", null: false
# t.datetime "updated_at", null: false
# t.string ... | true |
fec6ad6c53684e9d060943a513a76f7674367117 | Ruby | stephaniejmars/linked-lists | /lib/linked_list.rb | UTF-8 | 1,827 | 3.9375 | 4 | [
"MIT"
] | permissive | require_relative 'node'
class LinkedList
attr_reader :head
def initialize
@head = nil
end
# Time complexity - O(1)
# Space complexity - O(1)
def add_first(data)
#creating/adding a new node
new_node = Node.new(data)
#calling out/linking that the next node to this one is the current head
... | true |
7470510d559379e94c2981243fb32c180128db1d | Ruby | AllenBlank/Certainly-Sudoku | /tools/generator.rb | UTF-8 | 1,420 | 3.796875 | 4 | [] | no_license | load 'solver.rb'
# this is stolen from another ruby quiz, the method itself and
# a couple of lines too.
# http://rubyquiz.strd6.com/quizzes/182-sudoku-generator
class Generator
attr_accessor :puzzle
def initialize pattern="0"*81
order = gen_order pattern
solution = Solver.new( gen_seed ).solution
s... | true |
d03cc298645f8eaba52beee41e37c2a65da53c57 | Ruby | Nickolai8/rb101 | /exercises_small_problems/documentation_again/class_and_instance_methods.rb | UTF-8 | 165 | 3 | 3 | [] | no_license | # The difference between File::path and File#path is that ::path is called on
# the 'File' class, while #path is called on an instance/object of the
# class 'File'. | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.