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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
6549279360f6271d934aec847b02d83badc1fe2a | Ruby | doreymiller/ruby_small_problems | /advanced_1/transpose.rb | UTF-8 | 1,234 | 4.34375 | 4 | [] | no_license | # transpose.rb
# input - an array of arrays
# output - a new array of arrays with the original 'transposed'
# algorithm -
# initialize new array a = Array.new[3][3]
# using 0.upto(array.length-1) do |array_num|
# inner loop 0.upto(array.length-1) do |index|
# set a[index][array_num] = matrix[array_num][index]
# --... | true |
f5cfc1e15b7d458a0b6ea46c1502dabe2c4a5d5d | Ruby | Bast-i1/rails-longest-word-game | /app/controllers/games_controller.rb | UTF-8 | 313 | 2.515625 | 3 | [] | no_license | class GamesController < ApplicationController
def new
@letters = ('a'..'z').to_a.sample(10)
# @games = params[:games]
# unless @games == "I am going to work"
# @answer = "I don't care, get dressed and go to work!"
# else
# @answer = 'Great!'
# end
end
def score
end
end
| true |
dbe7d4b72cf68f52216edaa33d744d9a9ddf483c | Ruby | vinzee/amurabuzz | /lib/tubesock.rb | UTF-8 | 1,922 | 2.515625 | 3 | [] | no_license | require "tubesock/version"
require "tubesock/hijack" if defined?(Rails)
class Tubesock
class HijackNotAvailable < RuntimeError
end
def initialize(socket, version)
@socket = socket
@version = version
end
def self.hijack(env)
if env['rack.hijack']
env['rack.hijack'].call
socket =... | true |
a72d803b88888027b559ec68c088bba545a1b907 | Ruby | willisaybar/sql-crowdfunding-lab-onl01-seng-pt-012220 | /lib/sql_queries.rb | UTF-8 | 3,145 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your sql queries in this file in the appropriate method like the example below:
#
# def select_category_from_projects
# "SELECT category FROM projects;"
# end
# Make sure each ruby method returns a string containing a valid SQL statement.
# SELECT
# FROM
# JOIN
# ON
# WHERE
# GROUP BY
# HAVING
# ORDER BY
# ... | true |
be05c31fd5b5b25e636a5720c416ad7eebad7e64 | Ruby | promoteinternational/konfa | /spec/konfa/autodoc/parser_spec.rb | UTF-8 | 5,923 | 2.609375 | 3 | [
"MIT"
] | permissive | $: << File.join(File.dirname(File.dirname(__FILE__)), "../support")
require 'konfa_subclasses'
require 'konfa/autodoc'
RSpec.shared_context 'parse test class' do |klass, expected_elements|
before {
@konfa_class = klass
@size = expected_elements
}
let(:instance) { Konfa::AutoDoc::Parser.new(@konfa_class... | true |
41d544fb70c3784e08358a0c7a8a757705d98a00 | Ruby | ksavietta/codeeval | /easy/happy-numbers/happy_numbers.rb | UTF-8 | 1,231 | 4.34375 | 4 | [] | no_license | # CHALLENGE DESCRIPTION:
# A happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits,
# and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1.
# Those numb... | true |
9ac61e9c67a7db29cf3e4681c2f9b97aa3072e36 | Ruby | byGeorge/npc-generator | /app/models/appearance.rb | UTF-8 | 663 | 3.484375 | 3 | [] | no_license | class Appearance < ActiveRecord::Base
#picks 1-3 blurbs from the database to make the character more interesting
def self.generate
blurb = Array.new
blurb.push(Appearance.all.sample)
i = 0
while i < rand(0..2) do
add = Appearance.all.sample
#makes sure two blurbs from the same category aren't added to... | true |
32bbdacdfe5f7b74cfe842031083ec8a17a21b87 | Ruby | Keisuke-Awa/algorithm | /atcoder/agc021/a.rb | UTF-8 | 108 | 3.078125 | 3 | [] | no_license | n = gets.to_i
max = n.digits.sum
(1..n).each do |i|
max = i.digits.sum if i.digits.sum > max
end
puts max | true |
38925fff4d299d95c4d75e5245c339a961a873b9 | Ruby | boaromayo/pagr | /scripts/window/Window_TutorialHeader.rb | UTF-8 | 1,921 | 2.546875 | 3 | [] | no_license | class Window_TutorialHeader < Window_Base
# ----------------------------
attr_accessor :tutorial
# ----------------------------
def initialize
super(256, 0, 384, 64)
self.contents = Bitmap.new(width - 32, height - 32)
@tutorial = 0
self.opacity = 0
refresh
end
# ----------------------------
def refresh
self... | true |
65a24b3addc643d50b20f664ef354b72370c8174 | Ruby | rafaj777225/Cursocodeacamp | /Pre-Work/sumaVectores.rb | UTF-8 | 326 | 3.625 | 4 | [] | no_license | =begin
Suma de Valores
Define una variable y asígnale un arreglo de números.
Crea una estructura de control iterativa que permita
imprimir la suma de cada número del arreglo más 5.
=end
arreglo=[5,8,1,4,2,7,6]
#el each funciona como el for para recorrer cada valor del array
arreglo.each do |z|z+=5
p z
en... | true |
f9f2f23f6393bee4e86d6723eb7a1987f22396af | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/518e9fa315b449dd93dc3b41c675ab66.rb | UTF-8 | 250 | 3.625 | 4 | [] | no_license | class Hamming
def self.compute(strand1, strand2)
hamming_sum = 0
i = 0
length = [strand1.length, strand2.length].min
while i < length
hamming_sum += 1 if strand1[i] != strand2[i]
i += 1
end
hamming_sum
end
end
| true |
1e9c5c8211d8429ea708199e561fd21fe05b6a51 | Ruby | rdormer/yanbi-ml | /lib/bayes/bayes.rb | UTF-8 | 3,271 | 3.125 | 3 | [
"MIT"
] | permissive | # Author:: Robert Dormer (mailto:rdormer@gmail.com)
# Copyright:: Copyright (c) 2016 Robert Dormer
# License:: MIT
# Naive Bayesian classifier. Training and classification are both done via passed in
# word bags, as opposed to raw text. The first argument to new is the class of WordBag
# that you want newdoc to... | true |
05fcf896d9841dc338435725f03429cab102c3fb | Ruby | luxerama/trlo | /lib/trlo/ui.rb | UTF-8 | 5,924 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'yaml'
require 'colored'
require 'highline'
module Trlo
class UI
GLOBAL_CONFIG_PATH = "#{ENV['HOME']}/.trlo"
LOCAL_CONFIG_PATH = "#{Dir.pwd}/.trlo"
def initialize(args)
# require 'trlo/debugger' if ARGV.delete('--debug')
@io = HighLine.new
@global_config = load_global_config
... | true |
39a013a497c5e126c35fc2c90fa588e45326aec4 | Ruby | ThibaudD/pidr | /average.rb | UTF-8 | 2,214 | 2.875 | 3 | [] | no_license | #!/bin/ruby
def average(array)
sum = 0
for t in array do
sum = sum + t
end
average = sum / array.length
end
def ecart_type(tab)
var = 0
average = average(tab)
for t in tab do
var = var + (t - average)**2
end
ecart_type = Math.sqrt(var/tab.length)
end
def confidence_interval(array)
tmp = ecart_type(ar... | true |
e068fe63a33f891b8afd1dabd94457616c15dd82 | Ruby | rrrene/inch | /lib/inch/api/filter.rb | UTF-8 | 647 | 2.578125 | 3 | [
"MIT"
] | permissive | module Inch
module API
# Filters a codebase's objects based on given options
class Filter
attr_reader :codebase
attr_reader :objects
def initialize(codebase, options)
@codebase = codebase
codebase.objects.filter! Options::Filter.new(options)
@objects = codebase.objec... | true |
4d2e5589bf8a2dd41367a90060e1a776d079bc16 | Ruby | oneearedrabbit/projecteuler | /9/9.rb | UTF-8 | 302 | 3.65625 | 4 | [] | no_license | def triplet?(a, b, c)
a*a + b*b == c*c
end
def good?(a,b,c)
a + b + c == 1000
end
if false
[*0..1000/2].each do |c|
p c
[*0..c].each do |a|
[*0..a].each do |b|
p [a,b,c] if triplet?(a,b,c) && good?(a,b,c)
end
end
end
end
puts [375, 200, 425].reduce(1, &:*) | true |
a456f3c61dc3e1b8f8c2329224b5242652a87a0f | Ruby | trav3r/homework0 | /test1.rb | UTF-8 | 1,664 | 3.296875 | 3 | [
"MIT"
] | permissive | require 'minitest/autorun'
require File.join(File.dirname(__FILE__), "task1")
class TestSum < MiniTest::Unit::TestCase
def test_empty_array_sums_to_zero
assert_equal 0, sum([])
end
def test_one_element_array_sums_to_it
assert_equal 10, sum([10])
end
def test_sum_general_case
assert_equal 60, su... | true |
78b5d1d88a95d8d18d2e14192d98cfbdecad2f8d | Ruby | gterrono/pcr-ruby | /lib/pcr.rb | UTF-8 | 1,443 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'json'
require 'open-uri'
require 'pcr/department'
require 'pcr/coursehistory'
#PCR class handles token and api url, so both are easily changed
module PCR
class Client
attr_reader :token
def initialize(token, api_endpt = "http://api.penncoursereview.com/v1/")
@token = token
@api_endpt = ... | true |
4e9bbc703ab6e15f626fd77c81faa544373c147e | Ruby | gregmarquet/project-euler-factorial-digit-sum-e-000 | /lib/project_euler_factorial_digit_sum.rb | UTF-8 | 232 | 3.734375 | 4 | [] | no_license | def factorial(num)
if (num == 0 || num == 1)
1
else
num * factorial(num - 1)
end
end
def sum_of_digits(num)
num.to_s.chars.map(&:to_i).reduce(:+)
end
def factorial_digit_sum(num)
sum_of_digits(factorial(num))
end | true |
f7f9001af0503d3d8039f09d298348993fe079c8 | Ruby | ghostfruitleaf/api-exercise-seven-wonders | /seven_wonders.rb | UTF-8 | 3,500 | 3.421875 | 3 | [] | no_license | # Pauline Chane
# Ada Developers Academy C14
# API Seven Wonders Activity
# 10/06/2020
# frozen_string_literal: true
require 'dotenv'
require 'httparty'
require 'awesome_print'
# load .env file
Dotenv.load
BASE_URL = 'https://us1.locationiq.com/v1/'
LOCATION_IQ_KEY = ENV['LOCATION_IQ_KEY']
def get_location(search_te... | true |
5a320001af6083b97339eef5495599d554f1a59a | Ruby | ZsoltFabok/project_euler | /spec/project_euler/problems/problem_4_spec.rb | UTF-8 | 686 | 2.890625 | 3 | [] | no_license | require 'spec_helper'
describe Problems::Problem4 do
context "#calculate" do
let(:number) {double}
subject(:problem) {Problems::Problem4.new(number)}
it "returns 9009 as the largest palindrome made from the product of two 2-digit numbers (91,99)" do
allow(number).to receive(:is_palindromic?).and_r... | true |
ba5c7bac65d746c9bfc8ddef2790076cef924c6d | Ruby | towski/bitcoin_trader | /emailer.rb | UTF-8 | 773 | 2.53125 | 3 | [] | no_license | require_relative 'application'
require 'mail'
password = YAML.load_file('email_password.yml')["password"]
options = {
:address => "smtp.gmail.com",
:user_name => 'towski@gmail.com',
:password => password,
:authentication => 'plain',
:enable_starttls_auto => true
}
M... | true |
7f7866f296f97432adebd812ee75fb0be39aa8ef | Ruby | ilankasan/Tivit-2 | /app/models/tivitcomment.rb | UTF-8 | 2,039 | 2.796875 | 3 | [] | no_license | # == Schema Information
# Schema version: 20110301074306
#
# Table name: tivitcomments
#
# id :integer(4) not null, primary key
# user_id :integer(4)
# comment :string(255)
# activity_id :integer(4)
# created_at :datetime
# updated_at :datetime
# Action Field is the type of comments:
# No... | true |
8732f558283400532b5185dc403c4cc05be1aff3 | Ruby | tomun/RubyFall2014 | /week8/exercises/book_spec.rb | UTF-8 | 910 | 3 | 3 | [
"Apache-2.0"
] | permissive | require './books.rb'
describe Printer do
context "#printing" do
it "should print out the right thing for Fiction" do
printer = Printer.new
fiction = FictionBook.new
printer.print(fiction).should eq "This book is Fiction!"
end
it "should print out the right thing for NonFiction" do
printer = Prin... | true |
34f666f89dbeb5121a3b69c6ec1cddd63fa42361 | Ruby | avdeev/oop-patterns-ruby | /7/chain/web.rb | UTF-8 | 1,347 | 3.0625 | 3 | [] | no_license | module Chainable
def next_in_chain(link)
@next = link
end
def method_missing(method, *args, &block)
if @next == nil
puts "This request cannot be handled!"
return
end
@next.__send__(method, *args, &block)
end
end
class WebManager
include Chainable
def initialize(link = nil)
... | true |
956bdff84d899e4d3a48e9c33d64f42a88c43b56 | Ruby | IsolatePy/Learn-How-To-Code-With-Ruby | /11- Hashes II/The_sort_and_sort_by_Methods_on_a_Hash.rb | UTF-8 | 347 | 3.109375 | 3 | [] | no_license | pokemon = {squirtle: "Water" , bulbasaur: "Grass" , charizad: "Fire" }
# you can sort by key or value
p pokemon.sort
p pokemon.sort.reverse
puts
p pokemon.sort_by { |pokemon, type| pokemon }
p pokemon.sort_by { |pokemon, type| pokemon }.reverse
puts
p pokemon.sort_by { |pokemon, type| type }
p pokemon.sort_by { |pok... | true |
d1a11a23d175168fce6d3e656f8d210134eecf8a | Ruby | chi-pocket-gophers-2015/GameZone | /spec/helpers/games_helper_spec.rb | UTF-8 | 1,984 | 2.9375 | 3 | [] | no_license | require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the TypesHelper. For example:
#
# describe TypesHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# ... | true |
0285a4c95485c70002580896e6c72bb0b33d0e57 | Ruby | argosity/hippo | /lib/hippo/concerns/export_methods.rb | UTF-8 | 5,091 | 2.890625 | 3 | [
"MIT"
] | permissive | module Hippo::Concerns
# @see ClassMethods
module ExportMethods
extend ActiveSupport::Concern
included do
# methods that the model has exported. Not intended for querying directly.
# The API and interested parties should call {#has_exported_method?}
class_... | true |
09a2fa72850064f79eda3dc12aaf3cb98fdacd5a | Ruby | naveenkrishnan01/automation | /omniture/clicks.rb | UTF-8 | 341 | 3.1875 | 3 | [] | no_license |
require 'rubygems'
require 'pry'
class Url_check
attr_accessor :url
def intialize
@url = url
end
def url_check_pt(url)
if url != ""
puts "The #{url} was clicked"
else
puts " Url not found"
end
end
end
#m=Url_check.new
#@t = m.url_check_pt("www.oprah.com")
#puts m.... | true |
50a3f403b89697bb8db87a0dfaec6e73ef43a460 | Ruby | rails/rails-docs-server | /lib/lock_file.rb | UTF-8 | 788 | 3.0625 | 3 | [] | no_license | require 'fileutils'
require 'logging'
class LockFile
extend Logging
def self.acquiring(filename)
# This idiom is atomic, either your process is able to create and open the
# lock file or Errno::EEXIST is raised. No race conditions are possible.
lock_file = File.open(filename, File::CREAT | File::EXCL ... | true |
144891c3256cfdd52dcfd83062d0b6fb6dc5a03c | Ruby | timotheeguerin/uniiv | /app/searcher/application_searcher.rb | UTF-8 | 550 | 2.578125 | 3 | [] | no_license | class ApplicationSearcher
attr_accessor :limit, :query, :page, :filters, :results
def initialize(filters)
@limit = filters[:limit]
@query = filters[:q]
@page = filters[:page]
@filters = filters
@results = []
end
def [](key)
params[key]
end
protected
def init_search(search)
... | true |
a9b9878ed0a7118e3b2b60c441d5023bd3c6b97c | Ruby | graysonthemason/stereo_lab | /cassette_spec.rb | UTF-8 | 1,136 | 2.6875 | 3 | [] | no_license | require_relative '../lib/vinyl.rb'
describe(Cassette) do
it('contains songs') do
annielennox_diva = Cassette.new("Why", "Walking on Broken Glass", "Precious", "Legend in My Living Room", "Cold", "Money Can't Buy It", "Little Bird", "Primitive", "Stay by Me", "The Gift")
expect(annielennox_diva.songs).to eq("... | true |
e7cccc0e8e6bedf50be02eeb73452cce5525edda | Ruby | todayfun/tonghua | /app/models/fin_report.rb | UTF-8 | 37,584 | 2.625 | 3 | [] | no_license | class FinReport < ActiveRecord::Base
attr_accessible :fd_code,
:fd_profit_after_share, # 基本每股收益
:fd_profit_base_share, # 稀释每股收益
:fd_profit_after_tax, # 税后盈利
:fd_repdate, # 财报日期
:fd_turnover, # 营业额
:fd_type, # 财... | true |
1b78a3319b0066856809808f845b27dcb4759841 | Ruby | Tinkerjoe-Git/mtg-cube-draft-project | /lib/api.rb | UTF-8 | 405 | 2.875 | 3 | [] | no_license |
class Cube::API
def initialize
@url = "https://api.magicthegathering.io/v1/cards"
end
def get_card_data
card_hash = HTTParty.get(@url)
card_array = card_hash["cards"]
self.create_card_objects(card_array)
end
def create_card_objects(card_array)
card_arra... | true |
b2affbc929182686929d808dd9d399f51c43b5a2 | Ruby | zhangli1049/fauxtran | /detail/where_loop_node.rb | UTF-8 | 745 | 2.609375 | 3 | [] | no_license | require_relative 'syntax_node'
class WhereLoopNode < SyntaxNode
def self.accept(line, stack, line_counter, new_indentation, comments)
if line =~ /^\s*where\s+(.+)\s*$/i
new_node = WhereLoopNode.new(line_counter, :where, new_indentation, line.chomp, comments)
stack.last << new_node
stack << new_... | true |
813cc382d6db6bb631887382ea240b2f68cbced5 | Ruby | obellech10/rb130_exercises | /easy_2/6_each_with_index.rb | UTF-8 | 463 | 3.90625 | 4 | [] | no_license | require 'pry'
system 'clear'
# First time solving
def each_with_index(array)
index = 0
array.each do |element|
yield(element, index)
index += 1
end
end
# Second time solving
def each_with_index(array)
index = 0
loop do
break if index >= array.size
yield(array[index], index)
index += 1
... | true |
e937f61716635b5064bb51fc670ef548e0e9b364 | Ruby | southpaw0511/test1 | /lesson2/alphabet.rb | UTF-8 | 199 | 3.3125 | 3 | [] | no_license | letters = ('а'..'я').to_a
vowels = ['а', 'е', 'ё', 'и', 'о', 'у', 'ы', 'э', 'ю', 'я',]
hash = Hash.new
letters.each.with_index do |v, i|
hash[v] = i if vowels.include?(v)
end
puts hash | true |
7610715298f42b52e1328b5ca3cda002d94fcd85 | Ruby | MobileGuru1013/graphql-ruby | /lib/graphql/execution/interpreter/hash_response.rb | UTF-8 | 1,070 | 2.6875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module GraphQL
module Execution
class Interpreter
# This response class handles `#write` by accumulating
# values into a Hash.
class HashResponse
def initialize
@result = {}
end
def final_value
@result
end
... | true |
d866be3bca17aa7982e9aedad3d12ad8700cb5b6 | Ruby | COMP-4900-PH/ProjectHarmony | /app/models/sailing.rb | UTF-8 | 2,247 | 2.984375 | 3 | [] | no_license | class Sailing < ActiveRecord::Base
has_many :travelling_parties
has_many :events
attr_accessor :people_on_sailing, :top_primary_language, :top_secondary_language, :age_under_18, :age_18_to_50, :age_51_and_over
# Calculate the amount of days until the ship leaves
def daysToSailing
(self.departure_date.to... | true |
8cb9f5098b3efa1e175a75a6a97436b8454594a1 | Ruby | pblaut/flight-game | /Scripts/Scene_Game.rb | UTF-8 | 11,390 | 2.9375 | 3 | [] | no_license | =begin
Game title: Flight
Date: March/April 2012
Authors: Piotr Blaut
Ciara Kennedy
This game is a Software Engineering project.
Scene_Game: Main game controls, processes every main module for gameplay.
=end
class Scene_Game
def initialize(window)
@window = window
@background = Image.new(window, "... | true |
cb29899a0156f35112d0a2b38a0248ab19cede6f | Ruby | hikarine3/programming_language_comparison | /examples/file/output_to_file_and_read_all/output_to_file_and_read_all.rb | UTF-8 | 344 | 2.796875 | 3 | [] | no_license | output_file = "/tmp/output_ruby.txt"
begin
File.open(output_file, "w") do |wfh|
wfh.puts("Hello World!\nAdditional line\n")
end
rescue SystemCallError => e
puts "class=#{e.class},message=#{e.message}"
rescue IOError => e
puts "class=#{e.class},message=#{e.message}"
end
File.open(output_file, "r") do |rfh|
... | true |
7997718df0e0a9e32002119dc9c8832e9c16fd6e | Ruby | EmilieAussage/Mario- | /exo_15.rb | UTF-8 | 143 | 3.234375 | 3 | [] | no_license | puts "Ton année de naissance ?"
print "> "
x = gets.chomp.to_i
year_now = 2020
for i in x..year_now
puts "#{i}: Tu avais #{i - x}"
end
| true |
0ff73f4b85c7e47f88eb4349746c3d4a4efc1f65 | Ruby | iZettle/ninetails | /app/components/ninetails/property_type.rb | UTF-8 | 1,335 | 3.140625 | 3 | [
"MIT"
] | permissive | module Ninetails
class PropertyType
attr_accessor :name, :type, :serialized_values, :property, :enumerable
def initialize(name, type)
@name = name
if type.is_a? Array
@enumerable = true
@type = type.first
@property = type.first.new
else
@enumerable = false
... | true |
9fc0b326763488f5cdbf8f411b6799b5b0e32fd1 | Ruby | C-D-Collaboration/codewars | /lib/7kata/vowel_2_index.rb | UTF-8 | 321 | 3.640625 | 4 | [] | no_license | class Vowel2Index
def self.vowel_2_index(string)
result = ''
vowel_array = "aeiou".chars
counter = 1
string.chars.each do |letter|
if vowel_array.include?(letter.downcase)
result += counter.to_s
else
result += letter
end
counter += 1
end
result
end
end... | true |
3b9798bd030037056c04119876260b6c2b5efe86 | Ruby | nagornyi/wapocutest | /features/objects/browser.rb | UTF-8 | 444 | 2.6875 | 3 | [
"MIT"
] | permissive | class BrowserContainer
attr_reader :browser
def initialize(browser)
@browser = browser
end
class << self
attr_accessor :title
end
# Here you place all browser-specific methods
def close
@browser.close
end
def contain? text
Watir::Wait.until { @browser.text.include? text }
end
de... | true |
9df73901736927c2ff10c54794df7e88e8140b88 | Ruby | icambron/url_to_png | /lib/url_to_png/client.rb | UTF-8 | 1,124 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'addressable/uri'
require 'digest'
require 'faraday'
require 'faraday_middleware'
require 'url_to_png/result'
module UrlToPng
class Client
def initialize(inopts = Configuration.new)
@options = defaults.merge(UrlToPng.configuration).merge(inopts)
raise "Need to provide an API key and secret"... | true |
b02e1df12647482f811d11d94ca14d19d30179ee | Ruby | calmcalmdown/faro10-RoR-react | /app/services/facebook/harvest_posts.rb | UTF-8 | 1,161 | 2.5625 | 3 | [] | no_license | module Facebook
class HarvestPosts
def self.run_all
@users = User.all.each do |user|
harvest(user)
end
end
def self.harvest(user)
if !user.oauth_token.nil?
begin
graph = Koala::Facebook::API.new(user.oauth_token)
if user.facebook_posts.count > 0
... | true |
666f23f1024b169c06016421ea2499ee5ba54316 | Ruby | possumtale/ruby-challenges | /patient_class.rb | UTF-8 | 329 | 3.078125 | 3 | [] | no_license | class Patient
attr_accessor :species, :finder, :location
def about_patient
return "#{@finder} found a #{@species} in #{@location} today."
end
end
new_raccoon = Patient.new
new_raccoon.species = "raccoon"
new_raccoon.finder = "Amy"
new_raccoon.location = "Lodi"
puts new_raccoon.abou... | true |
1428b00f68292b9f7022fc3960a60788a16abe38 | Ruby | asmolentzov/scrabble | /lib/player.rb | UTF-8 | 102 | 3.375 | 3 | [] | no_license | class Player
def initialize(name)
@name = name
end
def number
@name[-1].to_i
end
end
| true |
0e64dac3e47ef35a9f56b46bf644486518071eb0 | Ruby | sprestage/whiteboarding_in_ruby | /expedia_test.rb | UTF-8 | 1,745 | 2.59375 | 3 | [] | no_license | require 'minitest/autorun'
require_relative 'expedia'
class FindUniqueToFirstArrayTest < MiniTest::Test
def test_1
assert_equal [11,4,8,2,6], find_unique_to_first_array_starting_with_first([7,11,4,8,2,3,7,6], [3,7,5,1,7])
end
def test_2
assert_equal [], find_unique_to_first_array_starting_with_first([], ... | true |
71e9b6d15192355008a844be1c3d9470a7dddfa6 | Ruby | cooljasonmelton/mod-2-project-thats-my-favorite-wrestler | /app/models/wrestler.rb | UTF-8 | 797 | 2.6875 | 3 | [] | no_license | class Wrestler < ApplicationRecord
has_many :favorite_wrestlers
has_many :users, through: :favorite_wrestlers
validates :name, :bio, :presence => true
def self.sort_wrestler_by_name
self.all.sort do |a, b|
a.name <=> b.name
end
end
def get_wrestler_favs
Fa... | true |
07cf47319da51bb45604dd1132111f821c6971cc | Ruby | cider-load-test/eve_corplogo_generator | /lib/eve_corplogo_generator.rb | UTF-8 | 2,685 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'RMagick'
module Eve
module CorporateLogo
# Represents a complete logo.
# Attributes:
# image - The Magick::Image instance
# layers - Array of Layer instances
# output - Path to which the output of this Logo has been written
class Logo
attr_accessor :ima... | true |
767eb2fe5e4caf3cd8f299fde44239328d0342d6 | Ruby | Hollyw00d/math-dojo-ruby | /mathdojo.rb | UTF-8 | 508 | 3.859375 | 4 | [] | no_license | class MathDojo
attr_accessor :answer
def initialize
@answer = 0
end
def add(value)
if value.kind_of?(Array)
# add all elements of array
@answer += value.reduce(:+)
else
@answer += value
end
self
end
def subtract(value)
if value.kind_of?(Array)
@answer -= va... | true |
6567df9a6eb6a5bb2bbd88e2d8eff7314982f246 | Ruby | JeremyVe/assignment_ruby_warmup | /stock_picker.rb | UTF-8 | 741 | 3.75 | 4 | [] | no_license | def stock_picker array_price
# Set the Variables of buying and selling day, and profit
buy = 0
sell = 1
profit = array_price[sell]-array_price[buy]
# Loop through each day
array_price.each_with_index do |buy_price, buy_day|
unless buy_day == array_price.length
array_price.each_with_index do |sell_price,... | true |
2557234ceccdcc2cda8dddb87b771df77c31d3a8 | Ruby | ChristyTropila/ruby-oo-inheritance-inheritance-lab-nyc04-seng-ft-071220 | /lib/user.rb | UTF-8 | 420 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class User
# @@all =[]
# attr_accessor :first_name, :last_name
# def initialize(first_name, last_name)
# @first_name=first_name
# @last_name=last_name
# # @@all << self
# end
# def self.all
# @@all
# end
def first_name
@first_name
end
def first_name=(name)
@first_name=name... | true |
28cf2bde71159c48311b066bf7065d8a52778688 | Ruby | chanian/thecount | /lib/thecount/countable/twitter.rb | UTF-8 | 477 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'open-uri'
require 'cgi'
require 'json'
module TheCount
class Twitter < TheCount::Countable
def initialize
@service_name = "twitter"
@unit = "tweet"
@value = 0
end
def count(data)
url = data[:url]
begin
url = "http://urls.api.twitter.com/1/urls/count.json?ur... | true |
0250e00f660859bdf8a07d71f866ac18e83e1dc5 | Ruby | webmstk/Shad1k-project | /Lesson_1/pifagor.rb | UTF-8 | 732 | 3.65625 | 4 | [] | no_license | puts "Введите 1 сторону треугольника"
a = gets.chomp.to_f
puts "Введите 2 сторону треугольника"
b = gets.chomp.to_f
puts "Введите 3 сторону треугольника"
c = gets.chomp.to_f
if a > b && a > c
hypotenuse = a
katet1 = b
katet2 = c
elsif b > a && b > c
hypotenuse = b
katet1 = a
katet2 = c
else
hypotenuse = ... | true |
a92419bfef3947363438e159f3f4d491bf9b92a6 | Ruby | ra22/ruby-basics | /Loops 2/only_even.rb | UTF-8 | 154 | 3.40625 | 3 | [] | no_license | number = 0
until number == 10
number += 1
next if number.odd? #next lets you skip to the next iteration based on certain conditions
puts number
end | true |
ec86efbc0c330f0aeafddbfa1dc491034e4b3873 | Ruby | i2bskn/nginx_utils | /spec/nginx_utils/status_spec.rb | UTF-8 | 2,299 | 2.546875 | 3 | [
"MIT"
] | permissive | # coding: utf-8
require "spec_helper"
describe NginxUtils::Status do
let(:body) {"Active connections: 1 \nserver accepts handled requests\n 4 5 51 \nReading: 1 Writing: 3 Waiting: 2 \n"}
let(:status) {{active_connections: 1, accepts: 4, handled: 5, requests: 51, reading: 1, writing: 3, waiting: 2}}
describe ".... | true |
ca8124c5f71bb455df00734cfeaa82082e12b9ed | Ruby | izaxveta/bike-share | /app/models/dashboard_formatters/station.rb | UTF-8 | 608 | 2.515625 | 3 | [] | no_license | module StationDashboardFormatter
def dashboard_data
most_docks = maximum(:dock_count)
least_docks = minimum(:dock_count)
{
total: count,
average_docks: average(:dock_count).round,
most_docks: most_docks,
least_docks: least_docks,
with_most_docks: where(dock_count: most_docks... | true |
88ce722267125e4b516a066adb21d2b135b994ce | Ruby | alexformagio/monk | /ascent/inheritance.rb | UTF-8 | 397 | 4.25 | 4 | [] | no_license | class Rectangle
def initialize(length, breadth)
@length = length
@breadth = breadth
end
def perimeter
2 * (@length + @breadth)
end
end
class Square < Rectangle
def initialize(length)
@length = length
@breadth = length
end
end
rec = Rectangle.new(10,20)
sq = Square.new(10)
puts "Rectan... | true |
b4b78ea9c3fb8a09ea99886ec5b73e09929ed567 | Ruby | TRP1991/desafio-herencia-y-uml | /schedule.rb | UTF-8 | 652 | 2.984375 | 3 | [] | no_license | =begin
Estudiante: Tamara Rubilar
Desafío - Herencia y UML
=end
#llamada a los archivos
require_relative 'appointment'
require_relative 'dailyappointment'
require_relative 'monthlyappointment'
require_relative 'onetimeappointment'
puts OneTimeAppointment.new('Desafío Latam', 'Trabajo', 19, 30, 10, 8, 2020... | true |
dbbe064a48c4c79568ee7039103a00ce307a60e5 | Ruby | davehenton/mushroom-observer | /app/classes/api/parse_boolean.rb | UTF-8 | 599 | 2.765625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # encoding: utf-8
# Manages the Mushroom Observer Application Programming Interface
class API
def parse_boolean(key, args = {})
declare_parameter(key, :boolean, args)
str = get_param(key)
return args[:default] unless str
val = positive?(str)
limit = args[:limit]
fail BadLimitedParameterValue.... | true |
a316efacb0e43488fd5e27c2aea4f10ff916b49b | Ruby | cmingxu/dage | /app/models/ruku.rb | UTF-8 | 1,074 | 2.53125 | 3 | [] | no_license | # -*- encoding : utf-8 -*-
class Ruku < ActiveRecord::Base
belongs_to :user
belongs_to :item
attr_accessible :item_id, :name, :quantity, :user_id, :xinghao, :supplier, :name_param, :price
attr_accessor :name_param
validates :name_param, :presence => {:message => "名称不能空"}
validates :quantity, :presence => ... | true |
47d82bb19580d326238d974aa34a9fa62ecc87fb | Ruby | Ricartho/ttt-with-ai-project-noukod-000 | /lib/players/computer.rb | UTF-8 | 307 | 3.1875 | 3 | [] | no_license | module Players
class Computer < Player
def initialize (token)
super
@position = []
end
def move(board)
move_b = rand(9).to_i
if @position.include?(move_b)
move(board)
else
@position << move_b
return move_b.to_s
end
end
end
end | true |
d3ec9b68e781352cded5ce6670b0b3cdc192691b | Ruby | desktopgame/beacon | /beacon/rbtools/rfact.rb | UTF-8 | 76 | 2.90625 | 3 | [] | no_license | def fact(n)
if n == 0 then
1
else
n * fact(n - 1)
end
end
p fact(5) | true |
e8a0e8531836cf7be6caa3243ccdc32947211974 | Ruby | v-ramachandran/semantic-text-segmentation | /lib/ruby/lib/math/vector_operations.rb | UTF-8 | 642 | 3.4375 | 3 | [] | no_license | module Math
module Vector
def subtract vector_1, vector_2
vector_1.zip(vector_2).map do |element_1, element_2|
element_1 - element_2
end
end
def dot_product vector_1, vector_2
products = vector_1.zip(vector_2).map do |element_1, element_2|
element_1 * element_2
en... | true |
412f486df24d49c64a9fad41298ea19229f09ef2 | Ruby | yoshis777/design_pattern | /2_basic/aggregation.rb | UTF-8 | 678 | 3.359375 | 3 | [] | no_license | # 集約
# 実装を本来のクラスに持たせることができる
# A has-a B(AはBをもっている)の関係
class Engine
def start
end
def stop
end
end
# 集約されるオブジェクトの継承
class DieselEngine < Engine
end
class GasolineEngine < Engine
end
class Car
def initialize
# 他のオブジェクトをもたせる(集約)
@engine = Engine.new
end
def sunday_drive
@engine.start... | true |
190bd560b73cc7ac0d610718cef2afe9d11ce014 | Ruby | flyeven/rSugar | /first_last.rb | UTF-8 | 125 | 2.671875 | 3 | [] | no_license | #!/usr/bin/env ruby
#-*- coding: utf-8 -*-
first, *, last = 1,2,3,4,5
puts first.inspect # => 1
puts last.inspect # => 5
| true |
3e516a5259f7a50a729f548c2918f8bada8f62fd | Ruby | jaeg131194/octocatalog-diff | /rake/gem.rb | UTF-8 | 5,670 | 2.546875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | require 'fileutils'
require 'open3'
require 'shellwords'
require_relative '../lib/octocatalog-diff/version'
module OctocatalogDiff
# A class to contain methods and constants for cleaner code
class Gem
# Override version number from the environment
def self.version
version = ENV['OCTOCATALOG_DIFF_VERS... | true |
991b23e18f454d8193de59d42eecfc19842ab9fe | Ruby | doverh/Winning-Numbers | /close_but_no_cigar.rb | UTF-8 | 906 | 4.09375 | 4 | [] | no_license |
# Write a function that takes a number (our ticket number) and an array of numbers (the winning numbers from all the draws). To start with, just restrict to all 4 digit numbers. Having the numbers as strings may make it easier to solve. The function should return an array of all the winning numbers that are one digit ... | true |
7bc8f2bc1bbfc157525835ea61b4b89ab59bca37 | Ruby | sadiqmmm/trado | /db/seeds/demo/category_seeds.rb | UTF-8 | 510 | 2.53125 | 3 | [
"BSD-2-Clause",
"MIT"
] | permissive | puts '-----------------------------'
puts 'Executing category seeds'.colorize(:green)
categories = ["Computing", "Storage", "Components", "Software"]
categories.each_with_index do |category, index|
Category.create(
name: category,
description: "Description about your #{category} category",
... | true |
48b2ad04144ec75979b6df03a1b33cfd74df315a | Ruby | richard135/ar-exercises | /exercises/exercise_7.rb | UTF-8 | 462 | 2.875 | 3 | [] | no_license | require_relative '../setup'
require_relative './exercise_1'
require_relative './exercise_2'
require_relative './exercise_3'
require_relative './exercise_4'
require_relative './exercise_5'
require_relative './exercise_6'
puts "Exercise 7"
puts "----------"
# Your code goes here ...
puts "Please enter a store name"
in... | true |
63be3e1e0e7d34c94591858f20d2d1478e28a327 | Ruby | OmairRaza9/Tuesday-Nov-14th-02---Data-Modelling-1-to-Many | /assignment.rb | UTF-8 | 7,376 | 3.234375 | 3 | [] | no_license | Find the author with the name 'Kara Melton' and then select all the articles she has written.
SELECT name, id FROM authors;
name | id
-------------------+----
Terry Burns | 6
Anjuan Simmons | 7
Kara Melton | 8
(7 rows)
SELECT author_id, title, id FROM articles WHERE author_id = 8;
... | true |
32a006a0d964cb900649b928b791e59923364c66 | Ruby | aknishi/Towers-of-Hanoi-Poker | /Poker/lib/deck.rb | UTF-8 | 325 | 3.078125 | 3 | [] | no_license | require_relative 'card'
class Deck
#should create 52 unique cards
def self.create_deck
suits = Card.suits
values = Card.values
deck = suits.product(values).map {|option| Card.new(option[0], option[1]) }
deck.shuffle
end
def initialize(deck = Deck.create_deck)
@deck = deck
end
... | true |
3d2891278eb56ad0f8aabd447ad8606c104b6686 | Ruby | nelyj/sourced | /lib/sourced/event.rb | UTF-8 | 1,619 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'time'
require 'parametric/struct'
Parametric.policy :uuid do
UUID_EXP = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/.freeze
message do
"it must be a valid UUID"
end
validate do |value, key, payload|
!!(value.to_s =~ UUID_EXP)
end
meta_data do
{type: :string}
end
... | true |
043108b71d19502fddb6af900b9afbe05f4dbc93 | Ruby | vito/atomy | /lib/atomy/code/quasi_quote.rb | UTF-8 | 2,376 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | module Atomy
module Code
class QuasiQuote
attr_reader :node
def initialize(node)
@node = node
end
def bytecode(gen, mod)
Constructor.new(gen, mod).go(@node)
end
class Constructor
def initialize(gen, mod)
@gen = gen
@module = mod
... | true |
aa5500c26fc8f8bb751651f0e9cb8b5fdf8132f6 | Ruby | dbalci/aa-classworks | /W2/W2D3/battleship_project/lib/board.rb | UTF-8 | 1,642 | 3.671875 | 4 | [] | no_license | class Board
attr_reader :grid
def initialize(n)
@grid = Array.new(n) {Array.new(n, :N)}
@size = n * n
end
def size #getter
@size
end
def [](arr) #getter
@grid[arr[0]][arr[1]]
end
def []=(arr, value) #setter
@grid[arr[0]][arr[1]] = v... | true |
3f3c5e41ec3827fb16e609e4d30b4a106cd53ac0 | Ruby | icidij/W4D3 | /Chess copy/slideable.rb | UTF-8 | 1,159 | 3.125 | 3 | [] | no_license | module Slideable
def horizontal_dirs
HORIZONTAL_DIRS
end
def diagonal_dirs
DIAGONAL_DIRS
end
def moves
horizontals = []
diagonals = []
horizontal_dirs.each { |dir| horizontals += grow_unblocked_moves_in_dir(dir[0], dir[1]) }
diagonal_dirs.each { |dir| diagonals += grow_unblocked_... | true |
862b033a351651d19550e915075e683290d094a6 | Ruby | nullcast/KuroMusic | /lib/kuromusic/IO/MIDI.rb | UTF-8 | 1,893 | 2.921875 | 3 | [
"MIT"
] | permissive | require_relative "MIDI/Track"
class Midi
module IO
private
def self.midi_head(bin)
bin.seek(10)
track_num = bin.read(2).unpack('C*').reverse.each.with_index.inject(0) do |track_num, (value,index)|
track_num = track_num + (value << 8 * index)
end
dtime = bin.read(2).unpack('C*'... | true |
1598fe33232d1d16d5835255173c104325c8ba00 | Ruby | RaDIrkA/RubyTalkFERI | /code/demo01.rb | UTF-8 | 260 | 3.5 | 4 | [] | no_license | #!/usr/bin/env ruby
puts "Oto Brglez".object_id
puts 1.object_id
puts -1.class
puts "Oto Brglez".class
puts 1.1.class
# Chain...
puts "Oto Brglez".upcase.split(" ").reverse.join(" ").downcase
# Array
imena = %w(Janez Luka Miha)
puts imena.reverse[1,1].first.upcase | true |
de96a0a2583f50f23d48de5efa851bec9ce3b281 | Ruby | chriswebb09/dice-roll-ruby-001-prework-web | /dice_roll.rb | UTF-8 | 220 | 3.65625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Create method `roll` that returns a random number between 1 and 6
# Feel free to google "how to generate a random number in ruby"
def roll
nums = []
(1..6).each do |i|
nums << i
end
nums.shuffle.pop
end
| true |
e8843d91c4306546e7b34c250573b4e34aa13ea7 | Ruby | hkulekci/treehouse-ruby-notes | /13-Ruby-Standard-Library/04-erb.rb | UTF-8 | 1,016 | 3.859375 | 4 | [] | no_license | require 'erb'
class BankAccount
attr_reader :transactions
include Enumerable
TEMPLATE = <<-TEMPLATE
Bank Account : <%= @name %>
---
<% @transactions.each do |transaction| %>
Transaction : <%= transaction %>
<% end %>
---
TEMPLATE
def <=> (other_account)
self.balance <=> other_account.... | true |
4272a9029c9f1e8f45e65f4b7de5d4b3ce448a1c | Ruby | wasabi-moncl/market_img | /lib/mini_geo.rb | UTF-8 | 443 | 3.125 | 3 | [] | no_license | module MiniGeo
def geo
if x_pos.nil? && y_pos.nil?
result = "+0+0"
elsif x_pos.nil? && y_pos.class == Fixnum
result = "+0" + operation(y_pos)
elsif x_pos.class == Fixnum && y_pos.nil?
result = operation(x_pos) + "+0"
else
result = operation(x_pos) + operation(y_pos)
end
... | true |
4d7d1e7f7f8febe2728267cb890d4571f51f9d5d | Ruby | jruby/rubybench | /time/language/bench_rescue.rb | UTF-8 | 777 | 2.890625 | 3 | [
"BSD-2-Clause"
] | permissive | require 'benchmark'
def bench_rescue(bm)
bm.report("control") { 1_000_000.times { foo1 } }
bm.report("one rescue") { 1_000_000.times { foo2a } }
bm.report("one rescue + raise") { 1_000_000.times { foo2b } }
bm.report("five rescues") { 1_000_000.times { foo3a } }
bm.report("five rescues + raise") { 1_000_000.... | true |
7ac7b4e9906484b68cf62dca51009ebd50adf25c | Ruby | doro/israeli-elections | /tests/test.rb | UTF-8 | 4,858 | 2.65625 | 3 | [] | no_license | require 'test/unit'
require './israeli_elections.rb'
class Test2013 < Test::Unit::TestCase
def setup
election_result = IsraeliElections::build_election_result_from_file("data/elections_2013.json")
election_result.calc_seats()
@parties = {}
election_result.parties.each { |p| @parties[p.name] = p}
end
def... | true |
10822c4ee4014fa6b937a1b108141b7f2d7e1f49 | Ruby | SandoBP13049/rails_test | /test5/lib/solver/dic/rs.rb | UTF-8 | 199 | 2.515625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
require 'rubygems'
require 'sqlite3'
db = SQLite3::Database.new("unidic.db")
result = db.execute("SELECT * FROM word")
p result.size
result.each{|x|
puts x[1]
}
db.close | true |
f042859b959bdbd15364d8427b01d33519fd9e9d | Ruby | tpetersen0308/ruby_oo_tic_tac_toe | /lib/human_player.rb | UTF-8 | 839 | 2.859375 | 3 | [
"MIT"
] | permissive | require_relative './player.rb'
require_relative './io_formatter'
require_relative './messager.rb'
require_relative './game_status.rb'
require_relative './game_option_selector.rb'
module TicTacToe
class HumanPlayer < Player
attr_reader :formatter, :messager, :game_status, :option_selector
def initialize(... | true |
73e1a9ba497e99bd5e27720e0642df12ad9a713f | Ruby | Humagashi/challanges | /FullHouse/main.rb | UTF-8 | 218 | 3.015625 | 3 | [] | no_license | # https://edabit.com/challenge/qvpHxkZnTh4m9Dk4X
def is_full_house(hand)
#2 == hand.uniq.size
hand.group_by{|e| e}.map{|k, v| [k, v.length]}.to_h
puts a
end
is_full_house(["A", "A", "A", "K", "K"]) | true |
94ab0c27bda04e616c401b0ef4ed7d1328e05274 | Ruby | jonbleibdrey/collections_practice-onl01-seng-ft-052620 | /collections_practice.rb | UTF-8 | 718 | 3.6875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(num)
num.sort
end
def sort_array_desc(num)
num.sort.reverse
end
def sort_array_char_count(string)
string.sort_by(&:length)
end
def swap_elements(array)
swap=array[1]
array[1]=array[2]
array[2]=swap
array
end
def reverse_array(num)
num.reverse
end
def kesha_maker(strings)
outp... | true |
385b272c4f0be1774a445f8f6f16bc875c1b810f | Ruby | cgilroy/poker | /spec/game_spec.rb | UTF-8 | 2,085 | 3.265625 | 3 | [] | no_license | require 'game'
describe Game do
subject(:game) { Game.new }
describe "#initialize" do
it 'should set up an empty array of players' do
expect(game.players).to be_a(Array)
expect(game.players.length).to be(0)
end
it 'should create an empty pot' do
... | true |
aa138273d02ef8f1a7abb309e4e01fbd3ee3e4d7 | Ruby | mlongerich/bbor-exercises | /hamlet.rb | UTF-8 | 458 | 3.484375 | 3 | [] | no_license | require "open-uri"
# url = "http://ruby.bastardsbook.com/files/fundamentals/hamlet.txt"
# puts open(url).readline
# open("hamlet.txt", "w") do |file|
# file.write(open(url).read)
# end
# puts "---"
open("hamlet.txt", "r") do |file|
file.readlines.each_with_index do |line, number|
puts line if number%42 == 41... | true |
0e986b84a2eb31fc2762142bd74189463c89a184 | Ruby | 7e11/calcproject | /CalcGui.rb | UTF-8 | 5,065 | 3.734375 | 4 | [] | no_license |
#Declaring new methods for the String class.
class String
def isFloat
true if Float(self) rescue false
end
# def isInt
# true if Int(self) rescue false
# end
end
def fib (n)
#puts n
#these are the seeder values. IE: making the program stop
if (n == 0)
return 0
end
if (n == 1)
ret... | true |
c4e42da0b065e332ded99ae30d70cc269d81dd82 | Ruby | asmockler/telescope | /lib/telescope/status.rb | UTF-8 | 944 | 2.640625 | 3 | [] | no_license | require 'mongo'
module Telescope
module Status
NO_INFO = 'No info'.freeze
COUNTING_DOWN = 'Counting down'.freeze
LOCATION_PRESENT = 'Location present'.freeze
DEFAULT_STATUS = {
status: NO_INFO,
coordinates: nil,
countdown: nil,
}
class << self
def get_status
r... | true |
5f038603df51f9db006132060eca805ba8c3f89d | Ruby | Radik73/convert_util | /lib/sorters/sort_date.rb | UTF-8 | 343 | 2.75 | 3 | [] | no_license | require 'date'
require 'time'
# This class there are for sorting elements of content
module SortDate
def self.sort_data(content_struct)
content_struct[:content] = content_struct[:content].sort{ |a, b| Time.parse(b[2]) <=> Time.parse(a[2]) }
content_struct
end
def self.applicable?(option)
option.eql?... | true |
488a0df86c6b4cc66657f4af6c296222517f75b7 | Ruby | DanMcDonald91/SnakesAndLadders | /specs/game_spec.rb | UTF-8 | 451 | 2.546875 | 3 | [] | no_license | require("minitest/autorun")
require("minitest/rg")
require_relative("../Player")
require_relative("../Board")
require_relative("../Dice")
require_relative("../Game")
class TestGame < Minitest::Test
def setup
array_of_players = [@player1 = Player.new("Player1") ,
@player2 = Player.new("Player2")]
@g... | true |
3b5983880c318fa49b377264e75e62c920762b41 | Ruby | EBWiki/EBWiki | /app/models/date_range.rb | UTF-8 | 390 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
# Value object - date range
class DateRange < ValueObject
attr_reader :start_date, :end_date
def initialize(start_date:, end_date:) # rubocop:disable Lint/MissingSuper
@start_date = start_date.beginning_of_day
@end_date = end_date.end_of_day
end
def to_s
"from #{star... | true |
76d31e0f3bb3a2d9450e3346b6aef819ba6b23a9 | Ruby | jsw2a/Intro-to-Programming | /variables/3_var.rb | UTF-8 | 119 | 3.453125 | 3 | [] | no_license | puts "What is your name, friend?"
user_name = gets.chomp
10.times {puts "It's a pleasure to meet you, #{user_name}!"} | true |
54e55ad6cdedb28a3e6aa039393a85a6845f1ca0 | Ruby | SteveGC86/hangman | /spec/underscore_spec.rb | UTF-8 | 362 | 2.546875 | 3 | [] | no_license | require 'spec_helper'
require_relative '../hangman'
require_relative '../words'
RSpec.describe underscore do
describe '#length' do
context 'once word is loaded from'
let(:word) { described_class.new(input) }
let(:input) { 'fertilization ' }
it 'returns the length of the word' do
expect(word.len... | true |
f78232700d44dbbe3c8aeee43d60dfbf22446fa1 | Ruby | SamuelFHULL/documentacionPractica | /spec/alimentos_spec.rb | UTF-8 | 17,180 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'alimentos'
RSpec.describe Alimentos do
before :all do
@carne_vaca = Alimento::Alimento.new("Carne de vaca", 21.1, 0.0, 3.1, 50.0, 164.0)
@carne_cordero = Alimento::Alimento.new("Carne de cordero", 18.0, 0.0, 17.0, 20.0, 185.0)
@camarones = Alimento::Alimento.new("Camarones", 17.6, 1.5, 0.6, 18... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.