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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
6b8122f4471bee593e55af6324e647dd369a5276 | Ruby | kellyredding/test-belt | /lib/test_belt/callbacks/case.rb | UTF-8 | 2,628 | 2.84375 | 3 | [
"MIT"
] | permissive | module TestBelt::Callbacks
module Case
# Like their before/after brothers above, the _once callbacks run
# before/after tests respectively. The difference is that they only run
# once for the entire case. The before/setup callback will run before the
# first test for the class while the after/teard... | true |
b7c11248ecb04efb290fa7815f8c794686f4582a | Ruby | oscarjes/DuckSocial | /spec/models/user_spec.rb | UTF-8 | 1,771 | 2.59375 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
before do
@oscar = User.create(firstname: "Oscar", lastname: "Bob", email: "test@test.com", password: "test99")
@oscarred = User.create(firstname: "Oscarred", lastname: "Bob", email: "test@test2.com", password: "test99")
@yen = User.create(first... | true |
e2d49e9b1e7e82f50efbb17434c3c217bbbd8685 | Ruby | bertomartin/slimfit | /app/interfaces/building_interface.rb | UTF-8 | 831 | 2.515625 | 3 | [] | no_license | module Slimfit
module Interfaces
class BuildingInterface
attr_reader :target
def initialize(target = Slimfit::Models::Building)
@target = target
end
def build!(options)
@target.create!(options)
end
def build(options)
@target.create(options)
end... | true |
2d63f2ce6ba1a0acb1e4a6460820ff3a3cef6612 | Ruby | twarbelow/trip-weather | /app/facades/breweries_facade.rb | UTF-8 | 428 | 2.875 | 3 | [] | no_license | class BreweriesFacade
def self.breweries(location, quantity)
coords = LocationFacade.translate_to_coordinates(location)
forecast = WeatherService.get_forecast(coords[:lat], coords[:lng])
brew_response = BrewService.get_breweries(coords[:lat], coords[:lng], quantity)
breweries = brew_response.map do |... | true |
67eae602aefbd9466ee971043fe6eceb5c4f022c | Ruby | liaohui811/intellij_idea | /windows/plugins/ruby/rubystubs/rubystubs22/win32_ole_record.rb | UTF-8 | 8,098 | 3.203125 | 3 | [] | no_license | =begin
This is a machine generated stub using stdlib-doc for <b>class WIN32OLE_RECORD</b>
Sources used: ruby-2.2.10
Created by IntelliJ Ruby Stubs Generator.
=end
# <code>WIN32OLE_RECORD</code> objects represents VT_RECORD OLE variant.
# Win32OLE returns WIN32OLE_RECORD object if the result value of invoking
# OLE... | true |
521de703e68d9ba7bd4aabfc107b1f19c2a1831b | Ruby | MaxAlmeida/monsterhunt | /app/models/level_score.rb | UTF-8 | 350 | 2.578125 | 3 | [] | no_license | class LevelScore < ApplicationRecord
has_many :trophy
@@available_level_scores = self.all.to_a.map(&:serializable_hash)
def self.available_level_scores(category, score)
@@available_level_scores.select do |levelscore|
levelscore['category'] == category && levelscore['score'] == scor... | true |
386a4c3b5d89ab8c0964835850d82fee7e0b738e | Ruby | enjoy-self-inquiry/ruby_practice | /test/gate_test.rb | UTF-8 | 2,907 | 3.234375 | 3 | [] | no_license | require 'minitest/autorun'
require '../lib/gate'
require '../lib/ticket'
class GateTest < Minitest::Test
def setup
#setupとすることで、テストメソッドが実行前にこのメソッドが毎回呼ばれる。
@umeda = Gate.new(:umeda)
@juso = Gate.new(:juso)
@mikuni = Gate.new(:mikuni)
end
#ケース1「1区間・運賃ちょうど」
def test_umeda_to_juso
... | true |
e50112707d45794666359ae631738b5c15667159 | Ruby | blamb888/mimics-blackberry | /db/seeds.rb | UTF-8 | 2,050 | 2.546875 | 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 bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# ... | true |
0edb4c3ecde4a48c20e40525f7549cf477dcfe2b | Ruby | prakash-dubey/Training | /Ruby/ranger.rb | UTF-8 | 206 | 3.390625 | 3 | [] | no_license |
score = 65
result = case score
when 0..40 then "Fail"
when 41..60 then "Pass"
when 61..70 then "Pass with Merit"
when 71..100 then "Pass with Distinction"
else "Invalid score"
end
puts result | true |
d1f202b3ce37a696dfd3e3c7de6197ee68e62a2d | Ruby | WangHoong/weixin_rack_device | /lib/weixin/middleware.rb | UTF-8 | 2,067 | 2.546875 | 3 | [
"MIT"
] | permissive | # -*- encoding : utf-8 -*-
require 'digest/sha1'
module Weixin
class Middleware
POST_BODY = 'rack.input'.freeze
WEIXIN_MSG = 'weixin.msg'.freeze
WEIXIN_MSG_RAW = 'weixin.msg.raw'.freeze
def initialize(app, app_token, path)
@app = app
@app_token... | true |
6b46b2c89a5804223704510f33e031bf78b9d24c | Ruby | kguadron/reverse_sentence | /lib/reverse_sentence.rb | UTF-8 | 1,143 | 4.15625 | 4 | [] | no_license | # A method to reverse the words in a sentence, in place.
# Time complexity: O(n^2) where n is the length of my_sentence
# Space complexity: Constant or O(1) because we are not creating any new data
# structures and therefore not taking up more space in memory
def reverse_sentence(my_sentence)
my_sen... | true |
4e10517fea996c130996d464bf98c73e2027d38b | Ruby | tcurley42/cartoon-collections-online-web-sp-000 | /cartoon_collections.rb | UTF-8 | 1,881 | 4.03125 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(dwarves)# code an argument here
# Your code here
for i in 0...dwarves.size
puts "#{i+1}. #{dwarves[i]}"
end
end
def summon_captain_planet(array)# code an argument here
# Your code here
array.collect do |element|
element.capitalize + "!"
end
end
def long_planeteer_calls(calls... | true |
e8fd15672839a07141eb919de3c0d1f53fdb5109 | Ruby | sharesight/flappi | /lib/flappi/param_processor.rb | UTF-8 | 848 | 2.8125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Flappi
class ParamProcessor
def initialize(param_def)
@param_def = param_def
end
# Call block to process a parameter
#
# @yield A block that will be called to process the parameter
# @yieldparam [Object] param the actual parameter value before ... | true |
38ed30b5cc0a5b5f4b465e87e21b47d6ceaa273d | Ruby | roger35972134/Leetcode | /637.rb | UTF-8 | 666 | 3.375 | 3 | [] | no_license | # Definition for a binary tree node.
# class TreeNode
# attr_accessor :val, :left, :right
# def initialize(val)
# @val = val
# @left, @right = nil, nil
# end
# end
# @param {TreeNode} root
# @return {Float[]}
def average_of_levels(root)
queue = []
res = []
queue.push root
... | true |
0d8adf96be552e21ae8ca4baaca3526dad45e54b | Ruby | lfrancoeur/Ruby | /Comparison_with_the_inequality_operator.rb | UTF-8 | 241 | 3.359375 | 3 | [] | no_license | p 10 != 5
p 10 != 10
p "Hello" != "Goodbye"
p "Hello" != "Hello"
p "Hello" != "hello" #case senetive! this will return true
#for comaprison sake you can make a standard for data return
p "Hello".downcase != "heLLo".downcase
p "123" != 123
| true |
f32e1e29bd8d5bf50139009357b3e9d54c4b746a | Ruby | VirgilSecurity/virgil-sdk-ruby | /lib/virgil/sdk/cryptography/virgil_crypto.rb | UTF-8 | 20,574 | 2.59375 | 3 | [
"BSD-3-Clause"
] | permissive | # Copyright (C) 2016 Virgil Security Inc.
#
# Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# (1) Redistributions of so... | true |
b6f85f4164159071424de5e0dfd111095d8b7c3a | Ruby | Haseeb-Qureshi/advent-of-code-2018 | /day19.rb | UTF-8 | 1,161 | 3.25 | 3 | [] | no_license | require_relative 'day16_opcodes'
require 'colorize'
# Part 1
puts "Part 1"
REG = [0, 0, 0, 0, 0, 0]
input = "#ip 0
seti 5 0 1
seti 6 0 2
addi 0 1 0
addr 1 2 3
setr 1 0 0
seti 8 0 4
seti 9 0 5"
input = File.read('input19.txt')
instructions = input.lines.map(&:chomp)
instruction_pointer = instructions.shift.split.last... | true |
e6612162cd69dd3a3112880ad01b8050f85eddcb | Ruby | Renestl/AAO | /1 Intro/11_hashes/hashes1.rb | UTF-8 | 312 | 3.84375 | 4 | [] | no_license | # Data Structure - Hashes
# 'key => value' pairs
# => is a rocket
# key - rocket - value
# keys must be unique
my_hash = {
"name" => "Academy",
"color" => "red",
"age" => 5,
"isAwesome" => true,
42 => "hello"
}
# puts my_hash["age"]
# my_hash["color"] = "pink"
# my_hash["age"] += 1
puts my_hash[42] | true |
3b0c3185c3ab0d1bebdd801473eb711282bfbdb0 | Ruby | MagneticRegulus/120_oop | /lesson_2/lectures/5_classes_objects.rb | UTF-8 | 808 | 4.03125 | 4 | [] | no_license | =begin
Befor making changes to the class, what would the below code print?
bob = Person.new("Robert Smith")
puts "The person's name is: #{bob}"
# => This person's name is #<Person:0x0.......>
=end
class Person
attr_accessor :first_name, :last_name
def initialize(full_name)
split_name(full_name)
end
def ... | true |
00b3fd34bb1713c931d19fb7f539a69e8f73c108 | Ruby | AlexKVal/online-store | /db/seeds.rb | UTF-8 | 1,293 | 2.59375 | 3 | [] | no_license | # encoding: utf-8
Product.delete_all
Product.create!(title: 'Counter Strike',
description:
%{<p>
Counter Strike is just fine.
</p>},
image_url: 'cs.jpg',
price: 20.00)
# . . .
Product.create!(title: 'Ruby 2.0',
description:
%{<p>
Ruby is a pink to blood-red colored gemstone, a va... | true |
72460f3f9d177d49abb319d4eec7ca00950309ed | Ruby | lgrains/euler | /lib/euler/prob8.rb | UTF-8 | 557 | 3.46875 | 3 | [
"MIT"
] | permissive | module Euler
class Prob8
def initialize(num_string)
@num_string = num_string
@digit_array = @num_string.split('')
@digit_array.map!{|s| s.to_i}
end
def largest_product
max_prod = -1
five = @digit_array.shift(4)
begin
five.push(@digit_array.shift)
produ... | true |
cacc313d44768e362653a599d66d8ffad53802d0 | Ruby | idanwe/ZullerServer | /app/models/music_enums.rb | UTF-8 | 1,101 | 3.15625 | 3 | [] | no_license | class Music
def self.add_item(key,value)
@hash ||= {}
@hash[key]=value
end
def self.const_missing(key)
@hash[key]
end
def self.each
@hash.each {|key,value| yield(key,value)}
end
def self.for_select
music_for_select = []
@hash.each do |key,value|
music_for_select << [key, v... | true |
8317615f09cde2bafd1feb63de4ae4964fcd8e63 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/gigasecond/c527d776dbdf40979fb41bf001860732.rb | UTF-8 | 153 | 2.9375 | 3 | [] | no_license | class Gigasecond
ONEGEE_AS_DAYS = 10**9
def self.from(date_or_time)
time = date_or_time.to_time
(time + ONEGEE_AS_DAYS).to_date
end
end
| true |
6b90339d042ff4889c77fa756227931648b3975b | Ruby | 0x2C6/ortega_ruby | /lib/ortega/http.rb | UTF-8 | 788 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'net/http'
require 'ortega/file'
require 'ortega/uri'
require 'active_support/core_ext/hash/indifferent_access'
module Ortega
module HTTP
include Ortega::URI
def download(url, options = {}, &block)
options = options.with_indifferent_access
url = url_helper(url)
options[:name] = url... | true |
6857b623545c7aa5c38289b4cde2b40a7290febe | Ruby | ryanj-openquire/efs_cache | /lib/efs_cache.rb | UTF-8 | 1,527 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'efs_cache/version'
require 'efs_cache/manager'
require 'efs_cache/file_entry'
require 'yaml'
require 'fileutils'
require 'logger'
require 'securerandom'
module EfsCache
class << self
def configure
raise RuntimeError, 'EfsCache has already been configured' if @settings
self._configure_from... | true |
730c7aa6bbc5706fb1a76d0e5c9bb8b837b73bb4 | Ruby | morishin/humr | /lib/humr/handler.rb | UTF-8 | 261 | 2.5625 | 3 | [
"MIT"
] | permissive | module Humr
class Handler
@@handlers = {}
def name
self.class.instance_eval { @name }
end
def self.register(name)
@@handlers[name] = self
@name = name
end
def self.[](name)
@@handlers[name]
end
end
end
| true |
0cfc2fd307a4ea6f65b544f19ec1076cf4186556 | Ruby | LexieLoo82/SQL_Homework_Wk3 | /models/customer.rb | UTF-8 | 1,249 | 3.296875 | 3 | [] | no_license | require_relative('../db/sql_runner')
class Customer
attr_reader :id
attr_accessor :name, :funds
def initialize(options)
@id = options['id'].to_i if options['id']
@name = options['name']
@funds = options['funds'].to_i
end
def save()
sql = "INSERT INTO customers (name, funds)
VALUES ($1, $2)
RETURNING id"... | true |
74823a62723febe0e2bbae1db9c55691313347a7 | Ruby | heretoinfinity/phase-0-tracks | /ruby/iteration.rb | UTF-8 | 2,480 | 3.890625 | 4 | [] | no_license | arr = ['Ruby', 'JavaScript', 'HTML', 'CSS']
hash_ = {
'Clooney' => 'ER',
'Bale' => 'Batman',
'Depp' => 'Pirates of the Carribean',
'Dicaprio' => 'Titanic'
}
puts "array before .each"
puts arr
arr.each { |item|
puts "I know #{item}"
}
puts "array after .each"
puts arr
puts "-------------------------"
puts... | true |
1582e09eb78dae68d6dd57c8dfbd87f6448f54cd | Ruby | qxzsilver1/HackerRank | /Ruby/Strings/Methods-I/solution.rb | UTF-8 | 250 | 3.453125 | 3 | [] | no_license | # Enter your code here. Read input from STDIN. Print output to STDOUT
def process_text(str)
output = ""
str.map do |i|
output += i.to_s.strip + " "
end
return output.strip
#another way:
#str.map(&:strip).join(" ")
end
| true |
f56237490fb2bd1efd4e5156dd7150e58345f4da | Ruby | csssumahmood/todo-ruby-basics-001-prework-web | /lib/ruby_basics.rb | UTF-8 | 281 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def division(num1, num2)
num1/num2
end
def assign_variable(value)
name= value
end
def argue(name)
name
end
def greeting(name,language)
end
def return_a_value
return "Nice"
end
def last_evaluated_value
return "expert"
end
def pizza_party (cheese="cheese")
cheese
end
| true |
d54a0dad5230f2b2d2d210ab126816e098d38665 | Ruby | thien-truong/projecteuler-ruby | /3/lib/largest_prime_factor.rb | UTF-8 | 149 | 2.875 | 3 | [] | no_license | require 'prime'
class LargestPrimeFactor
def find_largest_prime_factor(limit)
Prime.prime_division(limit).map { |it| it.first }.last
end
end | true |
0a31bb91308c3f6a292cfc85dddbab530a7609b4 | Ruby | tayjames/sweater_weather | /app/facade/backgrounds_facade.rb | UTF-8 | 306 | 2.78125 | 3 | [] | no_license | class BackgroundsFacade
def initialize(location)
@location = location
@id = 2
end
def background
get_background(@location)
end
def get_background(location)
background_service = BackgroundService.new
background = background_service.background_by_location(location)
end
end
| true |
eefc08805d1ed3655c3c3f0a065c872e385b0cdd | Ruby | kbaba1001/learning_language | /ruby/third_day/ruby_csv.rb | UTF-8 | 709 | 3.875 | 4 | [] | no_license | require 'csv'
class CsvRow
def initialize(column)
@column = column
end
def method_missing name, *args
@column[name.to_s]
end
end
class RubyCsv
attr_reader :headers, :contents
def initialize(filename)
csv = CSV.readlines(filename)
@headers = csv.shift
@contents = csv
end
include ... | true |
63bbac46fd6ab9d628a99f6b4b933b7b0f5084e1 | Ruby | mklnz/dnsimple-dyndns | /lib/dnsimple_dyndns.rb | UTF-8 | 1,242 | 2.515625 | 3 | [] | no_license | class DnsimpleDyndns
CONFIG_PATH = File.expand_path('../../config', __FILE__)
CONFIG_FILE = File.join(CONFIG_PATH, 'config.yml')
TTL = 60
attr_accessor :config
def load_config
self.config = YAML.load_file(CONFIG_FILE).with_indifferent_access
end
def save_config
File.open(CONFIG_FILE, 'w') { |f|... | true |
0e2b622e92929f13e43f8226392e0af00c0eec6b | Ruby | medusa-project/ideals | /app/models/monthly_institution_item_download_count.rb | UTF-8 | 3,444 | 2.765625 | 3 | [] | no_license | ##
# This is a reporting model/table that enables more efficient queries for
# monthly item download counts within institutions than the alternative, which
# would be to query the `events` table and sum the counts of each download
# event (like {Institution#download_count_by_month} does).
#
# The data in this table is ... | true |
04f5cb2e71c7b668f27f1c300318c87727ef00c8 | Ruby | mesh1nek0x0/resolve-yukicoder | /no272/not.rb | UTF-8 | 70 | 3 | 3 | [] | no_license | #!/bin/ruby
X = gets.chomp.to_i
if X === 0
puts 1
else
puts 0
end | true |
f100524ab533109ddaeb745491ad465d1522c055 | Ruby | robertpfeiffer/heist | /lib/runtime/callable/macro/matches.rb | UTF-8 | 1,970 | 2.890625 | 3 | [
"MIT"
] | permissive | module Heist
class Runtime
class Macro
class Matches
def initialize
@data = {}
@depth = 0
@names = []
end
def depth=(depth)
mark!(depth) if depth < @depth
@names[depth] = [] if depth >= @depth
@depth = depth... | true |
ffa839505a397f8425c2db57a0e089fe0d0ab877 | Ruby | shmztko/redshift-test-scripts | /redshift-ctl/lib/redshift_shutdown_runner.rb | UTF-8 | 4,056 | 2.625 | 3 | [] | no_license | # Command runner for redshift boot script.
require File.expand_path('../redshift_cluster.rb', __FILE__)
require File.expand_path('../redshift_snapshot.rb', __FILE__)
class ShutdownRunner
WAIT_TIME = 10
def initialize(client, cluster_conf, logger)
@cluster_conf = cluster_conf
@logger = logger... | true |
0a4517a875ce85f00532deea6dd26335a278d0c2 | Ruby | cngshow/rails_common | /util/helpers.rb | UTF-8 | 6,730 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | =begin
Copyright Notice
This is a work of the U.S. Government and is not subject to copyright
protection in the United States. Foreign copyrights may apply.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of th... | true |
de70e5f9a052022f487ff72d9b37083fe7d01b68 | Ruby | INGIBITR/Ruby_labs | /Lab6/lab6pt3test.rb | UTF-8 | 772 | 2.703125 | 3 | [] | no_license | # frozen_string_literal: true
require_relative "lab6pt3module"
require "minitest/autorun"
# Test Class
class TestClass < Minitest::Test
def setup; end
def test_correct_int1
lam1 = ->(x) { x + Math.cos(x) }
assert_in_delta(7.58467, Integral.blockintprg(-1, 4, 10000, &lam1), 0.01)
end
def test_correct1... | true |
f5a851362cc72c2152d209a32f37f552da1af07b | Ruby | ChristopherDurand/Exercises | /ruby/oop/oo_basics_4/avoid_mutation.rb | UTF-8 | 165 | 3.375 | 3 | [
"MIT"
] | permissive | class Person
def name
@name.dup
end
def initialize(name)
@name = name
end
end
person1 = Person.new('James')
person1.name.reverse!
puts person1.name
| true |
1e86b9cd0159e1366f212c6aad70f5ab83b11551 | Ruby | dmdmdm1/101_Programming_Foundations | /lesson_3/practice_problems_easy_2/munsters.rb | UTF-8 | 303 | 3.296875 | 3 | [] | no_license | munsters_description = "The Munsters are creepy in a good way."
# Convert the string in the following ways (code will be executed on original
# munsters_description above):
p munsters_description.capitalize
p munsters_description.swapcase
p munsters_description.downcase
p munsters_description.upcase
| true |
85ae3067127eef6aad2131c5f9a99f78d493c1ca | Ruby | brazenbraden/text_comparator | /lib/comparators/percentage_comparator.rb | UTF-8 | 265 | 2.921875 | 3 | [] | no_license | class PercentageComparator
def compare(tokens1, tokens2)
combined = (tokens1 + tokens2).uniq
diff = (tokens1 - tokens2 | tokens2 - tokens1).count
unique = combined.count - diff
combined.empty? ? 1.0 : unique.to_f / combined.count.to_f
end
end | true |
aaa803237a1eaebc30f02ac5ea5333d76932b73d | Ruby | miketlawrence/vita-min | /app/lib/capybara_walkthrough_screenshots.rb | UTF-8 | 3,603 | 2.59375 | 3 | [] | no_license | class CapybaraWalkthroughScreenshots
def self.hook!(config)
config.before(:each) do |example|
CapybaraWalkthroughScreenshots.before(example)
end
config.after(:each) do
CapybaraWalkthroughScreenshots.after
end
Capybara::Session.class_exec do
capybara_visit = instance_method(:vis... | true |
2a0c51d77d2563e7e734a1eb342ae4de65a53330 | Ruby | luciaprietosantamaria/Bioinformatic-programming-challenges | /Assignment4/main.rb | UTF-8 | 9,556 | 3.40625 | 3 | [] | no_license | #-----------------------------------------------------------------
# Bioinformatic programming challenges
# Assignment4: MAIN SCRIPT
# author: Lucía Prieto Santamaría
#-----------------------------------------------------------------
# Searching for Orthologues
#---------------------------------------------------------... | true |
f9b30ddf7774c2fde65eb1a2c6558407c48e2715 | Ruby | Adub648/EventManager | /lib/event_manager.rb | UTF-8 | 3,714 | 3.515625 | 4 | [] | no_license | require 'csv'
require 'google/apis/civicinfo_v2'
require 'erb'
# set initial values
def initializeCode
@initial = true
@popular_times = {}
24.times { |hour| @popular_times.store(hour, 0) }
@popular_date = { Monday: 0, Tuesday: 0, Wednesday: 0, Thursday: 0, Friday: 0, Saturday: 0, Sunday: 0 }
end
# clean up zi... | true |
390f47308086b36f10017743027d64cb91879c88 | Ruby | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/DATA_STRUC_PYTHON_NOTES/WEEKS/wk17/CodeSignal-Solutions/CodeSignal-Solutions-master/Arcade/Intro/Ruby/commonCharacterCount.rb | UTF-8 | 284 | 3.484375 | 3 | [
"MIT",
"Python-2.0"
] | permissive | def commonCharacterCount(s1, s2)
q = (0x61..0x7b).to_a.filter{|e| s1.include?(e.chr) && s2.include?(e.chr)}
.map{|e| e.chr}.join
o = 0
q.chars.each do |e|
m = s1.chars.filter{|s| s == e}.length
n = s2.chars.filter{|s| s == e}.length
o += m < n ? m : n
end
return o
end | true |
4f24ce14e0c18e42a69d2a65af8570f5d1c014c0 | Ruby | gerndtr/ruby_practice | /ultimate_ruby.rb | UTF-8 | 398 | 4.25 | 4 | [] | no_license | def division (x, y)
ans = x / y
end
puts "Give me two numbers to divide, but not zero"
puts "The first one is..."
x = gets.chomp.to_f
puts "And the second one is..."
y = gets.chomp.to_f
if x == 0 || y == 0
puts "Sorry, they cannot be zero. Try again."
division
elsif
... | true |
dbad97ebb0378e3c0dd5a764ffa8f0428ddc874a | Ruby | pione/pione | /lib/pione/pnml/output-reduction.rb | UTF-8 | 3,193 | 2.703125 | 3 | [
"MIT",
"Ruby"
] | permissive | module Pione
module PNML
# `OutputReduction` is a net rewriting rule. This rule removes unnecessary
# output nodes of transitions. For example, the net likes the following
#
# A --> empty place --> empty transition --> place --> B
#
# is rewritten as the following.
#
# A -> pl... | true |
e485cc8d2f289b288daf93799057c87465cde531 | Ruby | AssemblyPayments/promisepay-ruby | /lib/promisepay/resources/charge_resource.rb | UTF-8 | 1,447 | 2.671875 | 3 | [
"MIT"
] | permissive | module Promisepay
# Resource for the Charges API
class ChargeResource < BaseResource
def model
Promisepay::Charge
end
# List all charges
#
# @see https://reference.promisepay.com/#list-charges
#
# @param options [Hash] Optional options.
# @option options [Integer] :limit Can a... | true |
84f8e3304ab10570cb5169c5c5d5393711a22f71 | Ruby | kleopatra999/heirloom | /lib/heirloom/catalog.rb | UTF-8 | 2,450 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'heirloom/catalog/add.rb'
require 'heirloom/catalog/delete.rb'
require 'heirloom/catalog/list.rb'
require 'heirloom/catalog/setup.rb'
require 'heirloom/catalog/show.rb'
require 'heirloom/catalog/verify.rb'
module Heirloom
class Catalog
def initialize(args)
@config = args[:config]
@name =... | true |
0a114f518ae63f579697c906a9af729ca1ae39e3 | Ruby | kwx4github/facebook-hackercup-problem-sets | /2015/qualifying_round/1.Cooking_the_Books/solutions/sources/x.7483.Mufid | UTF-8 | 1,757 | 3.34375 | 3 | [] | no_license | #!/usr/bin/env ruby
file_name = ARGV.first
$first_line = true
iteration = 0
$total = 0
class Swap
attr_accessor :x1
attr_accessor :x2
def initialize
self.x1 = 0
self.x2 = 0
end
end
File.open(file_name, "r") do |fh|
begin
while (line = fh.readline) != nil
if $first_line
... | true |
cc328c3492b5c5900279c44f3a3781d62ccc3201 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/gigasecond/057e44caf36246f3ae10cad46af2c86f.rb | UTF-8 | 116 | 2.75 | 3 | [] | no_license | class Gigasecond
GIGASECOND = 10 ** 9
def self.from moment
(moment.to_time + GIGASECOND).to_date
end
end
| true |
b3946169b0c7c75807988eea44387c7a8948d928 | Ruby | anishkothari/Tic-Tac-Toe | /lib/game/player.rb | UTF-8 | 1,391 | 3.421875 | 3 | [] | no_license | require 'board'
class Player
attr_reader :marker
def initialize(marker)
@marker = marker
end
end
class HumanPlayer < Player
def prompt_position(board)
gets.chomp.upcase
end
end
class EasyAIPlayer < Player
def prompt_position(board)
random_move(board)
end
def random_move(board)
... | true |
c9753866f8bb86e496fc928c1b9f6e5533f2c2cc | Ruby | nmacawile/ruby_basics | /learn_to_program_ruby/chapter8b.rb | UTF-8 | 1,835 | 3.984375 | 4 | [] | no_license |
def unit_text digit
unit = ''
if digit == 0
unit = ''
elsif digit == 1
unit = 'one'
elsif digit == 2
unit = 'two'
elsif digit == 3
unit = 'three'
elsif digit == 4
unit = 'four'
elsif digit == 5
unit = 'five'
elsif digit == 6
unit = 'six'
elsif digit == 7
unit = 'seven'
elsif digit == 8
uni... | true |
e586c167bb4979158a3742a89304dec759bd41be | Ruby | pgaret/advanced-hashes-hashketball-web-0916 | /hashketball.rb | UTF-8 | 4,412 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here!
require 'pry'
def game_hash
game = {
:home => {
:team_name => "Brooklyn Nets",
:colors => "Black, White",
:players => {
"Alan Anderson" => {
:number => 0,
:shoe =>16,
:points => 22,
:rebounds => 12,
:assists => 12... | true |
029dce552661fff162c5efb789760a29767a96a7 | Ruby | docljn/codeclan_class_notes | /week02/day3/pub_lab/pub.rb | UTF-8 | 736 | 3.46875 | 3 | [] | no_license | class Pub
attr_reader :name, :till, :stock
def initialize(name, till, stock)
@name = name
@till = till
@stock = stock
end
def add_money(amount)
@till += amount
end
def select_item(item_name)
# should probably change drinks to stock,
# but here is where I need to know how to
#... | true |
e9767e72e7ee12275ef31b27d5a25b190b37786e | Ruby | JordanVerasamy/sc2_analyzer | /analyzer.rb | UTF-8 | 936 | 3.078125 | 3 | [] | no_license | MY_NAMES = ['<aivNA>Alephnaut', '<ScSwrm>Lethologica']
require 'pp'
require './source'
require './replays'
require './google_sheets'
require './game'
class Analyzer
attr_accessor :name, :games
def initialize(name:,games:)
@name = name
@games = games
end
def bracketed_winrates
games
.group_... | true |
0bbfcd7f54e0957715a44ed005804f8e0d2b8b54 | Ruby | stpatrickschild/media-ranker | /test/models/work_test.rb | UTF-8 | 1,362 | 2.5625 | 3 | [] | no_license | require "test_helper"
describe Work do
describe 'validations' do
before do
# Arrange
@work = Work.new(
category: "book",
title: 'a new book',
creator: 'booker',
publication_year: 1989,
description: 'viral hemorrhagic fevers'
)
end
it 'work... | true |
a8278233668974fe62b254386c4679653fff5d28 | Ruby | yol/subconv | /lib/subconv/caption_filter.rb | UTF-8 | 4,210 | 2.984375 | 3 | [
"MIT"
] | permissive | require 'subconv/caption'
module Subconv
# Apply post-processing to captions
# Supported operations:
# - remove color nodes
# - remove flash nodes
# - convert XY viewport relative positions to simple top or bottom positions
# - merge multiple captions on screen at the same time into one caption
class Cap... | true |
c8cd06d417b82247da144e47eaf01ff66de33839 | Ruby | MIKEALGEE/bus_class_exercise | /specs/bus_specs.rb | UTF-8 | 795 | 3.125 | 3 | [] | no_license | require("minitest/autorun")
require("minitest/rg")
require_relative("../bus.rb")
require_relative("../person.rb")
class BusTest < MiniTest::Test
def setup()
@bus = Bus.new("22","Ocean Terminal", [])
@person1 = Person.new("Steve", "23")
@person2 = Person.new("Big Weirdo", "28")
@person3 = Person.new... | true |
23ce2d44dba05d005e7ef5567cb1e5aaef535f39 | Ruby | MPalhidai/Algorithms | /exercism/ruby/complete/allergies/allergies.rb | UTF-8 | 456 | 3.375 | 3 | [] | no_license | class Allergies
attr_reader :list
@@allergens = {
cats: 128,
pollen: 64,
chocolate: 32,
tomatoes: 16,
strawberries: 8,
shellfish: 4,
peanuts: 2,
eggs: 1
}
def initialize(score)
score %= 256
@list = []
@@allergens.each do |allergen, value|
if value <= score
... | true |
b179fedc26017001c8c1387fa6eed7af498dc1d4 | Ruby | moritzheiber/apprentice | /lib/apprentice/checks/galera.rb | UTF-8 | 5,312 | 3 | 3 | [
"MIT"
] | permissive | # Contains Galera specific methods for checking cluster member consistency
module Galera
# Galera knows {a couple of different states}[http://www.percona.com/doc/percona-xtradb-cluster/wsrep-status-index.html#wsrep_local_state].
# This constant describes their respective meaning for user feedback and, possibly, lo... | true |
bfdf62edfcc364a342d4776448f3c0f480d2dadc | Ruby | crishanks/my-collect-prework | /lib/my_collect.rb | UTF-8 | 218 | 3.5 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_collect(languages)
i = 0
result = []
while i < languages.length
result.push(yield(languages[i]))
i += 1
end
result
end
my_collect(['german', 'spanish', 'english']) do |lang|
lang.upcase
end
| true |
0fe2d563f29be3814979a9f2a500dc5c4760298d | Ruby | gabrielsugai/checkout_area_do_cliente | /spec/models/promo_spec.rb | UTF-8 | 2,582 | 2.640625 | 3 | [] | no_license | require 'rails_helper'
describe Promo, type: :model do
context '#cannot be blank' do
it 'title cannot be blank' do
promo = Promo.new
promo.valid?
expect(promo.errors[:title]).to include('não pode ficar em branco')
end
it 'discount cannot be blank' do
promo = Promo.new
pr... | true |
3807ae90ee4d316633f04f1e05d78bfd14c00646 | Ruby | DavideDaniel/servers | /my_first_sinatra_app/gamesServer.rb | UTF-8 | 1,966 | 3.234375 | 3 | [] | no_license | require 'sinatra'
get "/favicon.ico" do
end
magic = [
"It is certain",
"It is decidedly so",
"Without a doubt",
"Yes definitely",
"You may rely on it",
"As I see it yes",
"Most likely",
"Outlook good",
"Yes", "Signs point to yes",
"Reply hazy try again",
"Ask again later",
"Better not tell you... | true |
fa8764c0527a84bf2c9e7bc5b1fd05eb2026b90f | Ruby | fanjieqi/LeetCodeRuby | /1301-1400/1366. Rank Teams by Votes.rb | UTF-8 | 296 | 3.046875 | 3 | [
"MIT"
] | permissive | # @param {String[]} votes
# @return {String}
def rank_teams(votes)
chars = {}
votes.each do |vote|
(0..vote.size-1).each do |i|
char = vote[i]
chars[char] ||= (0..25).map{0}
chars[char][i] -= 1
end
end
chars.keys.sort_by { |char| chars[char] + [char] }.join
end
| true |
4ac18ea4e435070f3d5af81ab63e05d5ab90c78d | Ruby | Ji-Edward/ruby_practice | /whileloop.rb | UTF-8 | 288 | 3.453125 | 3 | [] | no_license | puts "what is your name?"
name = gets.chomp.downcase
while name != "edward"
puts "what is your name?"
name = gets.chomp.downcase
end
puts "what a great name!"
puts num = rand(11)
while num != 7
puts num = rand(11)
end
puts num=rand(1..10)
while num !=8
puts num=rand(1..10)
end | true |
6711473263109d2093c6c9609151557ed73312c9 | Ruby | fl00r/tarantool-ruby | /lib/tarantool/requests/update.rb | UTF-8 | 1,006 | 2.765625 | 3 | [
"BSD-2-Clause"
] | permissive | class Tarantool
module Requests
class Update < Request
request_type :update
OP_CODES = { set: 0, add: 1, and: 2, or: 3, xor: 4, splice: 5 }
def self.pack_ops(ops)
ops.map do |op|
raise ArgumentError.new('Operation should be array of size 3') unless op.size == 3
fie... | true |
6c6cacc22d5ca718e660095579674e7db0036aa3 | Ruby | limejuny/rbchat | /client.rb | UTF-8 | 1,931 | 3.203125 | 3 | [] | no_license | require "io/console"
require "socket"
require "json"
require "tty-cursor"
require "tty-screen"
class TTYChat
def initialize
@cursor = TTY::Cursor
(@height, @width) = TTY::Screen.size
@buffer = []
@len = 0
print @cursor.clear_screen
print @cursor.move_to(0, @height - 1)
print ">> "
end
... | true |
119014cd5a02b677e0421431df9688976db2d093 | Ruby | microjupiter/pokedex | /app/controllers/pokemon_controller.rb | UTF-8 | 683 | 2.53125 | 3 | [] | no_license | require './config/environment'
class PokemonController < ApplicationController
get "/" do
erb :welcome
end
# creates a new pokemon object w/params assigned to the trainer. redirects to trainers home
post '/pokemon/new' do
@pokemon = Pokemon.find_by_id(params['pokemon'])
@trainer = current_user
@pokemon_trai... | true |
21372a62b488fe914d5b84029a624955662ae815 | Ruby | emilkloeden/21-days-of-Euler | /Ruby/2.rb | UTF-8 | 468 | 4.1875 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# Declare a method that returns the nth fibonacci number
def fib (n)
a,b = 0, 1
return 0 if n <= 0
i = 0
until i >= n do
a, b = b, a + b
i += 1
end
return a
end
# Populate an array with even fibonacci numbers
i = 1
initial_range = []
begin
initial... | true |
958cb8cd899116ee1ac7ecea93f332741b781971 | Ruby | andrewazores/Capstone | /tools/common/AutomatonParts.rb | UTF-8 | 855 | 3 | 3 | [] | no_license | require_relative './JsonStringify'
class Automaton < JsonStringify
attr_reader :state_names, :transitions
def initialize(state_names, transitions)
@state_names = state_names
@transitions = transitions
end
end
class StateName < JsonStringify
attr_reader :label, :type
def initialize(label, type)
@... | true |
660d062dbf027c6597c4a8275552d04eaf724e61 | Ruby | danielevans/bridge-rb | /spec/lib/card_spec.rb | UTF-8 | 845 | 2.765625 | 3 | [] | no_license | require 'spec_helper'
module Bridge
RSpec.describe Card do
subject(:card) { Card.new }
describe ".all" do
it "returns 52 cards" do
expect(Card.all.length).to eq(52)
end
end
context "with two aces of differing suits" do
let(:ace_of_hearts) { Card.specifically_for(suit: Strain... | true |
10d65c4c94352a0706152fb910779e4eb5765c28 | Ruby | peetsnack/marvin | /lib/common.rb | UTF-8 | 2,201 | 2.875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
module Common
require 'ruby-bitly'
require 'nokogiri'
require 'open-uri'
def get_html_element(url, selector, mode = 'css')
# Make sure the URL is legit
url = URI::extract(url, ["http", "https"]).first
data = case mode
when 'css' then Nokogiri::HTML(open(url)).css... | true |
ed2fe7f968b021fc12dce37e37eb4412329e6ade | Ruby | stamppot/cbcl4 | /app/models/subscription_presenter.rb | UTF-8 | 5,502 | 2.578125 | 3 | [] | no_license | class SubscriptionPresenter
# Details view: subscription (one per survey), list of total, total_active (since last payment)
# Summary view: periods
# periods -> total used in period
attr_accessor :group, :subscriptions, :summary_view, :surveys, :periods, :detailed_view, :total_periods, :params
def initiali... | true |
4570ed520b229dee6eb1ed013e9c19e20c7de218 | Ruby | JBoshart/Scrabble | /lib/tilebag.rb | UTF-8 | 992 | 3.15625 | 3 | [] | no_license | class TileBag
attr_reader :total_tiles
def initialize
@default_tiles = {
"A" => 9, "B" => 2, "C" => 2,
"D" => 4, "E" => 12, "F" => 2,
"G" => 3, "H" => 2, "I" => 9,
"J" => 1, "K" => 1, "L" => 4,
"M" => 2, "N" => 6, "O" => 8,
"P" => 2, "Q" => 1, "R" => 6,
"S" =... | true |
03e0120b78bf6422eb646f644571a4a6aed6a255 | Ruby | itgsod-Daniel-Roos/RomerskaSiffror | /spec/romanize_spec.rb | UTF-8 | 2,194 | 3.75 | 4 | [] | no_license | require 'rspec'
require_relative '../lib/romanize'
describe 'converting arabic numerals to roman' do
it 'should take a number as argument' do
expect { romanize() }.to raise_error ArgumentError
expect { romanize(1000) }.not_to raise_error
end
#Detta test kan kommenteras bort om man inte vill test 'Undan... | true |
9c73ee96bfd0d1bc5370c1828a7bce8fa16743f8 | Ruby | ovkachanov/rubybase | /lesson_10/validation.rb | UTF-8 | 982 | 3 | 3 | [] | no_license | module Validation
def self.included(base)
base.extend ClassMethods
base.send :include, InstanceMethods
end
module ClassMethods
attr_reader :validates
def validate(name, *args)
@validates ||= []
@validates << { name => args }
end
end
module InstanceMethods
def validate!
... | true |
bfaff406e39b4ceeb87e0a26bdc99e1141697dd3 | Ruby | oleksii-zaprii/mobsgen | /app/controllers/events_controller.rb | UTF-8 | 1,667 | 2.59375 | 3 | [
"MIT"
] | permissive | class EventsController < ApplicationController
def index
@events = Event.all
end
def new
@event = Event.new
@participants = Stoat.all
end
def create
number_of_mobs = params[:event][:number_of_mobs].to_i
number_of_mobs = 1 if number_of_mobs < 1
@participants = Stoat.where(email: par... | true |
7cca9e069fa0993ee06f40cd779f860f8edfd18d | Ruby | AaronLasseigne/active_interaction | /lib/active_interaction/filters/abstract_numeric_filter.rb | UTF-8 | 1,012 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module ActiveInteraction
# @abstract
#
# Common logic for filters that handle numeric objects.
#
# @private
class AbstractNumericFilter < Filter
def database_column_type
self.class.slug
end
private
def matches?(value)
value.is_a?(klass)
rescue... | true |
6637c1ec260c1e8ca7732cc12185723d757406a4 | Ruby | stevenhaddox/SUPPORT | /lib/SUPPORT/user.rb | UTF-8 | 431 | 2.65625 | 3 | [
"MIT"
] | permissive | module SUPPORT
class User
attr_accessor :role, :username, :password, :enabled, :switched_from
alias :enabled? :enabled
def initialize data
@role = data[:role]
@username = data[:username]
@password = data[:password]
@enabled = data[:enabled]
end
def switched_from= user_r... | true |
c44fff21edd4acbfdb81aaa555c6fc5b84bdac5c | Ruby | tbeeley/student-directory | /directory.rb | UTF-8 | 1,685 | 3.3125 | 3 | [] | no_license |
students_fixed =[
{:name => "Dave", :cohort=> :june},
{:name => "Eddie", :cohort =>:june},
{:name => "Catharina", :cohort =>:june},
{:name => "Igor", :cohort => :june},
{:name => "Marco", :cohort => :june},
{:name => "Lisa", :cohort=> :june},
{:name => "Michiel", :cohort =>:june},
{:name => "Jean", :cohort =>... | true |
081e5c90ac7ab1693e102b05a30fbd63433ff20e | Ruby | adrianmarino/mmpi2-backpropagation | /lib/mmpi2_back_propagation.rb | UTF-8 | 2,109 | 2.703125 | 3 | [
"MIT"
] | permissive | class MMPI2BackPropagation
# -------------------------------------------------------------------------
# Public Methods...
# -------------------------------------------------------------------------
def train(tests, times = 3, a_max_error = NetConfiguration::MAX_ERROR)
logger = BackPropagationLogger.new
count =... | true |
9c58c46f26272a4cb034095a29ecc35ad0343bd6 | Ruby | theMiddler/ruby_programs | /ruby_learning/w01c03_v3.rb | UTF-8 | 822 | 4.03125 | 4 | [] | no_license | =begin
multiplication_table (integer, heading = '', decorate = false)
returns a string object.
table1 = multiplication_table 9, 'Times Table to 9', true
table2 = multiplication_table 20
puts table1
puts
puts table2
=end
require '~/RubyScripts/ruby_learning/old/prompt.rb'
def multiplication_table (integer,head... | true |
c600fed939969ac2593743df523cf78e91daaa75 | Ruby | tam-borine/learn_to_program | /ch10-nothing-new/sort.rb | UTF-8 | 771 | 3.671875 | 4 | [] | no_license | #I FINALLY UNDERSTAND THIS SO CAN USE IT WITHOUT GUILT. I GET THE DIFFERENT SORTING ALGORITHMS BUT UNDERSTANDING THIS BASIC HORSEWORK TOOK LONGER
def sort arr
rec_sort arr, []
end
def rec_sort unsorted, sorted
if unsorted.length <= 0
return sorted
end
# So if we got here, then it means we still
# have work to do.
smal... | true |
ed893a84aac4c16ec8548486bcd29ab67c54fff1 | Ruby | igorp984/ruby_tiwitter | /rails_app/app/services/create_hashtags_messages_service.rb | UTF-8 | 444 | 2.5625 | 3 | [] | no_license | class CreateHashtagsMessagesService
def initialize (message, hashtag)
@message = message
@hashtag = hashtag
end
def charge
create_hashtags_messages
end
private
def create_hashtags_messages
if @message.hashtags.find_by(id: @hashtag.id)
return false
... | true |
09346c0d1b5a8859e0915cb8e4b69737543a487a | Ruby | Graeme189/Wk2_d2_homework | /bear.rb | UTF-8 | 305 | 3.421875 | 3 | [] | no_license | class Bear
attr_reader :name, :type, :stomach
def initialize(name, type, stomach)
@name = name
@type = type
@stomach = stomach
end
def eat_fish(fish)
@stomach.push(fish)
end
def hear_me_roar
return 'grrrrrr'
end
def food_count
return @stomach.count
end
end
| true |
2a79228c70847b3a6ce9119956ed77c91b314e95 | Ruby | EnzoRobaina/Atividades_Ruby | /Capitulo_6/1/Elton.rb | UTF-8 | 97 | 3.1875 | 3 | [] | no_license | puts 'Qual a nota?'
nota = gets.to_f
if nota > 6
puts 'Aprovado'
else
puts 'Reprovado'
end | true |
0335cb980e392dffbc728532dc8404007f36ddfd | Ruby | perpepajn25/single-source-of-truth | /lib/has_many_belongs_to/Player.rb | UTF-8 | 189 | 2.96875 | 3 | [] | no_license | class Player
attr_accessor :name, :team
def initialize(name)
@name = name
@@all << self
end
def join_team(team)
self.team = team
team.players << self
end
end
| true |
b8be1be19d9e9b510ce975503211695459ca4d64 | Ruby | kalaycibugra/myUniverse | /Planet.rb | UTF-8 | 635 | 2.625 | 3 | [] | no_license | class Planet
attr_accessor :intellegent,:distance,:id
def initialize(type,intellegent,distance,id)
@intellegent=intellegent
@type=type
@distance=distance
@id=id
end
end
class RockyPlanet < Planet#Rocky planet subclass
def initialize(intellegent,distance,id)
super("RockyPlanet",intellegent,distance,id)
end
... | true |
01417d1a3eddd4a21fd02d3f68f2ca5d877fc798 | Ruby | nhopkin/Intro-To-Programming | /Ch5:Loops/countdown.rb | UTF-8 | 310 | 4.1875 | 4 | [] | no_license | # countdown.rb
puts "Please enter an integer:"
x = gets.chomp.to_i
while x >= 0
puts x
#x = x - 1
x -= 1
#puts x
end
puts "Done with the while loop.
Enter another integer below to run the until loop."
# countdown.rb using until
x = gets.chomp.to_i
until x < 0
puts x
x -= 1
end
puts "Done!" | true |
68d1e58491b02e3606370f12e4ec1b9b8f38216f | Ruby | Jeff-Hostetler/TILDInteractive | /spec/support/test_object_factory.rb | UTF-8 | 491 | 2.5625 | 3 | [] | no_license | class TestObjectFactory
class << self
def new_user(overrides = {})
random_string = (0...8).map { (65 + rand(26)).chr }.join
defaults = {
first_name: "Beth#{random_string}",
last_name: "Jones",
email: "user#{random_string}@example.com",
password: "fake-password",... | true |
ec0147efdf3d80a0ccfdb4c5fb3fccd3db1d76a9 | Ruby | ohokay/placeholdit | /spec/placeholdit_spec.rb | UTF-8 | 2,963 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
class MyView
include Placeholdit::ViewHelpers
end
describe Placeholdit::ViewHelpers do
let(:view) { MyView.new }
it "should accept integers as params" do
expect(view.placeholdit_image_tag(500)).to eq "<img src='https://placehold.it/500' alt='A placeholder image' class='placeholder' he... | true |
6ee62fcc6527941f0560b558a76071023ae9a4d4 | Ruby | jpatel531/tictactoe | /spec/game_spec.rb | UTF-8 | 475 | 2.828125 | 3 | [] | no_license | require 'game'
describe Game do
let(:game) { Game.new }
let(:human) { game.human }
let(:computer) {game.computer}
let(:board) {game.board}
it 'the human player goes first' do
expect(game.turn).to eq human
end
it 'alerts a human winner' do
human.target 1, 1
human.target 1, 2
human.target 1, 3
e... | true |
f3e53d3e89928e3cbb7af702d5e560568be38d04 | Ruby | uk-gov-mirror/ministryofjustice.specialist-publisher | /app/services/remove_manual_document_service.rb | UTF-8 | 848 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | class RemoveManualDocumentService
def initialize(manual_repository, context)
@manual_repository = manual_repository
@context = context
end
def call
validate_never_published
remove
persist
[manual, document]
end
private
attr_reader :manual_repository, :context
def validate_never_... | true |
48be369343883e78886ff222c0bc977893672367 | Ruby | srashidi/Web_Refresher | /google_search.rb | UTF-8 | 151 | 2.734375 | 3 | [] | no_license | require 'rest-client'
puts "Type in a search query:"
query = gets.chomp.split(" ").join("+")
puts RestClient.get("http://www.google.com/#q=" + query) | true |
b91efb4883b12f91a1cffe83fdf5d61d726810d4 | Ruby | pronix/changer | /vendor/plugins/webmoney/spec/unit/wmid_spec.rb | UTF-8 | 573 | 2.53125 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + '/../spec_helper'
module Webmoney
describe Wmid, "class" do
before(:each) do
@t = Wmid.new('123456789012')
end
it "should be kind of Wmid" do
@t.should be_kind_of(Wmid)
end
it "should be string" do
@t.should == '123456789012'
end
it ... | true |
82357b0715bb46a662fe267c0fc21a83eb837d2f | Ruby | saasbook/sinatra_demo | /intermediate.rb | UTF-8 | 2,114 | 3.296875 | 3 | [] | no_license | =begin
Created on Feb 2nd, 2016
A toy Sinatra app to demostrate the basic concept of MVC, RESTful Routes and CRUD.
Run ``bundle install`` to make sure you have necessary gems installed.
TO run the script, type ``ruby intermediate.rb`` in command line.
@author: hezheng.yin
=end
# load libraries we need
require 'sinat... | true |
378087fe560f290b57cb8de5ee47578e15d294a1 | Ruby | thejennywang/ma-takeaway-2 | /lib/customer.rb | UTF-8 | 123 | 2.90625 | 3 | [] | no_license | class Customer
def initialize(name, mobile)
@name = name
@mobile = mobile
end
attr_reader :name, :mobile
end | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.