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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
b668e9591f06748afe01423e676a98a867565abc | Ruby | heaenwie/learn_ruby | /04_pig_latin/pig_latin.rb | UTF-8 | 296 | 3.203125 | 3 | [] | no_license | def translate(sentence)
words = sentence.split(' ')
(0..words.length-1).each do |i|
if words[i] =~ /\A[aeiou]/
words[i] += "ay"
else
inwords_splits = words[i].split /([aeio].*)/
words[i] = inwords_splits[1]+inwords_splits[0]+"ay"
end
end
words.join(' ')
end
| true |
4d03c701314cad5a5f66ce9de16c193e9672c915 | Ruby | tylertomlinson/museum_2001 | /lib/museum.rb | UTF-8 | 1,123 | 3.171875 | 3 | [] | no_license | class Museum
attr_reader :name,
:exhibits,
:patrons
def initialize(name)
@name = name
@exhibits = []
@patrons = []
end
def add_exhibit(exhibit)
@exhibits << exhibit
end
def recommend_exhibits(patron)
@exhibits.find_all { |exhibit| patron.interests.include?(... | true |
c6ac8deec9da455b27a160042e19289cc4324fdc | Ruby | aircross/YPortal | /app/models/terminal.rb | UTF-8 | 3,453 | 2.53125 | 3 | [] | no_license | require 'csv'
class Terminal < ActiveRecord::Base
enum status: [ :init, :active, :expired ]
include PrivateKey
include Communicate
extend OpenSpreadsheet
belongs_to :merchant
belongs_to :agent
has_many :auth_tokens, dependent: :destroy
before_create :set_mid, :set_duration
validates :mac, forma... | true |
1fea5eb4087a598370ea27a4a1530335469dbd1f | Ruby | allbecauseyoutoldmeso/game_of_life | /lib/cell.rb | UTF-8 | 138 | 2.8125 | 3 | [] | no_license | class Cell
def initialize(boolean)
@live = boolean
end
def live?
@live
end
def make_live
@live = true
end
end
| true |
c91e390f3e5cb13ac84ffc92944894b5d70ee1ad | Ruby | pld/photocracy | /test/performance/responses_test.rb | UTF-8 | 1,952 | 2.640625 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../test_helper'
class ResponsesTest < ActionController::IntegrationTest
def test_new
puts "responses/new:"
benchmark_time :get, 'responses/new'
benchmark_memory :get, 'responses/new'
end
def benchmark_time(method, url)
measured_times = []
10.times { measure... | true |
7f8ecbdb65b313154b5ba41e5ceb02297b2910da | Ruby | tstone/mess | /entities/property.rb | UTF-8 | 594 | 2.53125 | 3 | [] | no_license | module MESS
module Entities
class Property
include Transformative
attr_reader :name, :value
def initialize(parent, entity)
@parent = parent
@entity = entity[:prop_def]
@name = @entity[:property]
@value = Entities::Expression.new(self, @entity)
@parent.ad... | true |
ecea3be3349414ca020b2b0dc284437f17115d0a | Ruby | manofsteele/algorithm_projects | /quick_sort_project/lib/quick_sort.rb | UTF-8 | 1,299 | 3.6875 | 4 | [] | no_license | class QuickSort
# Quick sort has average case time complexity O(nlogn), but worst
# case O(n**2).
# Not in-place. Uses O(n) memory.
def self.sort1(array)
return array if array.length < 2
pivot = array[0]
left, right = [], []
array.each do |el|
if el <= pivot
left << el
els... | true |
e6454c1aa21ba06bf7172efc36846255331d4e44 | Ruby | lsylvain1726/Launch_School2017 | /learn_to_program/sorting.rb | UTF-8 | 433 | 3.59375 | 4 | [] | no_license | #sorting
def sort(arr)
rec_sort(arr, [])
end
def rec_sort(unsorted,sorted)
if unsorted.length <= 0
return sorted
end
smallest = unsorted.pop
still_unsorted = []
unsorted.each do |word|
if word < smallest
still_unsorted.push smallest
smallest = word
else
still_unsorted.push word
end
end
... | true |
7d45fffb669d97ec910bd1c94a5642a74662af5e | Ruby | julroche/final_project | /app/helpers/events_helper.rb | UTF-8 | 1,119 | 3.140625 | 3 | [] | no_license | module EventsHelper
require 'date'
def create_event_time(date, hour, minute)
time_string = "#{date} #{hour}:#{minute}:00"
event_time = DateTime.strptime(time_string, '%m/%d/%Y %H:%M:%S').in_time_zone
return event_time
end
# method to create an array of event times. Will use this to create array of sta... | true |
85682099659b79735a92af2a30cfcea618607383 | Ruby | fixdocker/juniorjobs | /app/utilities/time_utility.rb | UTF-8 | 518 | 2.921875 | 3 | [] | no_license | # frozen_string_literal: true
# TODO: documentation is missing for this class
# We should consider addig some documentation here
module TimeUtility
module_function
def today
Date.today
end
def yesterday
Date.today - 1.day
end
def last_week
Date.today - 1.week
end
def last_month
Date... | true |
ec725a94cdee45bc7ff614179d24d84d80016430 | Ruby | LendingHome/flood_on_rails | /app/models/game.rb | UTF-8 | 1,454 | 3.375 | 3 | [] | no_license | class Game
@@total_moves = 24
@@score_decrement = 38
attr_reader :board
attr_reader :state
attr_reader :moves_remaining
attr_reader :score
attr_reader :size
def initialize(size=nil, board_id=nil)
if board_id
board_params = SavedGame.find_by_id(board_id)
size = board_params[:size] unless !(board_params... | true |
9d0cbe684b50a478390be9724a309bc9bd19fed0 | Ruby | JamesClonk/ruby-sensei | /04_code_blocks/03_merge.rb | UTF-8 | 397 | 3.3125 | 3 | [] | no_license | # merge hashes
puts "\n***********************************\nmerge hashes"
h1 = {:name => 'Ruby', :version => '2.1.5'}
h2 = {:name => 'Ruby', :version => '2.2.0'}
h3 = {:name => 'Go', :version => '1.4'}
puts h1.merge(h2), h2.merge(h1)
h1.merge!(h2).merge!(h3)
puts h1
puts h2.merge(h1) { |_, _, n| n }
puts h2.merge(h1) ... | true |
1e4cfeee80cc518084989041a931f5a344f6bdf0 | Ruby | kendras05/control_flow_game | /while.rb | UTF-8 | 197 | 3.609375 | 4 | [] | no_license | puts "Game on!"
playing_game = true
while playing_game
number = Random.rand(10)
guess = gets.chomp.to_i
if number == guess
playing_game = false
end
end
puts "game over!"
| true |
c79d277969e73d3b0f3743996751351a3b621872 | Ruby | liamkillion/Active-Record-Association-Methods-web-100817 | /app/models/artist.rb | UTF-8 | 291 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Artist < ActiveRecord::Base
has_many :songs
has_many :genres, through: :songs
def get_genre_of_first_song
self.songs[0].genre
end
def song_count
self.songs.count
end
def genre_count
songs=self.songs.uniq! {|song| song[:genre_id]}
songs.count
end
end
| true |
aeda07defd42ae93070082ab1cbc86b7232c1d8a | Ruby | TheRealSavi/GRCC-CIS-123-TKoets-HW-2019-2020 | /GibbonsJ-ch3/Ch3Ex5.rb | UTF-8 | 251 | 3.71875 | 4 | [] | no_license | print "What is your height in inches:"
inches = gets.chomp().to_f
print "What is your weight in pounds:"
pounds = gets.chomp().to_f
cm = inches * 2.54
m = cm * 100
g = pounds * 453.59
kg = g * 1000
bmi = kg / m ** 2
puts "Your bmi is " + bmi.to_s
| true |
69c126df7783b7648f268b0f607cac22f0cc97d5 | Ruby | bobbiewang/aroma_rcm | /app/models/saled_store_product_item.rb | UTF-8 | 580 | 2.640625 | 3 | [] | no_license | class SaledStoreProductItem < ActiveRecord::Base
validates_numericality_of :sale_order_id, :store_product_item_id, :item_price, :quantity
belongs_to :sale_order
belongs_to :store_product_item
def self.total_saled_price
SaledStoreProductItem.find(:all).inject(0) { |sum,i| sum += i.total_price }
end
de... | true |
1dcb8782ee2134988392eb74428a80217c37067c | Ruby | fuumashirou/Clon_Panel | /app/models/stores/category.rb | UTF-8 | 743 | 2.515625 | 3 | [] | no_license | class Category
include Mongoid::Document
embedded_in :store
field :type, type: String
field :name, type: String
field :description, type: String
field :items, type: Integer, default: 0
before_validation :complete
after_save :change_items_category, if: Proc.new { |i| i.name_changed?... | true |
2ee659a14ccfdc01c80edbf87c27850f930425f6 | Ruby | timgaleckas/itunes | /lib/itunes/client/additional_metadata.rb | UTF-8 | 858 | 2.515625 | 3 | [
"MIT"
] | permissive | module ITunes
module AdditionalMetadata
PEOPLE_TYPES=%w(Actor Director Artist Producer Screenwriter)
def read_people(people_type, html)
raise ArgumentError, "you must pass #{PEOPLE_TYPES.join('|')}" unless PEOPLE_TYPES.include?( people_type )
nodes = html.xpath("//div[starts-with(@metrics-loc,'Tit... | true |
4babdaeb1d191c422c1a62f50b443e2468765a05 | Ruby | kilometro28/learningruby | /11_hashes/10_retrieves_keys_or_values_from_hash_as_array.rb | UTF-8 | 202 | 3 | 3 | [] | no_license | # retrieve keys or values from hash as array
shopping_list = {bananas: 5, oranges: 10,
carrots: 3, crackers: 5}
p shopping_list.keys
p shopping_list.values
p shopping_list.values.uniq
| true |
5b05b742c2d9ff49b4c6603454ed0dbc15ae42a5 | Ruby | Lawrence-de-Varga/Launch-School-Programming-Intro | /intro_to_programming/flow_control/ex3.rb | UTF-8 | 270 | 4 | 4 | [] | no_license | puts "Please enter a number from 0 to 100."
number = gets.chomp.to_i
ans = case
when number > 0 && number < 50
"Your number is between 0 and 50."
when number > 50 && number < 100
"Your number is between 50 and 100."
else
"Your number is over 100."
end
puts ans
| true |
d46293ff2a890f93d5d9f2857dace8e7ea7d4dee | Ruby | ejgann/mass-assignment-dc-web-102819 | /lib/person.rb | UTF-8 | 585 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Person
attr_accessor :name, :birthday, :hair_color, :eye_color, :height, :weight, :handed, :complexion, :t_shirt_size, :wrist_size, :glove_size, :pant_length, :pant_width
def initialize(attributes)
attributes.each {|key, value| self.send(("#{key}="), value)}
# iterates using "each" and th... | true |
078c10336c9267895773505d4ce625642dc5346a | Ruby | nobuoka/ruby-OAuthSimple | /lib/oauth_simple/helper_functions.rb | UTF-8 | 2,559 | 2.671875 | 3 | [] | no_license | # coding : utf-8
require 'openssl'
module OAuthSimple
module HelperFunctions
# ====================
# MODULE FUNCTIONS
# ====================
module_function
# nonce 用にランダムに文字列生成するメソッド
NONCE_STRING_SOURCE = ('a'..'z').to_a() + ('A'..'Z').to_a() + ('0'..'9').to_a()
def create_nonce_str( length = 16 )... | true |
fa9ecf04c858a4fcc2cc103634c9b60f047a3315 | Ruby | marcomartinez10/phase-0-tracks | /ruby/soccer.rb | UTF-8 | 2,921 | 3.1875 | 3 | [] | no_license | ## 8.5 ASSIGNMENT
require 'sqlite3'
db = SQLite3::Database.new("soccer.db")
puts "Welcome to SOCCER app, here you can join soccer matches
5 vs 5 in Brooklyn, Manhattan or Queens! Join before the slots are full!!"
puts "Please enter your name!"
name = gets.chomp
puts "------SLOTS AVAILABLE---------- "
slots_availab... | true |
5e181562a6a00c4dd844053a22dcde74d93ef4ed | Ruby | aub/spritz | /app/drops/base_drop.rb | UTF-8 | 3,479 | 2.671875 | 3 | [
"MIT"
] | permissive | class BaseDrop < Liquid::Drop
class_inheritable_reader :liquid_attributes
write_inheritable_attribute :liquid_attributes, [:id]
class_inheritable_reader :liquid_associations
write_inheritable_attribute :liquid_associations, []
attr_reader :source
# There are two helpers being defined here. The first is... | true |
e6fae64aa2d7e3a51b2474f22e65481827e0af47 | Ruby | cavi21/conekta-ruby | /lib/conekta/error.rb | UTF-8 | 2,448 | 2.53125 | 3 | [
"MIT"
] | permissive | module Conekta
class Error < StandardError
attr_reader :message, :type, :log_id, :details, :data
def initialize(options={})
@type = options["type"]
@log_id = options["log_id"]
if options["details"]
@details = options["details"].collect{|details|
Conekta::ErrorDetails.n... | true |
b5ea667b9da1baa56d63356d5eb03c2263e5afe0 | Ruby | GandT/learning | /Ruby/season2/p058/main.rb | UTF-8 | 250 | 3.421875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
=begin
2017.5.3
数え上げループ
=end
10.times{ |i|
print "pa", i
}
puts ""
0.upto(20){ |i|
print "pe", i
}
puts ""
15.downto(1){ |i|
print "pi", i
}
puts ""
20.step(100,3){ |i|
print "po", i
}
puts ""
| true |
7c7cddd64b3d2201177f7a0d88095bd81e78d239 | Ruby | MaggieHibberd/fizz_buzz_ruby | /spec/fizz_buzz_spec.rb | UTF-8 | 1,884 | 3.640625 | 4 | [] | no_license | require 'fizz_buzz'
describe '#fizzbuzz' do
it 'will take the number 3 and return the word "Fizz"' do
expect(fizz_buzz(3)).to eq [1, 2, "Fizz"]
end
it 'will take the number 6 and return the word "Fizz"' do
expect(fizz_buzz(6)).to eq [1, 2, "Fizz", 4, "Buzz", "Fizz"]
end
it 'will take the number 9 ... | true |
13cf8f7a2ffc8770795bef5f34d94e331ce110f0 | Ruby | MavenThought/ranyard | /app/helpers/conferences_helper.rb | UTF-8 | 502 | 2.625 | 3 | [] | no_license | module ConferencesHelper
def format_days(conf = @conference)
return "" unless conf.start && conf.finish
head = conf.days[0..-2].map { |d| d.day }.join(', ')
month = conf.days.first.strftime("%B")
year = conf.days.first.year
"#{month} #{head} & #{conf.days.last.day} #{year}"
end
def format_... | true |
f7597e1fb24f784f19597ea59176d5c12080ca4f | Ruby | lllverb/money | /spec/models/user_spec.rb | UTF-8 | 1,788 | 2.5625 | 3 | [] | no_license | require 'rails_helper'
describe User do
describe '#create' do
it "ニックネーム, メアド, パスワード, 確認があれば通る" do
user = build(:user)
user.valid?
expect(user).to be_valid
end
it "ニックネーム無しでは通らない" do
user = build(:user, nickname: "")
user.valid?
expect(user.errors[:nickname]).to includ... | true |
31901096d0ae9651cedf287bedfbf2f5fa9c51df | Ruby | MotokiMiyahara/03_sort | /sort_range.rb | UTF-8 | 6,380 | 3.484375 | 3 | [] | no_license | #!/usr/bin/env ruby
# vim:set fileencoding=utf-8 ts=2 sw=2 sts=2 et:
# 使い方:
# ./sort_range.rb {filename}
# {filename}から整数列データを読み込み、ソートの行われていない範囲を出力します
# なお、{filename}を省略した場合は、標準入力からデータを読み込みます
#
# 使用例:
# ./sort_range.rb data/input_case_1.txt
#
# 速度テスト:
# ./sort_range.rb --test {filename}
# 速度テストを行い、結果を... | true |
a0f02de39d5e278dfe4473084a592ffbe2574b8d | Ruby | leemiyinghao/NCU-CSIE-2014-LinerAged | /HW2/HW2-1.rb | UTF-8 | 1,510 | 3.203125 | 3 | [] | no_license | #!/usr/bin/ruby
def det(arr) #YES,in the dirty recursive way!!
arr.length.times do |i|
arr[0].length.times do |j|
arr[i][j] = Float(arr[i][j])
end
end
if arr[0].length == 1
return 0
elsif arr[0].length == 2
return (arr[0][0]*arr[1][1] - arr[0][1]*arr[1][0])
else
d = 0
temp = Arr... | true |
8da10f800fe2b211b5575de13e50e63b68ab8678 | Ruby | andrebras/food-delivery-april-25 | /app/repositories/customer_repository.rb | UTF-8 | 415 | 2.765625 | 3 | [] | no_license | require_relative 'base_repository'
class CustomerRepository < BaseRepository
def build_row_header
['id', 'name', 'address']
end
def build_row(customer)
[customer.id, customer.name, customer.address]
end
def build_instance(row)
customer_attributes = {
id: row[:id].to_i,
name: row[:na... | true |
ce92012f1dbec5efa006179bdc49f832fbfb2bb2 | Ruby | thebravoman/software_engineering_2014 | /class002_homework/Vladimir_Yordanov/Vladimir_Yordanov_1.rb | UTF-8 | 389 | 3.21875 | 3 | [] | no_license | homeworks = Array.new
i = 0
counter = 0
#-- Writing the number of the programs in an array --
Dir.glob("/path/**/*.*") do |my_text_file|
#splitting names by "_" and "."
s = my_text_file.split(/_/)
homeworks[i] = s.last.split(/\./).first
i = i + 1
end #end Dir.glob
#printing the results
for counter in 1..19
put... | true |
e147fe01c5fe75dd6e291715ffae08bdb6f63b2f | Ruby | SandoBP13049/solver_bp13049 | /solver/arai/src/csp/parser.rb | UTF-8 | 29,917 | 2.921875 | 3 | [] | no_license | #!/usr/bin/ruby
# -*- coding: utf-8 -*-
require 'set'
#require 'jcode'
#$KCODE="u"
#coding:utf-8
#
# テキスト表現された制約充足問題の字句解析器、構文解析器のモジュール
#
module RS::CSP::Text
end
#
# @abstract ビジターパターンのビジタークラス。サブクラスで{#visit}を実装する。
# @see RS::CSP::Text::Acceptor
#
class RS::CSP::Text::Visitor
public
# 引数のオブジェクトのacceptメソッドを呼ぶようにサブク... | true |
82fad27d9176bf43f2f054bd856545df6303624e | Ruby | scharlau/RubyBasics | /03/string_spec.rb | UTF-8 | 680 | 3.390625 | 3 | [] | no_license | # spec file for ruby tests
# find more on string at http://ruby-doc.org/core/
require 'hello'
describe "some ruby string methods" do
it "should greet me" do
Hello.new.greeting.should == "hello there"
end
it "should tell me how many characters there are" do
Hello.new.number("hello world").should == 11... | true |
6f8fc05e05595130d2a5ace7160773cbb034101e | Ruby | beausievers/Compositions | /distance-etude-2/de2.rb | UTF-8 | 30,837 | 3.03125 | 3 | [] | no_license | require '../MM/mm.rb'
require '../PCSet/pcset.rb'
require '../random.rb'
include Math
def choose(n, k)
return [[]] if n.nil? || n.empty? && k == 0
return [] if n.nil? || n.empty? && k > 0
return [[]] if n.size > 0 && k == 0
c2 = n.clone
c2.pop
new_element = n.clone.pop
choose(c2, k) + append_all(choose(c... | true |
f95dce0b5b7158027aeb927891c7b88e6c753257 | Ruby | Taishawnk/ruby-class-variables-and-class-methods-lab-online-web-pt-120919 | /lib/song.rb | UTF-8 | 927 | 3.109375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require"pry"
class Song
@@count = 0
@@genres = []
@@artists = []
attr_accessor :name,:artist,:genre
def initialize(name,artist,genre)
@name = name
@artist = artist
@genre = genre
@@count +=1
@@genres << genre
@@artists << artist
end
def self.count
@@count
end
def self.... | true |
77ed72af37754782262299bbef8269025e0e343a | Ruby | cIvanrc/problems | /testing/ruby_testing/example_rspec_tdd/spec/matchers/equality/equality_spec.rb | UTF-8 | 613 | 2.828125 | 3 | [] | no_license | describe "Matchers of Equality" do
before :each do
puts "BEFORE each test"
end
after :each do
puts "AFTER each"
end
it "#equal - Test if it is the same object" do
x = "Ruby"
y = "Ruby"
expect(x).not_to equal(y)
expect(x).to equal(x)
end
it "#be - Test if it is the same object" ... | true |
a473ce39512a6a5f6b103233f8031314a748b577 | Ruby | meltar/Ruby-Euler-Problems | /2013/Problem7.rb | UTF-8 | 388 | 4.28125 | 4 | [] | no_license | # By listing the first six prime numbers 2, 3, 5, 7, 11, and 13, we
# can see that the 6th prime is 13.
#
# What is the 10,001st prime number?
require 'prime'
def prime_index index
count = 0
result = 0
Prime.each do |prime|
count += 1
result = prime
break if count == index
end
result
end
#value... | true |
e6dc7f0ce31d1e4652a3065ff3fb8fae15322bb6 | Ruby | liambarstad/Credit-check | /Homework/loop_testprgrm.rb | UTF-8 | 937 | 4 | 4 | [] | no_license | require './loop_challenge.rb'
#TEST PROGRAM:
puts "How many people would you like in this group?"
answer1 = gets.chomp.to_i
group = Group.new(answer1)
group.init_group
answer2 = "y"
while answer2 == "y" || answer2 == "Y"
puts "Would you like to add anyone else? (y/n)"
answer2 = gets.chomp
if answer2 == "y" || ans... | true |
23e9fc201d72a6b1fede3fe80d3c56c394a7774f | Ruby | ishowta/chatbot | /add_resource.rb | UTF-8 | 1,234 | 2.546875 | 3 | [] | no_license | #!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'xcodeproj'
# グループを作ってその中にファイルへの参照を追加する
def add_file_refs(xcproj, parent_group, group_name, path)
group = xcproj.new(Xcodeproj::Project::Object::PBXGroup)
group.name = group_name
parent_group << group
# next unless File::exists?(path) && File::ftype(path) =... | true |
d3d43923ec1bd9e61163483791ed7d4a40f76a5e | Ruby | countercheck/Solomon | /lib/complex_split.rb | UTF-8 | 2,193 | 3.296875 | 3 | [] | no_license | class ComplexSplit
def initialize preferences
@preferences_a = preferences[:preferences_a]
@preferences_b = preferences[:preferences_b]
@available = preferences[:preferences_b].dup
@stage = 0
end
def results
start unless @results
return @results
end
def start
@results = {prefe... | true |
8a80b8f14be5f38c28495155b0be2646b094a0d8 | Ruby | dodycode/belajarRuby | /aritmatika.rb | UTF-8 | 155 | 3.109375 | 3 | [] | no_license | pangkatTiga = 2**3
puts pangkatTiga
puts "Apakah hasilnya genap? Hasil = #{pangkatTiga.even?}"
puts "Apakah hasilnya ganjil? Hasil = #{pangkatTiga.odd?}" | true |
4481cea701134969460a9ff0ebe7728a2fae991e | Ruby | alaibe/marilyne | /lib/marilyne/presenter.rb | UTF-8 | 394 | 3 | 3 | [
"MIT"
] | permissive | module Marilyne
# == Base presenter
class Presenter
attr_reader :template, :object, :objects
# params:
# * <tt>:template</tt> - Template where you frome
# * <tt>:objects</tt> - All presented objects
def initialize(template, *objects)
@template = template
objects.length ... | true |
ebba748c8bb479908211b3df690dfe3f1668e2ed | Ruby | Mioratahina/lib | /ai.rb | UTF-8 | 658 | 3.609375 | 4 | [] | no_license | puts "Bienvenue dans le jeu d'ascensseur"
print "Entrer le nombre d'etage que vous voulez jouer : "
n = Integer(gets.chomp)
pos = 1
print "Appuiez sur j pour jouer : "
a = gets.chomp
while a == "j"
x = rand(1..6)
if pos != n
case x
when 5,6
pos += 1
puts " \n vous êtes dans le #{pos} étage \n "
when 1
... | true |
15aa30b3206648d60521f45a2d9efb1cb9e1975a | Ruby | wwood/rarff | /lib/rarff.rb | UTF-8 | 9,380 | 2.875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # = rarff
# This is the top-level include file for rarff. See the README file for
# details.
################################################################################
# Custom scan that returns a boolean indicating whether the regex matched.
# TODO: Is there a way to avoid doing this?
class String
def my_sc... | true |
90ccce4b69d5b8a2bb0e705f24acb94f3ee624b7 | Ruby | Iron-Ham/code-challenge | /week019--knight-probability/solution_yz.rb | UTF-8 | 911 | 3.265625 | 3 | [] | no_license | def knight_probability(n, k, r, c)
@max = n - 1
@moves = [[-2,-1],[-1,-2],[-2,1],[-1,2],[1,-2],[2,-1],[2,1],[1,2]].map { |move| move.freeze }.freeze
@numerator = 0
@valid_moves_cache = {}
@failures_cache = {}
numerator = failure_count(k, r, c)
puts "1 - #{numerator} / #{8**k}"
1 - numerator.fdiv(8**k)... | true |
52998aedd488b72161744d5a37c1290d9fe45fee | Ruby | vatadepalli/ruby | /conditionals.rb | UTF-8 | 687 | 4.59375 | 5 | [] | no_license | number = 10
# if, elseif, else
if number.between?(1, 10)
puts "The number is between 1 and 10"
elsif number.between?(11, 20) # can have many elseif
puts "The number is between 11 and 20"
else # else not mandatory
puts "The number is bigger than 20"
end
# if
number = 5
puts "The number is odd." if number.odd?
#... | true |
755d3d7f00866902726baf5a45c301bc83f14328 | Ruby | deanwilson/puppet-ip_in_range | /spec/functions/ip_in_range_spec.rb | UTF-8 | 1,267 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | require 'spec_helper'
describe 'ip_in_range' do
# Basic functionality tests
#################################################
it 'returns true when the ip is contained in the range' do
is_expected.to run.with_params('192.168.100.12', '192.168.100.0/24').and_return(true)
end
it 'returns true when the ip ... | true |
b7c8d8fd19ebb629af77570a584d898fb5c74864 | Ruby | k5342/tskserver-notification-bot | /events.rb | UTF-8 | 1,167 | 2.5625 | 3 | [] | no_license | require_relative './serverinfo'
module Events
class StandardEvent
def initialize(**kwargs)
@events = kwargs
end
private
def _access_member(key)
@events[key]
end
end
class MinecraftServerEvent < StandardEvent
def initialize(server:, last_checked_at:, infos: {}, **kwargs)
... | true |
3dcefd396d8b2da94b8f1064c08f7b1c78d786a0 | Ruby | stevenspiel/stock_trends | /app/apis/mod.rb | UTF-8 | 2,360 | 2.703125 | 3 | [] | no_license | class Mod
require 'open-uri'
require 'net/http'
def new
@api = Api.market_on_demand
end
# def initialize(normalized: false, number_of_days: 1, data_period: 'Minute', start_date: nil, end_date: nil, data_interval: 5, symbol: nil, type: 'price', params: 'sma')
def initialize(normalized: nil, number_of_d... | true |
203d16f94086aaafffc61e306145883776fee3f1 | Ruby | mutle/fu2 | /lib/fubot/commands/fubot_emoji.rb | UTF-8 | 1,170 | 2.703125 | 3 | [
"MIT"
] | permissive | Fubot.command /emojis/i do
def help
["emojis", "List custom emojis"]
end
def call(bot, args, message)
emojis = CustomEmoji.all.map { |e| [e.name.downcase, ":#{e.name.downcase}:", e.url].join(" ") }.join("\n")
bot.reply "All custom emojis: \n\n#{emojis}"
end
end
Fubot.command /emoji ([^ ]+) at ([^ ... | true |
b3153118866fd13f2050657ef6be4323653376f0 | Ruby | rhetprieto/geotix-app-template | /server.rb | UTF-8 | 7,643 | 2.625 | 3 | [] | no_license | require 'sinatra'
require 'dotenv/load' # Manages environment variables
require 'json'
require 'openssl' # Verifies the webhook signature
require 'logger' # Logs debug statements
require 'pry' if ENV.fetch('RACK_ENV'){'development'} == 'development'
# This is template code to create a Geotix App server.
# You can read ... | true |
fb6aaf2a920165548fa0bb3964d719ed78154723 | Ruby | shaliko/acts_as_random_id | /lib/acts_as_random_id/model_additions.rb | UTF-8 | 1,101 | 2.609375 | 3 | [
"MIT"
] | permissive | module ActsAsRandomId
module ModelAdditions
def self.included(base)
base.send :extend, ClassMethods
# Handles a generate unique ID
# @param [Hash] options. The default format is "!{:field => :id}".
# @return [Integer, String] the value of unique ID.
def ensure_unique_id(options)
... | true |
104f7889dec35ba78dde59756634d9ea700d232c | Ruby | chalt0319/playlister-sinatra-v-000 | /app/models/artist.rb | UTF-8 | 389 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Artist < ActiveRecord::Base
has_many :songs
has_many :genres, through: :songs
def slug
name = self.name
split = name.split(" ")
downcased = []
split.map {|word| downcased << word.downcase}
joined = downcased.join("-")
joined
end
def self.find_by_slug(slug)
Art... | true |
0d4ea37456a4e8362d851bb21e1ca5e4492bd6a5 | Ruby | max-codeware/SymDesc | /test/test-Int.rb | UTF-8 | 2,821 | 3.140625 | 3 | [
"MIT"
] | permissive | require_relative "test.rb"
class TestInt < Test::Unit::TestCase
def setup
@i = Int.new 5
end
def test_new
assert @i.is_a?(Int), "Wrong initialization of SymDesc::Int"
assert @i.frozen?, "SymDesc::Int objects are expected to be frozen"
assert_equal @i, 5, "SymDesc::Int initialized with a wrong va... | true |
7e7cc91c50f2b5473b1474060e021d41bd1af87e | Ruby | ekuiter/youplay | /app/lib/stats_colors.rb | UTF-8 | 628 | 3.046875 | 3 | [] | no_license | module StatsColors
@i = -1
def self.reset
@i = -1
end
def self.color(transparency = 1)
return colors(transparency)[0] if @i == -1
colors(transparency)[@i]
end
def self.next_color(transparency = 1)
@i < colors.length - 1 ? @i += 1 : @i = 0
color(transparency)
end
def self.generate... | true |
5ce07f8b82c9485a1c2f9f9033400bb7c45a71a2 | Ruby | mbrown78/LS_ruby_basics | /return/BLD_part4.rb | UTF-8 | 131 | 3.1875 | 3 | [] | no_license | def meal
puts 'Dinner'
return 'Breakfast'
end
puts meal
#Dinner -- output returns nil
#Breakfast -- method returns breakfast | true |
0065a9c18961dc93303d053446341046f3deb815 | Ruby | robfors/quack_concurrency | /spec/queue_spec.rb | UTF-8 | 6,649 | 3.0625 | 3 | [
"MIT"
] | permissive | require 'quack_concurrency'
describe QuackConcurrency::Queue do
describe "::new" do
context "called with no arguments" do
it "should return a Queue" do
queue = QuackConcurrency::Queue.new
expect(queue).to be_a(QuackConcurrency::Queue)
end
end
end
describe "#clear" do
... | true |
6fcd0cf73adea388b4d5492f8ed08e5770239317 | Ruby | ryancoopersmith/biblioculture | /spec/features/user_adds_books_spec.rb | UTF-8 | 2,360 | 2.5625 | 3 | [] | no_license | require 'rails_helper'
feature 'user adds books' do
# As a user that would like to see the fair prices for books
# I should be able to add multiple books at once
# So that I can quickly make a decision about what price to sell/buy a book at
#
# [X] I should be able to add multiple books at a time either by t... | true |
d3b1445d659f6c7d5ecbd6dc4beda16e76ef0b1a | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/08d4867533de446fa2132c5d476e0915.rb | UTF-8 | 4,044 | 3.875 | 4 | [] | no_license | # ======================================================================
# NITPICKERS README
# ======================================================================
#
# This section contains what I was thinking and where I know I could
# use more help. Obviously if you see somewhere else an improvement
# can be made, ... | true |
0c131e588cdb6630ab404e42e4550808b0ce2874 | Ruby | takatoshiH/AtCoder | /ABC/ABC100B.rb | UTF-8 | 113 | 2.828125 | 3 | [] | no_license | d, n = gets.chomp.split(" ").map(&:to_i)
n == 100 ? answer = 101 * 100 ** d : answer = n * 100 ** d
puts answer | true |
20638ec3f5223ab3edde614c2f0feb0359730fae | Ruby | krzyszti/my_projects | /Ruby/excercises/isomorphic.rb | UTF-8 | 893 | 4.0625 | 4 | [
"MIT"
] | permissive | ''' Example from https://leetcode.com/problems/isomorphic-strings/
Given two strings s and t, determine if they are isomorphic.
Two strings are isomorphic if the characters in s can be replaced to get t.
All occurrences of a character must be replaced with another character while preserving the order of characters. ... | true |
bc061ff6f3e7f3793ba470a7331d93945d618b07 | Ruby | dgrebenyuk/courses | /Ruby/Lecture1/hw_results/student_6.rb | UTF-8 | 656 | 3.234375 | 3 | [] | no_license | def work1
size_array = 4
summa = 0
my_array = Array.new(size_array){Array.new(size_array){rand(-10..10)}}
my_array.each do |first|
first.each do |second|
if 0 > second
puts second
summa += second
end
end
end
puts 'Summa: ' + summa.to_s
end
def work2
... | true |
07878f35a372c36d64674e7f76ac5c4c8bee3f37 | Ruby | 9point6/microservices-training | /cuke/features/stubs/stub_base.rb | UTF-8 | 477 | 2.5625 | 3 | [] | no_license | module StubHelpers
def class_name_to_lowercase(class_name)
class_name.to_s.partition('::').last.gsub(/([a-z])([A-Z])/, '\1_\2').downcase
end
def initialize_class(class_name, caller_method = nil)
caller_method ||= class_name_to_lowercase(class_name)
class_eval %([def #{caller_method}
... | true |
409d38c18f425d38882fcf0fbeb242b4de8742ac | Ruby | mikelondon/phase-1 | /week-6/credit-card/my_solution.rb | UTF-8 | 3,307 | 4.21875 | 4 | [
"MIT"
] | permissive | # Class Warfare, Validate a Credit Card Number
# I worked on this challenge with Alivia Blount.
# I spent 1.25 hours on this challenge.
# Pseudocode
# Initialize Method (class)
# Input: 16 digit number (no spaces) integer type no float
# Output: return object
# Steps: check if input is 16 digits long
#IF valid th... | true |
bca21f361ae95d61b0c5d098f5918bdb397e6f69 | Ruby | benjamintillett/battleships | /spec/cell_spec.rb | UTF-8 | 801 | 3.03125 | 3 | [] | no_license | require 'cell'
describe Cell do
let(:ship) { double :ship}
let(:water) { double :water }
let(:cell) { Cell.new(water) }
it "Can intitalize with water" do
expect(cell.content).to eq water
end
it "Is able to add a ship" do
cell.add_ship!(ship)
expect(cell.content).to eq ship
end
it "the contents of... | true |
7e84498519aade8fa71c2c7a4d96c9166cca261f | Ruby | kyleburton/twilio-in-ten-minutes | /newflow/lib/newflow/state.rb | UTF-8 | 1,604 | 2.875 | 3 | [] | no_license | module Newflow
class State
attr_reader :name, :transitions
def initialize(name, opts={}, &transitions_block)
#logger.debug "State.initialize: name=#{name} opts=#{opts.inspect}"
@name = name
@opts = opts
@is_start = opts[:start]
@is_stop = opts[:stop]
@on_entry = T... | true |
9ba6e8f4320a0f20e301800ae65d6b1a639f6fd6 | Ruby | hiroponz/triangle | /triangle.rb | UTF-8 | 794 | 3.875 | 4 | [] | no_license | class Triangle
attr_reader :sides
CATEGORY_TO_SAY = {
invalid: "三角形じゃないです><",
regular: "正三角形ですね!",
isosceles: "二等辺三角形ですね!",
scalene: "不等辺三角形ですね!",
}
def initialize(*sides)
@sides = sides.map(&:to_f).sort
end
def is_valid?
return false unless @sides.length == 3
return false if ... | true |
6be4ff7c4f9bdb1a5e3b2d00116fd3fec405d0a5 | Ruby | darrenclark/scanty | /lib/post.rb | UTF-8 | 1,098 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'markdown'
class Post < Sequel::Model
unless table_exists?
set_schema do
primary_key :id
text :title
text :body
text :slug
text :tags
timestamp :created_at
end
create_table
end
def url
"/#{slug}"
end
def full_url
Blog.url_base.gsub(/\/$/, '') + url
end
def body_html
to_h... | true |
0f324f5db860e0482b62a3844f4d133a9d4bf80f | Ruby | robbertkl/pxcbackup | /lib/pxcbackup/repo.rb | UTF-8 | 816 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'shellwords'
require 'pxcbackup/backup'
module PXCBackup
class Repo
attr_reader :path
def initialize(path, options = {})
@path = path
@which = PathResolver.new(options)
end
def backups
backups = []
Dir.foreach(@path) do |file|
path = File.join(@path, file)
... | true |
b755d42e9341a187454e58d4c8d40ebdbb1bdd3c | Ruby | kudoku/Learning-projects | /conways_game_of_life/carlos_CGOL_03.rb | UTF-8 | 1,394 | 4.09375 | 4 | [] | no_license | # carlos_CGOL_03.rb
# 03. Redisplay a new Matrix if user wants to
class Matrix
def initialize
@rows = 10
@columns = 10
@matrix_data = [] # Initialize just to know we will use this variable
end
def fill_with_data
@matrix_data = []
(1..@rows).each do |row_number|
new_row = []
(1.... | true |
1921fa5048491c2a072b7dfd411cf4034b95feee | Ruby | Nithinkrishna1/resume_simple_exporter | /csv.rb | UTF-8 | 145 | 2.53125 | 3 | [] | no_license | require 'csv'
module Csv
def csv(format,subjects,marks)
CSV.open("file.csv","wb") do |csv|
csv << subjects
csv << marks
end
end
end
| true |
d25c5a8c4a159694f41514ddacebbe793c080f6f | Ruby | waihon/studio_game | /22-distribution/lib/games/clumsy_player.rb | UTF-8 | 910 | 3.375 | 3 | [
"LicenseRef-scancode-other-permissive"
] | permissive | #####
# Pragmatic Studio Ruby Programming
# 22 - Distribution
# This version has changes:
# 1. Embed ClumbsyPlayer class within Games module.
# 2. In test code, prefix class name with Games::.
#####
require_relative 'player'
require_relative 'treasure_trove'
module Games
class ClumsyPlayer < Player
def found_tr... | true |
d142b708a39948719621c5cc60f0bc66d955d846 | Ruby | mighark/dasof | /p1/test.rb | UTF-8 | 7,970 | 3.234375 | 3 | [] | no_license | require_relative "empresa"
require_relative "pedido"
require_relative "paquete"
require_relative "reparto"
class Aplicacion
def initialize()
@@empresas = Array.new()
@@pedidos = Array.new()
@@paquetes = Array.new()
@@sinEntregar = Array.new()
@@camiones = Array.ne... | true |
fec00dc8c8e387a53bf5887bdcaf08d8f09e4ec1 | Ruby | donsalvadori/Ruby-Repo | /easy-bank-account.rb | UTF-8 | 1,050 | 3.578125 | 4 | [] | no_license |
class BankAccount
attr_reader :balance
attr_accessor :transactions
#self/class methods. Opted to use class << self notation instead of self.method()
class << self
def create_for(first_name, last_name)
@accounts ||=[]
@accounts << BankAccount.new(first_name,last_name)
end
def find_for(first_name, ... | true |
af5b8970ad788785d6bb861eb1fe2a0e0f265583 | Ruby | BrianARuff/ruby_practice | /respond_to?.rb | UTF-8 | 1,037 | 4.0625 | 4 | [] | no_license | # num = 1000
#
# p num.respond_to?("next")
# p num.respond_to?("length")
# puts "100".include?("1")
# symbol - light weight string... lacking string functionality, useful when you don't need a string object.
# p "Hello".respond_to?(:length)
# p "Hello".respond_to?(:next)
# 1_000_000.times do p "hi" end # 44 seconds... | true |
d04cf4764bf4f7bc32c3c72031ae43e28d43266e | Ruby | knapo/a9n | /lib/a9n/struct.rb | UTF-8 | 642 | 2.875 | 3 | [
"MIT"
] | permissive | module A9n
class Struct
extend Forwardable
attr_reader :data
def_delegators :data, :empty?, :keys, :key?, :fetch, :[], :[]=
def initialize(data = {})
@data = data
end
alias to_hash data
alias to_h data
def merge(another_data)
data.merge!(another_data)
end
def ... | true |
4bd487c0998cccb76f6405df31c5bd4f9655048a | Ruby | ShintaTomita/lodgeServ_app | /app/models/book.rb | UTF-8 | 700 | 2.71875 | 3 | [] | no_license | class Book < ApplicationRecord
belongs_to :user, optional: true
belongs_to :room, optional: true
validates :check_in, presence: true
validates :check_out, presence: true
validates :customers, presence: true
validate :date_before_start
validate :date_before_end
validate :number_before_customers
def date_before_start
... | true |
86704941032848b11650ff244ef1dc77e25dfa79 | Ruby | ftodoroski/ruby-oo-relationships-practice-blood-oath-exercise-nyc-web-010620 | /tools/console.rb | UTF-8 | 626 | 2.78125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative '../config/environment.rb'
require_relative '../app/cult.rb'
require_relative '../app/follower.rb'
require_relative '../app/bloodoath.rb'
def reload
load 'config/environment.rb'
end
# Insert code here to run before hitting the binding.pry
# This is a convenient place to define variables and/or set u... | true |
5bb462fe6911f8972ab5ddb5536063d743dc4c15 | Ruby | kmdsbng/graphviz_store | /www/index.cgi | UTF-8 | 1,491 | 2.53125 | 3 | [] | no_license | #!/usr/local/bin/ruby -Ku
$: << '/home/kmdsbng/graph/lib'
require 'base'
require 'db'
def make_list_content(graphs)
htmls = []
graphs.map{|item|
<<EOS
<div class="list_item">
<table>
<tr>
<td width="100">
<a href="#{item.get_url()}"><img src="#{item.get_thumbnail_url()}" width="100" heigh... | true |
c46389a976489908af979875c815005d0e7ae128 | Ruby | chayadeaver/programming-univbasics-4-square-array-online-web-prework | /lib/square_array.rb | UTF-8 | 194 | 3.40625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry'
# numbers = [1,2,3]
def square_array(numbers)
i = 0
new_numbers =[]
while i < numbers.length do
new_numbers << numbers[i]**2
i += 1
end
new_numbers
end | true |
c2623cd7738cb3b926351b3438174dc1ac990c58 | Ruby | fowlmouth/mrIRC | /examples/QuestionBot.rb | UTF-8 | 3,004 | 3.109375 | 3 | [] | no_license | #!/usr/bin/ruby
begin
require 'rubygems'
rescue LoadError
end
require 'mrIRC'
require 'george'
Database = George.new('~/Working/ircbot/QuestionBotDatabase.george',
read_only: false, comment_chars: '::')
IRC_CODES = {
'&bl;' => "\x02",
'&rs;' => "\x0F",
'&ul;' => "\x1F",
'&rv;' => "\x16"... | true |
a96dcde20e04ce82cac8616acbdd4cc124aeebf4 | Ruby | EmilyAnne39/ruby_practice | /games.rb/blackjack.rb | UTF-8 | 7,540 | 4.125 | 4 | [] | no_license | #Generally, with a class, we are creating a way to describe something. We have the general description and and then describe what the elements of
#the class will do
#For this exercise, We are going to create the various classes need for each element of blackjack. This includes the Card class, which outlines what our ... | true |
c88438768aea8642b68a0861db2b6e2873f974d0 | Ruby | reichardn/flatiron-bnb-methods-v-000 | /lib/area.rb | UTF-8 | 778 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | module Area
module ClassMethods
def highest_ratio_res_to_listings
max = -1
ans = nil
self.all.each do |c|
ratio = c.reservations.length / c.listings.length.to_f
if ratio > max
max = ratio
ans = c
end
end
ans
end
def most_res... | true |
2ec35083f386039d42395fd204895de1ad137445 | Ruby | rpereira2/REPL_game | /REPL-Game.rb | UTF-8 | 1,405 | 4.125 | 4 | [] | no_license | def doesnt_have_it
puts "he doesnt have it!, who has it?"
end
def error_message
puts "What?? Please tell me who the bartender, owner or the girl??! Im in a rush!"
end
def error_option
puts "please type YES or NO, hurry!! Im in a rush!"
choose
end
def get_name
puts "Hey! What's your name?"
@name = gets.... | true |
21cf2343e3961762ca1e65c52de8c65b27a245aa | Ruby | jshefta/citibike | /app/citi_bike.rb | UTF-8 | 487 | 2.90625 | 3 | [] | no_license | require 'json'
class CitiBike
def call(env)
request = Rack::Request.new(env)
text = request.params["text"]
station = bike_station_status(text)
[200,{},["#{station["num_bikes_available"]} bikes available"]]
end
def bike_station_status(text)
response = Net::HTTP.get(URI("https://gbfs.citibike... | true |
42766686903a82711cbf4e17470829c233f5ee5f | Ruby | snlamm/key-for-min-value-001-prework-web | /key_for_min.rb | UTF-8 | 472 | 3.703125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
require 'pry'
def key_for_min_value(name_hash)
value_array = name_hash.collect {|key, value| value}
num = 0
if value_array.size == 0
nil
else
until value_array.include?(num)
... | true |
56c84c9f48ff619fa816da90fff967934671e065 | Ruby | cjsweeten101/OdinProjects | /mastermind/player.rb | UTF-8 | 662 | 3.578125 | 4 | [] | no_license | class Player
attr_reader :code
def initialize
@code = []
end
def guess
@code = prompt_code
end
def prompt_code
input = ''
result = []
until result.all? {|n| n.is_a? Integer} && result.length == 4 && result.all? {|n| n > 0 && n <=6 }
print "Code:"
result = gets.chomp
exit if resu... | true |
0af17f519deee4caf96d7333f41c9c4ae00cf8ea | Ruby | barnabyalter/wtf-logger | /lib/wtf_logger/wtf_logger.rb | UTF-8 | 552 | 3.125 | 3 | [
"MIT"
] | permissive | require 'logger'
require 'colorize'
def logger
if defined?(::Rails)
@logger ||= Rails.logger
else
@logger ||= Logger.new(STDOUT)
end
end
def btw(message)
logger.debug(message.cyan)
end
def fyi(message)
logger.info(message)
end
def smh(message)
logger.warn(message.magenta)
end
def wtf(message)
... | true |
c617e34628dedd1977917d676cf241b83c70c831 | Ruby | restforce/restforce | /lib/restforce/concerns/verbs.rb | UTF-8 | 1,689 | 2.546875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Restforce
module Concerns
module Verbs
# Internal: Define methods to handle a verb.
#
# verbs - A list of verbs to define methods for.
#
# Examples
#
# define_verbs :get, :post
#
# Returns nil.
def define_verbs(*ve... | true |
68e71aaa73be8c6c933f3d5d290283fc493506bf | Ruby | etanb/pocketrant | /spec/helpers/sentiment_helper_spec.rb | UTF-8 | 1,130 | 2.90625 | 3 | [] | no_license | require 'spec_helper'
include SentimentHelper
describe SentimentHelper do
describe "#alchemy_general_sentiment" do
it "posts the message to the database with a sentiment score" do
dream_count = Dream.all.count
alchemy_general_sentiment("#dream I love dragons!", 1)
new_dream_count = Dream.all.c... | true |
9c77d5c801d2af6a7581c768e207e42ef4a115f5 | Ruby | Cashman1396/programming-univbasics-4-square-array-online-web-prework | /lib/square_array.rb | UTF-8 | 167 | 2.84375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def square_array(array)
squared = []
counter = 0
while counter < array.size do
squared << (array[counter] ** 2)
counter = counter + 1
end
squared
end | true |
6bec5ff02908614c1ba3d10aa8d9a3fec08d2d90 | Ruby | CosmicCosmos/SPOJ-1 | /AE00/AE00.rb | UTF-8 | 165 | 2.609375 | 3 | [] | no_license | t = gets.to_i
i = 0
sol = t
for q in 2..t do
for i in q..(t-1) do
if i*q > t
break
end
sol+=1
end
if i == q
break
end
end
puts sol
| true |
d62fda96ea05530413b740160d2b2f6eb77e5107 | Ruby | sjmog/dnd_engine | /spec/base_class_spec.rb | UTF-8 | 534 | 2.671875 | 3 | [] | no_license | require 'base_class'
describe BaseClass do
subject(:base_class) { described_class.new }
subject(:wizard) { described_class.new(:wizard, 3) }
describe '#name' do
it 'returns the class name' do
expect(wizard.name).to eq :wizard
end
it 'defaults to fighter' do
expect(base_class.name).t... | true |
d056029b2abce8e608a32939bb6624f997112128 | Ruby | daniloisr/room-scheduler | /app/models/schedule_builder.rb | UTF-8 | 210 | 2.71875 | 3 | [] | no_license | class ScheduleBuilder
# Creates a Schedule using the current weekday and hour
def self.build(user, wday, hours)
init = Week.at(wday) + hours.to_i.hours
Schedule.new(user: user, init: init)
end
end | true |
41c3d4bb3649a8dd2ce6523dd5abb1a65b7bc7a0 | Ruby | millertron/ruby-math-puzzles | /70/01_palindrome_in_dec_oct_bin.rb | UTF-8 | 383 | 4.15625 | 4 | [] | no_license | # The smallest number greater than 10 that is a palindrome in binary, decimal and octal format
num = 11
while true
if num.to_s == num.to_s.reverse && num.to_s(8) == num.to_s(8).reverse && num.to_s(2) == num.to_s(2).reverse
puts "Smallest palindrome: #{num} (decimal), #{num.to_s(8)} (octal), #{num.to_s(2)} (binary)"... | true |
ccea0845f97373696e5869b26da3abaf1431dd71 | Ruby | alu0100454741/EquipoDJ-prct12 | /lib/matrixlpp/matriz_operaciones.rb | UTF-8 | 2,836 | 3.453125 | 3 | [
"MIT"
] | permissive | require "./lib/matrixlpp/matriz.rb"
require "./lib/matrixlpp/matriz_dispersa.rb"
require "./lib/matrixlpp/matriz_densa.rb"
module Matrixlpp
class Matriz
# Permite sumar matrices (dispersas o densas) de iguales dimensiones.
# * *Argumentos* :
# - +other+: Matriz densa o dispersa. Debe ser de igual t... | true |
43e25a77a76688841a78abee0ef50b1492d868a7 | Ruby | njs2114/Euler | /Euler/Problem42.rb | UTF-8 | 1,406 | 3.75 | 4 | [] | no_license | def c_to_i(c)
case c
when 'a', 'A'
return 1
when 'b', 'B'
return 2
when 'c', 'C'
return 3
when 'd', 'D'
return 4
when 'e', 'E'
return 5
when 'f', 'F'
return 6
when 'g', 'G'
return 7
when 'h', 'H'
return 8
when 'i', 'I'
return 9
when 'j', 'J'
return 10
when... | true |
d8a0a5e4ea6876d329b32f78515a5b75012ea642 | Ruby | karthickpdy/CP | /SPOJ/acode.rb | UTF-8 | 1,016 | 3.21875 | 3 | [] | no_license | # while true
# s = gets.chomp
# break if s == "0"
# dp = [1]
# ans = nil
# s.each_char.with_index do |c,i|
# if c != "0"
# add_val = 0
# if i - 1 >= 0 && "#{s[i-1]+c}".to_i <= 26
# add_val = i - 2 >= 0 ? dp[i-2] : 1
# end
# dp[i] = dp[i-1] + add_val if i - 1 >= 0
# else
# x = "#{s[i-1]+c}"... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.