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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e47075a11eb8949d0c55997157888f84db256ea8 | Ruby | maca/scruby | /lib/scruby/sclang.rb | UTF-8 | 1,181 | 2.65625 | 3 | [
"MIT",
"GPL-3.0-or-later"
] | permissive | require "concurrent-edge"
module Scruby
class SclangError < StandardError; end
class Sclang
include Concurrent
def initialize
@process = Process.new("sclang", "-i scruby")
end
def spawn
spawn_async.value!
end
def spawn_async
return Promises.fulfilled_future(self) if p... | true |
9ca7b151a7f68e2603813877d5252b98e6dedd8d | Ruby | dreikanter/feeder | /app/services/push.rb | UTF-8 | 1,400 | 2.5625 | 3 | [
"MIT"
] | permissive | # TODO: Drop this class
# :reek:TooManyStatements
class Push
include Logging
include Callee
param :post
def call
publish_post_content
# TODO: Use better way to limit API calls rate
sleep 1
end
private
def publish_post_content
attachment_ids = create_attachments
post_id = create_po... | true |
4c03360143d7404285c3f70642c099a479de1dd0 | Ruby | microsoftgraph/msgraph-sdk-ruby | /lib/models/column_validation.rb | UTF-8 | 6,461 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'microsoft_kiota_abstractions'
require_relative '../microsoft_graph'
require_relative './models'
module MicrosoftGraph
module Models
class ColumnValidation
include MicrosoftKiotaAbstractions::AdditionalDataHolder, MicrosoftKiotaAbstractions::Parsable
##
# Stores... | true |
da536462e7c27de22fada711be6bd720d49ab5cb | Ruby | benwah/test-concurrency | /runners.rb | UTF-8 | 1,689 | 2.796875 | 3 | [] | no_license | require_relative './thread_pool.rb'
require 'ruby-prof'
class BaseRunner
def initialize(job, number_of_times)
@job = job
@number_of_times = number_of_times
end
def run
puts "[#{self.class}] Doing #{@job} #{@number_of_times} times."
start_time = Time.now.utc
perform
puts "Total time: #{Ti... | true |
38fbfe51b5f7859bbff82de253b927f849128e99 | Ruby | RubyMoney/money | /spec/money/constructors_spec.rb | UTF-8 | 2,474 | 3.203125 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
describe Money::Constructors do
describe "::empty" do
it "creates a new Money object of 0 cents" do
expect(Money.empty).to eq Money.new(0)
end
it "instantiates a subclass when inheritance is used" do
special_money_class = Class.new(Money)
expect(special_money_class.e... | true |
e9a5f08883f544584d0c40bd4e21dc8a88f24abe | Ruby | fredrik/resize.fakedew.net | /receive/app.rb | UTF-8 | 1,095 | 2.53125 | 3 | [] | no_license | require 'sinatra'
require 'resque'
require_relative './attachments_helper'
require_relative '../process/resize_job'
# set up worker queue
Resque.redis = Redis.new
get '/' do
'OK'
end
post '/resize/notify' do
# receives a 'store' notification from Mailgun.
# enqueue a set of ResizeJob workers, one for each i... | true |
e3875dbddaa0570d0c2c8eff2801f3e5bbae5c88 | Ruby | itggot-jacob-karlin/webbserver-slutprojekt | /auth.rb | UTF-8 | 2,052 | 3.03125 | 3 | [] | no_license | require 'session'
module Auth
def open_database()
db = SQLite3::Database.new('db/db.sqlite3')
db.results_as_hash = true
return db
end
def get_user_by_username(username, db)
users = db.execute("SELECT * FROM users WHERE username = '#{username}'")
if users.length ==... | true |
763e75b8105b70bc7af13b1d5b3090f1f553055c | Ruby | tribune/multipart_body | /test/test.rb | UTF-8 | 6,515 | 2.921875 | 3 | [
"MIT"
] | permissive | require File.join(File.dirname(__FILE__), 'test_helper')
require 'tempfile'
class MultipartBodyTest < Test::Unit::TestCase
context "MultipartBody" do
setup do
@hash = {:test => 'test', :two => 'two'}
@parts = [Part.new('name', 'value'), Part.new('name2', 'value2')]
@example_text = "------multip... | true |
64162fd1f13f6c30c178e3ad1e8490da01afbfe8 | Ruby | macressler/pakyow | /pakyow-support/lib/support/hash.rb | UTF-8 | 1,112 | 3.4375 | 3 | [
"MIT"
] | permissive | class Hash
def deep_merge(second)
merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
self.merge(second, &merger)
end
def deep_merge!(second)
merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge!(v2, &merger) : v2 }
self.merge!(second, &merger)
... | true |
b671bbf09f86e9667a640c9e6c70f18e69c46b50 | Ruby | gesarlhamo/algorithm-problems | /sum.rb | UTF-8 | 141 | 3.5 | 4 | [] | no_license | def sum(array)
running_sum = 0
for i in array
running_sum = running_sum + i
end
return running_sum
end
puts sum([1,2,3,4,5,100]) | true |
af30cd86fb41bea74fc7d18a1e16b9091077c30a | Ruby | ebooshi/Chatroom-Modelado-y-Programacion-2018-1 | /src/Sala.rb | UTF-8 | 1,333 | 3.171875 | 3 | [] | no_license | # coding: utf-8
class Sala
#Constructor único para la clase sala
#Parámetro nombre: el nombre de la Sala
#Parámetro dueño: el cliente que declara la sala
def initialize(nombre, dueño)
@clientes = Hash.new #hash que va a contener a los Socket
@poblacion = 0
@dueño = dueño
@nombre = nombr... | true |
eb333f6cc8aa62081aade398854d24b2b2628913 | Ruby | BASIC-Belic/api-muncher | /test/lib/recipe_test.rb | UTF-8 | 1,881 | 2.875 | 3 | [] | no_license | require 'test_helper'
describe 'Recipe' do
it "Cannot be initialized without a name" do
expect {
Recipe.new
}.must_raise ArgumentError
end
it "Must initialize name properly" do
channel = Recipe.new("Name")
expect(channel.name).wont_be_nil
expect(channel.name).must_equal "Name"
end
... | true |
d7f2b5eab3fa93c701f3e0ab3031e910ec747f42 | Ruby | mzheng6/cs125-Honors | /Ghost.rb | UTF-8 | 1,717 | 3.078125 | 3 | [] | no_license | class Ghost < GameObject
def initialize(window, x, y, image)
super
@image, @image2, @image3, @image4 = *Image.load_tiles(window, image, 15, 15, false)
@count = 0
end
def draw()
@image.draw(@x, @y, 1, 1.0, 1.0)
end
def getcount()
return @count
end
def addcount()
@count += 1
end
... | true |
99b6cc4a54a7da7ccebe7dd5e3cd4d571182105a | Ruby | oriolbcn/ironhack_week1_excercises | /blocks/fizzbuzzpro.rb | UTF-8 | 690 | 4.3125 | 4 | [] | no_license | class FizzBuzz
def initialize(conditions)
@conditions = conditions
end
def run
1.upto(100) do |i|
print_number(i)
end
end
def print_number(number)
result = ""
@conditions.each do |condition|
condition_result = condition.call(number)
if condition_result
r... | true |
4b0bd796e4c83360f444b3ce432894060dd81869 | Ruby | andres/donor | /app/models/person/search.rb | UTF-8 | 549 | 2.625 | 3 | [
"MIT"
] | permissive | class Person::Search
attr_accessor :term
def self.with( term )
s = Person::Search.new
s.term = term
s.search
end
def search
Person.where(" ((first_name || ' ' || last_name) ILIKE :term)
OR ((last_name || ' ' || first_name) ILIKE :term)
OR (business_name ... | true |
0807a07767f618c48bebc4d97c3237f6d4a1bb84 | Ruby | JohnnyHandy/ruby-tutorial | /The_is_a?_Method.rb | UTF-8 | 57 | 2.75 | 3 | [] | no_license | p [1,2,3].class
p [1,2,3].is_a?(Array)
p 1.is_a?(Integer) | true |
2b0496399efdc51d8a2a8b38f9e8368767b754a2 | Ruby | joshuakemp1/Ruby | /recurrsion_examples.rb | UTF-8 | 169 | 3.203125 | 3 | [] | no_license | def game(variable)
if variable == 0
return 1
else
return game(variable -1) + game (variable -1)
end
end
my_var = game 26
puts "#{my_var}"
| true |
1ba13aba6ef973d99c635853d41cf878f16c6c54 | Ruby | lyuehh/program_exercise | /ruby/ruby_test/1/2yield_canshu.rb | GB18030 | 162 | 3.8125 | 4 | [] | no_license | #һĴ
def yield_an_arg
puts "Yielding 10!"
yield(10)
end
yield_an_arg {|x| puts "> Code block received this argument: #{x}" } | true |
da50d4714ab69f4231307988f2e4cd827753981c | Ruby | davidhusa/quickevent | /app/models/page.rb | UTF-8 | 889 | 2.625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] | permissive | class Page < ActiveRecord::Base
attr_accessible :content, :title, :event_id
# this turns the title into something url-friendly before saving
before_validation { |page| page.title = page.title.downcase.gsub(' ', '-') }
validates :title, :uniqueness => true
validates :title, :presence => true
validates_form... | true |
6d0d91dce3fa1decced7f1f32fcaed953a3a41cc | Ruby | kevxo/backend_module_0_capstone | /day_3/ex1.rb | UTF-8 | 980 | 4.21875 | 4 | [] | no_license | people = 20
cats = 30
dogs = 15
if people < cats && dogs < people
puts "Too many cats! The world is doomed!"
end
if people > cats
puts "Not many cats! The world is saved!"
end
if people < dogs
puts "The world is drooled on!"
end
if people > dogs
puts "The world is dry!"
end
dogs += 5
if !people >= dogs
... | true |
148187e29319299841fe6484cdd9cf0e1c20cdbc | Ruby | ricofehr/nextdeploy | /ror/app/models/systemimagetype.rb | UTF-8 | 390 | 2.578125 | 3 | [
"MIT"
] | permissive | # Store all exploitation system whi are the same type: unix / linux / windows mainly
#
# @author Eric Fehr (ricofehr@nextdeploy.io, github: ricofehr)
class Systemimagetype < ActiveRecord::Base
# One exploitation system is caracterised by one unique property type
has_many :systemimages, dependent: :destroy
# some... | true |
16b253a3a2c650ff3d2f943dd601372909d2e7e9 | Ruby | mameyer/control-orogen-motion_controller | /scripts/helpers/general.rb | UTF-8 | 3,228 | 2.625 | 3 | [] | no_license | #! /usr/bin/env ruby
@inSim = true
# Defines which kind of slam shuld be used, graph_slam or slam3d.
@use_slam3d = false
class TaskStruct
attr_accessor :name
attr_accessor :task
attr_accessor :config
def initialize()
@config = Array.new
@config << "default"
end
end
def getTask(na... | true |
7bb55ad6fa90f3339282bcc8b26c31dfc583a8f4 | Ruby | ggwc82/airport_challenge | /spec/weather_spec.rb | UTF-8 | 249 | 2.734375 | 3 | [] | no_license | require 'weather'
describe Weather do
subject(:weather) { Weather.new }
describe "#condition" do
it "returns sunny or stormy when called" do
expect(weather.condition).to satisfy {|s| ["sunny", "stormy"].include?(s)}
end
end
end | true |
c548d801f35f2a1f5ac400192a83f84166cb0b72 | Ruby | rongxanh88/cloney_island_airbnb | /app/services/cancellation_policy.rb | UTF-8 | 757 | 3.203125 | 3 | [
"MIT"
] | permissive | class CancellationPolicy
attr_reader :name, :refund, :description
def initialize(name)
@name = name
set_refund
set_description
end
private
def set_refund
if name == "Flexible"
@refund = "100%"
elsif name == "Moderate"
@refund = "50%"
else
@refund = "0%... | true |
89af0b796d35f2bda914b9f941667a02f7e0fbdd | Ruby | Sufl0wer/summer-2019 | /3581/1/command_line_parser.rb | UTF-8 | 666 | 2.84375 | 3 | [] | no_license | require 'optparse'
class CommandLineParser
class << self
def read_args
add_args = { 'file' => 'gems.yml' }
OptionParser.new do |arg|
pass_params(arg, add_args)
end.parse!
add_args
end
def find_gem_by_name(hash_gems, add_args)
hash_gems.select! { |name, _| name.inclu... | true |
8f2e40ac61cb96710f1daa3b000435b19006d129 | Ruby | fjur/Quick-Union | /Percolation/Percolation.rb | UTF-8 | 3,690 | 3.296875 | 3 | [] | no_license | # public class Percolation {
# public Percolation(int N) // create N-by-N grid, with all sites blocked
# public void open(int i, int j) // open site (row i, column j) if it is not open already
# public boolean isOpen(int i, int j) // is site (row i, column j) open?
# public boolea... | true |
ae254d105d3b7ea2e341b11fd7458879a7a2e6b5 | Ruby | BenTopping/traction-service | /app/models/ont/run_factory.rb | UTF-8 | 1,253 | 2.53125 | 3 | [] | no_license | # frozen_string_literal: true
# Ont namespace
module Ont
# RunFactory
# Creates or updates a run from a list of flowcell metadata.
class RunFactory
include ActiveModel::Model
validate :check_run
def initialize(flowcell_specs = [], run = nil)
@run = run || Ont::Run.new
@old_flowcells = @... | true |
b520c3a8a94d81a3c8e698efe57c7040bfa1824e | Ruby | Priya67/Daily_Work | /w2d3-master/poker/lib/card.rb | UTF-8 | 175 | 3.03125 | 3 | [] | no_license | class Card
attr_reader :number, :suit
def initialize(number, suit)
@number = number
@suit = suit
end
end
# card1 < card2
#
# card1 == card2
#
# [cards].sort
| true |
96da7e794487aa22636727c5d8c4dac8a5f6e930 | Ruby | inyoungcome/ruby-des | /test/key_schedule_test.rb | UTF-8 | 1,579 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class KeyScheduleTest < Test::Unit::TestCase
fixtures :key_schedule
def setup
@key_schedule = KeySchedule.new(key_schedule(:test_key))
end
def test_class
assert_kind_of KeySchedule, @key_schedule
end
def test_test_key
assert_kind_of Array, @key_schedule.key
as... | true |
9f371438d49332a1f4a355b2d0c7062b33ffa41f | Ruby | Boucherie/object_oriented_programming2 | /vampire.rb | UTF-8 | 842 | 3.46875 | 3 | [] | no_license | class Vampire
attr_reader :name, :age
attr_accessor :in_coffin, :drank_blood_today
@@coven = []
def initialize(name, age)
@name = name
@age = age
@in_coffin = false
@drank_blood_today = false
end
def self.create
fledgling = Vampire.new(name, age, in_coffin, drank_blood_today)
@@coven ... | true |
5c8520fe96ed47073d4504475e98dbd99ec4becf | Ruby | horandago/Waifu-Quest | /lib/Npc/barkeeper.rb | UTF-8 | 1,219 | 3.203125 | 3 | [] | no_license | require_relative '../npc.rb'
class Barkeeper < Npc
attr_reader :deny
ALE_COST = 10
def initialize
@@shop_list = ['Ale', 'Exit']
@deny = "Barkeeper: Geeee aaaat ya god damn droonk!"
end
def speak
@dialogue = ["VL1","VL2","VL3"]
anim("#{@dialogue.sample}")
end
def shop
anim("Wa can ee get fur ... | true |
4a089ff22d07d14c664c8ec5d4a860b9e5ae24c9 | Ruby | aronsonben/School-Projects | /CMSC330/p2_OCaml/p2a_OCaml-Basics/testing/framework/test.rb | UTF-8 | 10,759 | 2.703125 | 3 | [] | no_license | require_relative "test_utils.rb"
require "yaml"
require "fileutils"
require "logger"
require "open3"
class TestCase
@@MODULE_DIR_PREFIX = "module"
@@MODULE_CONFIG_FILE = "module.yml"
@@MODULE_EXPECTED_OUTPUT_FILE = "expected_output"
@@MODULE_STUDENT_OUTPUT_FILE = "student_output"
@@MODULE_STUDENT_E... | true |
a7dc48918ec6ee2479f4ee54e78e19fad4ec512e | Ruby | mikylamoehlenbruck/rb101 | /exercises/easy2.rb/ex2.rb | UTF-8 | 1,086 | 3.78125 | 4 | [] | no_license | SQRMETERS_TO_SQRFEET = 10.7639
SQRFEET_TO_SQRINCHES = 12**2
SQRINCHES_TO_SQRCM = 100**2
def get_length_meters
puts "Enter the length of the room in meters:"
length = gets.chomp.to_f
end
def get_width_meters
puts "Enter the width of the room in meters:"
width = gets.chomp.to_f
end
def gets_length_feet
puts ... | true |
6d18a8107c4a5d58f0c7018eb6407081bdcf2d97 | Ruby | zydronium/DevelopersAnonymous | /ruby/gilded_rose_test.rb | UTF-8 | 3,366 | 2.640625 | 3 | [
"CC-BY-4.0",
"CC-BY-3.0"
] | permissive | require 'test/unit'
require_relative 'gilded_rose'
class GildedRoseTest < Test::Unit::TestCase
MAX_BACKSTAGE_SELLIN = 30
MAX_QUALITY = 50
attr_reader :gilded_rose, :items, :random
def setup
@gilded_rose = GildedRose.new
@items = gilded_rose.make_items
@random = Random.new(3456789)
end
def... | true |
3fbbed50b015ae4333e74afbbb049a6c17cd7db2 | Ruby | henryaj/word-frequency-counter | /count.rb | UTF-8 | 654 | 4.3125 | 4 | [
"MIT"
] | permissive | # Word frequency counter by Henry Stanley
puts "Please enter your text. >"
text = gets.chomp
words = text.split(" ") # takes 'text' and splits using a space as a delimiter, assigns those words to an array
# set up a new hash called frequencies, with default value 0
frequencies = Hash.new(0)
# iterate over the array... | true |
0052029c8e0fa4bbe45bab53d0571840f2b655e8 | Ruby | nelsonjma/sql_to_datafile | /study/threads/threads_demo_a.rb | UTF-8 | 1,032 | 3.625 | 4 | [] | no_license | require 'rubygems'
def funcA
i=0
while i <=10
puts 'func A at: ' + Time.now.to_s + "\n"
sleep(2)
i=i+1
end
return 69
end
def funcB
(0..10).each do
puts 'func B at: ' + Time.now.to_s + "\n"
sleep(2)
end
return 70
end
puts 'Start Threads at: ' + Time.now.to_s
############# threa... | true |
b87cdd09db4c2d9a8a955d8a038aed29712886fb | Ruby | saner/masterclass-res | /lib/aggregates/article.rb | UTF-8 | 626 | 2.53125 | 3 | [] | no_license | require 'aggregate_root'
module Aggregates
class Article
include AggregateRoot
AlreadyCreated = Class.new(StandardError)
def initialize(id)
@id = id
@state = :draft
end
def create(author:, title:, content:)
raise AlreadyCreated if @state == :created
apply ArticleCreated... | true |
f2955c315f7b6110d6436ff5cb63e4b940a093fd | Ruby | hanami/view | /lib/hanami/view/exposures.rb | UTF-8 | 1,822 | 2.578125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "tsort"
require "dry/core/equalizer"
module Hanami
class View
# @api private
class Exposures
include Dry::Equalizer(:exposures)
include TSort
attr_reader :exposures
def initialize(exposures = {})
@exposures = exposures
end
... | true |
39a3ce9b10d3c9fbd43c6a9f4d56495c4fe3c29a | Ruby | boisyyy/ruby-challenges | /person.rb | UTF-8 | 499 | 3.953125 | 4 | [] | no_license |
class Person
attr_accessor :name, :age
attr_reader :birth_year
def initialize(name, birth_year)
@name = name
@age = 2019 - birth_year.to_i
@birth_year = birth_year
end
def to_s
return "name: #{@name}, age: #{age}"
end
end
person = Person.new("Janel", 1973)
put... | true |
92a6ff14398963c79bb26c2cde8db125f6ce22e9 | Ruby | activefx/data_miner | /lib/data_miner/step/sql.rb | UTF-8 | 3,643 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'csv'
require 'tmpdir'
require 'posix/spawn'
require 'unix_utils'
class DataMiner
class Step
# A step that executes a SQL, either from a string or as retrieved from a URL.
#
# Create these by calling +sql+ inside a +data_miner+ block.
#
# @see DataMiner::ActiveRecordClassMethods#data_mine... | true |
6835b13b7f2fed79449b2b157c58b36ba11c6957 | Ruby | joestephens/ruby-kickstart | /session1/3-challenge/7_string.rb | UTF-8 | 483 | 3.921875 | 4 | [
"MIT"
] | permissive | # given a string, return the character after every letter "r"
#
# pirates_say_arrrrrrrrr("are you really learning Ruby?") # => "eenu"
# pirates_say_arrrrrrrrr("Katy Perry is on the radio!") # => "rya"
# pirates_say_arrrrrrrrr("Pirates say arrrrrrrrr") # => "arrrrrrrr"
def pirates_say_arrrrrrrrr(string)
char... | true |
186fa87b8a6b9b1215f30ff700d2e0e80030d925 | Ruby | y5f/Projects | /Mini comp /parser.rb | UTF-8 | 9,206 | 3.140625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
require 'pp'
require_relative 'lexer'
require_relative 'ast'
JAVA_TOKEN_DEF={
#Conditions
:if => /if/,
:else => /else/,
:do => /do/,
:while => /while/,
:for => /for/,
#Primitive types
:int => /int/,
:bool => /boolean/,
:void => /void/,
#Boolean
:true => /true/,
... | true |
0f4067a2a0a57e5e0c4104f2012a83f2aa365adc | Ruby | glitterfang/muzukashi | /test_muzukashi.rb | UTF-8 | 1,619 | 2.640625 | 3 | [] | no_license | require File.expand_path(File.dirname(__FILE__), "muzukashi")
require 'shoulda'
require 'test/unit'
require 'fileutils'
class MuzukashiTest < Test::Unit::TestCase
CAGE_DIR = '.cage'
def check_cage
if File.exist?(".cage")
FileUtils.rm_rf(".cage")
end
end
context "making the cage" do
setup... | true |
64ba5ef1e677c400d3259aab210b52d059aa8b0d | Ruby | Mimerme/RTermGame | /RenderFactory.rb | UTF-8 | 856 | 2.984375 | 3 | [] | no_license | require './RTermGame.rb'
require './RTermGame.rb'
class RenderFactory
def initialize(size_x, size_y)
@size_x = size_x
@size_y = size_y
#| ->
#down ->
@screen_buffer = Array.new(@size_y) {Array.new(@size_x) {:empty}}
end
#Clears the screen to setup for the next frame
def clear_screen
sy... | true |
9b0bfe52a4c7426d99516b0f17cf7d7035539888 | Ruby | bigxiang/leetcode | /714.best-time-to-buy-and-sell-stock-with-transaction-fee/default.rb | UTF-8 | 484 | 3.125 | 3 | [
"MIT"
] | permissive | #
# @lc app=leetcode id=714 lang=ruby
#
# [714] Best Time to Buy and Sell Stock with Transaction Fee
#
# @lc code=start
# @param {Integer[]} prices
# @param {Integer} fee
# @return {Integer}
def max_profit(prices, fee)
with_s = 0
without_s = 0
prices.each_with_index do |p, i|
if i.zero?
with_s = -p
... | true |
9a6062f38ede3753967659b335721a90540851f9 | Ruby | jbvance/prime-ruby-v-000 | /prime.rb | UTF-8 | 132 | 3.46875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def prime?(int)
return false if int < 2
for num in 2..(int - 1)
if (int % num) == 0
return false
end
end
true
end
| true |
7170e3d4e0731cf3afa98137dd0f52061fb201bd | Ruby | dearshrewdwit/bitmap_editor | /app/errors/bitmap_errors.rb | UTF-8 | 610 | 2.828125 | 3 | [] | no_license | class BitmapError < StandardError
end
class InvalidCommand < BitmapError
def initialize(command_letter)
super("unrecognised command '#{command_letter}' :(")
end
end
class InvalidParameters < BitmapError
def initialize(msg = 'invalid parameters for command')
super
end
end
class NoImage < BitmapError
... | true |
3957fed3ae29ce70616d1fc2983068e5c16817e0 | Ruby | ciprianna/06-23-foodz | /models/recipe.rb | UTF-8 | 2,043 | 3.109375 | 3 | [] | no_license | class Recipe < ActiveRecord::Base
validates :name, presence: true, uniqueness: true
validates :recipe_type_id, presence: true
validates :time_to_make, presence: true
validates :information, presence: true
has_and_belongs_to_many :foods
# Returns recipes based on amount of time it takes to make
#
# tim... | true |
0a85f4a8a0ff5968f9a7d259ecdf475e005000d3 | Ruby | patricewhite/Ruby | /Strings/string_interpolation.rb | UTF-8 | 368 | 4.71875 | 5 | [] | no_license | # interpolation automatically converts to correct type
name = "Patrice"
p "Hello #{name}, how are you?"
age = 24
#old way
# to_s is to string
p "I am " + age.to_s + " years old"
#new way (Better)
p "I am #{age} years old"
p "The result of adding 1 + 1 is #{1 + 1}"
p "In 5 years, I will be #{age + 5} years old"
... | true |
4ecedad5fe46159040e152c2df26954cb1b6f540 | Ruby | imcodingideas/learning_ruby | /day_13/anagrams.rb | UTF-8 | 444 | 3.140625 | 3 | [] | no_license | def canonical(letter)
letter.split(//).sort!
end
def are_anagrams?(word_a, word_b)
canonical(word_a) == canonical(word_b)
end
p are_anagrams?('omar', 'amor')
p are_anagrams?('omar', 'amor')
def anagrams_for(word, array)
empty_array = []
letter = word.split(//).sort
array.select do |word|
x = word.split... | true |
33677a98cbd912519c0aeb342969106c4aef0c28 | Ruby | shasbot/cse548-project2 | /host-script/montool.rb | UTF-8 | 580 | 3.109375 | 3 | [] | no_license | #! /usr/bin/ruby
# SCRIPT to run on hosts, will parse data from other utilities, create syslog style events and add them to the database
#variables to read from config
use_w = TRUE
# var
#syslog event class
class LogObject
attr_accessor :timestamp, :pid, :hostname, :progname, :message
def initialize(timestamp,... | true |
3295972cbfba3957af0de1d5f3f75ddc430d86a3 | Ruby | phylor/techtalk-ruby-2.5 | /performance.rb | UTF-8 | 943 | 3.21875 | 3 | [] | no_license | require 'benchmark/ips'
Benchmark.ips do |x|
x.report "Large string interpolation" do |t|
a = "Hellooooooooooooooooooooooooooooooooooooooooooooooooooo"
b = "Wooooooooooooooooooooooooooooooooooooooooooooooooooorld"
t.times { "#{a}, #{b}!" }
end
x.report "Small string interpolation" do |t|
a = "H... | true |
ccebce76fa163da5991ea38aeeff829dab4cc749 | Ruby | oreillymedia/asciidoctor-htmlbook | /scripts/convert_book.rb | UTF-8 | 672 | 2.796875 | 3 | [] | no_license | # This script runs through a book folder and converts all asciidoc files to htmlbook files
require 'rubygems'
require 'asciidoctor'
require 'fileutils'
book_folder = ARGV[0]
raise "Book Folder does not exist: #{book_folder}" unless File.exists?(book_folder)
Dir.glob("#{book_folder}**/*.{asciidoc,adoc,asc}") do |file|... | true |
7480949a9101894174f2f153165325f9950d30d8 | Ruby | iguto/nothello | /lib/board.rb | UTF-8 | 2,700 | 3.375 | 3 | [] | no_license | require 'forwardable'
# require 'marshal'
class Board
attr_accessor :panels, :panel_iterator
SIZE = 8
DIRECTIONS = [:up, :right, :down, :left]
def initialize
create_empty_panels
set_panel(Position.new(3,3), Panel::TYPE::WHITE)
set_panel(Position.new(4,4), Panel::TYPE::WHITE)
set_panel(Positio... | true |
66a6d6dc3a493be62c61bae7b26bd1a44a7a9702 | Ruby | nbr625/Odin-Building-Blocks | /bubble_sort.rb | UTF-8 | 811 | 4.125 | 4 | [] | no_license |
## Takes an array of numbers and sorts them from lowest to largest
def bubble_sort(array)
misplaced = array.size - 1
while misplaced > 0
1.upto(misplaced) do |i|
if array[i - 1] > array[i]
array[i - 1], array[i] = array[i], array[i - 1] #blup, blup
end
end
misplaced -= 1
end
print array
e... | true |
d987e42faff9d8a24f2ce28fd22119a8f27cb013 | Ruby | dustinsmith1024/bracket | /app/models/team.rb | UTF-8 | 5,974 | 3.09375 | 3 | [] | no_license | class Team < ActiveRecord::Base
default_scope order('division, seed')
has_and_belongs_to_many :tags
has_many :winners, :class_name => 'Game', :foreign_key => 'winner_id'
has_many :team_ones, :class_name => 'Game', :foreign_key => 'team_one_id'
has_many :team_twos, :class_name => 'Game', :foreign_key => 'team_... | true |
db6cc41b6d87dba23d87f4f2f78691066621d7be | Ruby | philipesteiff/fastlane | /fastlane/actions/af_get_github_milestone.rb | UTF-8 | 5,096 | 2.5625 | 3 | [
"MIT"
] | permissive | module Fastlane
module Actions
module SharedValues
GITHUB_MILESTONE_NUMBER = :GITHUB_MILESTONE_NUMBER
end
# To share this integration with the other fastlane users:
# - Fork https://github.com/KrauseFx/fastlane
# - Clone the forked repository
# - Move this integration into lib/fastlane/... | true |
10ecb15ffd5b30d32fd19ebd0dd1147b58568699 | Ruby | benrodenhaeuser/exercises | /practice_problems/02_factorial.rb | UTF-8 | 2,100 | 4.3125 | 4 | [] | no_license | # Write a method that takes an integer `n` in; it should return
# n*(n-1)*(n-2)*...*2*1. Assume n >= 0.
#
# As a special case, `factorial(0) == 1`.
#
# Difficulty: easy.
# Recursion
def factorial(n)
if n == 0
1
else
n * factorial(n - 1)
end
end
puts("\nTests for #factorial — recursive solution")
puts("... | true |
a02098430ac2106a830f530e0f01c96b9dda7493 | Ruby | tfielder/sweater_weather | /app/services/giphy_request.rb | UTF-8 | 697 | 2.59375 | 3 | [] | no_license | class GiphyRequest
def initialize(term)
@term = format_term(term)
end
def get_url
get_giphy["data"][0]["url"]
end
private
def format_term(term)
term.gsub(/ /, '+')
end
def connection(url)
connect = Faraday.new(:url => "#{url}") do |f|
f.request :url_encoded
f.adapter Farad... | true |
d1d8f32f84e71fa7192891ca587a4758ce8c33e8 | Ruby | momajd/ruby-js-algorithms | /Ruby/strings/string_to_integer.rb | UTF-8 | 313 | 3.53125 | 4 | [] | no_license | def to_integer(str)
integer = 0
i = 0
neg = false
if str[0] == "-"
neg = true
i += 1
end
multiplier = 10**(str.length - 1 - i)
while i < str.length
digit = str[i].ord - "0".ord
integer += multiplier * digit
multiplier /= 10
i += 1
end
neg ? integer * -1 : integer
end
| true |
086df83e2ece8e52f5127dafa137b69021b737ae | Ruby | songzhou21/ruby | /sbxh/queue_thread.rb | UTF-8 | 254 | 3.234375 | 3 | [] | no_license | require 'thread'
q = Queue.new
producer = Thread.new {
10.times { |i|
q.push(i)
sleep(1)
}
q.push(nil)
}
consumer = Thread.new {
loop {
i = q.pop
break if i == nil
puts i
}
}
consumer.join
| true |
e824eab35a241b84f0a0fe7bbdede14bbfcefe38 | Ruby | Intimaria/ttps-ruby-tests | /src/01/12_longitud.rb | UTF-8 | 86 | 2.90625 | 3 | [] | no_license | def longitud(array)
a = []
array.map { |x| a << (x.nil? ? 0 : x.length) }
a
end
| true |
a0ef4356d873eb6073ce1a13fae291a945e73097 | Ruby | Hitendra1632/outlook_calendar | /lib/outlook_calendar/rest_caller.rb | UTF-8 | 657 | 2.71875 | 3 | [] | no_license | module OutlookCalendar
class RestCaller
attr_reader :method, :url, :headers, :params
def initialize(method, url, headers, params = {})
@method = method
@url = url
@headers = headers
@params = params
end
def call
parse_response
end
private
def parse_respons... | true |
fc0a98a741970fcd78069746fc3d166537a7e918 | Ruby | mknycha/sports-events-scraper | /classes/models/general_event.rb | UTF-8 | 1,375 | 2.875 | 3 | [] | no_license | # frozen_string_literal: true
class GeneralEvent < ActiveRecord::Base
EVENT_NAME_DELIMITER = ' v '
self.abstract_class = true
validates :team_home, :team_away, :link, :reporting_time,
:score_home, :score_away,
:ball_possession_home, :ball_possession_away,
:attacks_home, :attacks_away,
:shots_on_target_h... | true |
9ba5e135d71e852c104c83d5b746b1280537a316 | Ruby | LelandCurtis/enigma | /spec/enigma_spec.rb | UTF-8 | 5,464 | 3.140625 | 3 | [] | no_license | require 'simplecov'
SimpleCov.start
require 'date'
require './lib/enigma'
require './lib/cypher'
require './lib/encoder'
describe Enigma do
before(:each) do
@enigma = Enigma.new()
end
describe 'initialize' do
it 'exists' do
expect(@enigma).to be_a(Enigma)
end
it 'has attributes' do
end... | true |
9a644e19c99f5997d81d1a0cbfd1d6e0ba3d046a | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/clock/cb4c30be58fa49f4bdbda89b9bf9692d.rb | UTF-8 | 500 | 3.40625 | 3 | [] | no_license | class Clock
attr_reader :hour, :minute
def Clock.at (h, m = 0)
c = Clock.new(h, m)
end
def initialize (h, m)
@hour = h
@minute = m
end
def to_s
"%02d:%02d" % [@hour, @minute]
end
def + (d)
m = @minute + d
h = @hour
while m >= 60
m -= 60
h += 1
end
while m ... | true |
a28671b0f60660634ae8bdd4fa65c21442f9cfc1 | Ruby | DanielSLew/Ruby_Small_Problems | /Foundations/Advanced1/rotating_matrices.rb | UTF-8 | 814 | 4.34375 | 4 | [] | no_license | # Write a method that takes a matrix and rotates it 90 degrees
# Examples:
matrix1 = [
[1, 5, 8],
[4, 7, 2],
[3, 9, 6]
]
matrix2 = [
[3, 7, 4, 2],
[5, 1, 0, 8]
]
new_matrix1 = rotate90(matrix1)
new_matrix2 = rotate90(matrix2)
new_matrix3 = rotate90(rotate90(rotate90(rotate90(matrix2))))
p new_matrix1 == ... | true |
2c2ce7b2e755842c9c3bab889a9d13a0449ef741 | Ruby | GavinThomas1192/rubyOnRailsBasics | /rubyCollections/array_addition.rb | UTF-8 | 786 | 3.8125 | 4 | [] | no_license | grocery_list = ["Milk", "Eggs", "Bread"]
grocery_list << "Carrots"
grocery_list.push("Potatoes")
# PUTS VALUE IN FRONT
grocery_list.unshift("Ice Cream")
# This doesn't work unless its in an array
grocery_list += ["Ice Cream", "Pie"]
puts grocery_list
# puts grocery_list.last
# puts "Count! #{grocery_list.coun... | true |
2270dec78be91bf059deffc8a00bfadebe1f0dbc | Ruby | nickdba/Ruby | /subtitrari.rb | UTF-8 | 1,358 | 3.125 | 3 | [] | no_license | # Print side by side vids and subs
def print_side_by_side(vids, subs)
for i in (0..vids.size-1) do
printf "%-60s %-60s\n", File.basename(vids[i]), File.basename(subs[i])
end
end
# Mach subtitles names with video file names
def match_names(vids,subs)
for i in (0..vids.size-1) do
vid = vids[i]; subt = su... | true |
9b4ff97c4de5d87cebc7ca2e2cf5927782019230 | Ruby | RandyCoffman/writing_string_methods | /delete_character_test.rb | UTF-8 | 610 | 3.15625 | 3 | [] | no_license | require "minitest/autorun"
require_relative "delete_character.rb"
class Delete_method < Minitest::Test
def test_boolean #This is made to pass so I can establish a base
assert_equal(true, true)
end
def test_string
assert_equal(String, delete("abc", "a").class)
end
def test_delete
assert_equal("heo", delet... | true |
8418d2cca2de9ed2281168541958e756d5d23b07 | Ruby | Blakealtman123/Ixperience | /quizes/ruby_quiz.rb | UTF-8 | 2,134 | 5.15625 | 5 | [] | no_license | # Yay shark cage diving! First, we will define a Fish class.
class Fish
def initialize(color, name, speed)
@color = color
@name = name
@speed = speed
@food = []
end
def get_speed
@speed > 20 ? "This fish swims super fast!" : "This fish is kinda slow"
end
end
# STEP 4: Now we want to cre... | true |
c7038a60f9381057b7eaedc504b8132d5ac922c7 | Ruby | QPC-WORLDWIDE/rubinius | /lib/yaml/encoding.rb | UTF-8 | 612 | 2.8125 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #
# Handle Unicode-to-Internal conversion
#
module YAML
#
# Escape the string, condensing common escapes
#
def YAML.escape( value, skip = "" )
value.gsub( /\\/, "\\\\\\" ).
gsub( /"/, "\\\"" ).
gsub( /([\x00-\x1f])/ ) do |x|
skip[x] || ESCAPES[ x.unpack("C")[0] ]
... | true |
c09fc190dd8bb3aa15a10e854019e5db831d6702 | Ruby | sunaku/kwalify | /lib/kwalify/util.rb | UTF-8 | 4,223 | 2.796875 | 3 | [
"MIT"
] | permissive | ###
### $Rev$
### $Release: 0.7.2 $
### copyright(c) 2005-2010 kuwata-lab all rights reserved.
###
module Kwalify
module Util
module_function
##
## expand tab character to spaces
##
## ex.
## untabified_str = YamlHelper.untabify(tabbed_str)
##
def untabify(str, width=8)
ret... | true |
6ba88aa29dfe7197a4aec854f02d991ad92e7401 | Ruby | phillyrb/ec2manage | /lib/ec2manage/structure.rb | UTF-8 | 1,005 | 2.6875 | 3 | [] | no_license | require 'pathname'
require 'json'
require 'ostruct'
class EC2Manage::Structure
attr_reader :options
attr_reader :zone, :ami, :keypair, :group
attr_reader :volumes
def initialize(options)
@options = options
load_template
override_options
end
def override_options
[:zone, :ami, :keypair, :g... | true |
0463b95df2ad0eba2b85aaaa5c2128f2894e65c6 | Ruby | m1foley/fit-commit | /lib/fit_commit/validators/base.rb | UTF-8 | 1,041 | 2.65625 | 3 | [
"MIT"
] | permissive | require "fit_commit/has_errors"
module FitCommit
module Validators
class Base
include FitCommit::HasErrors
attr_accessor :branch_name, :config
def initialize(branch_name, config)
self.branch_name = branch_name
self.config = config
end
@all = []
class << self
... | true |
d4698d8b3570cc63d7a8c42343c7a446a0d8a773 | Ruby | bbttxu/wuwt-strike | /pips.rb | UTF-8 | 900 | 2.84375 | 3 | [] | no_license | #!/usr/bin/env ruby -wKU
# ruby script written after reading http://wattsupwiththat.com/2010/08/02/noaa-graphs-62-of-continental-us-below-normal-in-2010/
# processing in post appears overly simplistic, does not take into account weights of variations
require 'rubygems'
require 'PixelCounter'
require 'json'
color_weigh... | true |
a0509ec9ffb07417da0ad120d20f6da188bd88eb | Ruby | jrsacks/RubyVoiceControlledHomeAutomation | /code/lambda/ruby/tv_control.rb | UTF-8 | 2,329 | 2.625 | 3 | [] | no_license | $LOAD_PATH.unshift(File.dirname(__FILE__))
require 'aws-sigv4'
require 'net/http'
require 'json'
def send_to_sqs(key, secret, queue, message)
url = queue + "?Action=SendMessage&MessageBody=#{URI.encode_www_form_component(message)}"
signer = Aws::Sigv4::Signer.new(
service: 'sqs',
region: queue.split('.')[1... | true |
0f36c843bcc93da4d13d6a64c5960470e02b1e92 | Ruby | wonda-tea-coffee/atcoder | /abc/016/a.rb | UTF-8 | 66 | 2.71875 | 3 | [] | no_license | m, d = gets.chomp.split.map(&:to_i)
puts m % d == 0 ? 'YES' : 'NO' | true |
6540f07ff5214d82197ba7c9e61c4cc5b6d74efb | Ruby | sonchez/course_101 | /lesson3_practice_problems/practice_problems_medium_1/problem_5.rb | UTF-8 | 405 | 3.921875 | 4 | [] | no_license |
# the limit variable is not within the scope of the method.
# Unless the method calls the variable as an argument, it cannot
# enter the scope of the method.
# solution below
limit = 15
def fib(first_num, second_num, limit)
while second_num < limit
sum = first_num + second_num
first_num = second_num
s... | true |
29fb8e8096dbb246e53f5be9b82bcc9b1041ab04 | Ruby | geremyCohen/battleship | /board.rb | UTF-8 | 3,622 | 3.84375 | 4 | [
"MIT"
] | permissive | class Board < Hash
MASQUERADE_SHIPS = false
MAX_BOARD_LENGTH = 5
MAX_BOARD_WIDTH = 5
# TODO: Fix the legend, before and after of "MISS" is broken
LEGEND = {"." => "Unknown", "I" => "Ship", "o" => "Miss", "+" => "Hit", "X" => "Entire Ship Sunk"}
# on first turn, . is a unknown
# on second turn, o is a ... | true |
b56a45c12225e6b7230c0e7bfc2b3fe943292479 | Ruby | alexvirga/deli-counter-nyc-web-060319 | /deli_counter.rb | UTF-8 | 579 | 3.75 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | katz_deli = []
def line (katz_deli)
if katz_deli.length == 0
puts "The line is currently empty."
else
prompt = "The line is currently:"
for i in 0...katz_deli.length
prompt += " #{i+1}. #{katz_deli[i]}"
end
puts prompt
end
end
def take_a_number(katz_deli, name)
katz_deli.push(name)
puts "Wel... | true |
744791589ddbd2029795b1a72d6447463191d289 | Ruby | dyevri/rubyway | /one-liners.rb | UTF-8 | 519 | 3.734375 | 4 | [] | no_license | if 4 < 12
puts "That's right!"
end
puts "That's right!" if 4 < 12
puts "I like cheese!" unless 50 < 20
#Ternary Conditional Expsession
if 40 < 2
puts 'Yes it is.'
else puts 'No it is not'
end
puts 40 < 2 ? 'Yes it is' : 'No it is not'
puts "How are you filling today?"
feeling = gets.chomp.downcase
case feelin... | true |
e0a7c3b8ffd12bd04804600bd5fa6f2acc9cecb2 | Ruby | TomK32/gallerize | /lib/gallerize_cli/image.rb | UTF-8 | 1,846 | 2.625 | 3 | [] | no_license | require 'gallerize_cli/image/version'
module GallerizeCli
class Image
include FileUtils::Verbose
attr_reader :directory, :file_path, :versions
class << self
def generate_version_method(name)
unless public_method_defined?("#{name}_url")
define_method("#{name}_url") { self.versio... | true |
8e383c9577f0818c824026b69d1b441403d30c8a | Ruby | brunocascio/UNLP-ruby-evaderApp | /test/models/person_test.rb | UTF-8 | 3,060 | 2.71875 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class PersonTest < ActiveSupport::TestCase
test "Creates people with valid data" do
people().each do |p|
assert p.save, "Should save a new person with valid data"
end
end
test "Try to create person without data" do
assert_not Person.new().save(), "Shouldn't create a new p... | true |
50105247c571cc97f4d3227699d55dbd1491eef6 | Ruby | maxerogers/Ruby-KNN | /knn.rb | UTF-8 | 1,143 | 3.828125 | 4 | [] | no_license | # Step 1 calculate the Euclidean distance from the test vector from the training vectors
# Step 2 Sort the results and determine the min K neighbors
# Step 3 Print classification
puts "K-Nearest Neighbor"
class Neighbor
attr_accessor :klass, :vector
#can't use class since its a keyword
def initialize(klass, vector... | true |
a47ad976f124551d702b0d2a067f2f8eed00a7de | Ruby | Fromalaska49/ruby-hello-world | /bottles-of-beer.rb | UTF-8 | 179 | 2.6875 | 3 | [] | no_license | <% for i in (99).downto(1) %>
<%= i %> bottles of beer on the wall, <%= i %> bottles of beer, take one down, pass it around, <%= (i - 1) %> bottles of beer on the wall
<% end %> | true |
21cca923762c4c9ff9085a1a312aae769a85b3da | Ruby | CrazyJ100/math | /addition.rb | UTF-8 | 112 | 2.671875 | 3 | [] | no_license | def add(arg1,arg2)
arg1+arg2
end
def divide(arg1,arg2)
arg1/arg2
end
def subtract(arg1,arg2)
arg1-arg2
end
| true |
2d4b5d75b49f147ec0da51d33dbe57a8b66b6677 | Ruby | da99/datoki | /specs/0030-matching.rb | UTF-8 | 3,186 | 2.609375 | 3 | [
"MIT"
] | permissive |
describe :matching do
before {
CACHE[:datoki_matching] ||= begin
reset_db <<-EOF
CREATE TABLE "datoki_test" (
id serial NOT NULL PRIMARY KEY,
title varchar(15) NOT NULL,
... | true |
3e1ed6c3bf1472aae853891854eb662735166f87 | Ruby | jgendrano/slack_project | /app/models/message.rb | UTF-8 | 2,894 | 2.625 | 3 | [] | no_license | class Message < ActiveRecord::Base
belongs_to :user
belongs_to :channel
def self.current_messages(current_user, channel)
count = 1
user_list = self.get_username_list(current_user.token)
raw_messages = self.get_messages_from_slack(current_user, channel)
current_messages = raw_messages.map do |mess... | true |
94ecf06418c3ad7a0bfd0184fc0cbe96b0b4d1bb | Ruby | W1LBER/desafio_ciclos | /alfabeto.rb | UTF-8 | 162 | 3.171875 | 3 | [] | no_license |
def gen(user)
a = "a"
arr = []
user.times do |i|
arr.push(a)
a = a.next
print arr.last
end
end
gen(5)
| true |
9acb5bf2d9c307df974c5e4812c917dfed780fa1 | Ruby | andrewcallahan/projecteuler | /16.rb | UTF-8 | 59 | 2.703125 | 3 | [] | no_license | p (2**1000).to_s.split("").collect{ |i| i.to_i }.reduce(:+) | true |
54228b345384cc1eaad5b0c4574fbb59fa0973ec | Ruby | bobcook/blog | /scripts/load-old-data.rb | UTF-8 | 2,080 | 2.734375 | 3 | [] | no_license | require 'pg'
class Loader
def initialize
@con = PG::Connection.new :host => 'ec2-54-243-50-213.compute-1.amazonaws.com',
:port => '5432',
:user => 'gdgallhkmzucyp',
:password => 'BmSWLwkVV_Bfcjwz9sZPtSsIIX',
... | true |
77bc0fe0020544c3ad22a132bbd815cce8c82e02 | Ruby | vonagam/dip | /app/models/game/engine/parser/map.rb | UTF-8 | 2,265 | 2.796875 | 3 | [] | no_license | require 'yaml'
require 'set'
require_relative '../entity/area'
require_relative '../entity/map'
module Engine
class Parser::Map
attr_accessor :maps
def initialize()
@maps = {}
map_path ||= File.expand_path('../maps/', File.dirname(__FILE__))
Dir.chdir map_path do
Dir.glob "*.... | true |
b333d39781af760269c78f45b86c40a7a91f3810 | Ruby | colinhalexander/flavortown-practice | /flavor.rb | UTF-8 | 514 | 2.90625 | 3 | [] | no_license | require_relative "./join_module.rb"
class Flavor
#extend Join::ClassMethods
include Join::InstanceMethods
attr_reader :description, :label
@@all = []
def initialize(description, label)
@description = description
@label = label
@@all << self
end
def self.all
... | true |
f7faaa8ef0318debc84a22f9bc86688ada282192 | Ruby | applelele/cartoon-collections-onl01-seng-pt-030220 | /cartoon_collections.rb | UTF-8 | 549 | 3.34375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(array)
array.each_with_index do |dwarf, index|
puts "/#{index+1}. *#{dwarf}/"
end
end
def summon_captain_planet(array)
array.map {|planeteer| "#{planeteer.capitalize}!"}
end
def long_planeteer_calls(array)
array.any? {|planeteer| planeteer.length > 4}
end
def find_the_cheese(array)
... | true |
4a7925316acde50bd4f8689b52e76a56e5ba18ff | Ruby | Alurye/collections_practice_vol_2-nyc-web-031218 | /collections_practice.rb | UTF-8 | 2,085 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # your code goes here
require ('pry')
def begins_with_r(array)
# binding.pry
array.all? {|tool|
tool.start_with?('r')
}
end
def contain_a(array)
# contains_a = []
array.select {|element|
element.include?('a')
}
end
def first_wa(array)
array.find {|word|
if word.is_a? String
word.start... | true |
647ffe9a3b8f71b0307ec01179c8377f3356d4d8 | Ruby | pierre-pat/The-Nature-of-Code-Examples | /chp7_CA/NOC_7_02_GameOfLifeSimple/NOC_7_02_GameOfLifeSimple.rb | UTF-8 | 1,772 | 3.34375 | 3 | [] | no_license | # The Nature of Code
# NOC_7_02_GameOfLifeSimple
class GOL
def initialize(width, height)
@w = 8
@rows = height / @w
@cols = width / @w
puts "rows: #{@rows} - @cols #{@cols}"
init
end
def init
@board = Array.new(@cols) do
Array.new(@rows) { random(2).to_i }
end
end
def gener... | true |
8c3e76fb06f14dfcbad34423091274bf2ef35d0a | Ruby | westernmilling/people_doc | /lib/people_doc.rb | UTF-8 | 9,118 | 2.546875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# $LOAD_PATH.unshift File.dirname(__FILE__)
require 'people_doc/version'
require 'people_doc/httparty_request'
require 'logger'
module PeopleDoc
RESPONSE_HANDLERS = {
bad_request: ResponseHandlers::HandleBadRequest,
not_found: ResponseHandlers::HandleNotFound,
unauthorized:... | true |
7799714b671a470804d7bddf95a78fce20e88fbe | Ruby | gabpoiss/zebrasclub | /db/seeds.rb | UTF-8 | 1,078 | 2.59375 | 3 | [] | no_license | puts "Cleaning database..."
OrderItem.destroy_all
Order.destroy_all
Item.destroy_all
Category.destroy_all
puts "Creating categories..."
# # New seed........
categories = ["skate", "helmet", "jersey", "pants", "armband"]
categories.each do |category|
Category.create(item_type: category)
end
# Skates
sizes = [... | true |
fd430d8e044d44a151deececf68027d226a14f21 | Ruby | chickenriceplatter/advent_of_code | /2015/problem-18-1.rb | UTF-8 | 1,283 | 3.828125 | 4 | [] | no_license | require 'pry'
string = File.read("18-1-input.txt")
def neighbors(x,y)
locations = []
locations << [x+1, y] if((x+1) < 100)
locations << [x-1, y] if((x-1) >= 0)
locations << [x, y+1] if((y+1) < 100)
locations << [x, y-1] if((y-1) >= 0)
locations << [x-1, y-1] if(((x-1)>=0)&&((y-1)>=0))
locations << [x+1... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.