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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ab547c270d0dba6056f9985cce1f14a1a6a40406 | Ruby | mkrahu/launchschool-courses | /exercises/ruby_basics/04_user_input/repeater.rb | UTF-8 | 60 | 2.671875 | 3 | [] | no_license | puts ">> Type anything you want:"
answer = gets
puts answer
| true |
e3f26eea3867be42a34c1a3b2c9bd3a651e2efd2 | Ruby | DanielMolina24/ics.bc.s18 | /week2/ch06/angry_boss.rb | UTF-8 | 142 | 2.671875 | 3 | [] | no_license | puts "Now what do you want?!"
want= gets.chomp
puts "YOU WANT "+want.upcase+"?!"
puts "YOU KNOW WHAT YOU GET? A FINAL PAYCHECK CUZ YA FIRED!"
| true |
da4282551952fbaf08ee2d622eb7726269209f0e | Ruby | annahndr/cc_caraoke_wk2 | /specs/song_spec.rb | UTF-8 | 422 | 2.71875 | 3 | [] | no_license | require("minitest/autorun")
require("minitest/rg")
require_relative("../song")
require_relative("../room")
class SongTest < Minitest::Test
def setup
@song1 = Song.new("It's Raining Men")
@song2 = Song.new("Respect")
end
def test_get_name
assert_equal("It's Raining Men", @song1.name)
end
# def ... | true |
f8e5787e9cdc0992db1bc7fc79caf527d27dacdb | Ruby | jk0609/definitions | /spec/definitions_spec.rb | UTF-8 | 2,376 | 2.859375 | 3 | [
"MIT"
] | permissive | require('rspec')
require('definitions')
describe('Word') do
before() do
Word.clear
end
describe('#initialize') do
it('Creates a new Word object based on provided attributes') do
test_word = Word.new({
:name => 'Test',
:img => ""
})
expect(test_word.name)... | true |
ff48241e13feb91d41a5c09e95024b3ded2f7836 | Ruby | YonathanWubishet/console | /hw.rb | UTF-8 | 6,248 | 3.21875 | 3 | [] | no_license | require 'colorize'
require 'find'
class Store
attr_accessor :title, :author, :genre, :details
def initialize(title = "Anonymous", author = "Anonymous", genre = nil, details = nil )
self.title = title
self.author = author
self.genre = genre
self.details = details
end
def ... | true |
bb8d7127e57665faa5aa59a7947268f7d30a7de5 | Ruby | RDJoseDeSouza/nivelamento-aluno | /01-exercicio.rb | UTF-8 | 833 | 3.75 | 4 | [] | no_license | puts "Quantas horas há em um ano? "
puts "Em um ano há: " + (24 * 365).to_s + " horas"
puts
puts "Quantos minutos há em uma decada?"
puts "Em uma decada há " + (60*24*365*10).to_s + " minutos"
puts
puts "Qual sua idade em segundos?"
puts "Eu tenho 22 anos então em segundos a conversão fica: 22 anos = " + (60*60*24*... | true |
67d4fae4e1bf62782c846488444098c6b5ffbd2f | Ruby | tennmoku71/fashion-mnist-web | /app/controllers/images_controller.rb | UTF-8 | 2,018 | 2.515625 | 3 | [] | no_license | class ImagesController < ApplicationController
require 'securerandom'
require 'net/http'
require 'uri'
def index
end
def create
# サブミットされた画像ファイルを取得
uploaded_file = image_params[:file]
# 画像ファイルを適当に保存する
output_path = Rails.root.join('public', SecureRandom.hex(8))
File.open(output_pa... | true |
f39ce4a544e7fee698066e416117480cb1d2865a | Ruby | jrusnack/ruby-safe | /safe1.rb | UTF-8 | 4,448 | 2.546875 | 3 | [] | no_license |
describe "Safe level 1:" do
context "eval" do
it "should not evaluate tainted string" do
Thread.start {
$SAFE = 1
string = "rm -rf *".taint
expect { eval string }.to raise_error SecurityError
}.join
end
end
context "exec" do
it "%x{} should not execute tainted st... | true |
9dda9ee80301eb1d72fa21a3acac26a73bc4f092 | Ruby | goobering/table_tennis | /table_tennis/table_tennis.rb | UTF-8 | 1,240 | 3.890625 | 4 | [] | no_license | # A game shall be won by a player or pair first scoring 11 points
# unless both players or pairs score 10 points, when the game shall
# be won by the first player or pair subsequently gaining a lead of 2 points.
require_relative 'player'
class TableTennis
attr_accessor :players
def initialize()
... | true |
f46f2e23667f37ad24c4a4eb85a0a316b0fc93ac | Ruby | ryansperzel/module-one-final-project-guidelines-web-082817 | /lib/command_line_interface.rb | UTF-8 | 6,605 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'unirest'
require 'colorize'
require 'colorized_string'
require 'catpix'
$players_array = []
def team_data
response = Unirest.get "https://montanaflynn-fifa-world-cup.p.mashape.com/teams",
headers:{
"X-Mashape-Key" => "AYyq4yYeJLmshQdu0EvhtNVYVBRep1FSgP6jsnraZ5TInHi5VH",
"accepts" => "json... | true |
dec7451844dcfab596f59e1d83322c97ccd2f3bc | Ruby | jjsimg/theodinproj | /02_rubyprog/basic_ruby/testing_ruby/spec/connect_four_spec.rb | UTF-8 | 921 | 3.046875 | 3 | [] | no_license | require "connect_four"
describe ConnectFour do
let(:test_game) { ConnectFour.new }
describe "#choose_players" do
context "not infinitely loop" do
it "if user choice is 1 or 2" do
allow(test_game).to receive(:gets).and_return("2")
expect(test_game.choose_players).to eq(2)
end
end
end
describe ... | true |
3d737de1fa40259aa97d07030dbe12967b1b5b8a | Ruby | robin-drexler/cosch | /test/spec/appcache_path_generator_spec.rb | UTF-8 | 1,472 | 2.515625 | 3 | [] | no_license | require_relative 'helpers/runner'
require_relative '../../lib/appcache_path_generator'
require 'digest'
describe 'app cache path generator' do
it 'should return files in given folder with relative paths' do
test_dir = 'test_dir'
FileUtils.rm_rf(test_dir)
FileUtils.mkdir_p(File.join(test_dir, 'empty_sub... | true |
3b811262a3276724eedb487cb86ff22b0c9101a2 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/filtered-submissions/6e9892d7c0e4460e9caa2a4ff963670b.rb | UTF-8 | 232 | 3.484375 | 3 | [] | no_license | def compute string1, string2
distance = 0
short_length = [string1.length, string2.length].min
short_length.times do |i|
if string1[i] != string2[i]
distance += 1
end
end
return distance
end | true |
5ad35cec5f51c073fac4361042dc8ea5d0b087bd | Ruby | rubyworks/fluidity | /lib/fluidity/is.rb | UTF-8 | 263 | 2.953125 | 3 | [
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'fluidity/grammer'
class Object #BasicObject
# Use `is` nomenclature for assertions.
#
# 10.is.kind_of?(Integer)
#
def is(matcher=nil)
if matcher
matcher === self
else
::Fluidity::Grammer::Is.new(self)
end
end
end
| true |
3927aa8eaba279dbe479b0bac7f7e7f22aa1ec9e | Ruby | india518/restaurant_review_app | /chef.rb | UTF-8 | 3,423 | 3 | 3 | [] | no_license | require 'sqlite3'
require_relative 'reviews_database'
require_relative 'restaurant'
require_relative 'restaurant_review'
class Chef
attr_accessor :first_name, :last_name, :mentor_id
attr_reader :id
def self.find_all
query = "SELECT * FROM chefs"
chef_list = ReviewsDatabase.instance.execute(query)
... | true |
15d299ba715a96bb1e94504ee74732a9c2245785 | Ruby | bitops/rayon | /ping_pong.rb | UTF-8 | 491 | 3.328125 | 3 | [] | no_license | require 'fiber'
f1 = Fiber.new do |fiber| # we are called with f2 from 'resume'
puts "f1: ping"
fiber.transfer Fiber.current # we transfer ourselves to f2
puts "f1: ping"
fiber.transfer # transfer to f2
puts "f1: ping"
fiber.transfer # transfer to f2
end
f2 = Fiber.new do |fiber| # we are called with f1 f... | true |
d8947def9010109de84b7bba901cba7bc7f1f147 | Ruby | Porridjo/ruby_exos | /exo_09.rb | UTF-8 | 177 | 3.546875 | 4 | [] | no_license | puts "Bonjour, c'est quoi ton prénom ?"
print "> "
prenom = gets.chomp
puts "Et quel est ton nom de famille?"
print "> "
nom = gets.chomp
puts "Bonjour, #{prenom} #{nom} !"
| true |
07a9d02808618c40c7d5789f897d3f37c760a17e | Ruby | lukeovalle/stats | /test/integration/test_stats.rb | UTF-8 | 1,207 | 2.625 | 3 | [
"MIT"
] | permissive | require 'test/unit'
require 'mocha'
require 'stats'
class TestStats < Test::Unit::TestCase
def setup
Stats.redis = 'localhost:6379:stats_test'
Stats.redis.flushdb
end
def test_should_set
Stats.set("load", 1.2)
assert_equal 1.2, Stats.get("load").to_f
Stats.set("load", 1.7)
assert_equal 1... | true |
a87444d2b9ae2bfa34ffae0aa90d3f1bcf70597b | Ruby | joseph-gansukh/apis-and-iteration-chicago-web-82619 | /lib/command_line_interface.rb | UTF-8 | 288 | 3.75 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def welcome
puts "Welcome to the Star Wars archives!"
end
def get_character_from_user
puts "Which character would you like to learn about today? Enter quit to exit."
# use gets to capture the user's input. This method should return that input, downcased.
gets.chomp.downcase
end
| true |
1d9bfc8f5f341a8e5d6a1171f8bc3721633a844f | Ruby | ndrean/docker-slim | /app/helpers/pages_helper.rb | UTF-8 | 638 | 2.625 | 3 | [] | no_license | # frozen_string_literal: true
# fetchs from an API and display response as a background job
module PagesHelper
require 'open-uri'
# <- module method (self) => called with PagesHelper.count
# def self.incr_redis
# compteur = REDIS.get("compteur") || 0
# REDIS.incr('compteur')
# # Rails.lo... | true |
0124a15cf87ad7dff048180fa39d8115e1e33785 | Ruby | avni510/prime_factors | /spec/prime_factors_spec.rb | UTF-8 | 578 | 3.328125 | 3 | [] | no_license | require "prime_factors"
describe PrimeFactors do
[
['1', []],
['2', [2]],
['3', [3]],
['4', [2, 2]],
['5', [5]],
['6', [2, 3]],
['7', [7]],
['8', [2] * 3],
['9', [3, 3]],
['2*3*5*7*11*13', [2, 3, 5, 7, 11, 13]],
['8191 * 131071', [8191, 131071]],
['2**100', ... | true |
6670e22c33962bdad88bf07b3b35a35235df6229 | Ruby | jemini/jemini-core | /src/game_state.rb | UTF-8 | 4,284 | 2.75 | 3 | [
"BSD-3-Clause"
] | permissive | require 'logger_mixin'
#All other game states should inherit from this class.
module Jemini
class GameState
include LoggerMixin
attr_reader :container
@@active_state = nil
def self.active_state
@@active_state
end
def self.active_state=(state)
@@active_state = state
... | true |
175c046295a1c49e714301a8b83bafd108171dd2 | Ruby | maheshd1991/FirstRuby | /second.rb | UTF-8 | 93 | 2.859375 | 3 | [] | no_license | class Second
def first
a=/[a-z]/
puts a
end
end
a=Second.new
a.first
| true |
f1708775ec92a289441127ff1f0cbe20d97b9b89 | Ruby | oscarmolivera/code_farm | /Ruby/CodeWars/Collection Ruby 6 Kyu/6kyu-+1Array.rb | UTF-8 | 2,776 | 3.78125 | 4 | [] | no_license | =begin
+1 Array
Given an array of integers of any length, return an array that has 1 added to the value
represented by the array.
The array can't be empty Only non-negative, single digit integers are allowed
Return nil (or your language's equivalent) for invalid inputs.
Examples
For example the array [2, 3, 9] equa... | true |
836b642244a46b2344273e1083a2b4bd9a5dd01b | Ruby | SagnieresY/PROJECT_GRACE | /app/models/investment.rb | UTF-8 | 1,351 | 2.71875 | 3 | [] | no_license | class Investment < ApplicationRecord
belongs_to :foundation
belongs_to :project
has_many :milestones
validates :project, presence: true
validates :foundation, presence: true
def forecasted_amount
#calculates projected amount minus the missed milestones
valid_milestones = milestones.map do |m| #map ... | true |
34dd5ead448aa67d6f36a4b2f9d527de544074f3 | Ruby | gnomex/graph-algorithms | /lib/text_parser.rb | UTF-8 | 352 | 2.90625 | 3 | [
"MIT"
] | permissive | module Text
class Parse
TEXTREGEX = /[\w|\s]+/
def self.load_file(filename)
words = Array.new
File.open(filename, "r").each_line do |line|
line.gsub!(/\r\n?/, "\n") #Line break
# line.gsub!(/\W/, " ")
# line.downcase!
# words.push(line.split(' '))
end
... | true |
09d4654b1453891950841b24a1c4c88f40f6c998 | Ruby | matveyclark-zz/ruby-oo-relationships-practice-auto-shop-exercise-london-web-111819 | /tools/console.rb | UTF-8 | 682 | 2.921875 | 3 | [] | no_license | require_relative '../config/environment.rb'
require_relative '../app/models/car_owner.rb'
require_relative '../app/models/car.rb'
require_relative '../app/models/mechanic.rb'
require 'pry'
own1 = CarOwner.new('Owner1')
own2 = CarOwner.new('Owner2')
own3 = CarOwner.new('Owner3')
mech1 = Mechanic.new('Mechanic1', 'exo... | true |
9335de92eec4adef479a97ca438bfb7fefa4cd4a | Ruby | VincenzoAltieri/LS_101 | /lesson_5/ex13.rb | UTF-8 | 237 | 3.40625 | 3 | [] | no_license | # Given the following data structure, return a new array containing the same sub-arrays
# as the original but ordered logically according to the numeric value of the
# odd integers they contain.
arr = [[1, 6, 7], [1, 4, 9], [1, 8, 3]]
| true |
4ae7270441117aadb190fb1a84368ec735cae68b | Ruby | HD-4Code/My_Ruby | /exo_03.rb | UTF-8 | 156 | 3.78125 | 4 | [] | no_license | #2.3. Un programme qui calcule des âges
puts"Bonjour, peux-tu me donner ton âge?"
age = gets.chomp.to_i
puts"En 2017, tu auras eu "
age = age-4
puts age
| true |
adaea72457a8c1098d69314fcf0ed496089bbf99 | Ruby | d3diva/udacitask-part1 | /udacitask.rb | UTF-8 | 1,163 | 3.109375 | 3 | [] | no_license | require_relative 'todolist.rb'
# Creates a new todo list
list = TodoList.new("Todo list")
# Add four new items
list.add_item "Buy Grocery", due_time: "16:00"
list.add_item "Clean Bike", due_time: "17:00"
list.add_item "Walk Dusty", due_time: "18:00"
list.add_item "Water Plants"
# Print the list
list.print_items
# D... | true |
0509f0e748a8d2a457ec6f64900b092b91e4cc3c | Ruby | luxcodes/primes-coding-challenge | /runner.rb | UTF-8 | 767 | 3.4375 | 3 | [] | no_license | #!/usr/bin/env ruby
# sdad
require_relative "prime_table"
if ARGV.any?
if ARGV.length > 1
puts "\nExceeded maximum number of arguments"
puts "Please use the [--help] flag for more options"
elsif
if ARGV[0] == "--help"
puts ""
puts "WELCOME TO LU's PRIME TABLES!"
puts "\nUsage:"
... | true |
fdfd2602a854eceda9d2fd206657d5eaca78c7ba | Ruby | jmks/asdf-discover | /lib/asdf_discover/search_result.rb | UTF-8 | 881 | 2.6875 | 3 | [
"MIT"
] | permissive | module AsdfDiscover
# Amalgamated results from Searchers.
# Contains the data required to display warnings and write the .tool-versions file.
class SearchResult
Conflict = Struct.new(:tool, :sources)
def initialize(results)
@results = results
end
def consistent?
conflicts.none?
e... | true |
7526a81ece211a1b41d1ab708c992669262c943f | Ruby | bjornblomqvist/Keso | /lib/values/immutable_set.rb | UTF-8 | 3,519 | 3.1875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive |
require 'set'
class ImmutableSet
def initialize(*args)
if args.first.is_a? ImmutableSet::SetChange
@set_change = args.first
else
@set = Set.new;
args.each do |value|
if value.is_a? ImmutableSet
@set.merge value.set
elsif value.is_a? Set
@set.me... | true |
6426aacaa52e47cd860f9545029b6897c395d348 | Ruby | bharatagarwal/launch-school | /101_programming_foundations/small_problems/04_easy_4/05.rb | UTF-8 | 723 | 4.65625 | 5 | [] | no_license | # Write a method that searches for all multiples of 3 or 5 that lie between 1 and some other number, and then computes the sum of those multiples. For instance, if the supplied number is 20, the result should be 98 (3 + 5 + 6 + 9 + 10 + 12 + 15 + 18 + 20).
# You may assume that the number passed in is an integer great... | true |
3fc65a1f1631cb39cab278d4a0556301b1ef2dd3 | Ruby | kares/the-lot | /db/models/user.rb | UTF-8 | 519 | 2.5625 | 3 | [] | no_license | class User < ActiveRecord::Base
validates_presence_of :name
alias_attribute :username, :name
has_many :tasks, -> { order('priority ASC, created_at ASC') }
#def self.by_name(name)
# where(:name => name).take || create!(:name => name)
#end
def self.auth(username, password = nil)
user = where(:name... | true |
61e8611086090d1b03c530d30ae8804cba5c2a6e | Ruby | bbatsov/spellbook-dictionary | /web/app/helpers/application_helper.rb | UTF-8 | 3,547 | 2.515625 | 3 | [] | no_license | # Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
## Menu helpers
def menu
#home = menu_element("Welcome", welcome_path)
dicts = [];
Dictionary.find_each do |dict|
dicts << menu_element(dict.name, dictionary_path(dict))
... | true |
56f6af71c001ca67bb5595ee13a3e2d42cf6049f | Ruby | beersbr/Javascript_game_development | /documentation/docme.rb | UTF-8 | 1,180 | 2.578125 | 3 | [] | no_license | #ruby documentation file for javascript
args = /(([A-Za-z0-9_-]*),? ?)*/m
object = /function ([A-Z][a-z0-9A-Z_-]*)\((#{args})\)/m
# namespace = /([A-Z][a-zA-Z_]*) ?= ?\{\}/m
# namespace_function = /([A-Z][a-zA-Z_]*)\.([a-zA-Z_0-9]*)\((#{args})\)/
object_function = /this\.([a-z][a-z0-9A-Z_]*) ?= ?function\((#{args})\)/... | true |
7f7caa7ef5511b078185448081f57dea68125a36 | Ruby | ScottMS724/collections_practice-v-000 | /collections_practice.rb | UTF-8 | 970 | 3.671875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(integer_array)
integer_array.sort
end
def sort_array_desc(integer_array)
integer_array = integer_array.sort
return integer_array.reverse
end
def sort_array_char_count(string_array)
string_array.sort do |a, b|
a.length <=> b.length
end
end
def swap_elements(array)
array[1], array... | true |
1323b93b5aff4614906c0b47f9a098ea283042d7 | Ruby | Lukis92/ruby_tasks | /count_bits.rb | UTF-8 | 237 | 3.4375 | 3 | [] | no_license | # https://www.codewars.com/kata/526571aae218b8ee490006f4/
def count_bits(n)
n = n.to_s(2).to_i
count = 0
while n > 0
digit = n % 10
n /= 10
count += 1 if digit == 1
end
return count
# puts n.to_s(2).count "1"
end
count_bits(1234)
| true |
5736141b48661b654d21f9919758a7303160a096 | Ruby | ncaron/Launch-School | /Exercises/101-109 - Small Problems/easy_9/grocery_list.rb | UTF-8 | 559 | 4.625 | 5 | [] | no_license | # Write a method which takes a grocery list (array) of fruits with quantities and converts it into an array of
# the correct number of each fruit.
# Example:
# ```
# buy_fruit([["apples", 3], ["orange", 1], ["bananas", 2]]) ==
# ["apples", "apples", "apples", "orange", "bananas","bananas"]
# ```
def buy_fruit(list... | true |
274434284d7921dd5c239076abf41688ccfa15c4 | Ruby | eviceconti/alpha-blog | /app/controllers/articles_controller.rb | UTF-8 | 1,163 | 2.71875 | 3 | [] | no_license | class ArticlesController < ApplicationController
def new #action new
@article = Article.new #instance variable. Na pagina de visualizacao, o formulario vai usar essa variavel para escrever os campos em seus atributos
end
def create
#render plain: params[:article].inspect #somente para checar se o envio... | true |
d03d855731149c9140c246e8f2fb82951e4489e1 | Ruby | SMinTlab/X_I | /src/human.rb | UTF-8 | 332 | 3.078125 | 3 | [] | no_license | require './element.rb'
# Human class extends Element.
class Human < Element
attr_reader :age
def initialize(image)
super(image)
self.age = 0
@parameter.life = 5
@parameter.health = 100
@parameter.attack = 1
@parameter.defense = 1
end
def age=(age)
@parameter.age = age
@age = ag... | true |
74020e6dd6054db4b26d11fb34b921ff70bfc30c | Ruby | f1729/ruby-grokking-algorithms | /recursive_sum.rb | UTF-8 | 147 | 3.90625 | 4 | [] | no_license | def sum(list)
if list.length == 0
0
else
list.first + sum(list[1..-1])
end
end
my_list = [1, 3, 5, 7, 9]
puts sum(my_list) # => 25
| true |
135c38d6222ef216d7d5e4ece258fb28dbce870c | Ruby | AdaGold/algorithms_examples | /fibonacci.rb | UTF-8 | 1,158 | 3.875 | 4 | [] | no_license | require "benchmark"
def fibonacci_good(n)
raise ArgumentError, "n must be >= 0" if n < 0
return n if n < 2
two_previous = 0
one_previous = 1
num = 2
while num < n
temp = one_previous + two_previous
two_previous = one_previous
one_previous = temp
num += 1
end
return one_previous + two... | true |
61b485faa35dd30aa9597ee9d46117e14e28c6f4 | Ruby | ravendb/ravendb-ruby-client | /spec/support/order.rb | UTF-8 | 230 | 2.78125 | 3 | [
"MIT"
] | permissive | class Order
attr_accessor :id, :name, :uid, :product_id
def initialize(
id = nil,
name = "",
uid = nil,
product_id = nil
)
@id = id
@name = name
@uid = uid
@product_id = product_id
end
end
| true |
78af19d98263e54a620f17015f7ebfe1a94cab80 | Ruby | yukisako/Tansu | /app/models/lending.rb | UTF-8 | 863 | 2.53125 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
# == Schema Information
#
# Table name: lendings
#
# id :integer not null, primary key
# product_id :integer
# user_id :integer
# deadline :date
# status :string(255)
# created_at :datetime
# updated_at :datetime
#
class Lending < ActiveRecord::Base
validates ... | true |
c7108392ea4846981fd30db8258fc51044d6f748 | Ruby | yeinee/coderbyte-Ruby | /coderbyte_FirstFactorial.rb | UTF-8 | 278 | 3.328125 | 3 | [] | no_license | def FirstFactorial(num)
num2 = num
# code goes here
while num>1
num2 = num2*(num-1)
num = num-1
end
return num2
end
# keep this function call here
# to see how to enter arguments in Ruby scroll down
FirstFactorial(STDIN.gets)
| true |
3bbd0468dd5ef4ee37e140d9e06fd827ee8c86f3 | Ruby | glasnoster/model_view | /spec/model_view/model_view_spec.rb | UTF-8 | 5,146 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'pry'
describe ModelView do
let(:dummy_class) { Class.new { extend ModelView } }
let(:root_scope) { :__root__ }
context "root scope" do
describe :field do
context "without a block" do
it "adds the field to the root scope" do
dummy_class.field :a_field
... | true |
9814b51b1180d2715ab2fccd5e91fa0a09a7b770 | Ruby | pznicolasm/ruby_practices | /practica_4/p4e1/agenda_app.rb | UTF-8 | 1,165 | 3.328125 | 3 | [] | no_license | require 'csv'
require_relative 'agenda'
require_relative 'contact'
agenda = Agenda.new
ARGV.each do |csv_file_name|
puts "Processing #{csv_file_name}" #procesa el nombre del archivo pasado por parametro
agenda.read_in_csv_data(csv_file_name)
end
puts "Cantidad de Contactos Agendados = #{agenda.contacts.size}"
... | true |
22521efad46ddb3bb1e5db63934fe45d6ab93b5f | Ruby | jimmymixer/CodingDojoAssignments | /Ruby/first_vagrant_box/Ruby_Fundamentals/yield_blocks/yield_blocks.rb | UTF-8 | 882 | 4.46875 | 4 | [] | no_license | # def test
# puts "You are in the method"
# yield
# puts "You are again back to the method"
# yield
# end
# test { puts "You are in the block" }
# #-----------------------------------------------|
#
# def test
# yield 5
# puts "You are in the method test"
# yield 100
# end
# test { |i| puts "You are in th... | true |
2bdb6f4f6318002cc277eb9d9db612b304f78842 | Ruby | walehan/up | /app/models/game_session.rb | UTF-8 | 726 | 2.6875 | 3 | [] | no_license | class GameSession < ActiveRecord::Base
has_and_belongs_to_many :people
belongs_to :person, :foreign_key => :person_id
# todo - validate that an owner exists
def register_person(person_id)
# todo - validate that person isn't already in table
if is_valid
self.people << Person.find(person_id)
... | true |
c70b15918b00089f2a1ffb03580e1125943f1ea1 | Ruby | IanLockwood/phase-0 | /week-7/gps3_1/my_solution.rb | UTF-8 | 7,120 | 3.90625 | 4 | [
"MIT"
] | permissive | # U2.W5: Virus Predictor
# I worked on this challenge with: Lauren Jin.
# We spent 2.5 hours on this challenge.
#=======================================================================
# RELEASES 1-5
#=======================================================================
# EXPLANATION OF require_relative
# This... | true |
0358609353ba3ad81da4dce2769b529ca9daf8d7 | Ruby | jhaad/clearcats | /lib/ctsa_schema_reader.rb | UTF-8 | 7,235 | 2.625 | 3 | [] | no_license | require 'rexml/element'
require 'rexml/document'
class CtsaSchemaReader
attr_accessor :file_path, :xml_schema
def initialize(file_path)
@file_path = file_path
raise "Please supply a valid document path - was given #{@file_path}" if !File.exists?(@file_path)
@xml_schema = REXML::Document.n... | true |
d316df3470ef09e8e2de6dc4b1be21e3696bfecd | Ruby | zaharpecherin/CryptoChallangeApi | /app/services/crypto_service.rb | UTF-8 | 1,129 | 2.578125 | 3 | [] | no_license | require 'net/http'
API_ENDPOINT ||= 'https://api.nomics.com/v1'
class CryptoService
include HttpStatusCodes
include ApiExceptions
def request(endpoint:, params: {})
uri = URI(API_ENDPOINT + endpoint)
uri.query = URI.encode_www_form(authenticated_params(params))
@response = Net::HTTP.get_response(ur... | true |
61d039ecce923bfde47c1a220fc8a795ab86dd08 | Ruby | PederSchacht/car_plebes | /spec/integration/car_integration_spec.rb | UTF-8 | 1,715 | 3.21875 | 3 | [
"MIT"
] | permissive | require_relative '../spec_helper'
describe "Adding a car" do
before do
account = Account.new("Sam", 25)
account.save
car = Car.new("Ferrari", 33)
car.save
end
context "adding a unique car" do
let!(:output){ run_car_plebes_with_input("4", "Sam", "Aston Martin", "5000") }
it "should insert ... | true |
35d703ebee6d5b53796ebddff5065d70f5262c35 | Ruby | jessicammichael/programming-univbasics-nds-hash-of-arrays-lab-atlanta-web-111819 | /lib/hoa.rb | UTF-8 | 605 | 2.625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | '''ruby
BASE_HOA = {
:chipmunks => ["Alvin", "Simon", "Theodore"],
:third_earthers => ["Lion-O", "Cheetara", "Mumm-Ra (the ever-living)"],
:jetsons => ["George", "Jane", "Judy", "Elroy"]
}
def add_character(show, name)
boomerang_tv = {
:chipmunks => ["Alvin", "Simon", "Theodore"],
:third_earthers => ... | true |
3e9362097859ae325f4183f34778439557b6a561 | Ruby | rossta/montrose | /lib/montrose/rule/day_of_year.rb | UTF-8 | 690 | 3.109375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Montrose
module Rule
class DayOfYear
include Montrose::Rule
def self.apply_options(opts)
opts[:yday]
end
# Initializes rule
#
# @param [Array<Fixnum>] days - valid days of year, e.g. [1, 2, -1]
#
def initialize(days)
... | true |
c0e193f5a8cec9e716688bf173ca6c165adec167 | Ruby | crhilditch20/space_cowboys | /models/bounties.rb | UTF-8 | 1,624 | 3.03125 | 3 | [] | no_license | require('pg')
class Bounty
attr_accessor :bounty_value, :favourite_weapon
attr_reader :name, :homeworld
def initialize( options )
@name = options['name']
@favourite_weapon = options['favourite_weapon']
@bounty_value = options['bounty_value'].to_i
@homeworld = options['homeworld']
@id = optio... | true |
f00a063281522fde601b7ab42abbb8be6aea8bd5 | Ruby | Matlawton/coder-academy-t1a3 | /src/classes/booking_controller.rb | UTF-8 | 8,511 | 3.421875 | 3 | [] | no_license | require 'tty-box'
require 'tty-prompt'
require "colorize"
require "tty-progressbar"
require_relative "../utilities/camp_stats.rb"
require_relative "booking.rb"
# Booking controller is my main controller that handles all the booking information and the booking menu UI
class BookingController
attr_reader ... | true |
2fc80278f87328028fa3e8c54cd72f63319655ec | Ruby | justinsilvestre/tokipona | /lib/parsing.rb | UTF-8 | 1,069 | 3.15625 | 3 | [] | no_license | require_relative 'sentence'
require 'json'
class Parsing
attr_reader :original_text
def initialize(text)
@original_text = text.gsub(/[^a-zA-Z\s!\?\.,:;]/,'')
end
def sentences
return @sentences if defined? @sentences
raw_sentences = original_text.clone
@sentences = []
chunk_regex = /[^!\?\.,:]+[!\?\.,:... | true |
674782573d3a210934247f70d73166020229ff62 | Ruby | mfujiwara/AizuOnlineJudge | /volume27/2780.rb | UTF-8 | 568 | 3.203125 | 3 | [] | no_license | n = gets.to_i
a_array=gets.chomp.split(" ").map(&:to_i).sort { |a, b| b <=> a }
ret = -1
(0..n-2).each do |i|
((i+1)..(n-1)).each do |j|
prod = a_array[i] * a_array[j]
if ret != -1 && ret > prod
next
end
prods = prod.to_s.split("").map(&:to_i)
judge = tru... | true |
67f46928644eb9e9d82a8e9a6f9f36a63c9a661f | Ruby | laughgege/backup-some-code | /ruby/compare.rb | UTF-8 | 104 | 2.609375 | 3 | [] | no_license | p "str" == "str"
p 1 == 1.0
p 1.13 + 2
p "str" + "ing"
p 1 << 2
p ["a", "b"] << "c"
p $stdout << "hoge"
| true |
3c8565f21198393d7f8cad1a4cd864c89c72d71a | Ruby | DTrofimovich/Tsosi_8 | /2/lib/image_spoiler.rb | UTF-8 | 561 | 2.84375 | 3 | [] | no_license | class ImageSpoiler
def initialize(image)
@image = image
end
def spoil_image(per_cent_spoil)
image_c = @image.image.clone
lenght = @image.height * @image.width
random = (0..(lenght - 1)).to_a.sample(lenght * per_cent_spoil / 100)
random.each do |r|
if (image_c[r].to_a == CvColor::Black.t... | true |
127b3f3e0482f86d09a04a7ff25105c14e1fe07c | Ruby | yama130/AOL_Ruby | /vol0/0001.rb | UTF-8 | 75 | 2.921875 | 3 | [] | no_license | a=[]
10.times{
a.push(gets.to_i)
}
a.sort!
puts a[9]
puts a[8]
puts a[7]
| true |
f523034a7cdbc7613a0fad971a1c239cce1db894 | Ruby | JoinJanay-JS/say-hello-ruby-online-web-pt-090819 | /say_hello.rb | UTF-8 | 66 | 2.96875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def say_hello(Janay)
puts "Hello Ruby Programmer #{Janay}!"
end
| true |
b5960a85b587a981eec6cd74aef0cd3f574b9386 | Ruby | avdgaag/conformista | /lib/conformista/form_object.rb | UTF-8 | 3,406 | 2.78125 | 3 | [
"MIT"
] | permissive | module Conformista
# The FormObject is an ActiveModel-compliant object that knows how to present
# multiple Ruby objects (usually descendents of ActiveRecord::Base) to the
# view layer in an application. The form object is specifically designed to
# work with Rails `form_for` helpers.
#
# The form object's ... | true |
ad0af4f6c12160c0449c4ae25da8a37ceebff713 | Ruby | thedigitaloctopus/droptoflare | /lib/droptoflare/cloudflare.rb | UTF-8 | 1,344 | 2.8125 | 3 | [] | no_license | require 'json'
require 'net/http'
require 'uri'
# methods to create/update/list Cloudflare A records
class Cloudflare
def initialize(cf_token, domain, email)
@cf_token = cf_token
@domain = domain
@email = email
end
# Create new A record
def create_record(name, ip)
data = {
a: 'rec_new',
... | true |
7f5bc5961bf2291f18ddd48bd2e7d5fe3a1c480f | Ruby | sngeth/algorithms | /rotate_array.rb | UTF-8 | 1,064 | 3.65625 | 4 | [] | no_license | require "minitest/autorun"
require "byebug"
class RotatedArray
def rotate(arr, n)
len = arr.length
if (n < 0)
# calculate the positive rotations needed.
n = n + len
end
temp = Array.new(n-1)
# copy last N elements of array into temp
arr.each_with_index do |num, i|
temp[i]... | true |
a73df27f864ea24e4107d657b674606c8d459912 | Ruby | kkchu791/CodingProblems | /pramp/word_count_engine.rb | UTF-8 | 610 | 3.625 | 4 | [] | no_license | def word_count_engine(document)
string = strip_out_punctuations(document)
arr = string.split(" ")
hash = {}
arr.each do |el|
if hash[el]
hash[el] += 1
else
hash[el] = 1
end
end
res = hash.sort do |a, b|
b[1] <=> a[1]
end
res.each_with_index {|el, index| ... | true |
6c6208cbbb1bb5f671a183e4172ee340a63fcc5d | Ruby | karenhlai/aA_homeworks | /W1D5/Map.rb | UTF-8 | 640 | 3.46875 | 3 | [] | no_license | class Map
def initialize(set)
@set = set
end
def set(key, value)
pair_idx = set.index { |pair| pair[0] = key }
if pair_idx
set[pair_idx][1] = value
else
set << [key, value]
end
value
end
def get(key)
set.each { |pair|... | true |
67207bf2bd0af28618548ee6b28dc29eee2994de | Ruby | holderdeord/hdo-site | /lib/hdo/stats/representative_counts.rb | UTF-8 | 1,718 | 2.671875 | 3 | [] | permissive | module Hdo
module Stats
class RepresentativeCounts
def self.attendance_for_votes(votes, opts = {})
data = votes.
flat_map(&:vote_results).
group_by(&:representative).
inject({}) do |mem, (rep, vote_results)|
mem.merge(rep => new(vote_results).as_json)
... | true |
f747f34f7b6a4e71bf2192746d4732868b015a24 | Ruby | megamsys/megam_api | /lib/megam/core/sensors_collection.rb | UTF-8 | 2,760 | 3.109375 | 3 | [
"MIT"
] | permissive | module Megam
class SensorsCollection
include Enumerable
attr_reader :iterator
def initialize
@sensors = []
@sensors_by_name = {}
@insert_after_idx = nil
end
def all_sensor
@sensors
end
def [](index)
@sensors[index]
end
def []=(index, arg)
is_... | true |
9e05d1501680a4079c16de00bb8e22e6c933f766 | Ruby | thoran/AsxhistoricaldataCom | /lib/Month/self.cdate.rb | UTF-8 | 1,040 | 3.28125 | 3 | [] | no_license | # Month/self.cdate.rb
# Month.cdate
require 'date'
require 'Month/self.cdates'
class Month
class << self
def cdate(which_day, day, *args)
year, month = (
case args.size
when 0; [Date.today.year, Date.today.month]
when 1; [Date.today.year, args[0]]
when 2; [args[0], arg... | true |
5dc09915e0341605498c6ab9db3e2391db29e3c8 | Ruby | iLtc/launch-school | /100/introduction-to-programming/variables/name.rb | UTF-8 | 149 | 3.71875 | 4 | [] | no_license | print "First Name: "
first = gets.chomp
print "Last Name: "
last = gets.chomp
puts "Hello, #{first} #{last}!"
10.times {puts "#{first} #{last}"} | true |
bf3009c8f16dfa431f446e0063da44f46d1dece8 | Ruby | lamronby/learning | /ruby/FORPC101/l2ex4_fizzbuzz.rb | UTF-8 | 626 | 4.1875 | 4 | [] | no_license | =begin
Exercise4. Write a Ruby program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".
=end
# Lots of different ways to do the loop
x = 1
#while (x ... | true |
685bee742fa8bbda0ca4009ae6d9dfe897217477 | Ruby | kenchan/competitive_programming | /atcoder/abc047/c.rb | UTF-8 | 127 | 3.109375 | 3 | [] | no_license | S = gets.chomp
before = S[0]
count = 0
S.each_char do |c|
if before != c
count += 1
end
before = c
end
puts count
| true |
04c78b1f3dbc145071bffd9a1492b24ccc534c37 | Ruby | Michaelcb49/finstagram | /fizzbuzz.rb | UTF-8 | 1,003 | 3.703125 | 4 | [] | no_license | num = 0
div3i = 0
div5i = 0
div3f = 0
div5f = 0
puts "fizzbuzz"
def div3(num_divisible_by_3)
if div3i == div3f
num_divisible_by_3 = div3i
else
num_divisible_by_3 = 0
end
end
def div5(num_divisible_by_5)
if div5i == div5f
num_divisible_by_5 = div5i
else
num_divisi... | true |
c2b29a324ec5ebf1548e8148c80966c49ce1a126 | Ruby | bestwebua/MyRubyFirstSteps | /samples_of_code/teamtreehouse/block_call.rb | UTF-8 | 334 | 3.75 | 4 | [] | no_license | class MyArray
attr_reader :array
def initialize
@array = []
end
def push(item)
array.push(item)
end
def each(&block)
i = 0
while i < array.size
block.call(array[i])
i+=1
end
array
end
end
test = MyArray.new
(1..10).each { |i| test.push(i) }
test.each {... | true |
0287d26bb524be0037c471a2fb0dbe6319aaefe0 | Ruby | andrerondon/Code-Core--Web-Application | /semester_2/20th_ruby_object_oriented_programming/lab1/pizza.rb | UTF-8 | 531 | 4.15625 | 4 | [] | no_license | # Create a Pizza class and a Beer class. They both should have sugar, protein and fat attributes. The Pizza class should have weight attribute and the beer class should have volume attribute. Create a parent Food class and use inheritance.
require_relative './food.rb'
class Pizza < Food
attr_accessor :weight
def... | true |
7dd9316bba6176c2af0f3c4a88e51e848c46bca3 | Ruby | TomasOyarzun/Ruby_study | /entrada.rb | UTF-8 | 118 | 3.578125 | 4 | [] | no_license |
numero = -1
puts 'Ingrese un número entero entre 0 y 36'
numero = gets.chomp.to_i while numero < 0 || numero > 36
| true |
20974c3e82bc66b9b6f752620e84d93fa2be56f3 | Ruby | chrisbutcher/mapify | /lib/mapify.rb | UTF-8 | 567 | 2.984375 | 3 | [
"MIT"
] | permissive | module Enumerable
def mapify(*args)
fail_fast?(args)
map do |object|
args.map do |arg|
object.public_send(arg)
end
end
end
def hashify(*args)
fail_fast?(args)
map do |object|
args.reduce({}) do |hash, arg|
hash[arg] = object.public_send(arg)
hash
... | true |
bf117a88b1a82692d2e79d2896088d18599d2a84 | Ruby | joccreng/Ruby_Test | /condiciones.rb | UTF-8 | 533 | 3.375 | 3 | [] | no_license | edad = gets.chomp.to_i
#numero_dos = gets.chomp.to_i
#numero_uno = gets.chomp.to_i
#numero_dos = gets.chomp.to_i
#if numero_uno > numero_dos
# puts "#{numero_uno} es mayor que #{numero_dos}"
#elsif numero_uno == numero_dos
# puts "Ambos números son iguales"
#else
# puts "#{numero_uno} es menor que #{numero_dos}"
#en... | true |
05f5c0668479f7d940327414e4337ac55a8beac1 | Ruby | bubionbreakfast/VETBOOK---Vet-Management-App | /models/pet.rb | UTF-8 | 2,267 | 3.1875 | 3 | [] | no_license | require_relative( '../db/sql_runner' )
class Pet
attr_accessor :name, :birth_date, :sex, :type, :notes, :vet_id, :owner_id
attr_reader :id
def initialize( options )
@id = options['id'].to_i if options['id']
@name = options['name']
@birth_date = options['birth_date']
@sex = options['sex']
@t... | true |
3117cc97670f677a36a25207ab15aac922c5a504 | Ruby | aagooden/isbn_web | /app.rb | UTF-8 | 3,142 | 2.75 | 3 | [] | no_license |
require 'rubygems'
require 'fog'
require 'csv'
require "sinatra"
require_relative "isbn_functions"
require 'sinatra/activerecord'
require './config/environments' #database configuration
require "./models/user"
enable :sessions
configure do
$stdout.sync = true
end
get "/" do
session[:isbn] = Array.new
erb :welc... | true |
b77dcc715357d516ebc44ba7b5b23b11acdcc92f | Ruby | ciprianna/06-11-sql | /class_for_resource_database.rb | UTF-8 | 1,110 | 3.640625 | 4 | [] | no_license | # Class for Database Connection
class Pet
def initialize(id)
@id = id
end
# Adds a new entry to the Database
def self.add(name, age)
DATABASE.execute("INSERT INTO cats (name, age) VALUES ('#{name}', #{age});")
end
# Reads the entire table
def self.all
DATABASE.execute("SELECT * FROM cats;"... | true |
a0ab56fe8c1f71bc46d3fb8857c70f24572f5a58 | Ruby | jsextonprofessional/ruby_oop | /mammals/lion.rb | UTF-8 | 676 | 3.46875 | 3 | [] | no_license | require_relative 'mammal'
class Lion < Mammal
def initialize
puts "RAAAWR"
@health = 170
end
def fly
@health -= 10
end
def attack_town
@health -= 50
end
def eat_humans
@health += 20
end
end
puts lion = Lion.new
puts lion.display_health
put... | true |
932d2857a7c1c61d6518407df5e48716161022ad | Ruby | alexortiz94/aA-Ruby_Projects | /sudoku_project/board.rb | UTF-8 | 3,410 | 3.4375 | 3 | [] | no_license | require 'byebug'
require_relative 'tile.rb'
class Board
attr_reader :grid
def self.from_file(file)
board = File.readlines(file).map(&:chomp)
board.map do |row|
row.split("").map do |tile|
value = tile.to_i
if value == 0
Tile.new(... | true |
48513d8fe595576d38644a7462653347f99d49a6 | Ruby | alokpradhan/assignment_rspec_viking | /spec/viking_spec.rb | UTF-8 | 3,314 | 3.578125 | 4 | [] | no_license | require 'viking'
require_relative '../lib/weapons/axe.rb'
require_relative '../lib/weapons/weapon.rb'
describe Viking do
let(:viking){Viking.new("Random", 75)}
let(:axe){Axe.new}
let(:bow){Bow.new}
describe '#initialize' do
it 'should create viking with given name' do
expect(Viking.new("Olaf").name).to eq(... | true |
3b9e4e684e4392bd125d469eb991ad0d894bc9ea | Ruby | itchy/inherits_from | /spec/inherits_from/inherits_from_spec.rb | UTF-8 | 1,464 | 2.78125 | 3 | [] | no_license | require 'spec_helper'
class User
attr_accessor :user_field
def initialize
self.user_field = "User Field"
end
end
class Profile
include InheritsFrom
# rewrite inherits_from to not use belongs_to
def self.inherits_from(inheriter, args={})
inherited_methods(inheriter)
inherited_save(inheriter)
... | true |
5d423d18d457ceb7d0bd75d338408f6b9e416bb8 | Ruby | griswoldbar/aardvark | /lib/aardvark/linker/tree_builder.rb | UTF-8 | 3,156 | 2.859375 | 3 | [
"MIT"
] | permissive | module Aardvark
module Linker
class TreeBuilder
def self.build(chain)
temp = []
# chain.inject do |memo, link|
# next_type = link.name
# if next_type == :children && memo
# if memo.name == :father || memo.nam == :mother
# memo.name = :spouses
... | true |
2574f12a34b5b81f7420527368cc1802f7f5eb58 | Ruby | askien/normalizacao | /normalizacao.rb | UTF-8 | 7,013 | 2.59375 | 3 | [] | no_license | #!/usr/bin/ruby
# encoding: UTF-8
DIACRITIC_CHARS = "ÀÁÂÃÄÅàáâãäåĀāĂ㥹ÇçĆćĈĉĊċČčÐðĎďĐđÈÉÊËèéêëĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħÌÍÎÏìíîïĨĩĪīĬĭĮįİıĴĵĶķĸĹĺĻļĽľĿŀŁłÑñŃńŅņŇňʼnŊŋÒÓÔÕÖØòóôõöøŌōŎŏŐőŔŕŖŗŘřŚśŜŝŞşŠšſŢţŤťŦŧÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųŴŵÝýÿŶŷŸŹźŻżŽž"
REGULAR_CHARS = "AAAAAAaaaaaaAaAaAaCcCcCcCcCcDdDdDdEEEEeeeeEeEeEeEeEeGgGgGgGgHhHhIII... | true |
080af51d10b078f2b6165e60d764ca5bf179d22b | Ruby | jjawss/ruby-enumerables-hash-practice-emoticon-translator-lab-houston-web-102819 | /lib/translator.rb | UTF-8 | 423 | 2.9375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # require modules here
require "yaml"
def load_library(file_path)
YAML.load_file(file_path)
hash = {"get_meaning": {"angel", "angry", "bored", "confused", "embarrassed", "fish"
, "glasses", "grinning", "happy", "kiss", "sad", "surprised", "wink"}, "get_emoticon": {}}
return hash
end
def get_japanese_emoticon
# ... | true |
1ecce73e09b56f9c813aa54a364900949b41c986 | Ruby | gcapitanelli/preguntontas | /lib/preguntontas.rb | UTF-8 | 807 | 2.9375 | 3 | [] | no_license | require './lib/pregunta.rb'
class Partida_preguntontas
def initialize
@pregunta = Pregunta.new
@resultado = ""
@preguntaActual = 0
@puntaje = 0
end
def getResultado
@resultado
end
def getPreguntaActual
@preguntaActual
end
def incrementarPreguntaActual
@preguntaActual +... | true |
9c890407e2c91a713b19ed99d4fe4c5930d98993 | Ruby | Exoth/puffer_pages | /lib/puffer_pages/liquid/tags/array.rb | UTF-8 | 984 | 2.640625 | 3 | [
"MIT"
] | permissive | module PufferPages
module Liquid
module Tags
class Array < ::Liquid::Tag
Syntax = /^(#{::Liquid::VariableSignature}+)\s*=\s*(.*)\s*/
def initialize(tag_name, markup, tokens)
if markup =~ Syntax
@variable_name = $1
@items = variables_from_string($2)
... | true |
ba0f742453047014dffdb9b2f921e14215260ddc | Ruby | pedro-stanaka/BandejaoAndroid | /app/src/overlay/generator/generate_overlay | UTF-8 | 6,498 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'fileutils'
require 'yaml'
require 'color'
require 'optparse'
require 'mustache'
OVERLAY_FILES_PATH = File.dirname(__FILE__) + '/overlay_files'
CONFIG_FILE = File.dirname(__FILE__) + '/../universities.yml'
LAUNCHER_FILE = File.dirname(__FILE__) + '/icon_launcher.xcf'
FEATURE_GRAPHIC = File... | true |
33ac52cdf8659fef3b133b1282cd621191d32e00 | Ruby | forty-two-labs/marvel_gallery | /lib/marvel.rb | UTF-8 | 786 | 2.53125 | 3 | [] | no_license | require "net/http"
require "uri"
class Marvel
def self.load_characters
ts = Time.now.to_i
plain_secret = "#{ts}#{ENV["MARVEL_API_SECRET"]}#{ENV["MARVEL_API_KEY"]}"
hash = Digest::MD5.hexdigest(plain_secret)
url = "http://gateway.marvel.com:80/v1/public/characters?ts=#{ts}&apikey=#{ENV["MARVEL_AP... | true |
92ffaa1024ec7cc6495764d2ae33f50bea745f79 | Ruby | michdsouza/SalesTax | /spec/receipt_spec.rb | UTF-8 | 2,806 | 2.765625 | 3 | [] | no_license | require 'receipt.rb'
require 'product.rb'
require 'tax.rb'
describe Receipt do
before (:all) do
BASIC_SALES_TAX_RATE = 10
IMPORTED_SALES_TAX_RATE = 5
EXEMPT_SALES_TAX_RATE = 0
end
before (:each) do
@empty_tax = Tax.EMPTY
@basic_tax = Tax.new(@empty_tax, BASIC_SALES_TAX_RATE)
@imported... | true |
f66416752e2a6eae0192ededf8308531eb605b3f | Ruby | Alex-CAN/phase-0-tracks | /ruby/week_5/prob_solve.rb | UTF-8 | 1,413 | 4.34375 | 4 | [] | no_license | # method take two arguments integer and array
#iterate through each
# arr = [23, 4, 17, 9]
# def search(integer, array)
# index = 0
# # use length of array to loop the array
# while index < array.length
# if array[index] == integer
# output = index
# else
# output = nil
# end
# index += 1
# ... | true |
a3e43c23508ac08e2bd4c04b01dd1216fee6c9cb | Ruby | Smesworld/jungle_app | /app/models/sale.rb | UTF-8 | 886 | 2.71875 | 3 | [] | no_license | class Sale < ActiveRecord::Base
validate :end_after_start
validates :name, :starts_on, :ends_on, presence: true
validates :percent_off, presence: true, numericality: {only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 100}
def self.active
where("sales.starts_on <= ? AND sales.ends_on >... | true |
f7ca9e57207d206686dd40229f1b135817c905a0 | Ruby | cdhenry/ttt-3-display_board-example-bootcamp-prep-000 | /lib/display_board.rb | UTF-8 | 231 | 3.109375 | 3 | [] | no_license | # Define a method display_board that prints a 3x3 Tic Tac Toe Board
def display_board
playspace = " | | "
separator = "-----------"
puts playspace
puts separator
puts playspace
puts separator
puts playspace
end
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.