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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8a76ad20a2ef8514a424ef671aca77839ac27de6 | Ruby | SyxHyTex/Gerridae | /spec/helpers_spec.rb | UTF-8 | 2,458 | 2.671875 | 3 | [
"MIT"
] | permissive | require_relative 'spec_helper'
describe Helpers do
let(:dummy_class) { Class.new { include Helpers } }
subject(:skater) { }
describe "#create_filename" do
context "" do
end
end
describe "#ip_generate" do
let(:bad_ip_v) { 5 }
let(:not_ip_v) { 'jsiodjasipd' }
context "when improper... | true |
4d062778bef44244572934d87462f125a2b82077 | Ruby | cucumber-attic/cucumber-tmbundle | /support/spec/cucumber/mate/table_aligner_spec.rb | UTF-8 | 1,913 | 2.53125 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/../../../lib/cucumber/mate/table_aligner'
module Cucumber
module Mate
describe TableAligner do
it "should align a simple table" do
unaligned = [
" | a |b|",
" |c| d ... | true |
1e3384c5a067daf3fa06056bbc6d24409340555b | Ruby | mat2m10/guilder | /db/seeds.rb | UTF-8 | 2,470 | 2.984375 | 3 | [] | no_license | require 'faker'
require "open-uri"
require 'date'
puts "Destroying current bookings/crafts/users..."
Booking.destroy_all
Craft.destroy_all
User.destroy_all
today = DateTime.now
puts "Creating batman user..."
first = User.create(email: "b@t.man", username: "batman", first_name: "Bruce", last_name: "Wayne", password... | true |
c3cfbc85570528d6c4aa428d3b004098addd7b0b | Ruby | kiyotan815/atcorder | /beginners_selection/ruby/coins.rb | UTF-8 | 519 | 3.671875 | 4 | [] | no_license | text = <<-TEXT
500円玉をA 枚、100円玉をB枚、50円玉をC枚持っています。
これらの硬貨の中から何枚かを選び、
合計金額をちょうどX円にする方法が何通りあるかを出力します。
TEXT
puts text
print "A = "
a = gets.to_i
print "B = "
b = gets.to_i
print "C = "
c = gets.to_i
print "X = "
x = gets.to_i
cnt = 0
(0..a).each do |i|
(0..b).each do |j|
(0..c).each do |k|
cnt += 1 ... | true |
e6b231ac05f30fa00ba5f13922ebadc756d97e07 | Ruby | kputnam/stupidedi | /lib/stupidedi/parser/instruction.rb | UTF-8 | 3,373 | 2.609375 | 3 | [
"BSD-3-Clause"
] | permissive | # frozen_string_literal: true
module Stupidedi
using Refinements
module Parser
class Instruction
include Inspect
# The segment identifier to which this {Instruction} applies
#
# @return [Symbol]
attr_reader :segment_id
# The segment use contains helpful information about t... | true |
a71e8f103cc895e709d81949b3e896c2f89cb26b | Ruby | renanmaringolo/playing-logic | /salary_bonus.rb | UTF-8 | 833 | 3.671875 | 4 | [] | no_license | # Faça um programa que leia o nome de um vendedor, o seu salário fixo e o total de vendas efetuadas por ele no mês (em dinheiro). Sabendo que este vendedor ganha 15% de comissão sobre suas vendas efetuadas, informar o total a receber no final do mês, com duas casas decimais.
# Entrada
# O arquivo de entrada contém... | true |
40bb48191d7cfd6bf9a52e3625ec3ca33060f416 | Ruby | msosland/TakeAHike | /app/helpers/make_markers_array.rb | UTF-8 | 161 | 3.03125 | 3 | [
"MIT"
] | permissive | def make_markers_array(places)
coords = places.map do |place|
hash = {lat: place[:latitude], lng: place[:longitude], name: place[:name]}
end
coords
end | true |
32f12eed645c8c057ea71360357f29438c5867c0 | Ruby | armandofox/audience1st | /spec/support/custom_matchers.rb | UTF-8 | 1,435 | 2.9375 | 3 | [
"BSD-2-Clause"
] | permissive | module CustomMatchers
# test an enumerable to see if it includes a match for regex.
class IncludeMatchFor
include Enumerable
def initialize(regex)
@regex = regex
end
def matches?(target)
target.any? { |elt| elt.match(@regex) }
end
def failure_message
"expected #{@target.in... | true |
b52b0b7d7a2a9d37988c4a4ac8b306d4e1a620ac | Ruby | choonkeat/firehose | /lib/firehose/subscription.rb | UTF-8 | 2,850 | 2.5625 | 3 | [] | no_license | module Firehose
class Subscription
# Default TTL for how long a subscription should live on the server when the
# consumer disconnects.
# TODO should the Consumer handle TTL?
TTL = 15000
# Time to live for the amqp_queue on the server after the subscription is canceled. This
# is mostly for f... | true |
7a5be9f371159a0a40ea7c37a078b39ccdb52244 | Ruby | mcivorsteiner/local-beat | /lib/seatgeek.rb | UTF-8 | 1,756 | 2.625 | 3 | [] | no_license | require 'multi_json'
require 'echonest'
module Seatgeek
extend self
def find_event_with_songkick_artist_id_and_date(songkick_artist_id, event_date)
seatgeek_artist_id = Echonest.get_seatgeek_id(songkick_artist_id)
unless seatgeek_artist_id == nil
event = performer_event_on_date(seatgeek_artist_id, ... | true |
4bbd5928a0f80bb707d37614ff532d8328a8e704 | Ruby | mattopps/phase-0 | /week5/pad-array/My_pad_solution.rb | UTF-8 | 3,697 | 4.28125 | 4 | [
"MIT"
] | permissive |
# 0. Pseudocode
# What is the input? an array of items, a minimum length for the array, a value to pad the array if needed
# What is the output? an array
# What are the steps needed to solve the problem?
=begin
Destructive
1. define a method to accept the input (an array, a minimum length requirement, and a defaul... | true |
b9b0cfff6aea12be0c1ba455d2cb76d450575b70 | Ruby | nathikazad/channel26 | /app/controllers/application_controller.rb | UTF-8 | 10,060 | 2.578125 | 3 | [] | no_license | class ApplicationController < ActionController::Base
protect_from_forgery
@array=Array.new
@i=0
def generate_response(msg,student,twilio)
#authenticate
@array=(msg.downcase.split /[ _,-.''!?]|(\d+)/)
garbage=delete_useless()
if student.nil?
return "Sorry, I can't find you"
end
... | true |
0219afe75aa4780dcaa91deac9889f6c9800cae0 | Ruby | ender672/tiedye | /test/transform/test_fit.rb | UTF-8 | 681 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'helper'
module TieDye
describe "Fit" do
before do
path = File.expand_path("../../samples/wagon.jpg", __FILE__)
@image = Image.read path
end
it "grows an image into a box that is larger than it is" do
fit = @image.fit 800, 800
f = fit.run
assert_equal 800, f.x_size
... | true |
89acb3a54fe07f57ed34980128e1214d63dc828d | Ruby | ramirezpulidojavier/PDOO | /PRACTICAS/CAMBIAR_RUBY/RUBY2/Civitas/lib/dado.rb | UTF-8 | 1,037 | 3.140625 | 3 | [] | no_license | require "singleton"
module Civitas
class Dado
include Singleton
@@SalidaCarcel = 5
def initialize()
@random = Random.new
@ultimo_resultado = 0
@debug = true
end
def get_instance
return @instance
end
def tirar
if (@debug == false)
@random = r... | true |
65172b83e0cc0bcbc82b07323eb89446d1d05176 | Ruby | ryandhaase/The-Greasy-Spoon | /db/seeds.rb | UTF-8 | 577 | 2.515625 | 3 | [] | no_license | require 'faker'
# sample_image = Restaurant.find(2)
#
# 10.times do
# Restaurant.create!(
# name: Faker::Company.name,
# address: "#{Faker::Address.street_address}, #{Faker::Address.city}, #{Faker::Address.state_abbr} #{Faker::Number.number(5)}",
# phone: '555-555-5555',
# website: Faker::Internet.ur... | true |
cc696b59716d12e2d84f549c7fe38a6aa2edb54a | Ruby | pivotalexperimental/screw-unit-server | /vendor/js-test-core/vendor/lucky-luciano/spec/lucky_luciano/resource_spec.rb | UTF-8 | 9,746 | 2.5625 | 3 | [
"MIT"
] | permissive | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
module LuckyLuciano
module ResourceSpec
class Root < Resource
map "/"
end
class ResourceFixture < Resource
map "/foobar"
end
class ResourceFixtureWithSubPaths < Resource
map "/foobar/"
get "/baz" do
... | true |
de355eab7b417d28832f36eb07a1bf86adf38a97 | Ruby | cheljoh/feline_friends-y | /spec/spec_helper.rb | UTF-8 | 4,417 | 2.53125 | 3 | [] | no_license | module SpecHelpers
def create_integration
user = create_users[:user1]
order = create_orders[:order2]
cat = Cat.create(
name: "Chica",
age: 2,
description: "Actually a dog",
image: image_path,
price: 2000,
category_id: categories[0].id,
status: "inactive")
cat2... | true |
baab253ea9be2ce29cdf27d4f072878c796654ed | Ruby | kiahjade/makers-bnb | /spec/units/calendar_spec.rb | UTF-8 | 2,008 | 2.6875 | 3 | [] | no_license | require 'calendar'
require 'reset_test_database'
describe Calendar do
describe '#initialize' do
it 'starts with a start day of 1' do
PG.connect(dbname: 'makersbnb_test')
calendar = Calendar.new
expect(calendar.start_day).to eq 1
end
it 'starts with a end day of 3' do
PG.connect... | true |
9a872dcbfdaeec1b215849e75f311d9cfed9b814 | Ruby | shadowbq/low-fi | /group/group_put | UTF-8 | 2,363 | 2.703125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
GROUP_PUT = 1.0
require 'optparse'
require 'inifile'
@sensors = []
@non_sensors = []
myini = IniFile.load("#{Dir.home}/.group.ini")
myini.each do |s,p,v|
if s == 'sensors'
@sensors << p
else
@non_sensors << p
end
end
@servers = @sensors + @non_sensors
@servers = @servers.sort.... | true |
58a3b5ba03bfacd473a70a2fb79c8923dde99606 | Ruby | vonwenm/nlpltc | /nlpltc | UTF-8 | 1,943 | 3.171875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby -w
# Generate a nice-looking printed LibraryThing catalogue
#
# William Denton <wtd@pobox.com>
require 'csv'
require 'erb'
require 'rubygems'
require 'htmlentities'
require 'json'
csv = ARGV[0]
if csv.nil?
puts "Please specify a LibraryThing CSV export file"
exit
end
tex_template = "template.te... | true |
aa14120e3ef937e61fec6ea801a6de53100aac89 | Ruby | id774/scripts | /now.rb | UTF-8 | 510 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env ruby
#
# == Synopsis
#
# Display the current date and time.
#
# == Usage
#
# now [ -h | --help ] [ -f | --fmt fmtstring ]
#
# == Author
#
# id774
#
# == Copyright
#
# Copyright (c) id774 <idnanashi@gmail.com>
# Licensed under the same terms as Ruby.
#
require 'optparse'
require 'rdoc/usage'
fmt = "%Y/%... | true |
ddd7112262f51baac48d667d92de94d4d9fa724c | Ruby | chancancode/mruby-canada | /test/test_canada.rb | UTF-8 | 1,188 | 3.15625 | 3 | [
"MIT"
] | permissive | assert('dispatch eh? method to existing ? method') do
assert_true [].empty_eh?
assert_false [1,2,3].empty_eh?
end
assert('dispatch eh? methods to non-existing ? method') do
assert_raise(NoMethodError) do
[].not_there_eh?
end
end
assert('respond_to_eh?') do
yes = [:empty?, :empty_eh?, :respond_to?, :resp... | true |
39b7e1e4beaac20c81a77be37d79bedb0d00aed9 | Ruby | Jhowden/chess | /lib/user_commands.rb | UTF-8 | 1,868 | 3.375 | 3 | [] | no_license | class UserCommands
VALID_USER_MOVE_INPUT = /\A[a-h]{1}[1-8]{1}\s{1}[a-h]{1}[1-8]{1}\z/
VALID_QUEENSIDE_CASTLING_INPUT = /\A0-0-0\z/
VALID_KINGSIDE_CASTLING_INPUT = /\A0-0\z/
VALID_EN_PASSANT_EXPRESSION = /\A[a-h]{1}[1-8]{1}\s?[a-h]{1}[1-8]{1}\s?e.p.\z/
QUEEN_REPLACEMENT = /\AQueen\z/
KNIGHT_REPLACEMENT ... | true |
6c40326d7d49593138ef882d0d1ed7e27a5d587e | Ruby | matchbookmac/save_princess | /spec/character_spec.rb | UTF-8 | 478 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'character'
require 'board'
require 'rspec'
describe 'Character' do
before :each do
reader, writer = IO.pipe
writer.puts '3'
writer.puts Array.grid 3
board = Board.new reader
@character = board.mario
end
describe '.location' do
it 'knows its location on the board' do
expect... | true |
c72d5e892fbb55ee459588d37cce5e89330ce3dd | Ruby | RSijelmass/stringCalculator | /lib/string_calculator.rb | UTF-8 | 407 | 3.703125 | 4 | [] | no_license | class StringCalculator
def add(string)
delimiter = find_delimiter(string)
split_string = split_by_delimiter(string, delimiter)
split_string.inject(0) { |sum, char| sum + char.to_i }
end
def find_delimiter(string)
string[0..1] == '//' ? (return string[2]) : (return ',')
end
def split_by_delimiter(string... | true |
39b809c905021375a16f2acddc1b90568e59b447 | Ruby | dbaynes/RubyFall2013 | /week7/exercises/features/converter_steps.rb | UTF-8 | 1,461 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | Given(/^I have entered (\d+) into the converter$/) do |arg1|
#pending # express the regexp above with the code you wish you had
@converter = Converter.new(arg1)
end
Given(/^I set the type to Fahrenheit$/) do
#pending # express the regexp above with the code you wish you had
@converter.type = "Celcius"
end
Whe... | true |
c4cb8284d8ca38eabf48d2ba1396a912e89e1199 | Ruby | KevinTriplett/accounting_101 | /script/migrator.rb | UTF-8 | 2,884 | 2.9375 | 3 | [] | no_license | #!/usr/bin/env ruby
# Simple migration navigator for terminal.
#
# Install
# 1) Throw this code into script/migrator
# 2) chmod +x script/migrator
#
# Use
# script/migrator => show 10 latest migrations, choose one
# script/migrator 15 => show 15 latest migrations
# script/migrator -5 =>... | true |
98ac6910250705bffb32c0cca84c0eec08afe07f | Ruby | madhurinp3/inmarTests | /formfilling.rb | UTF-8 | 1,050 | 2.65625 | 3 | [] | no_license | #9. Write a Selenium script that fills the form www.practiceselenium.com/practice-form.html and submits the page. After submitting , verify that the page navigates to home page
require 'rubygems'
require 'watir'
require 'rspec'
@browser=Watir::Browser.new :chrome
@browser.window.maximize
@browser.goto "http://www.pra... | true |
adcd2670f0bbda378338b8473e7d412228cd4711 | Ruby | kaist-plrg/jstar | /tests/compile/basic/recent/MemberExpression[2,0].Contains.spec | UTF-8 | 103 | 2.546875 | 3 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | 1. If |MemberExpression| Contains _symbol_ is *true*, return *true*.
1. Return *false*. | true |
f75e65ab035a2f3ce0d6e5b9a311a37fceb5a4aa | Ruby | jmstacey/jprime | /legacy/jprime_client_worker_miller_rabin_optimized.rb | UTF-8 | 2,609 | 2.921875 | 3 | [] | no_license | # This second jprime worker implementation.
#
# Author:: Jon Stacey (mailto:jon@jonsview.com)
# Copyright:: Copyright (c) 2010 Jon Stacey
# License:: Distributes under the same terms as Ruby
require 'drb/drb'
require 'rinda/ring'
require 'rinda/tuplespace'
DRb.start_service
ts = Rinda::RingFinger.primary
# Not... | true |
1b59c38041862cd8e6c39ddf6b2c080d50fce46c | Ruby | nami/chat-rails-redux | /db/seeds.rb | UTF-8 | 2,299 | 2.625 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
d9fce9b72ba59071d291257b4b23e99bf5bf4511 | Ruby | lucanioi/exercism-ruby | /alphametics/alphametics/constraints/double_operand.rb | UTF-8 | 967 | 2.875 | 3 | [] | no_license | require_relative 'constraint'
module Alphametics
module Constraints
class DoubleOperand < Constraint
private
def find_negative_constraints
super.then(&method(:add_additive_id))
end
def add_additive_id(mapping)
mapping.dup.tap do |mapping|
(0...min_term_length).... | true |
e88c0155444c2e84e20d4994d5cab5963a52a335 | Ruby | soulnafein/code-katas | /ruby/word_wrap/lib/word_wrapper.rb | UTF-8 | 769 | 3.5 | 4 | [] | no_license | class WordWrapper
def initialize(max_width)
@max_width = max_width
end
def wrap(text)
return text if last_line?(text)
this_line, rest = split_text(text)
this_line + "\n" + rest
end
private
def wrap_point(current_line)
separators = [" ", "!", "?", ",", ";", "."]
separator_pos = sepa... | true |
f4bb5a1e93e6fab33ebd5d7dbf6dda3b113d9431 | Ruby | CMilligan26/project_record_shop_inventory | /record_shop_inventory/specs/genre_categorization_spec.rb | UTF-8 | 701 | 2.5625 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative('../models/genre_categorization')
class GenreCategorizationTest < MiniTest::Test
def setup
@genre_categorization = GenreCategorization.new({'id' => '1', 'record_id' => '2', 'genre_id' => '3'})
end
def test_genre_categorization_exists
... | true |
649cc863a93352d58666d5d9ff221ad6a30d74b0 | Ruby | zachauten/bump | /formula.rb | UTF-8 | 727 | 3.296875 | 3 | [] | no_license | class Formula
attr_accessor :name
attr_accessor :current_version
attr_accessor :latest_version
attr_accessor :guessed
#TODO: Maybe when one version has a decimal and the other doesn't, invalidate the formula?
def initialize(name, current_version, latest_version, guessed)
@name = name
... | true |
f3c34778fec19ec8a0532e7dc757aebcfcc2a190 | Ruby | felipegruoso/sage_one | /lib/parsers/you_do_invoice.rb | UTF-8 | 1,418 | 2.953125 | 3 | [] | no_license | # encoding: utf-8
module Parsers
class YouDoInvoice < Parsers::BaseParser
PRODUCT = "PRODUTO"
PRODUCT_IDENTIFIER = "I"
#
# Parses the file content into an array of products.
#
# @return [Array] a list containing all products to be imported.
# @raise [TypeError] ... | true |
0184bb8020cf399b10dda1dc242e0405852a2b82 | Ruby | jpgazmuri/Syllabus | /Ayudantías/1. Ruby/01_io.rb | UTF-8 | 253 | 3.9375 | 4 | [] | no_license | # Get user input
data = gets.chomp # gets = input (leaves the "\n" character), chomp = strip
# Print user input previously recieved
puts data
# Print user input without the "/n" character
print data
print ", esto se imprime en la misma linea"
p data | true |
bca474917b49a5f03f14ba152f19505084670003 | Ruby | RomainSai/CSV_scrapper | /app.rb | UTF-8 | 469 | 2.75 | 3 | [] | no_license | load 'lib/scrapper.rb'
require "csv"
def create_new_csv
CSV.open("db/annuaire.csv", "wb") do |csv|
csv << ["city", "email"]
end
return 0
end
def add_infos_to_csv
list = get_the_email_of_a_townhal_from_its_webpage(get_all_the_urls_of_val_doise_townhalls)
list.each do |hash|
CSV.open("db/annuaire.csv"... | true |
02de3faed35f6afc05d9e17ac9121055f087798c | Ruby | Mahaswami/stupidedi | /lib/stupidedi/versions/functional_groups/004010/element_types/fixnum_val.rb | UTF-8 | 9,558 | 2.9375 | 3 | [] | no_license | module Stupidedi
module Versions
module FunctionalGroups
module FortyTen
module ElementTypes
class Nn < SimpleElementDef
# @return [Integer]
attr_reader :precision
def initialize(id, name, min_length, max_length, precision, description = nil, parent =... | true |
ce674529562ef040535ae95c7819bfb6eb07d67d | Ruby | livmaina/ruby_oct_2018 | /evelyn_chavez/ruby_exercises/ruby_puzzles.rb | UTF-8 | 2,312 | 4.65625 | 5 | [] | no_license | # Create an array with the following values: 3,5,1,2,7,9,8,13,25,32. Print the sum of all numbers in the array. Also have the function return an array that only include numbers that are greater than 10 (e.g. when you pass the array above, it should return an array with the values of 13,25,32 - hint: use reject or find_... | true |
b573cba6c93f713eb21693624b0b01331b91b202 | Ruby | satbirdd/PianoServer | /lib/accepting.rb | UTF-8 | 716 | 2.796875 | 3 | [] | no_license | module Accepting
# handshank = Accepting::HandShank.new(room.acceptings)
# handshank.accepting(current_user)
# handshank.is_single?
#
# handshank.is_
#
class HandShank
def initialize(record, key)
@target = record
if record.send(key).nil?
record.send("#{key}=".to_sym, {})
... | true |
094097bb55af6822a96420ae6740be79673d104e | Ruby | timpalpant/bioruby-genomic-file | /spec/sparse_array_spec.rb | UTF-8 | 8,989 | 2.828125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #
# compact_array_spec.rb
# bioruby-genomic-file
#
# Created by Timothy Palpant on 6/25/11.
# Copyright 2011 UNC. All rights reserved.
#
require 'spec_helper'
require 'sparse_array'
describe SparseArray do
context "without data" do
before do
@test = SparseArray.new
end
it "should have nil... | true |
3f7e8b70ac4afac124039a26d92a5cf4615fb188 | Ruby | crismali/magic_carpet | /app/helpers/magic_carpet/js_fixtures_helper.rb | UTF-8 | 2,686 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive | module MagicCarpet
module JsFixturesHelper
attr_accessor :models
NIL = "nil"
def hydrate(value)
if array?(value)
hydrate_array(value)
elsif date?(value)
hydrate_date(value)
elsif time?(value)
hydrate_time(value)
elsif datetime?(value)
hydrate_dateti... | true |
9de644c0672a45a5fb2bb5278f7c3c9e24192f17 | Ruby | pritckat/ruby-class-variables-and-class-methods-lab-v-000 | /lib/song.rb | UTF-8 | 845 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song
attr_accessor :name, :artist, :genre
@@count = 0
@@genres = []
@@artists = []
@@song_names = []
def initialize(name, artist, genre)
@name = name
@artist = artist
@genre = genre
@@count += 1
@@genres << genre
@@artists << artist
@@song_names << name
end
def self.... | true |
cfef48952a1ec0456e012a8617350b71c1cbd44d | Ruby | SeaRbSg/little-schemer | /sotoseattle/sandbox/mathless_calc/spec/mathless_calculator_spec.rb | UTF-8 | 1,071 | 2.921875 | 3 | [] | no_license | require 'spec_helper'
describe 'MathlessCalculator' do
let(:calc) { MathlessCalculator.new }
it { calc.compute('(2 + 2)').must_equal '4' }
it { calc.compute('(2 + (1 + 1))').must_equal '4' }
it { calc.compute('(((1 + 1) + (1 + 1)) + (1 + 1))').must_equal '6' }
it { calc.compute('(3 x 2)').must_equal '6' }
... | true |
a8bf57d822753e44b4ddb9fc7c567c921768811d | Ruby | gradyzhu/W2D3 | /TDD_testing/lib/w2d3_testing.rb | UTF-8 | 770 | 3.515625 | 4 | [] | no_license | class Array
def my_uniq
self.reduce([]) do |uniqs, el|
unless uniqs.include?(el)
uniqs.push(el)
else
uniqs
end
end
end
def two_sum
pairs = []
i = 0
while i < self.length - 1
j = i + 1
while j < self.length
pairs << [i ,j] if self[i] ... | true |
14e372d9a8593f333751828a820fe1d002ed406d | Ruby | morganp/s1-e2 | /example/example1.rb | UTF-8 | 802 | 2.75 | 3 | [] | no_license | # examples/example1.rb
require '../lib/git_badge'
# In this example Anne and Dave create some Repositories (no commits)
app = GitBadge::Core.new
anne = app.new_person("Anne")
dave = app.new_person("Dave")
anne.new_repository("RMU-entance-exam")
anne.new_repository("RMU-s1-e1")
anne.new_repository("RMU-s1-e2")
an... | true |
7dd2f6727358a83f72e8569e0afd6fa25b1e302f | Ruby | mmish321/typeSpeed | /main.rb | UTF-8 | 3,437 | 3.28125 | 3 | [] | no_license | require 'gosu'
require_relative "word"
require_relative "z_order"
require_relative "compound_word"
class GameWindow < Gosu::Window
WIDTH = 1200
HEIGHT= 500
def initialize
super WIDTH, HEIGHT
self.caption = "TYPESPEED"
@background_image = Gosu::Image.new("media/background.jpeg", :tileable => true)
... | true |
ac3ffa7343121d27cd642f8eb2b7ec6d1d442c23 | Ruby | magnet-inc/blue_print | /lib/blue_print/context.rb | UTF-8 | 1,560 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'active_support/inflector'
require 'blue_print'
require 'blue_print/active_if'
class BluePrint::Context
def self.resolve(name)
if name.respond_to?(:active?)
return name
else
name.to_s.classify.sub(/(Context)?$/, 'Context').safe_constantize
end
end
def self.active_ifs
@active_... | true |
2c26c42b86632254ae9b36fc8709417adf136ddf | Ruby | arfo90/game-of-life-Ruby | /lib/seeder.rb | UTF-8 | 487 | 2.890625 | 3 | [] | no_license | require_relative 'tools'
class Seeder
attr_accessor :land_grid
def initialize(land_grid)
raise ArgumentError, "Land Grid is not yet set. should pass 2d array" unless land_grid.is_a?(Array)
@land_grid = land_grid
end
def seed
seeded_world = @land_grid
tools = Tools.new()
@land_grid[0].size.times... | true |
20779b940493ae2daf3138a0fd1017156475e339 | Ruby | houweifeng/itunes_receipt_encoder | /lib/itunes_receipt_encoder/in_app.rb | UTF-8 | 2,884 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'itunes_receipt_encoder/utils'
require 'itunes_receipt_encoder/asn1'
##
# ItunesReceiptEncoder
module ItunesReceiptEncoder
##
# ItunesReceiptEncoder::InApp
class InApp
include Utils
attr_accessor :quantity, :product_id, :transaction_id,
:original_transaction_id, :web_order_line... | true |
6a2a8a4cad048b73df8c043e6006d4293336d58f | Ruby | gropax/gramz | /spec/gramz/cfg/grammar_spec.rb | UTF-8 | 1,661 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
module Gramz::CFG
describe Grammar do
include DSL
let(:gram) {
grammar(:S) {
rule "S -> SN V"
rule "SN -> 'Jean'"
rule "V -> dort"
}
}
describe "#non_terms" do
it "should return the non terminal symbols used in rules" do
ex... | true |
6ea196f6d5c5e1782b42b665a71bcf8b95d78600 | Ruby | kinjalchotaliya/RubyPractice | /6thFeb/customex.rb | UTF-8 | 316 | 3.65625 | 4 | [] | no_license |
#custom Exception
puts "enter number1"
a = gets.chomp.to_i
puts "enter number2"
b = gets.chomp.to_i
class MyException < StandardError
def initialize(msg)
super
end
end
begin
raise MyException.new("number2 can't be zero") if b == 0
rescue => ex
puts ex
else
div = a / b
puts "division = #{div}"
end
| true |
68c0ee01ace79f75d9bf7ea4b6df7cacfe0ccef1 | Ruby | AdamPrusse/Coding-Exercises | /SmallOrder.rb | UTF-8 | 181 | 3.5625 | 4 | [] | no_license | puts "what would you like to order?"
answer = gets.chomp
p "You ordered #{answer}"
puts "what else would you like"
answer2 = gets.chomp
p "You ordered #{answer} and #{answer2}" | true |
df94be294095152f1fdf7be224f0d25df936441c | Ruby | melliemello/Rails-Girls | /01-Simple-Idea-App-wSinatra/models/model.rb | UTF-8 | 1,185 | 2.640625 | 3 | [] | no_license |
class Model
attr_reader :id
def initialize(attributes = {}, id = nil)
self.attributes = attributes
@id = id
end
def self.db
Database.new("./database/#{name.downcase}s.yaml")
end
def self.all
db.all.map do |id, attributes|
new(attributes, id)
end
end
def self.find(id)
... | true |
31529cf3f72b44f81cbe8a227d97d23ad492e0bb | Ruby | ChuckBTaylor/triangle-classification-web-082817 | /lib/triangle.rb | UTF-8 | 736 | 3.578125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Triangle
attr_reader :sides
def initialize(side1, side2, side3)
@sides = [side1, side2, side3]
end
def valid?
sorted = self.sides.sort
if sorted.any? {|side| side <= 0}
false
else
sorted[0] + sorted [1] <= sorted[2] ? false : true
end
end
def check_ty... | true |
e95ba7746a0fc4edee4f8c5896a98d870bd929df | Ruby | smhaggerty/CodeQuizzes_solutions | /ruby/beginner/quiz_3.rb | UTF-8 | 3,453 | 4.65625 | 5 | [] | no_license | # What does this code print?
# x = "HELLO"
# if true
# puts x
# end
"HELLO"
# What does this code print?
# if true
# y = "Baaaaah"
# end
# puts y
"Baaaaah"
# Identify the elements of this code:
# def my_name()
# return("Zoo Lander")
# end
# "def my_name()" is the function declation statement, whi... | true |
8c7a159b206b550d09e325432ed705a48e69a8b7 | Ruby | coremessage/evil_events | /spec/support/spec_support/fake_data_generator.rb | UTF-8 | 2,402 | 2.71875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module SpecSupport::FakeDataGenerator
module_function
BOOL_VARIANTS = [true, false].freeze
INT_RANGE = (0..100)
FLOAT_RANGE = (0.0..100.0)
STR_LENGTH = 10
STR_LETTERS = (('a'..'z').to_a | ('A'..'Z').to_a).freeze
FACTORY_METHODS = %i[
gen_int
ge... | true |
89c88b72119bb612db5cd6277ba5b8bf3a9504d9 | Ruby | joegnelson/swagger-codegen | /samples/client/petstore/ruby/lib/pet_api.rb | UTF-8 | 11,368 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | require "uri"
class PetApi
basePath = "http://petstore.swagger.io/v2"
# apiInvoker = APIInvoker
# Update an existing pet
#
# @param body Pet object that needs to be added to the store
# @return void
def self.updatePet (body, opts={})
query_param_keys = []
headerParams = {}
# set... | true |
d632782e2f6373a6f6ba9f1f079396ddf8b58c64 | Ruby | codewithirene567/prime-ruby-onl01-seng-ft-050420 | /prime.rb | UTF-8 | 523 | 3.625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | binding"pry"
def prime?(integer)
lowest_prime_number = 2
if integer > 1
range = (lowest_prime_number...integer-1).to_a
range.none? {|testing| integer % testing == 0 }
else
false
end
end
#if Prime.prime?(@nth_value)
#puts ("#{@nth_value} is prime")
#else
# puts ("This is not a prime number.")
#... | true |
01acbfb3a99d80cd63feeb402311389db20218f9 | Ruby | BettinaBF/rails-yelp-mvp | /db/seeds.rb | UTF-8 | 300 | 2.859375 | 3 | [] | no_license | require 'faker'
puts 'Creating 5 fake restaurants...'
5.times do
restaurant = Restaurant.create!(
name: "\"The #{Faker::Hipster.word}\"",
address: Faker::Address.street_address,
category: ['chinese', 'italian', 'japanese', 'french', 'belgian'].sample(1)[0]
)
end
puts 'Finished!'
| true |
008d16eaa37deb0c5686354d086a4db9114a4422 | Ruby | mark-rushakoff/cf-interface | /spec/component_announcement_message_spec.rb | UTF-8 | 2,980 | 2.53125 | 3 | [
"MIT"
] | permissive | require "spec_helper"
require "cf_message_bus/mock_message_bus"
require "cf/interface"
require "cf/interface/component_announcement_message"
describe CF::Interface::ComponentAnnouncementMessage do
subject(:message) do
described_class.new(
component_type: "component_type",
index: 99,
host: "192.... | true |
b0a707a7a33761d2304ab2fce6c78132b6fd33c0 | Ruby | stormpath/stormpath-rails | /lib/stormpath/rails/facebook_auth_code_exchange.rb | UTF-8 | 1,191 | 2.515625 | 3 | [] | no_license | module Stormpath
module Rails
class FacebookAuthCodeExchange
FACEBOOK_EXCHANGE_URL = URI('https://graph.facebook.com/v2.7/oauth/access_token')
attr_reader :root_url, :code
def initialize(root_url, code)
raise(NoFacebookAuthorizationError) if code.nil?
@root_url = root_url
... | true |
6788b0e7fb5414817468603d097bc2ce9beb4caf | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/2f131292c4cb4ff6b7f69e816df1c05b.rb | UTF-8 | 295 | 3.375 | 3 | [] | no_license | class Hamming
def Hamming.compute(strand_x, strand_y)
[strand_x.size,strand_y.size].min.times.map{ |c|
Hamming.diff(strand_x[c], strand_y[c])
}.reduce(0,:+)
end
private
def Hamming.diff(char_x, char_y)
if(char_x != char_y)
1
else
0
end
end
end
| true |
6028e38c06d3c46e612ebb286c421a0004ede566 | Ruby | harhogefoo/AtCoder_Ruby | /ABC033/C.rb | UTF-8 | 133 | 2.640625 | 3 | [] | no_license | n = gets.chomp.split("+")
count = 0
n.each do |input|
next if input == "0"
next if eval(input) == 0
count += 1
end
puts count
| true |
ad57f9b759bf79dae7c569bf30ea0dfb1c3f452e | Ruby | barnzdan/ruby | /example3.rb | UTF-8 | 218 | 3.765625 | 4 | [] | no_license | #!/usr/bin/env ruby
class Square
def initialize(side_length)
@side_length = side_length
end
def area
@side_length * @side_length
end
end
a = Square.new(10)
b = Square.new(5)
puts a.area
puts b.area
| true |
3aad615ce8d5cc50c000055cb5f61ac31ef93072 | Ruby | SimonDein/launch | /course_101/exercises/easy_7/combine_two_lists.rb | UTF-8 | 1,086 | 4.53125 | 5 | [] | no_license | # Write a method that combines two Arrays passed in as arguments,
# and returns a new Array that contains all elements from both Array arguments, with the elements taken in alternation.
# You may assume that both input Arrays are non-empty, and that they have the same number of elements.
# solution 1
def interleave(ar... | true |
87ffb5784fbc39e3ac5f4220d76a464b0bf6f507 | Ruby | cjferm16/RB101 | /Exercises/Easy 9/grocery_list.rb | UTF-8 | 260 | 3.828125 | 4 | [] | no_license | def buy_fruit(array)
newarr = []
array.map do |array|
array[1].times do
newarr << array[0]
end
end
p newarr
end
p buy_fruit([["apples", 3], ["orange", 1], ["bananas", 2]]) ==
["apples", "apples", "apples", "orange", "bananas","bananas"] | true |
9fc23e505974eb620020ea879388530c59e1b0d5 | Ruby | TimothyFell/enigma | /lib/date_offsets.rb | UTF-8 | 437 | 3.609375 | 4 | [] | no_license | ## date_offsets.rb
require 'pry'
require 'date'
class DateOffsets
attr_reader :date
def initialize(date)
@date = date
end
# Input: date object
# Output: array of 4 date-based offset integers
def convert_date
(@date.strftime('%d') + @date.strftime('%m') + @date.strftime('%y')).to_i
end
def ... | true |
5ffe41684a5d090003b99cff9762255d6630914e | Ruby | Shinya-Org-SS/localmap | /db/seeds.rb | UTF-8 | 1,153 | 2.625 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
d2b9a1c580cde1c7e752c9ad7d61436d32c6700b | Ruby | AntonioJacksonII/futbol | /test/season_stats_test.rb | UTF-8 | 1,906 | 2.84375 | 3 | [] | no_license | require_relative 'test_helper'
class SeasonStatsTest < Minitest::Test
def setup
@season_stats = SeasonStats.new('./data/teams.csv', './test/fixtures/truncated_game_stats2.csv')
end
def test_initialization
assert_instance_of SeasonStats, @season_stats
end
def test_season_stat_percentage
assert_e... | true |
f1de5a4d95c1e1296b7bdc2cdb00d980da030f2f | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/difference-of-squares/b04e27c093db47689ecdaec1b665237e.rb | UTF-8 | 260 | 3.640625 | 4 | [] | no_license | class Squares
def initialize value
@value = value
end
def square_of_sums
(1..@value).inject(:+)**2
end
def sum_of_squares
(1..@value).collect { |v| v**2 }.inject(:+)
end
def difference
square_of_sums - sum_of_squares
end
end
| true |
0abe7c8998f513c12fdbc9e2ba322e3402b7afbc | Ruby | jennianelson/pokemon-scraper-v-000 | /lib/pokemon.rb | UTF-8 | 731 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Pokemon
attr_accessor :name, :type, :db, :id, :hp
def initialize (name:, type:, db:, id:, hp: nil)
@name = name
@type = type
@db = db
@id = id
@hp = hp
end
def self.save(name, type, db)
sql = <<-SQL
INSERT INTO pokemon(name, type)
VALUES (?, ?)
SQL
db.execute(... | true |
d09908bf423bf57a5b2c28f856ea731357ab35ad | Ruby | CedrickFlocon/AdventOfCode | /2015/day_07/operation.rb | UTF-8 | 417 | 3.578125 | 4 | [
"WTFPL"
] | permissive | class Operation
def initialize(action, values)
@values = values
@action = action
end
def compute
case @action
when 'LSHIFT'
@values[0] << @values[1]
when 'RSHIFT'
@values[0] >> @values[1]
when 'AND'
@values[0] & @values[1]
when 'OR'
@values[0] ... | true |
2fd70955a1aaebe4588453e6455dd72ca8574ca4 | Ruby | ESTCOSMO/mitsumottaro | /app/models/dst_item_form.rb | UTF-8 | 578 | 2.546875 | 3 | [] | no_license | class DstItemForm
include ActiveModel::Model
attr_accessor :name, :category_id, :sub_category_id, :type
validates :name, presence: true
validates :type, presence: true
with_options if: :sub_category? do |sub_category|
sub_category.validates :category_id, presence: true
end
with_options if: :st... | true |
0398b27024d70e8c9e1b313dc57a59afd9f84fa9 | Ruby | knollt/square_array-v-000 | /square_array.rb | UTF-8 | 290 | 3.578125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
new_array = []
array.each {|arr|
new_array.push (arr * arr)}
return new_array
end
# OPTION 2
# def square_array(array)
# squared_array = []
# array.each do |num|
# square = num ** 2
# squared_array << square
# end
# squared_array
# end
| true |
c5e3755784b91dcfb331763b6a4f832c9640d537 | Ruby | infrablocks/ruby_terraform | /spec/ruby_terraform/models/list_spec.rb | UTF-8 | 11,114 | 2.703125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'spec_helper'
# rubocop:disable Layout/LineContinuationLeadingSpace
describe RubyTerraform::Models::List do
describe '#value' do
it 'returns the underlying array with values still boxed' do
value = [V.known(1), V.known(2), V.known(3)]
list = described_class.new(... | true |
7f2b3f0e860b92375e78f029c7b64b1d28b8f10d | Ruby | omkz/algorithms-in-ruby | /lib/arrays_and_strings/dutch_national_flag_test.rb | UTF-8 | 365 | 2.578125 | 3 | [] | no_license | require_relative "../../test_helper"
require_relative "dutch_national_flag"
describe DutchNationalFlag do
describe "regular cases" do
it "should sort the array properly" do
expected = [3, 3, 2, 4, 4, 4, 4, 6, 8, 6, 5]
actual = DutchNationalFlag.run([3, 5, 2, 6, 8, 4, 4, 6, 4, 4, 3], 5)
expect(a... | true |
75a3861c9c860faf8910a22c4e8e69e03a52885b | Ruby | d0nn13/VolcanoFTP | /lib/volcano_ftp/command/type.rb | UTF-8 | 479 | 2.609375 | 3 | [] | no_license | # ==== TYPE ====
# Sets the transfer mode
class FTPCommandType < FTPCommand
def initialize(arg)
super()
@code = 'TYPE'
@args << arg unless arg.nil?
end
def do(client)
begin
session = client.session
raise FTP530 unless session.logged?
session.set_mode(@args[0]) unless @args.lengt... | true |
dd93562e80b43fe7cd1435120bdd7396f9e2894d | Ruby | xuwupeng2000/rent | /spec/models/rent_history_spec.rb | UTF-8 | 1,179 | 2.53125 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../spec_helper'
describe RentRecord do
def app
RentController
end
describe '#process_dataset' do
# We know it is valid so there is no point to test this
context 'CSV is invalid' do
it "should raise error" do
end
end
context 'valid CSV' do
... | true |
756f021f1e4f78b96f459063ff593d17218d2e26 | Ruby | babyshoes/8th-light-tic-tac-toe | /lib/board.rb | UTF-8 | 2,213 | 3.53125 | 4 | [] | no_license | class Board
attr_reader :dimension
attr_accessor :squares, :turn_num, :copy, :winner, :game
def initialize(dimension = 3, squares = [], turn_num = 0)
@dimension = dimension
@squares = squares
@turn_num = turn_num
@dimension = dimension
populate_board if squares.all? {|row| row.empty?}
end
... | true |
fee7ebda6c43a9b71543f2b2a80ba32c878670a0 | Ruby | redfiche/WebKeno | /KenoRunner.rb | UTF-8 | 1,063 | 2.84375 | 3 | [] | no_license | #!/usr/bin/env ruby
require './Keno.rb'
require './KenoSerializer.rb'
first_race = ARGV[0].to_i
race_interval = ARGV[1].to_i
pick_interval = ARGV[2].to_i
puts "#{DateTime.now} starting KenoRunner"
logger = Logger.new 'keno.log'
keno = Keno.new
serializer = KenoSerializer.new
serializer.del_keno
next_race_time = Time... | true |
565c6b9139108402db817bf6ed40b596cc19e581 | Ruby | mdub/trunction | /spec/trunction_spec.rb | UTF-8 | 1,487 | 2.828125 | 3 | [] | no_license | # encoding: utf-8
require 'trunction'
describe Trunction do
let(:full_text) { Nokogiri::HTML::DocumentFragment.parse(input).text }
let(:total_words) { full_text.split.length }
let(:ellipsis) { "…" }
include Trunction
let(:result) do
truncate_html(input, max_words).gsub("\n", '')
end
descri... | true |
130e04b039bf3234721a93e35437d793abad5398 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/combine_anagrams_latest/15919.rb | UTF-8 | 248 | 3.125 | 3 | [] | no_license | def combine_anagrams(words)
res={}
words.each do |word|
key=word.split('').sort.join
res[key] ||= []
res[key] << word
end
p res.values
end
combine_anagrams(['cars', 'for', 'potatoes', 'racs', 'four','scar', 'creams', 'scream']) | true |
3f449af40fa7c01ac97b02d482db43bf7d827dcb | Ruby | bantu4fun/nbp_rates | /lib/tasks/get_nbp_rates.rake | UTF-8 | 559 | 2.515625 | 3 | [] | no_license | require 'open-uri'
namespace :nbp do
desc "Get current year NBP exchange rates"
task :get_nbp_rates => :environment do
open("http://www.nbp.pl/kursy/xml/dir.txt", "r:utf-8") do |f|
files = f.readlines.map { |line| line.strip! }.select { |line| line =~ /^c[0-9]{3}z[0-9]{6}$/ }
files.each do |filen... | true |
05d33f040e51041ce0911deaab5fa162afaa70c3 | Ruby | Noirbot/advent | /2017/d13/sol.rb | UTF-8 | 320 | 3.109375 | 3 | [] | no_license | input = File.read("input.txt").split("\n").map { |line| line.split(': ').map(&:to_i) }
delay = 0
loop do
caught = false
input.each do |gate|
layer, range = gate
if (layer + delay) % ((range * 2) - 2) == 0
caught = true
break
end
end
break if !caught
delay = delay + 1
end
puts delay | true |
c6852994d4283dfb920fa98c5ae0666793e96510 | Ruby | fidothe/box_dividers | /lib/box_dividers/pdf.rb | UTF-8 | 666 | 2.703125 | 3 | [
"MIT"
] | permissive | require_relative 'transformations'
require 'prawn'
module BoxDividers
class Pdf
include Prawn::View
attr_reader :bounding_box
def initialize(bounding_box)
@bounding_box = bounding_box
end
def draw_path(path)
points = path.points.dup
first_point = points.shift
close_and_... | true |
d73b6fe9adb2e44ba0c56e1a303ddb671b64aa93 | Ruby | hack4reno2011/Reno-Collective | /app.rb | UTF-8 | 1,728 | 2.515625 | 3 | [] | no_license | require 'rubygems'
require 'sinatra'
require 'tropo-webapi-ruby'
require 'httparty'
require 'logger'
require 'net/http'
require 'uri'
use Rack::Session::Pool
get '/' do
"Hello World"
end
post '/start.json' do
tropo_session = Tropo::Generator.parse request.env["rack.input"].read
session[:callid] = tropo_se... | true |
c7a2dc9543a47ce0084899158cf73ebdc578786e | Ruby | howardbdev/regex-lab-v-000 | /lib/regex_lab.rb | UTF-8 | 411 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def starts_with_a_vowel?(word)
word.scan(/\b[aeiouAEIOU]\w*/) != []
end
def words_starting_with_un_and_ending_with_ing(text)
text.scan(/\bun\w*ing\b/)
end
def words_five_letters_long(text)
text.scan(/\b\w{5}\b/)
end
def first_word_capitalized_and_ends_with_punctuation?(text)
text.scan(/\A[A-Z].*[.,?!]\z/) !=... | true |
df9a6047e1422f2bead1747e02df568ab0d2b93e | Ruby | AllPurposeName/everyone_probably_calls_this_chatter | /app/services/new_message_service.rb | UTF-8 | 644 | 2.75 | 3 | [] | no_license | class NewMessageService
attr_reader :body, :chat_room, :filters, :user
def initialize(body:, user:, chat_room:, filters: default_filters)
@body = body
@chat_room = chat_room
@filters = filters
@user = user
end
def self.create!(body:, user:, chat_room:)
new(body: body, user: use... | true |
91c6c479a75eaf9d2b4358e77b41d0fd5c96a79d | Ruby | SS-X-Ray/Xchedule-API | /services/update_activity.rb | UTF-8 | 324 | 2.5625 | 3 | [] | no_license | # Service object to update activity information
class UpdateActivity
def self.call(update_data:)
old_record = Activity[update_data['activity_id']]
update_data.keys.each do |key|
if key != 'activity_id'
old_record.send("#{key}=", update_data[key])
old_record.save
end
end
end
... | true |
2c8b7eb618adf584b0367db705ed5898ac017145 | Ruby | StylesTrip/head-first-ruby | /get_number.rb | UTF-8 | 962 | 4.46875 | 4 | [] | no_license | # Get My Number Game
# Written by: me
puts "Welcome to 'Get My Number!'"
print "What's your name? "
input = gets
name = input.chomp
puts "Welcome, #{name}!"
#p input # same as puts input.inspect
# Store a random number for the player to guess
puts "I've got a random number between 1 and 100."
puts "Can you guess i... | true |
a55e6ecfdb3385ff83bf10296b7376e85164c79b | Ruby | isabellademetz/kwk-l1-ruby-object-attributes-lab-kwk-students-l1-la-070918 | /lib/dog.rb | UTF-8 | 276 | 3.390625 | 3 | [] | no_license | # dog.rb
class Dog
def initalize(name,breed)
@name = name
@breed = breed
end
def name
@name = "Fido"
end
def name=(new_name)
@name = new_name
end
def breed
@breed = "Beagle"
end
def breed=(new_breed)
@breed = new_breed
end
end
| true |
66a705dc8b868e7c5540cca54edc0071b718fa07 | Ruby | sjmckinney/gruyere-test-demo | /features/support/base_page.rb | UTF-8 | 2,236 | 3.015625 | 3 | [] | no_license | require_relative 'utilities'
include Utilities
class BasePage
def initialize(driver)
@driver = driver
end
def visit(url)
@driver.get(url)
end
def find(locator)
begin
@driver.find_element(locator)
rescue Exception => e
$LOG.info("Error has occurred in : #{__FILE__} @ lin... | true |
d16de3f927a7173eeb868f67ae76c27d562dc19a | Ruby | PizzaPowered/firering | /lib/firering/instantiator.rb | UTF-8 | 1,024 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Firering
module Instantiator
def instantiate(conn, data, base_key = nil, &callback)
instance = new
instance.connection = conn
attributes = data.is_a?(Hash) ? data : Yajl::Parser.parse(data, :symbolize_keys => true)
attributes = attributes[base_key] if base_key
attributes ||=... | true |
1fcd87d557f74547efddf6df97581b341513eadd | Ruby | chasenyc/bigO | /two_sum.rb | UTF-8 | 1,724 | 3.734375 | 4 | [] | no_license | def bad_two_sum?(arr, target_sum)
possibilites = []
(arr.length-1).times do |idx|
idy = 1 + idx
while idy < arr.length
possibilites << [arr[idx],arr[idy]]
idy += 1
end
end
possibilites.each do |pair|
return true if pair.first + pair.last == target_sum
end
false
end
arr = [0, 1,... | true |
4985abfafe3a8915a76b640afac9106424cd886a | Ruby | marinmari/Ruby_exo | /exo_09.rb | UTF-8 | 189 | 3.5625 | 4 | [] | no_license | puts "Quelle est ton année de naissance"
annee = gets.chomp.to_i
if annee < 2021
while annee <= 2021
puts "#{annee}"
annee += 1
end
else
puts "Impossible"
end
| true |
26f2bde28c6bce3dc3c186e0205a4e64864dd740 | Ruby | judesamp/simple_circle | /spec/app/entities/issue_spec.rb | UTF-8 | 1,826 | 2.640625 | 3 | [] | no_license | require_relative '../../spec_helper'
require_relative '../../../app/entities/issue'
require_relative '../../../app/entities/article'
require_relative '../../../app/entities/event'
require_relative '../../../app/entities/newsletter'
describe "Issue" do
let(:newsletter) {Newsletter.process({:title => "Original Newsle... | true |
54c9cfe8f56de3f35a8a7611873d2ec7417bcea2 | Ruby | Yamini-Gahlot/parrot-ruby-cb-gh-000 | /parrot.rb | UTF-8 | 126 | 3.234375 | 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(st = "Squawk!")
puts st
return st
end | true |
9e8ec43d9092548bd2cb7044c5add24a901976f9 | Ruby | lienne/BelleLearnsRuby | /loops_and_arrays.rb | UTF-8 | 1,389 | 4.625 | 5 | [] | no_license | the_count = [1, 2, 3, 4, 5]
fruits = ['apples', 'oranges', 'pears', 'apricots']
change = [1, 'pennies', 2, 'dimes', 3, 'quarters']
# this first kind of for-loop goes through a list
# in a more traditional style found in other languages
for number in the_count
puts "This is count #{number}"
end
# same as above, bu... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.