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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
4ea248891e4269068c04b9c302bee26a8fafe8a1 | Ruby | joseph-ravenwolfe/polski | /lib/polski/adapter/string_adapter.rb | UTF-8 | 531 | 3.078125 | 3 | [
"MIT"
] | permissive | module Polski
module Adapter
# The String Adapter acts as a Ruby String interface to the Polski
# calculator. It provides Array-like push functionality to the calculator
# and returns calculated results.
#
class StringAdapter
attr_accessor :calculator
def initialize(calculator)
... | true |
f8a878b562685e1dcf4a55fec236b3a0e49d1510 | Ruby | open-sourcepad/the-streams-stats | /app/models/holiday.rb | UTF-8 | 267 | 2.546875 | 3 | [] | no_license | class Holiday < ApplicationRecord
validates :name, :date, presence: true
after_save :update_is_weekday
scope :weekdays, -> { where(is_weekday: true) }
private
def update_is_weekday
update_column(:is_weekday, (1..5).include?(date.wday))
end
end | true |
d47dd061439d0969ad739fb332a8715f15fc9a05 | Ruby | MikeAlphaBravo/Deck_Of_Cards_Ruby | /spec/deck_spec.rb | UTF-8 | 425 | 2.8125 | 3 | [
"MIT"
] | permissive | require './deck'
RSpec.describe Deck do
let(:deck) { Deck.new }
describe "initialize" do
it "has 52 cards" do
expect(deck.cards.length).to eq(52)
end
it 'has a default deck of unique cards' do
expect(deck.cards.uniq).to eq(deck.cards)
end
end
describe "deal" do
it "removes d... | true |
0d5c4419c614ce02576a0dc26fa5d3de0ac92b99 | Ruby | redolent/shovel | /boise_weekly.rb | UTF-8 | 6,665 | 2.859375 | 3 | [] | no_license | require 'nokogiri'
require 'mechanize'
require 'open-uri'
require './categories'
require './event'
module Shovel
class BoiseWeekly
@base_url = 'http://www.boiseweekly.com/boise/EventSearch?narrowByDate='
def self.scrape options = {}
events = []
sub_url = case options[:when]
... | true |
e76893277a1a46e3fb277cab711249719376fac3 | Ruby | 1-8192/D-D-Spell-Search | /app/models/character_class.rb | UTF-8 | 608 | 2.84375 | 3 | [] | no_license | # The model for the character class class data.
class CharacterClass < ActiveRecord::Base
has_many :spells, through: :spell_slots
#Displays instance info in a nicer format
def display
puts
puts "* Class: #{self.class_name} *"
puts
puts "Description: #{self.description}"
puts
puts "Spellca... | true |
7fcc6928de2a83a7f4d2e9045567d1453a06d343 | Ruby | funapy-sandbox/ruby_sample | /1/1/main.rb | UTF-8 | 202 | 3.328125 | 3 | [] | no_license | str1 = "string"
str2 = "string"
puts str1.object_id
puts str2.object_id
puts str1 == str2 # 内容は同じ
puts str1.equal?(str2) # 内容は同じでもオブジェクトとしては異なる | true |
cf0e22f577d86225f5ed366d4981bd606517357a | Ruby | graemeworthy/pink_shirt | /spec/textile_spec.rb | UTF-8 | 1,852 | 3 | 3 | [
"MIT"
] | permissive | #read-specs.rb
require 'yaml'
require 'redcloth'
# TextileSpec
# =============
# the textile spec
# from
class TextileSpec
SPECS_PATH = "./spec/textile-spec/"
def initialize(subset = nil)
@subset = subset
@specs_path ||= SPECS_PATH
end
def index
@index ||= TextileSpec::Index.new
end
def get_spec(name)
f... | true |
9085ae1877e0e7449731406a8a69ae0fd08f3a84 | Ruby | jeffreydking04/euler | /p35.rb | UTF-8 | 672 | 3.53125 | 4 | [] | no_license | require 'prime.rb'
answer_array = [2]
(3..999999).each do |x|
array = x.to_s.chars
next if array.include?("0") ||
array.include?("2") ||
array.include?("4") ||
array.include?("6") ||
array.include?("8")
next if !Prime.prime?(x)
circular_array = []
(0...array.size).ea... | true |
a5f181f7ee881340cc1abc60ac649cdf602f8ed6 | Ruby | Tubbz-alt/lectures-app | /lib/lecture.rb | UTF-8 | 1,026 | 2.65625 | 3 | [] | no_license | class Lecture
BUCKET = "ada-lectures"
attr_accessor :name, :description, :date, :link, :url, :key
def initialize(key, url, attrs={})
@key = key
@url = url
@name = attrs["name"]
@description = attrs["description"]
@link = attrs["link"]
@date = begin
... | true |
15c093e1548ccb298c236ce0aff9ea4554b0743f | Ruby | bheim6/football_machine_learning | /app/models/stored_neural_net.rb | UTF-8 | 911 | 2.5625 | 3 | [] | no_license | class StoredNeuralNet < ApplicationRecord
def revive_net
nn = NeuralNet.new(*layer_sizes)
nn.weights[0] = Matrix.rows(first_weights)
nn.weights[1] = Matrix.rows(hidden_weights)
nn.weights[2] = Matrix.rows(last_weights)
nn.biases[0] = Matrix.rows(first_biases)
nn.biases[1] = Matrix.rows(hidden... | true |
94a1d5ace1a35110822d726d10454f474444deb1 | Ruby | tulios/money_mg | /lib/money_mg/utils/formater.rb | UTF-8 | 765 | 3.28125 | 3 | [] | no_license | module MoneyMg
module Formater
# Converte uma data para string, se não informar o padrão formata
# para dd/mm/yyyy
#
# params:
# => Date: date (data)
# => String: pattern (padrão de conversão)
#
def self.date_to_string(date, pattern = "%d/%m/%Y")
if date
date.strf... | true |
fbb2289b70e34423663c50bf548e38cf7569bdbf | Ruby | cheonandrew113/programming-univbasics-4-array-concept-review-lab-nyc-web-071519 | /lib/array_methods.rb | UTF-8 | 427 | 3.984375 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #takes in an array and a value and returns the index of that value'
def find_element_index(array, value_to_find)
array.include?(value_to_find)
return array.index(value_to_find)
end
#'takes in an array of integers and returns the highest value integer'
def find_max_value(array)
return array.max
end
#takes in ... | true |
28dac1802fc8996e5877c940427ceb16c6dd4d68 | Ruby | hlxwell/leetcode-ruby | /expand_subarry.rb | UTF-8 | 385 | 3.359375 | 3 | [] | no_license | @solutions = []
def iterate_arr(arr)
if arr.none? { |elem| elem.is_a? Array }
@solutions << arr
return
end
# byebug
arr.each_with_index do |elem, i|
if elem.is_a? Array
new_arr = arr.dup
elem.each do |n|
new_arr[i] = n
iterate_arr(new_arr)
end
return
en... | true |
fa180b2a8aac4adf2a9f29a2e7810d117f4f2a51 | Ruby | evilgeniusnyc/parrot-ruby-ruby-apply-000 | /parrot.rb | UTF-8 | 146 | 3.109375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Create method `parrot` that outputs a given phrase and
# returns the phrase
def parrot (parameter = "Squawk!")
puts parameter
parameter
end
| true |
8bcf1747c1a6bc8067ac4140de9e44c04c49672b | Ruby | ivantsepp/annotate_gem | /test/annotate_gem/gemfile_test.rb | UTF-8 | 2,546 | 2.546875 | 3 | [
"MIT"
] | permissive | require "test_helper"
class AnnotateGem::GemfileTest < Minitest::Test
def test_parses_source
gemfile = gemfile_for(unindent(<<-GEMFILE))
hello
world!
GEMFILE
assert 2, gemfile.source.length
assert_equal "hello\n", gemfile.source.first
assert_equal "world!\n", gemfile.source.last
en... | true |
a6cc5dfedd78b92b5c4fec5e5818499211f7df7d | Ruby | fatwebdev/thinknetica_1 | /Lesson_04/station.rb | UTF-8 | 686 | 3.578125 | 4 | [] | no_license | class Station
attr_reader :trains, :name
def initialize(name)
@name = name
@trains = {}
end
def take_train(train)
if trains[train.type]
trains[train.type] << train
else
trains[train.type] = [train]
end
end
def send_train(train)
train.forward
end
def delete_train(... | true |
4d3986af44facbc33be8f063d8a3ea94dcc66f3d | Ruby | vshl/exercism.io | /prime-factors/prime_factors.rb | UTF-8 | 511 | 3.6875 | 4 | [] | no_license | =begin
Write your code for the 'Prime Factors' exercise in this file. Make the tests in
`prime_factors_test.rb` pass.
To get started with TDD, see the `README.md` file in your
`ruby/prime-factors` directory.
=end
class PrimeFactors
def self.of(number)
return [] if number <= 1
return [number] if number <= 3
... | true |
8f75f481674d4b57fc7f1946a571c66733144588 | Ruby | bloudermilk/literally | /15_ranges.rb | UTF-8 | 210 | 3.609375 | 4 | [
"MIT"
] | permissive | #
# Ranges
#
a = 1..100
a.include?(50) # => true
a.include?(1.5) # => true
b = "a".."g"
b.include?("b") # => true
b.include?("n") # => false
c = 1...100
c.include?(1) # => true
c.include?(100) # => false
| true |
6ac466df379d42be161ed328d946cc683c94f739 | Ruby | katyjane8/enigma | /test/decrypt_test.rb | UTF-8 | 1,279 | 3.0625 | 3 | [] | no_license | require_relative 'test_helper'
require 'minitest/autorun'
require 'minitest/pride'
require './lib/decrypt'
class DecryptTest < Minitest::Test
def test_it_exists
decrypt = Decrypt.new
assert_instance_of Decrypt, decrypt
end
def test_valid_key_evaluates_to_true
decrypt_with_int = Decrypt.new.valid... | true |
65cb9f9956defe7ca44fa209e8eae87be43126cd | Ruby | upstill/RecipePower-source | /test/unit/referent_structure_test.rb | UTF-8 | 9,648 | 2.640625 | 3 | [] | no_license | # encoding: UTF-8
require 'test_helper'
require 'page_ref.rb'
class ReferentStructureTest < ActiveSupport::TestCase
test "Successfully creating tags" do
goat_milk_tag = create :ingredient_tag, name: "goat milk"
assert_not_nil goat_milk_tag, "Goat Milk Tag not created"
assert_equal :Ingredient, goat_milk_... | true |
d93cf91c300868e43ebd99ee60e4062076233cc9 | Ruby | Maxwell-Baird/adopt_dont_shop_paired | /spec/models/favorites_spec.rb | UTF-8 | 3,300 | 2.734375 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Favorites, type: :model do
subject { Favorites.new([]) }
before(:each) do
shelter = Shelter.create(name: "Dumb Friends League",
address: "2080 S. Quebec St.",
city: "Denver",
st... | true |
7bdeb867a6e7d4d22defc011fcafbe69e31da464 | Ruby | fotanus/logtool | /lib/logtool.rb | UTF-8 | 2,146 | 2.984375 | 3 | [] | no_license | #!/usr/bin/env ruby
require File.join(File.dirname(File.expand_path(__FILE__)), "logtool", "block.rb")
require File.join(File.dirname(File.expand_path(__FILE__)), "logtool", "parser.rb")
require File.join(File.dirname(File.expand_path(__FILE__)), "logtool", "query.rb")
module LogTool
def self.usage
<<USAGE
Usage: ... | true |
00818a3e958a64f94c9b913bd628160f91c512ab | Ruby | learnable/tuvi | /lib/tuvi/application_runner.rb | UTF-8 | 923 | 3.3125 | 3 | [
"MIT"
] | permissive | class ApplicationRunner
def initialize(steps)
@steps = steps
end
def run
puts "Welcome! Type 'exit' to quit at any time."
current_step_id = "start"
while true do
current_step_id = execute_step(current_step_id)
end
end
def execute_step(step_id)
current_step = @steps[step_id]
... | true |
9ad7720d22dbefe39f9019084ddfdb9b1af279b0 | Ruby | dallsop/meteorologist | /app/controllers/meteorologist_controller.rb | UTF-8 | 2,149 | 2.734375 | 3 | [] | no_license | require 'open-uri'
class MeteorologistController < ApplicationController
def street_to_weather_form
# Nothing to do here.
render("street_to_weather_form.html.erb")
end
def street_to_weather
@street_address = params[:user_street_address]
url_safe_street_address = URI.encode(@street_address)
... | true |
95f2a71ca8510ac942173d130868d6be6f15fbb2 | Ruby | sahilda/advent-of-code | /2017/solutions/day23.rb | UTF-8 | 3,475 | 3.578125 | 4 | [] | no_license | require_relative 'lib/file_reader.rb'
require 'prime'
class Register
attr_accessor :name, :value
def initialize(name, value)
@name = name
@value = value
end
end
class Program
attr_accessor :waiting, :current, :data
def initialize(data, value)
@registers = {}
@last_s... | true |
59cebccbc28803be4df6c157797dc4d897a954bc | Ruby | kingdomlevel/snowman | /specs/game_spec.rb | UTF-8 | 1,741 | 3.296875 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/reporters')
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
require_relative('../game.rb')
require_relative('../player.rb')
require_relative('../hidden_word.rb')
class TestGame < MiniTest::Test
def setup()
@tony = Player.new("Tony")
hidde... | true |
86c2b3340db53f6a763fb48702d6b5f19991c18e | Ruby | OliBerry84/RubyProject | /models/artists.rb | UTF-8 | 930 | 3.109375 | 3 | [] | no_license | require_relative('../db/sql_runner.rb')
class Artist
attr_reader( :name, :id )
def initialize( options )
@id = options['id'].to_i if options['id']
@name = options['name']
end
def save()
sql = "INSERT INTO artists
(
name
)
VALUES
(
$1
)
RETURNING id"
values... | true |
f18526b8a8b47c0a602dc1f074d2044f646be1c3 | Ruby | kschlunz/my-collect-prework | /lib/my_collect.rb | UTF-8 | 347 | 3.453125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
def my_collect(collection)
new_collection = []
i = 0
while i < collection.length
new_collection << yield(collection[i])
i = i + 1
end
new_collection
end
my_collect(['ruby', 'javascript', 'python', 'objective-c']) {|language| language.upcase}
my_collect(['Tim Jones', 'Tom Smith', 'Sophie Johnson', '... | true |
c268c3c81a9bae2634602c97460fcce04efedf32 | Ruby | Rogelio1213/ruby_tests | /rango_numeros.rb | UTF-8 | 480 | 3.5625 | 4 | [] | no_license |
print "Ingresa el límite inferior: "
n = gets.to_i
x = n
#x = 3
print "Ingresa el límite superior: "
n = gets.to_i
while x <= n
#print x, "-"
puts x
x = x + 1
end
#print " Ingrese las horas trabajadas por el empleado: "
#horas_trabajadas = gets.to_i
#print " Ingrese el pago por hora: "
#costo_ho... | true |
3a38c1f319cd2ed809e9f71da35aac2d2dce37b6 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/robot-name/0e89b84adf50489cb758de483b751d93.rb | UTF-8 | 187 | 3.0625 | 3 | [] | no_license | class Robot
def name
l = (0...2).map{ ('A'..'Z').to_a[rand(26)]}.join
n = (0...2).map{ (1...99999).to_a[rand(10000)]}.join[0..2]
l + n
end
def reset
name
end
end
| true |
bb89b7b9b0bb4af0e312f623dd35c4105dd96db7 | Ruby | thomasvincent/ddd_sample_app_ruby | /domain/cargo/delivery.rb | UTF-8 | 4,429 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'date'
require 'ice_nine'
require 'value_object'
class Delivery < ValueObject
attr_reader :transport_status
attr_reader :last_known_location
attr_reader :is_misdirected
attr_reader :eta
attr_reader :is_unloaded_at_destination
attr_reader :routing_status
attr_reader :calculated_at
attr_reader :l... | true |
69098eb3f85ce0b5880473a7fe20575ccd176d33 | Ruby | fidelisrafael/bank-cli | /lib/bank/cli/option_parser.rb | UTF-8 | 1,599 | 2.96875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'optparse'
require_relative '../api/validator'
module Bank
module CLI
class OptionParser
attr_reader :args
def initialize(args = [])
@args = args
end
def parse!
# Creates one `Hash` with the parsed options from the received args
... | true |
3e7f35e775721e84a5a632c3bc2f32cfe142d33d | Ruby | lawrend/ruby-object-initialize-lab-q-000 | /lib/person.rb | UTF-8 | 148 | 2.90625 | 3 | [] | no_license | class Person
def initialize(this_name)
@name=this_name
end
def name(this_name)
@name=this_name
end
def name
@name
end
end
| true |
8a22c4a7a67ab40734858d1bb8db4cf7ed914418 | Ruby | nohat/pronunciation-search | /app/models/pronunciation/parser.rb | UTF-8 | 2,517 | 2.828125 | 3 | [] | no_license | class Pronunciation::Parser
attr_accessor :syllables, :current_syllable, :vowel, :consonant_queue
def initialize(input)
@input = input
@syllables = []
@consonant_queue = []
@current_syllable = Pronunciation::Syllable.new
super()
end
state_machine :state, :initial => :initial_onset do
e... | true |
cc48cda203f5c1038fe72777f98c124ad5da40d0 | Ruby | hrdwdmrbl/geo_web | /lib/web/cache/memcached_cache.rb | UTF-8 | 381 | 2.515625 | 3 | [] | no_license | require 'dalli'
module Web
# a basic cache interface, implemented with memcached
class MemcachedCache
def initialize(client = nil)
@client = client || Dalli::Client.new
end
def get(key)
@client.get(key)
end
def set(key, value, expires = nil)
expires ? @client.set(key, v... | true |
fe548f5c8f5e337dcf3612853b77912be989e9b0 | Ruby | mikewayne/numbers_to_words | /spec/numbers_to_words_spec.rb | UTF-8 | 222 | 2.734375 | 3 | [] | no_license | require('rspec')
require('numbers_to_words')
describe("String#numbers_to_words") do
it("takes in a number and outputs the 'word' that represents the number") do
expect(("2").numbers_to_words()).to(eq("two"))
end
end
| true |
c5d68bffd0cec45afe0a1f722494661fb7e218a3 | Ruby | dougpotter/controlcenter | /branches/extraction/lib/additive_fact_behaviors.rb | UTF-8 | 4,041 | 2.734375 | 3 | [] | no_license | module AdditiveFactBehaviors
def self.included(base)
base.class_eval do
def self.acts_as_additive_fact
extend FactBehaviors::ClassMethods
include FactBehaviors::InstanceMethods
extend ClassMethods
include InstanceMethods
end
end
end
module ClassMethods
#... | true |
fc69565cb35466a0860ddcc46df522aed03613b3 | Ruby | learnwhytocode/learnwhytocode.github.com | /downloads/code/local-data-env/my_code_alpha.rb | UTF-8 | 1,792 | 3.109375 | 3 | [] | no_license | require 'rubygems'
require 'json'
require 'httparty'
###############
# Constants
TWITTER_DATA_HOST = File.expand_path("data-hold")
TWITTER_USER_DATA_PATH = File.join(TWITTER_DATA_HOST, "users")
TWITTER_TWEETS_DATA_PATH = File.join(TWITTER_DATA_HOST, "statuses")
def url_for_twitter_user_info(screen_name)
# pre: scr... | true |
3372beb5869a07c9264c4f80810aecd81c054873 | Ruby | wonda-tea-coffee/atcoder | /abc/066/a.rb | UTF-8 | 54 | 2.875 | 3 | [] | no_license | a = gets.chomp.split.map(&:to_i).sort
puts a[0] + a[1] | true |
ac1064926ebd09861bdb8077151bee621fdc6266 | Ruby | chsweet/mastermind | /lib/comparison.rb | UTF-8 | 804 | 3.671875 | 4 | [] | no_license | class Comparison
attr_accessor :guess_count, :player_guess
def initialize(secret_code, player_guess=nil, guess_count=nil)
@player_guess = player_guess
@guess_count = guess_count
@code_split = secret_code.chars
end
def elements_correct
intersection = player_guess_split & @code_split
intersect... | true |
29347096dda732151a47dbde9fadf650956cb998 | Ruby | jcampbell18/rubyOnRails | /ruby/2_EssentialTraining/Ex_Files_Ruby_EssT_2_Classes/Exercise Files/Chapter_04/04_03/04_03_datetime.rb | UTF-8 | 783 | 3 | 3 | [] | no_license | # This file is a transcript of the IRB session shown in the movie.
# You should be able to cut and paste it into IRB to get
# similar results shown in the comments.
# irb
require 'date'
# => true
DateTime.now
# => #<DateTime: 2018-10-10T12:11:26-04:00 ((2458402j,58286s,180559000n),-14400s,2299161j)>
DateTime.new(2000... | true |
89eca67128350a05e8d491607c270e5ff9ff8caf | Ruby | agc0610/phase-0-tracks | /ruby/nested_data_structures_v2.rb | UTF-8 | 1,823 | 3.578125 | 4 | [] | no_license | #nested data structure: biology textbook with units that have a name, chapter amounts, names, and starting page numbers
biology_textbook = {
unit_1: {
"name" => "Basics",
"number_of_chapters" => 3,
"chapter_names" => ["Introduction", "Fundamental Terms and Concepts", "The 6 Kingdoms" ],
"starts_on_pa... | true |
eb152c72671b70b29d26efbbe9e26e79c2ec1415 | Ruby | AshwatthNagpal/RNATranscription1 | /spec/rna_transcription_spec.rb | UTF-8 | 583 | 2.8125 | 3 | [] | no_license | require 'rna_transcription.rb'
describe 'dna_to_rna' do
it 'return empty string if input is empty' do
expect(dna_to_rna("")).to eq ""
end
it 'complement of cytosine to guanine' do
expect(dna_to_rna("C")).to eq "G"
end
it 'complement of guanine to cytosine' do
expect(dna_to_rna("G")).to eq "C"
en... | true |
c7ecd67de58382f2907c289c53970506c074c83a | Ruby | fox3000wang/BASH_SHELL | /ruby/RubyLearning/1.3.Range/3.rb | UTF-8 | 69 | 3.09375 | 3 | [] | no_license | print "1: "
puts (1..10) === 10
print "2: "
puts (1...10) === 10 | true |
89ec6f2632a917ecb5be231f09b5e1102e5a4daf | Ruby | miguel7penteado/ruby_lembretes | /1/nome.rb | UTF-8 | 231 | 3.65625 | 4 | [] | no_license | #!/usr/bin/ruby
class Pessoa
def initialize(nome)
@nome = nome.capitalize
end
def digaSeuNome
puts "Meu nome eh #{@nome}!"
end
end
mano = Pessoa.new("Miguel Suez Xve Penteado")
mano.digaSeuNome
| true |
5d1d4721c98dce739ea90642cbe91abdeda34585 | Ruby | gengogo5/atcoder | /ABC/abc126/ABC126_C.rb | UTF-8 | 263 | 2.84375 | 3 | [] | no_license | N,K = gets.split.map(&:to_i)
ret = 0
(1..N).each do |i|
# サイコロ確率
d = 1.0 / N
now = i
loop do
break if now >= K
# 得点
now *= 2
# コイン表連続確率
d /= 2
end
# 確率足し合わせ
ret += d
end
puts ret
| true |
c4aaa70157db3f32394067ef6e107e77e1f373a7 | Ruby | bnguyenngoc/Shopify-Summer-2019-Internship-Challenge | /api/app/controllers/products_controller.rb | UTF-8 | 1,772 | 2.671875 | 3 | [] | no_license | class ProductsController < ApplicationController
# querys all products through GraphQL
# POST /query
def query
result = Schema.execute(
params[:query]
)
render json: result
end
# returns one specific product
# GET /products/:id
def show
result = Product.find(params[:id])
r... | true |
ddaef2196b42e470000950bc31ace1a1efa3b2b9 | Ruby | zsy056/solutions | /leetcode/19-remove-nth-node-from-end-of-list.rb | UTF-8 | 492 | 3.609375 | 4 | [] | no_license | # Definition for singly-linked list.
# class ListNode
# attr_accessor :val, :next
# def initialize(val)
# @val = val
# @next = nil
# end
# end
# @param {ListNode} head
# @param {Integer} n
# @return {ListNode}
def remove_nth_from_end(head, n)
dummy = ListNode.new 0
dummy.next = head
p... | true |
d06449a1bcd0b1b47fda2b12e2422d59598deca4 | Ruby | leshow/vector | /scripts/util/metadata/transform.rb | UTF-8 | 954 | 2.6875 | 3 | [
"Apache-2.0",
"OpenSSL"
] | permissive | #encoding: utf-8
require_relative "component"
require_relative "output"
class Transform < Component
attr_reader :allow_you_to_description,
:input_types,
:output,
:output_types
def initialize(hash)
super(hash)
# init
@allow_you_to_description = hash.fetch("allow_you_to_description")
... | true |
a27852499f9eb0b4210224a92a4fad30147bf9d3 | Ruby | possumtale/ruby-challenges | /chore2.rb | UTF-8 | 470 | 3.796875 | 4 | [] | no_license | all_chores = [
"wash dishes",
"sweep the floor",
"do laundry",
"walk the dog",
"feed the cats",
"give me a foot rub"
]
total_chores = all_chores.size
chores_done = 0
while (chores_done <= total_chores)
puts "Did you " + all_chores[chores_done] + "?"
answer = gets.chomp.downcase
if ... | true |
e2f2f94ee04927a6f3347466cfd4e2011e23bb27 | Ruby | dmorrill10/rename_files | /lib/rename_files/cli.rb | UTF-8 | 3,097 | 3.1875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'shellwords'
require 'zaru'
require 'optparse'
module RenameFiles
def self.new_file_name(f, prefix: '', postfix: '')
if prefix && !prefix.empty? && !f.match(/^#{prefix}/)
f = prefix + f
end
if postfix && !postfix.empty? && !f.match(/#{postfix}$/)
f << postfix
... | true |
6416d09ff8e9600dd7192a704e33c8fe9398735c | Ruby | taw/libgmp-ruby | /tests/test-07.rb | UTF-8 | 203 | 2.84375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'gmp'
a=GMP::Z.new(100)
b=GMP::Z.new(16)
c=a**5
d=a**b
e=2**b
f=a.powmod(2,256)
g=b.powmod(10,a)
h=a.powmod(b,256)
i=a.powmod(b,c)
[a,b,c,d,e,f,g,h,i].each { |var| p var }
| true |
040818eacb0367dccdf4cdbb8567dae1667566f5 | Ruby | jonathanbouren/LS_Ruby | /RB101/Lesson2_Small_Programs/loan_calculator/loan_calculator.rb | UTF-8 | 3,185 | 3.625 | 4 | [] | no_license | require 'pry'
require 'yaml'
MESSAGES = YAML.load_file('loan_calculator_messages.yml')
YES_ANSWERS = ["y", "yes", "yeah", "yep", "ok", "sure", "probably"]
NO_ANSWERS = ["n", "no", "nope", "nada", "no way", "never", "not really"]
def wave_left
system("clear")
puts "=>"
puts "==>"
puts "===>"
puts "====> _"... | true |
5f499b023d98d189cad966b35d93dbcdc156eccd | Ruby | sploadie/linear_regression | /parse.rb | UTF-8 | 571 | 3.4375 | 3 | [] | no_license | require 'csv'
def parse_csv(filepath)
csv_array = CSV.read filepath
raise 'CSV first line should be "km,price"' if csv_array.shift != ['km','price']
raise 'CSV file has no data' if csv_array.count == 0
raise 'CSV file contains only one point' if csv_array.count == 1
data = csv_array.map do |poi... | true |
368eb5fb77fb74bb5ff21608fe9c96b608ca8b9b | Ruby | yhara/unbabel | /ruby/lib/unbabel.rb | UTF-8 | 5,240 | 2.96875 | 3 | [] | no_license | require 'tempfile'
require 'fileutils'
class String
def unindent
self =~ /^(\s*)/
indent = $1
self.lines.map{|line|
line.sub(indent, "")
}.join
end
end
# String#lines for ruby <= 1.8.6
unless "".respond_to?(:lines)
class String
def lines
self.split(/\r?\n/).map{|line| line+"\n"}
... | true |
32cf0f08b4306639c70947328b15daed6c1d8a67 | Ruby | olotintemitope/andela_ruby | /testing.rb | UTF-8 | 343 | 2.828125 | 3 | [] | no_license |
require_relative "file" #call the class file here
require 'rspec' # call the rspec library here
describe "Number" do
context "#add" do
it "can add numbers" do
expect(NewNumber.new.add(4,4)).to eql(8)
end
it "can add 2 negative" do
expect(NewNumber.new.add(-5,-3)).to eql(-8)
... | true |
80226c750347b118180b527ecd354d6e881ab1fb | Ruby | kaleungting/rater-app | /app/models/business.rb | UTF-8 | 1,910 | 2.53125 | 3 | [] | no_license | # == Schema Information
#
# Table name: businesses
#
# id :bigint not null, primary key
# name :string not null
# address :string not null
# city :string not null
# state :string not null
# zipcode :string ... | true |
1be83d4368ce8f57a3f31e708711b0f0a1052ebf | Ruby | ISS-Analytics/weather_weaver_api | /specs/fake_weather_oracle.rb | UTF-8 | 1,068 | 2.90625 | 3 | [] | no_license | # frozen_string_literal: true
require 'yaml'
# Fake oracle fixture class
class FakeWeatherOracle
DARKSKY_API_URL = 'https://api.darksky.net/forecast'.freeze
# Include dry-types types into namespace
module Types
include Dry::Types.module
end
Location = Types::Hash.symbolized(
longitude: Types::Coer... | true |
011ea685d8204c71258990904d5969172197bc84 | Ruby | nilbus/teaspoon | /lib/teaspoon/runner.rb | UTF-8 | 1,474 | 2.53125 | 3 | [
"BSD-3-Clause",
"MIT"
] | permissive | require "json"
require "teaspoon/result"
module Teaspoon
class Runner
attr_accessor :formatters
attr_reader :failure_count
def initialize(suite_name = :default)
@suite_name = suite_name
@formatters = Teaspoon.configuration.formatters.map{ |f| resolve_formatter(f).new(suite_name) }
@... | true |
0888b9713ec08d21d011b7c99723d1b8f0b6cd83 | Ruby | jkshareef/advanced-hashes-hashketball-seattle-web-career-042219 | /hashketball.rb | UTF-8 | 6,000 | 3.40625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here!
require 'pry'
def game_hash
{:home => {
:team_name => "Brooklyn Nets",
:colors => ["Black", "White"],
:players => {
"Alan Anderson" =>
{:number => "0" , :shoe => "16", :points => "22", :rebounds => "12", :assists => "12", :steals => "3", :blocks => "1... | true |
de23d12e38d6bce87f39d241ca0743143418c373 | Ruby | zhouqt/dotfiles | /lib/ruby/paste.rb | UTF-8 | 1,470 | 2.75 | 3 | [] | no_license | #!/usr/bin/env ruby
# coding: utf-8
#Author: Roy L Zuo (roylzuo at gmail dot com)
#Description: 粘贴一段文字到 pastbin.com
require 'rubygems'
require 'mechanize'
$paste_bin = {
:pastebin => {
:url => 'http://pastebin.com',
:code => 'paste_code' ,
:edit_url => 'http://pastebin.com/index',
:opts => { 'paste_... | true |
879353692c7bf1673db408c1773afd50f945b3b3 | Ruby | jvennin/Adekwat | /app/models/step.rb | UTF-8 | 1,355 | 2.890625 | 3 | [] | no_license | class Step
attr_reader :travel_mode, :options
def initialize(attributes = {})
@travel_mode = attributes["travel_mode"]
@options = attributes
end
def is_walking?
@travel_mode == "WALKING"
end
def is_subway?
@travel_mode == "TRANSIT"
end
def line_color
if @travel_mode == "TRANSIT"
... | true |
2ac2dfe1177c94d510cf38d4edb9af83312914b8 | Ruby | cph/set_builder | /lib/set_builder/modifier.rb | UTF-8 | 2,718 | 3.109375 | 3 | [
"MIT"
] | permissive | require "set_builder/modifiers"
require "set_builder/modifier/adverb"
require "set_builder/modifier/verb"
module SetBuilder
module Modifier
@registered_modifiers = {}
def self.registered?(klass)
@registered_modifiers.values.member?(klass)
end
def self.name(klass)
@registered_modi... | true |
e4a0637b68980eff3128f4ad540004f1f0e8320a | Ruby | mocchi0420/project-euler | /euler021.rb | UTF-8 | 1,061 | 3.546875 | 4 | [] | no_license | # coding: utf-8
# Problem 21 「友愛数」
# 簡単な方針
# 友愛数の組にはa!=bの条件から、絶対にa<bとなるような数値が存在している。
# また、友愛数の性質上、約数の和が自身の数値より大きくなるような数値が対象となる。
# このことから、自身より大きな約数の和を持っている数値を見つけたら、その相手の数値を調べる。
# もしこの結果、友愛数となる組が見つかったら、そのまま結果に格納する。
def euler021(index=10000)
arr = Array.new(index,0)
ret = []
2.upto(index-1) do |hoge|
arr[hoge] = ge... | true |
4794b11ba998674557a54d5d017335e6b49fcb58 | Ruby | ttuan/hackerrank_solutions | /algorithms/implementation/beautiful-days-at-the-movies.rb | UTF-8 | 245 | 3.515625 | 4 | [] | no_license | #!/bin/ruby
def beautifulDays(i, j, k)
rs = 0
for d in (i..j) do
rs += 1 if (d - d.to_s.reverse.to_i) % k == 0
end
rs
end
i, j, k = gets.strip.split(' ')
i = i.to_i
j = j.to_i
k = k.to_i
result = beautifulDays(i, j, k)
puts result
| true |
a84596e8477ec31c21397406c1c8db9c29ec2df7 | Ruby | raspygold/advent_of_code | /2015/12/solution-1.rb | UTF-8 | 279 | 2.90625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
file_path = File.expand_path("../input.txt", __FILE__)
input = File.read(file_path)
require "json"
# input_json = JSON.parse input
total = 0
input.scan(/-?\d+/) do |num|
total += num.to_i
puts num.to_i if num.to_i < 0
end
puts total
# => 191164
| true |
4d6394fa11615dc367bc9d611fc1713e2e7f835e | Ruby | anthonyltam/mern-setup | /Desktop/PROJECTS/W1D1/enumerables.rb | UTF-8 | 2,889 | 3.6875 | 4 | [] | no_license | require 'byebug'
class Array
def my_each(&prc)
i = 0
while i < self.length
prc.call(self[i])
i += 1
end
self
end
def my_select(&prc)
result = []
self.my_each do |el|
result << el if prc.call(el)
end
result
end
def my_reject(&prc)
result = []
self.... | true |
f4cfce492cff946b0b42c800c10a2dded1ca3975 | Ruby | artichoke/ferrocarril | /mruby-sys/vendor/mruby-bc7c5d3/mrbgems/mruby-range-ext/mrblib/range.rb | UTF-8 | 1,591 | 3.390625 | 3 | [
"MIT",
"MPL-2.0"
] | permissive | class Range
##
# call-seq:
# rng.first -> obj
# rng.first(n) -> an_array
#
# Returns the first object in the range, or an array of the first +n+
# elements.
#
# (10..20).first #=> 10
# (10..20).first(3) #=> [10, 11, 12]
#
def first(*args)
return self.begin if args.empty?
... | true |
04dd651afcf3a52711f36a3dbb1c834247e34b7f | Ruby | meutley/TrackMyHealth | /app/helpers/application_helper.rb | UTF-8 | 336 | 2.515625 | 3 | [
"MIT"
] | permissive | module ApplicationHelper
def to_user_timezone_formatted(value)
tz = current_user&.timezone
return value&.in_time_zone(tz)&.strftime("%-m/%-d/%Y %I:%M %p")
end
# Static data
def weight_units
return ["lbs", "kg"]
end
def blood_glucose_units
return ["mg/dL", "mmol/... | true |
46e27a598693003768ea120aab5ce3a4a75bd9dc | Ruby | Matoone/THP_S3_J2 | /app_3.rb | UTF-8 | 1,849 | 3.328125 | 3 | [] | no_license | require 'bundler'
Bundler.require
require_relative 'lib/game'
require_relative 'lib/player'
def welcome_message
puts "==================================== O_O ===================================="
puts "==================================== ===================================="
puts ""
puts "==============... | true |
9b15999dcebd416bd719b1de08e759f1ce2a05ad | Ruby | davemcg3/design_patterns | /pure/flyweight/ruby/generic_example.rb | UTF-8 | 1,926 | 3.421875 | 3 | [] | no_license | class AbstractFlyweight
def operation (extrinsicState)
raise "Not implemented"
end
end
class ConcreteFlyweight < AbstractFlyweight
def initialize
@intrinsicState = "stored in the concrete flyweight"
print "ConcreteFlyweight instantiated\n"
end
def operation (extrinsicState)
print "Running op... | true |
50bd781770e1cb2d117c6515f19b98c6af0139ab | Ruby | dustalov/greeb | /spec/tokenizer_spec.rb | UTF-8 | 2,549 | 2.9375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # encoding: utf-8
require_relative 'spec_helper'
describe Tokenizer do
describe 'after tokenization' do
subject { Tokenizer.tokenize('vodka') }
it 'should has the tokens set' do
subject.must_be_kind_of Array
end
end
describe 'tokenization facilities' do
it 'can handle words' do
Tok... | true |
3e8c230b0cf4a347a3f4787426b3434cec73ae44 | Ruby | AlanKrajina/artist-song-modules-online-web-sp-000 | /lib/concerns/findable.rb | UTF-8 | 208 | 2.9375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | module Findable
# runs .all method (that returns @@array), then it loops and returns the first match object name with argument name
def find_by_name(name)
all.detect{|a| a.name == name}
end
end | true |
d3e0aab62b8f94e43179847e6bc51aff24d94981 | Ruby | Shane0018/WebDev2021-classCode | /Topic8::OOP-Part1/my_trial.rb | UTF-8 | 1,179 | 3.609375 | 4 | [] | no_license | class Animals
def initialize(eats, runs, plays, moves, makes_noise)
@eats = eats
@runs = runs
@plays = plays
@moves = moves
@makes_noise = makes_noise
@awake = true
end
# method reader
def plays
puts @plays
end
def moves
pu... | true |
89f22b07ab8ecb5f378c26ca3f602fa7bb0c29cb | Ruby | Luxor/fix-protocol-tools | /lib/fix_protocol_tools/messages_processor.rb | UTF-8 | 3,541 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'term/ansicolor'
require 'logger'
require 'fix_protocol_tools/specification/dictionary'
module FixProtocolTools
class MessagesProcessor
include Term::ANSIColor
MESSAGE_DELIMITER = "\x01"
def initialize(options)
@spec = nil
@is_even_line = true
@output = STDOUT
@grep = opt... | true |
348ce771ee9b50d858130e660aa06dda48dfca76 | Ruby | dannamite/RubyByExample | /prime.rb | UTF-8 | 420 | 4.09375 | 4 | [] | no_license | # Find prime numbers between 1 and a given number.
puts "Find all the prime numbers between 1 and a given number"
print "Enter number: "
num = gets.chomp.to_i
prime_num = []
(2..num).each do |n|
flag = true
(2..n-1).each do |m|
if n % m == 0
flag = false
break
end
end
if flag == true
... | true |
405aa5148cdd97f6d04a96a2ac8470de5d0693a4 | Ruby | jkhoang313/project-euler-even-fibonacci-web-1116 | /lib/oo_even_fibonacci.rb | UTF-8 | 499 | 3.640625 | 4 | [] | no_license | # Implement your object-oriented solution here!
class EvenFibonacci
attr_accessor :limit
def initialize(limit)
@limit = limit
end
def sum
first_num = 1
second_num = 2
sum_of_last_two_num = first_num + second_num
sum = 2
while sum_of_last_two_num < limit
sum += sum_of_last_two_nu... | true |
37393a70817c8cb59e237649defc93a5efc6b7fd | Ruby | braktar/grape | /lib/grape/validations.rb | UTF-8 | 626 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
module Grape
# Registry to store and locate known Validators.
module Validations
class << self
attr_accessor :validators
end
self.validators = {}
# Register a new validator, so it can be used to validate parameters.
# @param short_name [String] all lower-ca... | true |
92b14f0108ad363cb2dd60c64295d980a3c077bb | Ruby | brendanlim/Splat | /lib/splat/vendors/twilio/xml/twilio_xml.rb | UTF-8 | 3,629 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'xsd/qname'
# {}RestException
class RestException
@@schema_type = "RestException"
@@schema_ns = nil
@@schema_element = [["status", ["SOAP::SOAPString", XSD::QName.new(nil, "Status")]], ["message", ["SOAP::SOAPString", XSD::QName.new(nil, "Message")]], ["code", ["SOAP::SOAPString", XSD::QName.new(nil, "Co... | true |
bfdd1d9c5d3a05b235e5ba748b9fddd9e4460dfc | Ruby | gegerlan/aog | /Src/Scripts/Game_Actor.rb | UTF-8 | 26,236 | 2.703125 | 3 | [] | no_license | #==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles the actor. It's used within the Game_Actors class
# ($game_actors) and refers to the Game_Party class ($game_party).
#===... | true |
700490e529148a6765056b2b7138168c1cd58118 | Ruby | Priyankasahas/toy-robot | /lib/directions/facing_south.rb | UTF-8 | 354 | 3.125 | 3 | [] | no_license | # Face south
class FacingSouth
attr_reader :robot, :direction
def initialize(robot)
@robot = robot
@direction = 'SOUTH'
end
def left
@robot.facing_direction = @robot.facing_east
end
def right
@robot.facing_direction = @robot.facing_west
end
def move
@robot.set_position(@robot.x_a... | true |
dce86a58bbe36b2fdfa3d2b3f069cd32e8b3cd36 | Ruby | varyonic/amex_enhanced_authorization | /lib/amex_enhanced_authorization/request.rb | UTF-8 | 1,395 | 2.578125 | 3 | [
"MIT"
] | permissive | module AmexEnhancedAuthorization
# Amex requests use extended headers and a JSON body.
class Request < LoggedRequest
attr_reader :client_id
attr_reader :authorization
def initialize(method, path, client_id, logger)
super(method, path, logger)
@client_id = client_id
end
# Return re... | true |
bad4741d181b6f3dd5d74a73709c333fb4cf0c7c | Ruby | DenisePlaut/daily_challenges | /DenisePilletteChallenges/Week 4/Ruby-Basics-master/rps.rb | UTF-8 | 735 | 4.0625 | 4 | [] | no_license | puts "Player 1 input: Rock, Paper or Scissors"
player1 = gets.chomp.downcase
puts "Player 2 input: Rock, Paper, or Scissors"
player2 = gets.chomp.downcase
if player1 == "rock" && player2 == "scissors"
print "Player1 wins!\n"
elsif player1 == "paper" && player2 == "rock"
print "Player1 wins!\n"
elsif pla... | true |
0feeee2257ff2abecb8cc8cc0b9f75efe690e0e9 | Ruby | samtes/cal_meal | /admin_cal | UTF-8 | 1,973 | 3.21875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
$LOAD_PATH << "lib"
$LOAD_PATH << "models"
require 'environment'
Environment.environment = ENV["ENVIRONMENT"] || "production"
$stderr = $stdout
require 'smart_colored/extend'
require 'person'
require 'diet'
def main_menu
<<EOS
Hi Sam, what do you want to do?
EOS
end
def diet_menu
<<EOS
Select th... | true |
ee6338707d8a1feb9595f437b7671a32e73c19ef | Ruby | adityavs/AdventOfCode2017 | /day11/main.rb | UTF-8 | 452 | 3.125 | 3 | [] | no_license | DATA = File.read('data.txt')
.strip
.split(",")
.map(&:to_sym)
DIRECTIONS = {
n: [ 0, 1, -1],
ne: [ 1, 0, -1],
se: [ 1, -1, 0],
s: [ 0, -1, 1],
sw: [-1, 0, 1],
nw: [-1, 1, 0],
}
DISTANCES = DATA
.inject([[0,0,0]]){ |l, dir| l.push DIRECTIONS[dir].zip(l.last).map(&:sum... | true |
0e57c4692450238dad2dc2dc2066da54e62b4142 | Ruby | stefanverhoeff/euler | /ruby/problem17.rb | UTF-8 | 1,171 | 4.03125 | 4 | [] | no_license | def say_number(num)
ones = %w{ q one two three four five six seven eight nine }
tentotwenties = %w{ ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen }
tens = %w{ q q twenty thirty forty fifty sixty seventy eighty ninety }
said = ''
orig = num
if num >= 1000
said... | true |
a09ed29ac040c0ceab34f2449882c7f0389978bb | Ruby | sseleznevqa/marta | /spec/magic_finder_class_spec.rb | UTF-8 | 5,603 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'marta/black_magic'
require 'spec_helper'
describe "Magic Finder" do
before(:all) do
@page_three_url = "file://#{Dir.pwd}" +
"/spec/test_data_folder/page_three.html"
@xpath = "//*/BODY/H1[contains(@class,'element')][contains(@class,'find')]"
@xpath_without_granny =
"//BODY/H1... | true |
f51b5dedfa8162c26e7c745ed04ecab8481410c2 | Ruby | tbscanlon/learn-to-program-v2 | /chapter-7/ex7.rb | UTF-8 | 210 | 3.796875 | 4 | [] | no_license | # Repeat alphabetical input
words = Array.new
user_input = 0
puts "Start entering words. Enter nothing to stop"
while user_input != ""
user_input = gets.chomp
words.push(user_input)
end
puts words.sort!
| true |
d6e26e285f25059f1b3a5f7150e7cdfe123382f1 | Ruby | Alex-Desjardins/sweater_weather_api | /app/poros/location.rb | UTF-8 | 228 | 2.765625 | 3 | [] | no_license | class Location
attr_reader :coordinates, :city, :state, :country
def initialize(data)
@coordinates = data[:latLng]
@city = data[:adminArea5]
@state = data[:adminArea3]
@country = data[:adminArea1]
end
end
| true |
7d1725f95cd5a89c7fd796629861275e4f0c5cbb | Ruby | KrstnP/padawan-coding-exercises-no-03 | /exercise_02.rb | UTF-8 | 91 | 2.96875 | 3 | [] | no_license | PI = 3.141592653589793
radius = 157
a = PI * (radius ** 2)
puts "Area of a circle is #{a}"
| true |
876e8aefbf61fea2c87654c998b990dc3825bf6d | Ruby | igorcb/transport | /app/services/palletizing_pallets/input_in_house_service.rb | UTF-8 | 1,069 | 2.578125 | 3 | [] | no_license | module PalletizingPallets
class InputInHouseService
def initialize(house, pallet, current_user)
@house = house
@pallet = pallet
@current_user = current_user
end
def call
return {success: false, message: "House can't be nil"} if @house.nil?
return {success: false, message: "... | true |
f96262f4534d4962cca9fc3450160a4c21ff2879 | Ruby | arafatkatze/rubex | /lib/rubex/ast/ruby_method_def.rb | UTF-8 | 2,936 | 3 | 3 | [
"BSD-2-Clause"
] | permissive | module Rubex
module AST
class RubyMethodDef
# Ruby name of the method.
attr_reader :name
# The equivalent C name of the method.
attr_reader :c_name
# Method arguments.
attr_reader :args
# The statments/expressions contained within the method.
attr_reader :statements... | true |
b847bc08d084a17fba6de95bb5c3c7f75da86519 | Ruby | RobinWagner/Ruby-Assignment | /04_pig_latin/pig_latin.rb | UTF-8 | 642 | 3.84375 | 4 | [] | no_license | #write your code here
def translate(words)
vowels = ['a', 'e', 'i', 'o', 'u']
consonants = ('a'..'z').to_a.reject { |letter| vowels.include? letter }
words.split(' ').map do |word|
if vowels.include? word[0]
word + 'ay'
elsif word[0..1] == 'qu'
word[2..-1] + word[0..1] + 'ay'
elsif conso... | true |
36d9b5c3d635f41f7d89c2bed84700a337fdc907 | Ruby | awslabs/cloud-templates-ruby | /lib/aws/templates/utils/expressions/function.rb | UTF-8 | 1,196 | 3 | 3 | [
"Apache-2.0"
] | permissive | require 'aws/templates/utils'
require 'facets/string/pathize'
require 'facets/module/lastname'
module Aws
module Templates
module Utils
module Expressions
##
# Function DSL class
#
# Embodies properties specific to functions like name and string formatting into the usual
... | true |
13643b5ec7b644c512d97a599b5929840a2afc92 | Ruby | ryunosuketheend/furimaapp-29698 | /spec/models/address_order_spec.rb | UTF-8 | 2,946 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
describe AddressOrder do
before do
@buyer = FactoryBot.create(:user)
@seller = FactoryBot.create(:user)
@item = FactoryBot.create(:item, user_id: @seller.id)
@address_order = FactoryBot.build(:address_order, user_id: @buyer.id, item_id: @item.id)
end
describe '商品購入機能' do
... | true |
4ace20922df4f087574db2067e6ddbf1fd52b1cc | Ruby | tomekcieslar/circle | /app/lib/line.rb | UTF-8 | 688 | 2.984375 | 3 | [] | no_license | class Line
InvalidFormat = Class.new(StandardError)
def initialize(source)
raise('Line is an abstract class and cannot be instantiated.') unless self.class < Line
@source = source
validate_format!
end
def self.parse(source)
raise ArgumentError, 'you need to provide a string as an argument' if... | true |
aa86b9bfa50210de3445f926ab348546ce80a70f | Ruby | inetufo/baidu-map | /lib/baidu-map/api_wrappers/places.rb | UTF-8 | 1,936 | 2.65625 | 3 | [
"MIT"
] | permissive | module BaiduMap
class Places
include BaseNetMethods
extend Forwardable
def_delegators :@options, :key, :keyword, :radius, :page_size, :page_num
attr_reader :lat, :lng, :region
def initialize(lat, lng, region, options = {})
@lat, @lng, @region = lat, lng, region
options[... | true |
27f99f8c0c48699746a63b798a87af7dca1af241 | Ruby | matsossah/mind-spirits | /app/models/reservation_service.rb | UTF-8 | 907 | 2.890625 | 3 | [] | no_license | class ProfessionalNotAvailableException < StandardError; end
class ReservationService
def initialize(professional, user, start_time, end_time, address)
@professional = professional
@user = user
@start_time = start_time
@end_time = end_time
@address = address
end
def reserve!
ActiveRecord... | true |
3c65d3298ed897aecfb608d453919bb1ace23721 | Ruby | faker-ruby/faker | /lib/faker/default/world_cup.rb | UTF-8 | 1,718 | 2.734375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Faker
class WorldCup < Base
class << self
##
# Produces a national team name.
#
# @return [String]
#
# @example
# Faker::WorldCup.team #=> "Iran"
#
# @faker.version 1.9.0
def team
fetch('world_cup.teams')
... | true |
1024b2f966345690d881c8ce89617717817b81d3 | Ruby | itggot-erling-reimer/slutprojektvt19webbserver | /app.rb | UTF-8 | 2,274 | 2.6875 | 3 | [] | no_license | require 'sinatra'
require 'sqlite3'
require 'slim'
class App < Sinatra::Base
enable :sessions
db = SQLite3::Database.new("db/forum19db.db")
get "/" do
@user = session[:user]
if !@user
redirect "/login"
end
@posts = db.execute('SELECT * FROM posts WHER... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.