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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
76ef469befcd8a964bc47a36c1ccb55031191c71 | Ruby | jfitisoff/site-object | /lib/site-object/page.rb | UTF-8 | 24,863 | 3.015625 | 3 | [
"MIT"
] | permissive | # Page objects are containers for all of the functionality of a page that you want to expose for testing
# purposes. When you create a page object you define a URL to access it, elements for all of the page
# elements that you want to work with as well as higher level methods that use those elements to perform
# page o... | true |
16280eb8681660fe3375a5c0eefd9a89a1bdff3a | Ruby | maximkoo/ruby-repo | /ZeroVision/gosu_geom.rb | UTF-8 | 5,218 | 3.03125 | 3 | [] | no_license | require 'gosu'
module GosuGeom
class Point
attr_accessor :x,:y
def initialize(x,y)
@x,@y=x,y
end;
def to_s
"x=#{@x}, y=#{@y}"
end
end;
class Segment
attr_reader :p1,:p2
def initialize(p1,p2)
@p1,@p2=p1,p2
end;
def to_s
"p1=#{p1.x},#{p1.y}, p2=#{p2.x},#{p2.y}"
end;
end;
class... | true |
2524da3e3605cd03c9ec745b043824825a2a273f | Ruby | dbrady/game-players | /grow-castle/archers.rb | UTF-8 | 3,233 | 3.640625 | 4 | [] | no_license | #!/usr/bin/env ruby
# Chart/track archers
# WHY ISN'T THERE A WAY TO DO THIS IN RUBY
def commaize(num)
num.to_s.reverse.chars.each_slice(3).map(&:join).join(",").reverse
end
# Set this to your starting/current upgrade cost and level
# Upgrading archers costs 1,000gp more at each step past the first.
# Upgrading ... | true |
4049b5070e33e6579749b6a86604565e849e9e37 | Ruby | projectmoment/justmoment.today | /app/helpers/comments_helper.rb | UTF-8 | 1,061 | 2.59375 | 3 | [] | no_license | module CommentsHelper
def getNameById(user_id)
name = User.find(user_id).name
if name.nil?
return nil
end
return name
end
def getIdByName(userName)
user = User.find_by(name: userName.delete('@'))
if user.nil?
return nil
end
return user.id
end
def r... | true |
f18142de99b50605dea49e64feaa83bc06cee6e4 | Ruby | trddddd/smartvpn-billing | /spec/lib/bytes_converter_spec.rb | UTF-8 | 1,089 | 2.71875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe BytesConverter do
describe '#bytes_to_gigabytes' do
let(:bytes) { 2147483658 }
let(:gbytes) { 2 }
subject { described_class.bytes_to_gigabytes(bytes) }
it 'converts to gbytes' do
expect(subject).to eq gbytes
end
end
describe '#prettify_float' do
sub... | true |
3e8043ac9495426ba04be7c534a1e0e65ff53c57 | Ruby | MorrisStranger/App_Academy | /Ruby/lru_cache/better_cache_and_hashmap/skeleton/lib/p07_dynamic_array_bonus.rb | UTF-8 | 3,841 | 3.53125 | 4 | [] | no_license | class StaticArray
attr_reader :store
def initialize(capacity)
@store = Array.new(capacity)
end
def [](i)
validate!(i)
self.store[i]
end
def []=(i, val)
validate!(i)
self.store[i] = val
end
def length
self.store.length
end
private
def validate!(i)
raise "Overflow e... | true |
d60fccd6fc90aa11ee3038d285f07370dea981fc | Ruby | wata-gh/survey | /app/decorators/question_decorator.rb | UTF-8 | 958 | 2.9375 | 3 | [] | no_license | module QuestionDecorator
TYPE_NAME = {
'single' => '1ใค้ธๆ',
'multiple' => '่คๆฐ้ธๆ',
'date' => 'ๆฅ็จ่ชฟๆด',
'free' => 'ใใชใผใใฉใผใใใ',
}
TYPE_COMMENT = {
'single' => '1ใค้ธๆใใฆใใ ใใ',
'multiple' => '่คๆฐ้ธๆๅฏ',
'date' => 'ๆฅ็จใๅ
ฅๅใใฆใใ ใใ',
'free' => 'ใใชใผใใฉใผใใใ',
}
def type_name
... | true |
f748843882fc266adcf8d98c58fc3d8b756e45c8 | Ruby | rjungemann/tojour | /lib/tojour/cli.rb | UTF-8 | 2,491 | 2.71875 | 3 | [
"MIT"
] | permissive | require 'base64'
require_relative 'utils'
require_relative 'sock'
require_relative 'jour'
module Tojour
class Cli
def initialize(options)
@options = options
end
def send_file(name)
Jour.new(name, 'file').resolve do |r|
Utils.log "Found #{name} running at #{r.target}:#{r.port}"
... | true |
17f31d11cc66be5b0b1c7b83103337ae96a7415a | Ruby | brettrann/advent-of-code-2015 | /day09/gareve_reddit.rb | UTF-8 | 267 | 2.625 | 3 | [] | no_license | #!/usr/bin/env ruby
dist = {}
File.readlines('input.txt').map(&:split).each do |x, to, y, equals, d|
dist[[x,y].sort] = d.to_i
end
p dist.keys.flatten.uniq.permutation.map { |comb|
comb.each_cons(2).reduce(0) {|s, x| s+ dist[x.sort] }
}.sort.rotate(-1).first(2)
| true |
d6e93b7f46f88298d15194ddfb75eacf5099e73d | Ruby | jkeroes/learn-ruby-the-hard-way | /exercises/28/ex28_test.rb | UTF-8 | 2,249 | 3.390625 | 3 | [] | no_license | require 'minitest/autorun'
class BooleanTests < MiniTest::Unit::TestCase
def test_minitest
assert_equal 1, 1
assert_equal 'a', 'a'
assert_equal true, true
refute_equal true, false
end
def test_boolean_practice
assert_equal true, (true and true)
assert_equal false, (false and true)
a... | true |
1d307a9dd6e176d9d590b141a9af589799031823 | Ruby | binarygit/caeser_cipher | /spec/main_spec.rb | UTF-8 | 1,561 | 3.03125 | 3 | [] | no_license | require 'rspec'
require './lib/main'
RSpec.describe CaeserCipher do
describe '#encode' do
it 'encodes a single letter' do
expect(subject.encode('b', 3)).to eql('e')
end
it 'encodes another single letter' do
expect(subject.encode('x', 4)).to eql('b')
end
it 'encodes all english alp... | true |
e76027edd3dc63822f79a0e7505a040081bedacd | Ruby | jaesypg/facebook | /app/models/user.rb | UTF-8 | 440 | 2.53125 | 3 | [] | no_license | class User < ActiveRecord::Base
# Remember to create a migration!
# e.g., User.authenticate('josh@codedivision.com', 'apples123')
has_many :statuses
has_many :likes
def self.authenticate(email, password)
# if email and password correspond to a valid user, return that user
# otherwise, return nil
@... | true |
59e32b5cd6a644b317541a5cc379f46301beccbd | Ruby | noahpatterson/Episode7-1 | /lib/calculates_route.rb | UTF-8 | 648 | 3.359375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class CalculatesRoute
def self.calculate(points)
remaining_points = points
route = []
route << {point: remaining_points.slice!(0), distance: 0}
until remaining_points == [] do
next_point = shortest_distance(route.last.fetch(:point), remaining_points)
remaining_points.delete(next_point.fe... | true |
6a4bc478c2bf42c6255f90097cd86898677760a9 | Ruby | ngoctoandhv/Ruby_Basic | /04. Ruby - String/01.String.rb | UTF-8 | 2,127 | 3.609375 | 4 | [] | no_license |
#==============================================tu hoc ===========================================
puts %*xin chao "Ban"*
# ket qua: xin chao "Ban"
c="Ngoc Toan"
puts %*xin chao "Ban":#{c}*
#ketqua : xin chao "Ban":Ngoc Toan
#kiem tra chuoi rong hay ko
s=""
s.empty?
# ket qua : true
# gan chuoi
a="nguyen"
b="toan... | true |
0156eb086ef54a2185f67c633a68b7d16b145bd5 | Ruby | arkorwan/advent-of-code | /2019/p12.rb | UTF-8 | 785 | 3.078125 | 3 | [] | no_license |
apos = [
[5,4,4],
[-11,-11,-3],
[0,7,0],
[-13,2,10]
]
pos = apos.map(&:clone)
vel = Array.new(4).map{[0,0,0]}
# part 1
1000.times{
4.times.to_a.combination(2){|i,j|
3.times{|k|
g = pos[i][k] <=> pos[j][k]
vel[i][k] -= g
vel[j][k] += g
}
}
4.times{|i|
3.times{|k|
pos[i][k] += vel[i][k]
... | true |
9aa9248578ac08215536d2b931f1a2b3b0bada9c | Ruby | TahaMaqbool/book-review-api | /app/workers/reminder_worker.rb | UTF-8 | 1,022 | 2.5625 | 3 | [] | no_license | class ReminderWorker
include Sidekiq::Worker
DATES = %w[24-12-2019 13-12-2019].freeze
EVENTS = [
{
date: '24-12-2019',
event: 'Faizan Birthday'
},
{
date: '13-12-2019',
event: 'Test Event'
}
].freeze
def perform
date_today = Date.today.strftime('%d-%m-%Y')
i... | true |
a6bd5a93b8f5564a302a31670a9cbb5f55ab2c07 | Ruby | viswans83/rsirts | /lib/rsirts/parser.rb | UTF-8 | 913 | 2.90625 | 3 | [
"MIT"
] | permissive | module Rsirts
class ParseError < StandardError; end
class Parser
ZMAP_VALUES = Hash[ "12345689-".each_char.to_a.map { |v| [v, v == '-' ? 0 : v.to_i] } ]
def self.parse path
new.parse path
end
def parse path
map_depth(
File.new(path)
.readlines
.map { |l... | true |
1ddbb6526369d3b6940026a4b5a45078e3f04f75 | Ruby | ymagoon/learn_ruby | /basic/mastermind.rb | UTF-8 | 3,110 | 4.28125 | 4 | [] | no_license | =begin
Now refactor your code to allow the human player to choose whether she wants to be the creator of the secret code or the guesser.
Build it out so that the computer will guess if you decide to choose your own secret colors. Start by having the computer guess randomly (but keeping the ones that match exactly).
Nex... | true |
1782e20fe1a1639f34602faf9eda99b373864563 | Ruby | oriolgual/basecamp2_to_basecamp3 | /todos_import.rb | UTF-8 | 785 | 2.578125 | 3 | [] | no_license | require_relative 'todo_list'
class TodosImport
attr_reader :client, :project_id, :todo_list_id, :basecamp_3_project_url
def initialize(client, project_id, todo_list_id, basecamp_3_project_url)
@client = client
@project_id = project_id
@todo_list_id = todo_list_id
@basecamp_3_project_url = basecamp... | true |
29cf773588337f8487cffdd0df105f07db54246b | Ruby | nishants/gyani | /todo.rb | UTF-8 | 2,448 | 2.65625 | 3 | [] | no_license | TODO
0. why to consider max weight at all.
-1. KeyMap can be called as Index
2. create a client.
3. create search by keywords.
5. remove all semicolons
6. separate settings for test and development.
7. create migrations.
8. add modules for all classes.
9.corrent indentation to two tabs in all files.
10. add tests for m... | true |
ba36e5de11de04f8af0ad24bece3241ee6082921 | Ruby | tommyrharper/bank-tech-test | /spec/statement_spec.rb | UTF-8 | 1,110 | 2.828125 | 3 | [] | no_license | require 'statement'
describe Statement do
it 'creates an accurate statement with one deposit' do
transaction_double = double(
:Transaction,
date: '10/01/2012',
amount: 1000,
type: 'credit',
balance: 1000
)
transaction_list = [transaction_double]
subject.update(transacti... | true |
34b4f9fc0e70d2f0afd8eab9733f43b7a571665a | Ruby | jocegonz/api-muncher | /lib/edamam_api_wrapper.rb | UTF-8 | 1,699 | 2.859375 | 3 | [] | no_license | # require 'httparty'
class EdamamApiWrapper
BASE_URL = "https://api.edamam.com/search"
SHOW_URL = "http://www.edamam.com/ontologies/edamam.owl%23"
APP_ID = ENV["app_id"]
APP_KEY = ENV["app_key"]
def self.search(query)
#needs to be encoded
encoded_query = URI.encode("#{query}")
url = BASE_URL + "... | true |
af52cd219f57b20f5ef10c721507cfbabd5280cf | Ruby | MidnightDemon/tanuki | /test/unit/user_test.rb | UTF-8 | 790 | 2.671875 | 3 | [] | no_license | require 'test_helper'
class UserTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
test "should not save user without an email/password" do
user = User.new
assert !user.save, "Saved the user without an email/password"
end
=begin
test "entries for date should return a valid ... | true |
2014a51e5326291a78b82ce9422e6af12f130c2a | Ruby | johslarsen/jrb | /bin/rpath.rb | UTF-8 | 1,506 | 2.875 | 3 | [
"Unlicense"
] | permissive | #!/usr/bin/env ruby
module RPath
# Public: Determine the relative path to target from directory
def self.relative(target, directory)
target = File.expand_path(target)
directory = File.expand_path(directory) << "/"
target << "/" if directory.start_with?(target)
return "./" if target == directory
... | true |
6e12de1a23dbe8f5d1a716a36fb6cd6fc1d10a02 | Ruby | drjolo/RubyLearning | /week_3/exercise5-String_exercises.rb | UTF-8 | 494 | 3.328125 | 3 | [] | no_license | =begin
doctest: hash_string_to_pairs(string) separates a string with a key/value pair into separate strings
>> key = ':id'
>> value = rand(10).to_i.to_s
>> test_string = "#{key}=#{value}"
>> arr = hash_string_to_pairs( test_string )
>> arr == [key, value]
=> true
=end
def hash_string_to_pairs( hash_string )
k... | true |
81ceb0271a5839a90861b283dc64b4c2f6fede17 | Ruby | RJB92/Ruby | /angry_boss.rb | UTF-8 | 249 | 3.078125 | 3 | [] | no_license | puts "WHAT THE FUCK DO YOU WANT!!!!"
want = gets.chomp
if want == 'Less Money'.downcase
puts "Oh sounds about fair, NOW BACK TO WORK MUTHA FUCKA!!!"
else
puts "WHADYA MEAN YOU WANT " + want.upcase + "!!!!!!!!! YOOOUUURRRREEEE FIIAAAARRRDDD"
end
| true |
e6e02974f6781c1c354134d00bf4c09fb97065fb | Ruby | miyagawa/roar | /lib/roar/representer/json/hal.rb | UTF-8 | 2,050 | 2.59375 | 3 | [] | no_license | module Roar::Representer
module JSON
module HAL
def self.included(base)
base.class_eval do
include Roar::Representer::JSON
include Links # overwrites #links_definition_options.
extend ClassMethods # overwrites #links_definition_options, again.
end
en... | true |
57adf76065f508625d079857b43bfc18829192a8 | Ruby | ludwigbacklund/CodiWeb | /CodiGrammar.rb | UTF-8 | 4,936 | 2.640625 | 3 | [] | no_license | require_relative "parse.rb"
require_relative "CodiLogic.rb"
class CodiWeb
attr_accessor :variable_list
def initialize(file)
@file = file
@ruleparser = Parser.new("CodiWeb") do
token(/\s/)
token(/\d+/) { |x| x.to_i }
token(/(\w+-\w+|\w+|"{1}.+?"{1})/) { |x| x }
token(/(==|<=|>=|<|>|!... | true |
da288be6a47c7a2d053d18b6d84f21984719fc99 | Ruby | j4netkim/cli-proj | /lib/nailpolish.rb | UTF-8 | 487 | 2.78125 | 3 | [
"MIT"
] | permissive | class NailPolish
attr_reader :brand, :name, :price, :product_colors, :tag_list, :polish_list
@@all = []
def initialize(brand: nil, name: nil, price: nil, product_colors: nil, tag_list: nil, polish_list: nil)
@brand = brand
@name = name
@price = price
@product_color... | true |
93d7e16a14fc0db74b12c8177113f147a86a642d | Ruby | kken339039/leetcode-club | /Ruby/topic_202_happy_numer.rb | UTF-8 | 265 | 3.5 | 4 | [] | no_license | # @param {Integer} n
# @return {Boolean}
def is_happy(n)
cache = {}
while !cache[n] && n != 1
cache[n] = n
n.to_s.split("").each_with_index do |e, i|
val = e.to_i
n = 0 if i == 0
n += val**2
end
end
return n == 1
end | true |
d4da6d2f3d91e3080ee0f83591a73a05c5a276a8 | Ruby | DanielLChang/AppAcademy | /w1/w1d5/tictactoeai/skeleton/lib/tic_tac_toe_node.rb | UTF-8 | 1,268 | 3.546875 | 4 | [] | no_license | require_relative 'tic_tac_toe'
class TicTacToeNode
MASTER_LIST = [0, 1, 2].product([0, 1, 2])
attr_accessor :board, :next_mover_mark, :prev_move_pos
def initialize(board, next_mover_mark, prev_move_pos = nil)
@board = board
@next_mover_mark = next_mover_mark
@prev_move_pos = prev_move_pos
end
... | true |
98f0d1e4ef0dfe0de57fdf0f55920d635386372f | Ruby | arceusVen1/javeloTests | /backend/level_3/milestone.rb | UTF-8 | 225 | 2.6875 | 3 | [] | no_license | require 'date'
class Milestone
attr_reader :id, :objective, :target, :date
def initialize(id, objective, target, date)
@id = id
@objective = objective
@target = target
@date = Date.parse(date)
end
end | true |
fa09614d9235b981c87fb367dd8b9af875607df8 | Ruby | tfausak/erudite | /spec/erudite/example/outcome_spec.rb | UTF-8 | 1,362 | 2.59375 | 3 | [
"MIT"
] | permissive | # coding: utf-8
require 'spec_helper'
describe Erudite::Example::Outcome do
it 'requires a result' do
expect { described_class.new }.to raise_error(ArgumentError)
end
it 'requires some output' do
expect { described_class.new(nil) }.to raise_error(ArgumentError)
end
it 'can be initialized' do
e... | true |
51c0e19ebd22cde8b2dbf7dc8107712df8d39c64 | Ruby | jwoertink/sample_shoes | /clock.rb | UTF-8 | 2,175 | 2.9375 | 3 | [] | no_license | font 'ShareTechMono-Regular.ttf' #http://www.google.com/fonts#QuickUsePlace:quickUse/Family:
Shoes.app(width: 500, height: 400, title: 'Sample Shoes Clock') do
# Setup Variables
@center_x = app.width / 2
@diameter = 280
@radius = @diameter / 2
@offset_y = 10
@marker_length = 15
@fps = 10
def clock_h... | true |
134d86fea0c62622f653daedbfbfeb05be1c181f | Ruby | FantasticJimmy/Lighthouse_Labs | /W2/D4/lighthouse-test-oop-mock-STUDENT_NAME/lib/bazuka.rb | UTF-8 | 174 | 2.875 | 3 | [] | no_license | class Bazuka < Weapon
def initialize
@name = "Bazuka"
@weight = 40
@damage = 15
@range = 1
end
def hit(enemy)
enemy.wound(@damage,@name)
end
end | true |
9b5afc0451de41a710dc7f4be3c86396d7c91fdc | Ruby | georgedayiv/sparktest | /app/controllers/spark_controller.rb | UTF-8 | 1,905 | 2.8125 | 3 | [] | no_license | require 'spark_core'
class SparkController < ApplicationController
def index
if params[:core] && Reading.pluck(:core).include?(params[:core])
@chart = chart(params[:core].to_s)
else
@chart = chart("Spark1")
end
end
def spark1
@spark1 = Reading.new
reading = get_readings(SPARK1)
@spark1.core = "S... | true |
9f28697c70602a8416fd46bba07b53abd59b194f | Ruby | jomi-se/aoc | /2017/day20/part_2.rb | UTF-8 | 2,040 | 3.03125 | 3 | [] | no_license | module Day20
class Part2
def self.run(particles)
@particles = []
particles.each_with_index do |particle, index|
split = particle.split(', ')
pdef = split[0]
vdef = split[1]
adef = split[2]
pdef_split = pdef.match(/p=<(.*),(.*),(.*)>/).captures
... | true |
ed8687d7d2d0e0e6251627b7157c84540ad24ea9 | Ruby | vishnugopal/colloquy | /lib/colloquy/helpers/scribe.rb | UTF-8 | 2,345 | 2.671875 | 3 | [] | no_license | require 'singleton'
require 'yaml'
class Colloquy::ScribeConfigurationNotFoundException < Exception
end
class Colloquy::ScribeGemsNotFoundException < Exception
end
class Colloquy::ScribeConnectionNotFoundException < Exception
end
module Colloquy::Helpers::Scribe
def self.included(klass)
klass.class_eval do
... | true |
707009e999ab21cccb640c743881d55332289ea0 | Ruby | thatrubylove/foptparse | /lib/foptparse.rb | UTF-8 | 594 | 2.921875 | 3 | [] | no_license | require 'ruby_love'
require 'options'
module RubyLove::OptionParser
extend self
def parse(text="")
help = Options::HelpCommandOption.command
return help if empty?(text)
split_argument_and_options(text)
end
alias_method :call, :parse
private
def empty?(text)
text.size == 0
end
def ext... | true |
e59814ca9359c124a7debdf6ea725ef361935e5a | Ruby | tysonvanburen/DPL-notes | /modules.rb | UTF-8 | 687 | 3.40625 | 3 | [] | no_license | class Router
def get(path, options = {}, &block)
puts "before block"
yield
puts "after block"
#yield tells ruby to run whatevers inside that block of code and when its done go ahead and run the method.
end
def debug(*data)
data.each do |datum|
puts datum
end
end
# a splat "*" go... | true |
93073f567ab6fd17aa674f4792cf79a2467d6713 | Ruby | sgg2123/apples-and-holidays-prework | /lib/holiday.rb | UTF-8 | 1,075 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def second_supply_for_fourth_of_july(holiday_hash)
holiday_hash[:summer][:fourth_of_july][1]
end
def add_supply_to_winter_holidays(holiday_hash, supply)
holiday_hash[:winter].each do |holiday, items|
items.push(supply)
end
end
def add_supply_to_memorial_day(holiday_hash, supply)
holiday_h... | true |
d72444ea1b8e2d80d2c65c492c4fa5e4d659429e | Ruby | johnktravers/flash_cards | /test/card_generator_test.rb | UTF-8 | 1,539 | 3.203125 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/card'
require './lib/turn'
require './lib/deck'
require './lib/round'
require './lib/card_generator'
class CardGeneratorTest < Minitest::Test
def setup
@filename = "lib/cards.txt"
@actual_cards = CardGenerator.new(@filename)
... | true |
3b66db01fbc2175975f227df547374c099798003 | Ruby | schazbot/oxford-comma-london-web-career-021819 | /lib/oxford_comma.rb | UTF-8 | 862 | 4.28125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(array)
if array.length == 1
array.join
elsif array.length == 2
array.join(" and ")
else
array.insert(-2, "and ")
last_word = array.last
string = array[0..-2].join(", ")
string << last_word
end
end
#return
#Write a method oxford_comma that takes an argument array ... | true |
04b26ba4451eca5cc3c6202caa2c98086d4c3b13 | Ruby | thinker1981/CloudStatsAgent | /lib/cloudstats/server/command_processor_server.rb | UTF-8 | 1,865 | 2.734375 | 3 | [] | no_license | require_relative './command_executor'
module CloudStats
# Listens to requests and responses command result
class CommandProcessorServer
attr_reader :server_driver, :executor, :alive
alias alive? alive
def initialize(server_driver, opts = {})
@server_driver = server_driver
@alive = false
... | true |
c9ff894fc24a8ae9edb1e2c50a31803610bb94a3 | Ruby | cjhuitt/flogpp | /lib/cleaners/cast_cleaner.rb | UTF-8 | 277 | 2.59375 | 3 | [
"MIT"
] | permissive | class CastCleaner
def self.Clean code
code.gsub(CAST_BLOCK, "")
end
private
CAST_BLOCK =
/(?:[=,(][[:space:]]*) #non-matching comma, parenthesis, or equals
\([^()]+\) #at least one non-parenthesis character
/x
end
| true |
30357905c572be391f0df9160ed5aa063777baaa | Ruby | greenjoshua/RB101 | /small_problems/medium1/diamonds.rb | UTF-8 | 380 | 3.75 | 4 | [] | no_license | def diamond(number)
counter = (number - 1) / 2
reverse_counter = 1
until counter <= 0
puts " "*counter + "*"*reverse_counter + " "*counter
counter -= 1
reverse_counter += 2
end
until counter > (number - 1) / 2
puts " "*counter + "*"*reverse_counter + " "*counter
counter += 1
reve... | true |
8b51d9766a91f6f9abb3892d2e7d80234466c444 | Ruby | chn-challenger/learn_to_program | /ch10-nothing-new/sort.rb | UTF-8 | 581 | 4.03125 | 4 | [] | no_license | def sort(array,order='ascend')
number_of_items = array.length
number_of_swaps = 0
for x in 0...(number_of_items-1)
if order == 'ascend'
if array[x] > array[x+1]
holdx = array[x]
array[x] = array[x+1]
array[x+1] = holdx
number_of_swaps += 1
end
else
if array[x] < array[x+1]
holdx = ... | true |
83c810209dfdba23fcb5ac545064fbc694cda120 | Ruby | MurrayT/GutenbergTreeTagger | /res/script/cleanup.rb | UTF-8 | 715 | 2.96875 | 3 | [] | no_license | #!/usr/bin/env ruby
abort "Incorrect usage" unless ARGV.length == 3 and ARGV.all?
infilename = ARGV[0]
outfilename = ARGV[1]
forbiddenfilename = ARGV[2]
for filename in [infilename, forbiddenfilename] do
abort "File #{filename} not found" unless File.file? filename
end
forbidden = File.open(forbiddenfilename, "... | true |
9c47ad0502aec54c3bb9ce8557c587043aaaa55b | Ruby | Miguel-mm/qytetetruby | /lib/tablero.rb | UTF-8 | 3,325 | 2.71875 | 3 | [
"MIT"
] | permissive | #encoding :utf-8
require_relative 'tipo_casilla'
require_relative 'titulo_propiedad'
require_relative 'casilla'
require_relative 'calle'
module ModeloQytetet
class Tablero
#Consultores
attr_reader :carcel, :parking, :impuesto
#Constructor:
def initialize()
@casillas = []
@carcel ... | true |
9ed7067788c15fc142b4468333962f2ed7fb94e4 | Ruby | mattf/condor_hadoop | /hadoop_namenode | UTF-8 | 3,435 | 2.625 | 3 | [] | no_license | #!/usr/bin/ruby
require 'optparse'
def list(options)
IO.popen(%{
condor_q -constraint 'HadoopType =?= "NameNode"' \
-format "%4d" ClusterId \
-format " %12s" 'formatTime(QDate, "%d/%m %H:%M")' \
-format " %8s" 'ifThenElse(JobStatus == 1, "Pending",
... | true |
52089f5dd5a019f2f23568ec9cb0adefa768de24 | Ruby | tamnil/codeeval | /ruby/moderate/trailing_string/trailing.rb | UTF-8 | 320 | 3.078125 | 3 | [] | no_license | def entrada(*args)
File.read(ARGV[0]).split("\n")
end
teste = entrada()
# processa a linha:
teste.reject!(&:empty?)
teste.each do |line|
arr = line.split(",")
compareWord = arr[1]
word = arr[0]
regex = Regexp.new compareWord + "$"
if regex.match(word) != nil
puts "1"
else
puts "0"
end
end
| true |
d0d95e1e8c69588385c9c4cc77538caf5cc668cb | Ruby | dtphuc/lono | /lib/templates/blueprint/setup/configs.rb | UTF-8 | 1,510 | 2.78125 | 3 | [] | no_license | # This class is used by `lono configure [blueprint]` to create starter config files.
# Example files that get created:
#
# Variables:
#
# configs/[blueprint]/variables/[Lono.env].rb
#
# Params:
#
# configs/[blueprint]/params/[Lono.env].txt - short form
# configs/[blueprint]/params/[Lono.env]/[param].txt - medi... | true |
c92d3230e678c0e2a78caa4f0abe2e6bf304d181 | Ruby | ScoutRFP/thrift-validator-ruby | /lib/thrift/validator.rb | UTF-8 | 1,377 | 2.71875 | 3 | [
"MIT"
] | permissive | require 'thrift/validator/version'
require 'thrift'
module Thrift
class Validator
DEFAULT_TYPE = Thrift::ProtocolException::UNKNOWN
# @param structs [Object] any Thrift value -- struct, primitive, or a collection thereof
# @raise [Thrift::ProtocolException] if any deviation from schema was detected
... | true |
8c5ad61bbd11dc74535c65be8470b2b81ecdb515 | Ruby | karlstolley/535 | /ruby/scripts/create_html5.rb | UTF-8 | 1,574 | 4.03125 | 4 | [] | no_license | # Version 5: Writes to a Separate HTML File
class CreateHTML
def ask_questions
questions = {
"What is the course number of class" => 'number',
"What is the course title of class" => 'title',
"Who teaches class" => 'instructor',
"What day of the week do you attend class" => 'day',
"W... | true |
fbd6f31889a9178138f6460039c4a2539d2073b0 | Ruby | SaranyaJami/greycampus | /[13-05-2021]6th_day_report/lambda.rb | UTF-8 | 104 | 2.9375 | 3 | [] | no_license | l=lambda {"abcd"}
puts l.call
puts
#as increment
inc=lambda do |i|
return i+1
end
puts inc.call(1) | true |
5b3f82d20d898a835162657360f4577d587ac61e | Ruby | Mic92/record-indirect-branches | /relay/reduce-callgraph.rb | UTF-8 | 4,959 | 2.765625 | 3 | [] | no_license | #!/usr/bin/env ruby
require "json"
require "set"
require "fileutils"
def parse_function_node(node)
function_name, type, function_id = node.split(':')
{
function_name: function_name,
function_id: function_id,
function_type: type,
}
end
def parse_relay_callgraph(path)
callgraph = open(path).map do ... | true |
6fb809fd1f818fb3d2e6844a1a68c34adb7fabf1 | Ruby | michal-lipski/world-weather-app | /app/helpers/coordinates_parser.rb | UTF-8 | 401 | 3 | 3 | [] | no_license | module CoordinatesParser
def normalize (coordinates)
latitude = format_coords coordinates["latitude"].to_s
longitude = format_coords coordinates["longitude"].to_s
{"latitude"=>latitude, "longitude"=>longitude}
end
def format_coords(value)
value = ("%-8d" % [value.gsub!('.', '')]).gsub!(" ","0"... | true |
29abf79051ca0148802db552cb8e1830c9fa58a4 | Ruby | gengogo5/atcoder | /ABC/abc177/ABC177_B.rb | UTF-8 | 189 | 2.984375 | 3 | [] | no_license | S = gets.chomp
T = gets.chomp
mx = 0
(S.length - T.length + 1).times do |i|
eq = 0
T.length.times do |j|
eq += 1 if T[j] == S[j+i]
end
mx = [mx, eq].max
end
puts T.length - mx | true |
c8e5f397795de7d9a396d89b333d5be9b24dd197 | Ruby | brookseakate/betsy-shipping | /lib/shipping_service/api_client.rb | UTF-8 | 1,649 | 3.1875 | 3 | [] | no_license | require 'httparty'
module ShippingService::APIClient
BASE_URL = "https://heathership.herokuapp.com/"
BASE_SEARCH = "&origin_country=US&origin_state=WA&origin_city=Seattle&origin_zip=98122&destination_country=US"
def methods_for_order(order)
weight = (order.total_weight) * 16 # Gives weight in ounces for sh... | true |
8dfa0d8050f3594563c49309cbf5069e1de003ff | Ruby | btucker/google_visualization | /test/tc_data_type.rb | UTF-8 | 934 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require File.join(File.dirname(__FILE__), 'helper.rb')
class TC_DataType < Test::Unit::TestCase
def test_new
assert_raise(NoMethodError) { DataType.new }
end
def test_constants
assert_equal(DataType.const_defined?(:STRING), true)
assert_equal(DataType.const_defined?(:NUMBER), true)
assert_equ... | true |
c2d26806f0dedea34dc56d58eb54cba45370a821 | Ruby | ckolderup/backtracks-worker | /models/artist.rb | UTF-8 | 203 | 2.765625 | 3 | [] | no_license | class Artist
attr_reader :name
attr_reader :url
def initialize(param = {})
@name = param[:name]
@url = param[:url]
@url = "http://#{@url}" unless @url.start_with?("http://")
end
end
| true |
98f53d26ce67761d9d34e46a21fb0bee86cc9160 | Ruby | dtinth/codejom56 | /final/unfinished/turn.rb | UTF-8 | 239 | 2.96875 | 3 | [] | no_license |
cases do
x, y, theta = strs
x, y = [x.to_i, y.to_i]
theta = theta.to_f * Math::PI / 180
theta2 = Math.atan2(y, x)
rho = Math.hypot(x, y)
puts "%.2f %.2f" % [rho * Math.cos(theta + theta2), rho * Math.sin(theta + theta2)]
end
| true |
9a943ecec2247ac87f55369240a2b09745e6b1ed | Ruby | sooo-s/AtCoder | /abc209/c/main.rb | UTF-8 | 179 | 3.21875 | 3 | [] | no_license | N = gets.to_i # 10
C = gets.chomp.split.map(&:to_i) # n = 10, m = 20
divmod = 10.pow(9) + 7
ans = 1
C.sort.each_with_index do |c, i|
ans *= c - i
ans %= divmod
end
puts ans
| true |
0f6d23b3cd974a3f477fb64cccf28367cba5340c | Ruby | thekindofme/hw_watch | /test/unit/shop_test.rb | UTF-8 | 1,902 | 2.546875 | 3 | [] | no_license | require 'test_helper'
class ShopTest < ActiveSupport::TestCase
test "able to create a shop with valid data" do
shop=Shop.new(:address=>"some address here.", :name=>"shop123", :rating=>51, :shop_link=>"http://some_link.com/here", :tel1=>"2412-124-512-1241", :tel2=>"2322-111-512-1241",
:www_link... | true |
e3ebeeff27e2136a0355c5d44c5f4d0703ddc742 | Ruby | pa-childs/Udemy_Courses | /learn_to_code-ruby/Section_22/use_rdoc.rb | UTF-8 | 595 | 4.21875 | 4 | [] | no_license | # An Album class that stores an array of songs
class Album
include Enumerable
# An Array object of songes. Each song is a string.
attr_reader :songs
# Creats a new Album with and empty songs array.
def initialize
@songs = []
end
# Add a song to the Album objects songs array.
def add_song(song)... | true |
8ae4407ffff41fa65f4b158408d6e2ede746d6d2 | Ruby | mmojica13/ics_bc_18 | /week2/ch07/leap_year_counter.rb | UTF-8 | 432 | 4 | 4 | [] | no_license | puts "Enter a starting year"
start_year = gets.chomp.to_i
puts " "
puts "Enter an ending year"
end_year = gets.chomp.to_i
puts " "
puts "These are all the leap years in between " + start_year.to_s + " and " + end_year.to_s + "!"
puts " "
leap_year = start_year
while leap_year <= end_year
if leap_year % 4 == 0
if ... | true |
d5118dcaba4b6cea4eb161c2624622f986a69a16 | Ruby | Eschults/inbox | /app/models/conversation.rb | UTF-8 | 693 | 2.71875 | 3 | [] | no_license | class Conversation < ActiveRecord::Base
belongs_to :user1, class_name: "User"
belongs_to :user2, class_name: "User"
has_many :messages, dependent: :destroy
validates :user1, uniqueness: {scope: :user2}
validates :user1, :user2, presence: true
def users
return [user1, user2]
end
def other_user(use... | true |
a85ec8ad46bfe11ac922d8afba1cc43728b5e51c | Ruby | kduraiswami/superduber | /app/models/event.rb | UTF-8 | 9,056 | 2.671875 | 3 | [] | no_license | class Event
include UberRequestsConcern
include Mongoid::Document
include Geocoder::Model::Mongoid
field :name, type: String
field :depart_address, type: String
field :arrival_address, type: String
field :arrival_datetime, type: Time #UTC; Mongo can't store timezone information
field :timezone_offset, t... | true |
1be54e30ab76fe1648bfb8a5935b2838c415b327 | Ruby | lylyanne/checkers | /board.rb | UTF-8 | 3,564 | 3.203125 | 3 | [] | no_license | require_relative 'piece'
require 'colorize'
require 'io/console'
class Board
attr_accessor :cursor, :start, :sequence
def self.onboard?(pos)
pos[0].between?(0, 7) && pos[1].between?(0, 7)
end
def initialize(fill_grid = true)
make_starting_grid(fill_grid)
@cursor = [0, 0]
@sequence = []
end
... | true |
7bd2103afe27533dd7f054621c9d36d2e0494103 | Ruby | diana/hayk-assessment-the-bachelor | /lib/bachelor.rb | UTF-8 | 1,285 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def get_first_name_of_season_winner(data, season)
# code here
data[season].each do |contestant_stats|
if contestant_stats["status"] == "Winner"
return contestant_stats["name"].split[0]
end
end
end
def get_contestant_name(data, occupation)
data.each do |seasons, season_contest|
... | true |
0fca2518bd0d1e4eb206d74b87fd6442919318ee | Ruby | MatsLagarde/FormationRubyGosuWithFireball | /lib/ruby_game/monster.rb | UTF-8 | 316 | 2.5625 | 3 | [
"MIT"
] | permissive | module RubyGame
class Monster < Container
include Abilities
def initialize(positionX, positionY, motif="ghost1.png",speed, behaviour)
super(positionX, positionY, motif, speed)
@behaviour = behaviour
end
def move()
self.public_send("move_" + @behaviour.to_s)
end
end
end
| true |
c6f65984f7046c08c4a71250154b9fc3e3468164 | Ruby | hoslersk/anagram-detector-web-0716 | /lib/anagram.rb | UTF-8 | 481 | 3.71875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Your code goes here!
require 'pry'
class Anagram
attr_accessor :word
def initialize(word)
@word = word
end
def match(word_arr)
match_arr = []
word_arr.each do |letters|
sorted_letters = letters.split("").sort
sorted_letters = sorted_letters.join
init_word = @word.spli... | true |
c326195bfe5c8f76aac978e327d1992f96e084d4 | Ruby | rapapolu/ruby-programs | /factorial.rb | UTF-8 | 251 | 4.03125 | 4 | [] | no_license | #factorisl_example
class Factorisl
def find_fact(number)
if number == 1
return 1
else
return number * find_fact(number-1)
end
end
end
fact = Factorisl.new
puts fact.find_fact(5) | true |
11ff18a0750633ac0b52aca4cf48109ecbc1c0b7 | Ruby | lucaspiquet/thp_S2J1 | /tests-ruby/lib/04_simon_says.rb | UTF-8 | 818 | 4.1875 | 4 | [] | no_license | def echo (coucou)
return coucou
end
def shout (coucou)
return coucou.upcase
end
def repeat (coucou, i=2)
return ([coucou] * i).join(" ") # rรฉpรฉtition x 2
end
def start_of_word(string, i) # i = rang de la lettre dans le mot
return string[0,i]
end
def first_word (string)
return string.split(" ").first # str... | true |
379c6551564b2a4f2d931f8d1feaa35dc399cc73 | Ruby | yoosee/local_settings | /bin/compare_dir.rb | UTF-8 | 744 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/ruby
#
#
require 'digest/md5'
require 'hashdiff'
require 'pp'
orig_dir = ARGV.shift
dest_dir = ARGV.shift
def listmd5 dir
list = Hash.new
Dir.open(dir).sort.each do |f|
print "."
fn = dir + '/' + f
next unless File.file? fn
m = Digest::MD5.file(fn).to_s
list[f] = m
end
puts ''
... | true |
22ef8b5565ea6403459677bd34b1a093af3d3095 | Ruby | intolerable/haml_tumblr | /lib/haml_tumblr/helpers.rb | UTF-8 | 312 | 2.703125 | 3 | [] | no_license | def process( tag )
tag.to_s.split("_").map(&:capitalize).join
end
def link_to( *args )
if block_given?
haml_tag :a, :href => args.first do
yield
end
else
haml_tag :a, :href => args.last do
haml_concat args.first
end
end
nil
end
def tab
tab_up
yield
tab_down
end
| true |
955eeec279b0064b988b0b617bb32c69de65b58b | Ruby | jcompagni10/AA_Projects | /alpha/7appacademy-online-rspec-1-7db389dec276/lib/03_simon_says.rb | UTF-8 | 411 | 4.09375 | 4 | [] | no_license | def echo(str)
str
end
def shout(str)
str.upcase
end
def repeat(str, n=2)
str + " #{str}" * (n-1)
end
def start_of_word(str, n)
str[0..n-1]
end
def first_word(str)
str.split.first
end
def titleize(str)
littles = %w[the is over by a and]
str.split.map.with_index do |word, idx|
if !littles.include?(... | true |
801fcdec3a7422bc90b118407fd1319f71641ee0 | Ruby | corsonknowles/AppAcademy | /w2d4/minmaxstackqueue.rb | UTF-8 | 2,580 | 3.4375 | 3 | [] | no_license |
class MyQueue
def initialize
@store = []
end
def enqueue(entry)
@store.unshift(entry)
end
def dequeue(entry)
@store.pop(entry)
end
def peek
@store[-1]
end
def size
@store.length
end
def empty?
@store.empty?
end
end
class MyStack
def initialize
@store = []
... | true |
d2a10fb3345566e3b2cd31d3411ac3b3a91e7e39 | Ruby | wenyizou/OdinProject_Ruby | /binary_search_tree/bst.rb | UTF-8 | 1,513 | 3.859375 | 4 | [] | no_license | require_relative './node'
class BST
attr_accessor :root
def initialize(ary=nil)
@root = nil
return @root if ary.nil?
@root = build_Tree(ary)
end
# build the tree
def build_Tree(ary)
return nil if ary.empty?
root = Node.new(ary[0])
ary[1..-1].each do |x|
n=root
while tr... | true |
a9d5b49a6e62fe8fd96ce818d398ecbee0a059a9 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/rna-transcription/73805575826344a98d2775f96b923f08.rb | UTF-8 | 605 | 3.484375 | 3 | [] | no_license | class Complement
def self.of_dna(dna_strand)
transcription = DnaRnaTranslator.new(dna_strand)
transcription.translate_dna_to_rna
end
def self.of_rna(rna_strand)
transcription = DnaRnaTranslator.new(rna_strand)
transcription.translate_rna_to_dna
end
end
class DnaRnaTranslator
def initialize(s... | true |
23443d5cb6934597adf8ff28f72c63e57ab6f2d3 | Ruby | o5411980/vending_machine | /answer_code/tdd-bc-osaka3.0-task-master/vending_machine.rb | UTF-8 | 4,610 | 3.390625 | 3 | [] | no_license | require "./drink"
require "./category"
# require "./vending_machine.rb"
# TODO: ใฝใใใฏใฌใผใใณใใใณใผใใฌใใฅใผ
# ใใกใคใซๅใซใใคใใณใฏไฝฟใใชใใใขใณในใณ๏ผ_๏ผใใญใฃใกใซใฑใผในใง
# require "./VendingMachine.rb"
class VendingMachine
# ๅฉ็จๅฏ่ฝใชใ้
AVAILABLE_MONEY = [10, 50, 100, 500, 1000].freeze
attr_reader :total, :sale_amount, :stocks, :unsdn
# ๅๆ่จญๅฎ
# TOD... | true |
d58376313955a0fe4051dd0808e1b3c9856e3bde | Ruby | igorpertsev/factory_settings | /lib/factory_settings/storages/in_memory.rb | UTF-8 | 971 | 2.5625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative "base"
module FactorySettings
module Storages
# In memory storage class. Only stores data in memory and resets all on application restart.
class InMemory < Base
def initialize
super
@storage = {}
end
def exists?(key)
w... | true |
650f18a70867ed800fae67c951e721caf37acf4d | Ruby | dogwood008/fxdon_bot | /source/sqs.rb | UTF-8 | 950 | 2.578125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'json'
require 'singleton'
require 'aws-sdk'
class Sqs
include Singleton
# http://docs.aws.amazon.com/sdkforruby/api/Aws/SQS/Client.html#receive_message-instance_method
MAX_NUMBER_OF_MESSAGES = 10.freeze
def initialize
raise NotImplementedError
end
def create_qu... | true |
caf83f67baaf5f68daaa8ebdadbcacbc57986fea | Ruby | piaoyehong1107/ruby-oo-relationships-practice-blood-oath-exercise-hou01-seng-ft-071320 | /app/models/cult.rb | UTF-8 | 1,416 | 3 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Cult
attr_accessor :name, :location, :founding_year, :slogan,:follower
@@all=[]
def initialize(name, location, founding_year, slogan)
@name=name
@location=location
@founding_year=founding_year
@slogan=slogan
@@all<<self
end
def recruit_follower(follower)
BloodOath.n... | true |
44d569a7ef882f8ca5c5b921919634d95588d3e5 | Ruby | IsaacVerm/find_apartment | /lib/request.rb | UTF-8 | 271 | 2.96875 | 3 | [] | no_license | class Request
def initialize(url, sleep = 2.00)
@url = url
@variable_sleep_time = rand(0.5*sleep..1.5*sleep)
end
def get_page
sleep(@variable_sleep_time)
Nokogiri::HTML(RestClient.get(@url))
end
end
| true |
f5d68e6d5d919502c2cc6bad359d08a7f5d18283 | Ruby | yatinsns/templates | /ruby/example.rb | UTF-8 | 322 | 2.703125 | 3 | [] | no_license | #!/usr/bin/env ruby
# require 'optparse'
def main
# opts = {}
# OptionParser.new do |o|
# o.on('-a', '--aDesc A', Integer) { |x| opts[:a] = x }
# o.on('-b', '--bDesc B', Integer) { |x| opts[:b] = x }
# o.on('--c') { opts[:c] = :C }
# end.parse!
# Do something with 'opts'
end
main if __FILE__ == $... | true |
1847d566b47bd6b7d61ac5a68954d54df46f4b03 | Ruby | leebardon/OO-Get-Swole | /lib/lifter.rb | UTF-8 | 900 | 3.28125 | 3 | [] | no_license | require_relative './membership.rb'
require_relative './gym.rb'
class Lifter
attr_reader :name, :lift_total
@@all = []
def initialize(name, lift_total)
@name = name
@lift_total = lift_total
@@all << self
end
def self.all
@@all
end
def memberships
Membership.all.select {|membership|... | true |
eaddd06349eddfa45c3d03a2d4272d68556f86a6 | Ruby | MustafaTaha15/badges-and-schedules-re-coded-000 | /conference_badges.rb | UTF-8 | 503 | 3.796875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def badge_maker(name)
"Hello, my name is #{name}."
end
def batch_badge_creator(attendees)
result=[]
attendees.each do |name|
result<<badge_maker(name)
end
result
end
def assign_rooms(attendees)
result=[]
attendees.each_with_index do |name,index|
result<<"Hello, #{name}! You'll... | true |
2bb847201590c8093012cea0b706459d09f72704 | Ruby | JuanjoMoya/Ironhack | /Part-time/Module1_Ruby_and_OOP/Octubre2016/8saturday/test/test.rb | UTF-8 | 2,057 | 4.0625 | 4 | [] | no_license | # class Home
# attr_reader(:name, :city, :capacity, :price)
#
# def initialize(name, city, capacity, price)
# @name = name
# @city = city
# @capacity = capacity
# @price = price
# end
# end
#
#
# homes = [
# Home.new("Nizar's place", "San Juan", 2, 42),
# Home.new("Fernando's place", "Seville"... | true |
5c341b5722d7c93deeb1e34ae2008e8e0a19a522 | Ruby | awertman/brand-img | /lib/assets/instagram_module.rb | UTF-8 | 1,466 | 2.53125 | 3 | [] | no_license | module InstagramModule
class Request
def initialize
Instagram.configure do |config|
config.client_id = ENV['secret_id']
config.access_token = ENV['token']
end
end
def get_recent_media_by_tag tag, pages, max_id = nil
@brand = Brand.find_by_name(tag)
if !@brand
... | true |
d5e339a112ff27d2ebc0ab0607c99d2c98382ee2 | Ruby | johnyjamma93/manybots | /config/initializers/serialize_filter.rb | UTF-8 | 470 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'json'
class SerializeFilter
def initialize(attribute)
@attribute = attribute.to_s
end
def before_save(record)
record.send("#{@attribute}=", SerializeFilter.encrypt(record.send("#{@attribute}")))
end
def after_save(record)
record.send("#{@attribute}=", SerializeFilter.decrypt(record.sen... | true |
3295d0dfe91a650c9f6dc705eba57ad3f6382d70 | Ruby | Kite0301/atcoder | /Beginner/001/c.rb | UTF-8 | 815 | 2.828125 | 3 | [] | no_license | d,l = gets.chomp.split.map(&:to_i)
if d >= 113
case (d-113)/225
when 0
dir = "NNE"
when 1
dir = "NE"
when 2
dir = "ENE"
when 3
dir = "E"
when 4
dir = "ESE"
when 5
dir = "SE"
when 6
dir = "SSE"
when 7
dir = "S"
when 8
dir = "SSW"
when 9
dir = "SW"
when 10
dir = "WSW"
when 11
dir = "W... | true |
56c566965ed463e1fae1bf5dc7fb9ae8de7b24f8 | Ruby | yfove/reinforcing_exercise_tdd | /calculator.rb | UTF-8 | 219 | 3.453125 | 3 | [] | no_license | def add(number1, number2)
return number1 + number2
end
def subtract(number1, number2)
return number1 - number2
end
def sum(array)
total = 0
array.each do |number|
total += number
end
return total
end
| true |
648e6f626591cae3e095c084ee8275a8e11b4ad8 | Ruby | jimmy2/launchschool_101_programming_fundamentals | /101_109_small_problems/easy_6/exercise_10.rb | UTF-8 | 857 | 4.75 | 5 | [] | no_license | # 101-109 - Small Problems > Easy 6 > Right Triangles
# Write a method that takes a positive integer, n, as an argument, and displays a right triangle
# whose sides each have n stars. The hypotenuse of the triangle (the diagonal side in the images
# below) should have one end at the lower-left of the triangle, and the... | true |
43aca0e22f7fc206c0ad14e7d567b3f40d80a059 | Ruby | KevinMookOrg/dyph | /lib/dyph/outcome/resolved.rb | UTF-8 | 573 | 2.828125 | 3 | [
"MIT"
] | permissive | module Dyph
class Outcome::Resolved < Outcome
attr_reader :result
def initialize(result)
@result = result
@combiner = ->(x, y) { x + y }
end
def set_combiner(lambda)
@combiner = lambda
end
def ==(other)
self.class == other.class &&
self.result == other.result
... | true |
808c9a49561e7ee8c0a5bcf99a5e8d0273c063c2 | Ruby | robdodson/zerp | /lib/zerp.rb | UTF-8 | 170 | 2.625 | 3 | [
"MIT"
] | permissive | require "zerp/version"
module Zerp
# Your code goes here...
class Dinosaur
def initialize
puts 'You got a dinosaur here motherfucker!'
end
end
end
| true |
cf515bb43c2ea239982e878421dc87af4f0d59eb | Ruby | laurestrepov/Ruby_01 | /duck_typing/plotter.rb | UTF-8 | 343 | 3 | 3 | [] | no_license | class Plotter
AVAILABLE_DOCS = %w(jpg png svg)
def initialize(document, size = '46.8 x 33.1')
@document = document
@size = size
end
def print
if AVAILABLE_DOCS.include?(@document.type) && @document.image
puts "printing at...#{@size}"
true
else
puts "invalid document !"
f... | true |
910fdd7f256da59659e4e6c4cb6884a7c226d4b8 | Ruby | sanmedina/libro_rails | /cap05/Persona.rb | UTF-8 | 249 | 3.65625 | 4 | [] | no_license | class Persona
attr_accessor :nombre, :apellidos
def initialize(nombre = "NN", apellidos = "")
@nombre = nombre
@apellidos = apellidos
end
def to_s
"Hola, mi nombre es #{@nombre} #{@apellidos}."
end
end | true |
f38c50692b58344b972cb855b5b2b6dd7396650e | Ruby | maggieholbling/jungle | /spec/models/user_spec.rb | UTF-8 | 2,668 | 2.5625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
subject! { User.create(first_name: 'test_name', last_name: 'test_name', email: 'aaa@gg.com', password: 'hhhhhh', password_confirmation: 'hhhhhh') }
describe 'Validations' do
it 'User should save' do
expect(subject).to be_valid
end
it 'U... | true |
11167f0bd6ab99325f32616e11546c05b0057b5a | Ruby | aauugguussttiinn/ruby-first-lesson | /exo_11.rb | UTF-8 | 121 | 3.046875 | 3 | [] | no_license | puts "Hi, user, give me a number please"
given_number = gets.to_i
given_number.times do
puts "Salut รงa farte ?"
end
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.