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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
95a24b375c28782032382eab6234acee58a81d70 | Ruby | sattelbergerp/ttt-with-ai-project-cb-000 | /bin/tictactoe | UTF-8 | 790 | 3.203125 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative '../config/environment'
loop do
puts "CLI Ruby"
puts "1. 2 Player"
puts "2. 1 Player"
puts "3. 0 Player (AI vs. AI)"
puts "exit. Exit the game"
print "Select Option (1-3): "
inputs = gets.strip.split(" ")
skip_aftergame = false
case inputs[0]
when "1"
start_game(Player... | true |
f27f044867e74dfb9a1ae085c89dc9809bc34564 | Ruby | hmohamed0/ruby_fundamentals2 | /exersize6.rb | UTF-8 | 761 | 3.953125 | 4 | [] | no_license | def list_groceries(list)
list.each do |x| puts "* " + x end
puts
end
grocery_list = ["carrots","toilet paper","apples","salmon"]
list_groceries(grocery_list)
#2 adds rice to list
grocery_list << "rice"
list_groceries(grocery_list)
puts grocery_list.length
puts
#4 Checks list to see if bananas included
product_... | true |
b81b524929c79f8da7c0c12e1a5bbe08bfed4738 | Ruby | DragDropQueen/groupify | /lib/groupify/group.rb | UTF-8 | 181 | 2.703125 | 3 | [
"MIT"
] | permissive | module Groupify
module Group
def random
all.shuffle
end
def groups(n)
per = (all.count / n.to_f).ceil
random.each_slice(per).to_a
end
end
end
| true |
b0b5aecaadc8fc05a5c259d030426d3c7d1cd833 | Ruby | UbuntuEvangelist/therubyracer | /vendor/bundle/ruby/2.5.0/gems/amqp-1.8.0/examples/queues/using_explicit_acknowledgements.rb | UTF-8 | 2,957 | 2.8125 | 3 | [
"Ruby",
"MIT"
] | permissive | #!/usr/bin/env ruby
# encoding: utf-8
require "bundler"
Bundler.setup
$:.unshift(File.expand_path("../../../lib", __FILE__))
require 'amqp'
puts "=> Subscribing for messages using explicit acknowledgements model"
puts
# this example uses Kernel#sleep and thus we must run EventMachine reactor in
# a separate thread... | true |
9fa3952f3818b36e63993e587f885c589603c535 | Ruby | mlibrary/pairtree | /lib/pairtree.rb | UTF-8 | 3,095 | 2.90625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | require "pairtree/identifier"
require "pairtree/path"
require "pairtree/obj"
require "pairtree/root"
require "fileutils"
module Pairtree
class IdentifierError < RuntimeError; end
class PathError < RuntimeError; end
class VersionMismatch < RuntimeError; end
SPEC_VERSION = 0.1
##
# Instantiate a pairtre... | true |
5fc2fd2a3f57238c4c395782ca0b7f8ad59a3cbc | Ruby | CoderAcademy-SYD/payme | /payme.rb | UTF-8 | 1,452 | 2.90625 | 3 | [] | no_license | #
# payme - A easy way to pay me :)
#
# Required libraries
require_relative "payment"
require_relative "ux"
# Main
Ux.welcome
Ux.say_title('Money')
amount = Ux.ask_number("How much would you like to Pay (USD): ", Float,
Payment::AMOUNT_MIN, Payment::AMOUNT_MAX)
Ux.say_title("Personal Info"... | true |
cafa4d97b5c74af2389a3ca3c0230e42ce0bddac | Ruby | kremso/tmzone | /lib/tort/cache.rb | UTF-8 | 653 | 2.5625 | 3 | [] | no_license | require 'tort/cache/redis_backend'
require 'yaml'
module Tort
class Cache
def initialize(namespace, searcher, backend = Tort::RedisBackend.new(namespace))
@searcher = searcher
@backend = backend
end
def search(phrase, &block)
if (batched_results = @backend.fetch(phrase))
YAML::... | true |
7638010165ccaf342fafd42956c6f809d8b07305 | Ruby | daimyo-college/ruby-super-intro-lesson | /rines/chapter6/3-9.rb | UTF-8 | 136 | 2.765625 | 3 | [] | no_license | menu = {"コーヒー" => 300,"カフェラテ" => 400,}
menu.each{|key,value|
if value >= 350
puts "#{key} - #{value}円"
end
} | true |
e668c358e2ff9a010397f7c73a118b601b8cf9f4 | Ruby | vladcenan/ruby_training_modules | /exceptions.rb | UTF-8 | 249 | 2.625 | 3 | [] | no_license | #!/usr/bin/env ruby
files = ['exceptionsfile1.txt', 'exceptionsfile2.txt']
files.each do |f|
begin
file = open(f)
if file
puts 'File opened successfully'
end
rescue StandardError
puts f+' do not exist!'
next
end
end
| true |
6c0c42cc1441aec626f4df6cfec8713c7b687bba | Ruby | danguita/profile-updater | /lib/github_api/request.rb | UTF-8 | 407 | 2.671875 | 3 | [
"MIT"
] | permissive | require_relative "client"
module ProfileUpdater
module GithubApi
class EmptyBioError < StandardError; end
class Request
attr_reader :bio
def initialize(bio:)
@bio = bio.to_s.strip.force_encoding(Encoding::UTF_8).freeze
end
def call
raise EmptyBioError, "Bio can't be ... | true |
44ddbe5c715174e3984e89e45625f0e3599f7cc0 | Ruby | Mattlk13/maglev | /src/test/testGlobals6.rb | UTF-8 | 415 | 3.125 | 3 | [] | no_license | class CA
RuntimeArg = []
NoArg = [ 5 ]
class CB
class NoArg < self
end
end
NoArg.each { | e | RuntimeArg << CB::NoArg }
end
r = CA::NoArg
unless r == [ 5 ]
raise 'ERROR'
end
r = CA::RuntimeArg
# puts r.length
# puts r[0].class
unless r == [ CA::CB::NoArg ]
raise 'ERROR'
end
# puts r.length
# put... | true |
59e971d4f73379a997ee1d53fbb97792ca65ccee | Ruby | galestorm/hotel | /specs/block_spec.rb | UTF-8 | 1,428 | 2.78125 | 3 | [] | no_license | require_relative 'spec_helper'
describe 'Block' do
let(:check_in) {Date.new(2017,9,5)}
let(:check_out) {Date.new(2017,9,7)}
let(:rooms) {[Hotel_System::Room.new(1)]}
let(:rate_adjustor) {0.75}
let(:my_block) {Hotel_System::Block.new(check_in, check_out, rooms, rate_adjustor)}
describe 'initialize' do
... | true |
e45d9844fab60e0dade1aa541d8f74677f766e94 | Ruby | justindelatorre/ruby_challenges | /medium_1/3_pig_latin/pig_latin.rb | UTF-8 | 952 | 3.53125 | 4 | [] | no_license | =begin
https://launchschool.com/exercises/0b445a57
=end
class PigLatin
def self.translate(phrase)
words = phrase.split
arr = words.map do |word|
self.apply_pig_latin(word)
end
arr.size > 1 ? arr.join(' ') : arr.join
end
private
def self.apply_pig_latin(word)
length = w... | true |
6e126c43d4438f9fe515dc074cf86e7054218b96 | Ruby | marinacor1/headcount | /lib/result_set.rb | UTF-8 | 280 | 2.65625 | 3 | [] | no_license | require_relative 'result_entry'
require 'pry'
class ResultSet
attr_reader :matching_districts, :statewide_average
def initialize(entries = [])
@matching_districts = entries.fetch(:matching_districts)
@statewide_average = entries.fetch(:statewide_average)
end
end
| true |
7dda6bf9bcead50ace973f73ddfe09ab5978c50c | Ruby | neilkelty/learning_ruby | /learn_to_program/ch6.rb | UTF-8 | 1,995 | 4.15625 | 4 | [] | no_license | section_break = '====================================='
# List of the 10 methods we've covered in chapters 1 - 5
# puts, gets, to_s, to_i, to_f, chomp, +, -, *, /
puts('hello'.+ 'world')
puts((10.* 9).+ 9)
puts self
puts section_break #Not part of the tutorial, just helps me visually.
#6.1 Fancy String Methods
var... | true |
81343b589ab46dadaec9a49955580be1f00dd268 | Ruby | tchiu2/stock-portfolio-server | /app/services/portfolio_builder.rb | UTF-8 | 579 | 2.71875 | 3 | [] | no_license | module PortfolioBuilder
def self.build(positions)
return positions if positions.empty?
symbols = positions.keys.join(",")
quotes = Iex::Client.quotes(symbols)
positions.reduce({}) do |acc, (k, v)|
quote = quotes[k.to_s]["quote"]
acc.merge(k => {
symbol: k,
name: quo... | true |
8860f7651fcfc7318ea54195c493aa5ff5d588ee | Ruby | RomanADavis/learn-programming | /learn-ruby-the-hard-way/game/scene.rb | UTF-8 | 336 | 3.84375 | 4 | [] | no_license | class Room
def initialize(name)
@name = name
@visible = [] #list of interactables in the romm
@hidden = [] #hidden items
end
def reveal(item)
if @hidden.include? item
puts "#{item} revealed!"
@visible << @hidden.delete(item)
else
puts "#{item} isn't here."
e... | true |
65b45fd9a5b54cbdc79fd3f65281e01e096a5cd5 | Ruby | wfsiew/Akamomiji_rails | /app/models/reservation.rb | UTF-8 | 904 | 2.625 | 3 | [] | no_license | class Reservation < ActiveRecord::Base
attr_accessible :id, :location, :name, :pax, :phone_no, :remarks, :reserve_date, :reserve_time,
:status, :table
self.table_name = 'reservation'
validates_presence_of :location, message: 'Location is required'
validates_presence_of :name, message: '... | true |
4d6328c7f56adf5c39247090717ad5c247ff6878 | Ruby | Steiner87/Time | /app2.rb | UTF-8 | 2,543 | 3.25 | 3 | [] | no_license |
def get_dates years,months,days,hours=0,minuts=0,seconds=0
# 1) Создаем объект date и присваиваем ему введенные значения
date=Time.new(years,months,days,hours,minuts,seconds)
# 2)Переводим объект в цифровое Unix отображение
date_unix=date.to_i #Дата в Unix системе исчесления
puts date.str... | true |
e469822454839d4d2a3446aeb44c6e2cd627aa14 | Ruby | matt-12/Final-Project | /FinalProject.rb | UTF-8 | 3,037 | 2.90625 | 3 | [] | no_license | puts "Welcome to Stratego!"
puts "If you take the button labled 'f' then you win!""
require 'fox16'
include Fox
class HelloWorldWindow < FXMainWindow
def initialize(app)
super(app, 'Hello World Program')
@mtx = FXMatrix.new(self, 6)
numbers1 = ["F", "5", "4", "4", "3", "3", "3", "2", "2", "2", "2", "1... | true |
27c661f11d9fbe2ab929a3d5132d32b47a8deb92 | Ruby | james-cape/potluck | /test/dish_test.rb | UTF-8 | 547 | 2.796875 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/dish'
require 'pry'
class DishTest < Minitest::Test
def setup
@dish = Dish.new("Couscous Salad", :appetizer)
end
def test_dish_exists
expected = Dish
actual = @dish
assert_instance_of expected, actual
end
def test_salad_na... | true |
179541f91b42249ffd598cf36a76ae531e26cca2 | Ruby | DragonRuby/dragonruby-game-toolkit-contrib | /dragon/easing.rb | UTF-8 | 3,080 | 2.8125 | 3 | [
"LicenseRef-scancode-other-permissive",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # coding: utf-8
# Copyright 2019 DragonRuby LLC
# MIT License
# easing.rb has been released under MIT (*only this file*).
module GTK
module Easing
def self.ease start_tick, current_tick, duration, *definitions
ease_extended start_tick,
current_tick,
start_tick + dura... | true |
1ab142b59978d944cfcfc4e825197ed6169f16cd | Ruby | peperon/ProjectEulerProblems | /problem9_spec.rb | UTF-8 | 246 | 2.71875 | 3 | [] | no_license | require './problem9'
describe Problem9Solution do
it "Finds the special pythagorean triplet" do
solution = Problem9Solution.new
a, b, c = solution.find
expect(a * a + b * b).to eq(c * c)
expect(a + b + c).to eq(1000)
end
end
| true |
d111b871e1792347b37a3c01a57ab48e47d5843e | Ruby | ambshar/lsruby | /assessment/atbash.rb | UTF-8 | 455 | 3.375 | 3 | [] | no_license | require 'pry'
class Atbash
KEYS = ("a".."z").to_a
VALUES = KEYS.reverse
CODE_KEY = Hash[KEYS.zip(VALUES)]
def self.encode(string)
string_array = string.downcase.scan(/[a-z0-9]/)
#output = []
result = string_array.each_with_object([]) do |chr, output|
output << (chr.to_i == 0 ? CODE_KEY[chr]... | true |
6d30496bae2f69780271a6b3c1fb9921bdf334da | Ruby | jonnyguio/GildedRose-Refactoring-Kata | /ruby/gilded_rose.rb | UTF-8 | 1,245 | 3.09375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
class GildedRose
def initialize(items)
@items = items
end
def update_quality
@items.each do |item|
if item.name.include?('Backstage passes')
item.quality += 1 if item.sell_in > 10
item.quality += 2 if (item.sell_in <= 10) && (item.sell_in > 5)
... | true |
79fdacb4c6db27331a135ebe45cdd08bc4a58209 | Ruby | DrDhoom/RMVXA-Script-Repository | /Himeworks/Post_Battle_Events.rb | UTF-8 | 6,632 | 2.796875 | 3 | [
"MIT"
] | permissive | =begin
#===============================================================================
Title: Post-Battle Events
Author: Hime
Date: Nov 18, 2015
--------------------------------------------------------------------------------
** Change log
Nov 18, 2015
- fixed bug where post battle victory event only ran once... | true |
4fa0cc888dd5fb0fda7a0baedc2ed7b134e34d3c | Ruby | smirik/Three-body-resonances | /classes/body.rb | UTF-8 | 195 | 2.75 | 3 | [] | no_license | require 'classes/body_elements.rb'
require 'classes/degrees.rb'
class Body
attr_accessor :mass, :pos, :vel, :time
def pp
puts "Axis: #{@axis}, mean motion: #{@mean_motion}"
end
end | true |
3877d99cf8d67d292381360543e364ed4f282ada | Ruby | srekhi/goal_tracker | /app/models/post.rb | UTF-8 | 540 | 2.734375 | 3 | [] | no_license | # == Schema Information
#
# Table name: posts
#
# id :integer not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# body :text
# author :string
#
class Post < ApplicationRecord
validate :has_sunny_in_body
validates :body, presence: t... | true |
ccd7e579dd9e63ab9cfbc3177a0a5e59104df481 | Ruby | ReaazDollie/dummy_text | /lib/dummy_text/word.rb | UTF-8 | 383 | 2.984375 | 3 | [
"MIT"
] | permissive | require 'dummy_text/text'
module DummyText
class Word < Text
def initialize
end
def render(count, template)
data = get_file_as_array(template)
data.join.split('. ').join.split[0...count].join(" ")
end
def self.number_of_words(template)
data = self.get_file_as_stri... | true |
15afa81e9bb6f97e9121658ae48d8051c5770898 | Ruby | tdyer/EMRack | /event_machine/async_server.rb | UTF-8 | 1,310 | 2.578125 | 3 | [] | no_license | #!/usr/bin/env ruby
# http://www.igvita.com/2008/05/27/ruby-eventmachine-the-speed-demon/
require 'rubygems'
require 'eventmachine'
require 'evma_httpserver'
# install the gem
# gem install eventmachine_httpserver
# to run:
# async_server.rb
# 5 clients each making 2 requests
# ab -n 10 -c 5 http://127.0.0.1:9292/... | true |
8347accf89b2ce1f5f2f234bf51625eb416dceae | Ruby | nysol/doc | /olddoc/mcmd/jp/examples/mjoin.rb | UTF-8 | 1,127 | 2.78125 | 3 | [] | no_license | #!/usr/bin/env ruby
# coding: utf-8
require "./mkTex.rb"
File.open("dat1.csv","w"){|fpw| fpw.write(
<<'EOF'
item,date,price
A,20081201,100
A,20081213,98
B,20081002,400
B,20081209,450
C,20081201,100
EOF
)}
File.open("ref1.csv","w"){|fpw| fpw.write(
<<'EOF'
item,cost
A,50
B,300
E,200
EOF
)}
############## 例1
title="基本... | true |
9d5c9c84321eac28cc6cca022c8a0870fc7b0066 | Ruby | software-engineering-amsterdam/many-ql | /geert.kai/spec/type_checker_spec.rb | UTF-8 | 1,489 | 2.703125 | 3 | [] | no_license | require_relative "spec_helper"
describe "Type checker" do
it "detects duplicate labels" do
question = QL::AST::Question.new("Wat is uw leeftijd?", "leeftijd", IntegerType.new)
form = Form.new("dubbel label", [question, question])
errors = form.accept(DuplicateLabelChecker.new)
expect(errors.first.me... | true |
8163d43059685e39149c1057337044c772419bf6 | Ruby | cycloped-io/cycloped-io | /classification/utils/select_specs.rb | UTF-8 | 2,122 | 2.8125 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: utf-8
require 'bundler/setup'
$:.unshift 'lib'
$:.unshift '../category-mapping/lib'
require 'slop'
require 'csv'
require 'cycr'
require 'progress'
require 'mapping'
options = Slop.new do
banner '#{$PROGRAM_NAME} -f terms.csv -o specs.csv -t term [-h host] [-p port]\n' +
'Select ... | true |
3c898dd2796ae916ab02f33d96a21c314d043aa0 | Ruby | chdmark/phase-0 | /week-5/calculate-mode/my_solution.rb | UTF-8 | 2,219 | 4.03125 | 4 | [
"MIT"
] | permissive | # Calculate the mode Pairing Challenge
# I worked on this challenge with Mike Cerrone
# I spent 1.5 hours on this challenge.
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented.
# 0. Pseudocode
# What is the inpu... | true |
e2fb1f10d7498770408b412c64e1e68c31e08586 | Ruby | ncbo/goo | /lib/goo/validators/implementations/superior_equal_to.rb | UTF-8 | 646 | 2.6875 | 3 | [
"BSD-2-Clause"
] | permissive | module Goo
module Validators
class SuperiorEqualTo < ValidatorBase
include Validator
key :superior_equal_to_
error_message ->(obj) {
"`#{@attr}` must be superior or equal to `#{@property}`"
}
validity_check -> (obj) do
target_values = self.class.attr_value(@propert... | true |
26f4bafc65e6558df356a4e31e15a99d73b28aa2 | Ruby | yanshiyason/cob | /lib/credentials.rb | UTF-8 | 1,729 | 2.96875 | 3 | [] | no_license | # frozen_string_literal: true
#
# class to handle the credentials
#
# usage:
#
# c = Credentials.new
# c.username
# c.pa_token
#
class Credentials
def initialize
@config_file = ENV['GITHUB_CREDENTIALS_FILE'] ||
"#{ENV['HOME']}/.cob/github_credentials.json"
end
def config
@config ||= p... | true |
72732f2163f97f511ec03666bf9f2e0e7d1ada4f | Ruby | BenRKarl/WDI_work | /w03/d02/Corey_Leveen/yellow_submarine/app.rb | UTF-8 | 706 | 2.921875 | 3 | [] | no_license | require 'bundler'
Bundler.require
get '/' do
class Sailor
attr_accessor :name
def initialize(name)
@name = name
end
end
class Submarine
attr_accessor :color, :sailors
def initialize(color='yellow')
@color = color
@sailors = []
end
def accept_sailor(sailor)
@sailors << sailor
end
... | true |
a1413a91c0ebcf5ee2e3573aa239e6f6b72f9fbb | Ruby | MadBomber/experiments | /ruby_misc/table_read/spec_script.rb | UTF-8 | 8,251 | 2.875 | 3 | [] | no_license | # table_read/spec_script.rb
require 'pathname'
require_relative './db_access'
require_relative './talent_pool'
# Provides access to the contents of
# a ScenArtist (Scene Artist) script
# which stored in an SQLite database.
class SpecScript
attr_accessor :raw
attr_accessor :script
attr_accessor :characters
... | true |
ba391b330fc2d0741c41273655da2f4dd52c13b4 | Ruby | zaheerkth/operators-dumbo-web-career-010719 | /lib/operations.rb | UTF-8 | 154 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def unsafe?(speed)
if speed >60 || speed <40
true
else
false
end
end
def not_safe?(speed)
speed.between?(40,60)?false:true
end
| true |
70fc95250a7eed9b16fe0bf5c25ec776c802cb63 | Ruby | proxyto/RubyTasks | /WarmUpWeek/digits.rb | UTF-8 | 316 | 3.484375 | 3 | [] | no_license | def to_digits(n)
n.to_s.chars.map {|d| d.to_i}
end
def count_digits(n)
to_digits(n).length
end
def sum_digits(n)
to_digits(n).reduce {|a,e| a+e}
end
def factorial_digits(n)
to_digits(n).reduce {|a,e| a*e}
end
puts to_digits(12345)
puts count_digits(12345)
puts sum_digits(12345)
puts factorial_digits(12345) | true |
f2eb4a5c50436cb8dfba716e2f2e78b7b4ee1c79 | Ruby | WillRadi/rental_cars | /app/models/rental.rb | UTF-8 | 1,026 | 2.671875 | 3 | [] | no_license | class Rental < ApplicationRecord
belongs_to :customer
belongs_to :car_category
has_one :car_rental
validate :end_date_must_be_greater_than_start_date
validate :start_date_is_not_past
validate :end_date_is_not_past
enum status: { scheduled: 0, ongoing: 5 }
before_create :create_code
private
def e... | true |
26787a0c442ca0e62145dde15345095abdaf7397 | Ruby | NgariNdungu/dsa | /rb_bin_search.rb | UTF-8 | 576 | 3.453125 | 3 | [] | no_license | def bin_search(item, search_list)
found = false
return found if search_list.empty?
while !found
mid = search_list.length / 2
if search_list[mid] == item
found = true
elsif search_list[mid] < item
return bin_search(item, search_list[mid+1..-1])
else
return bin_search(item, search... | true |
50c707dc51d9f1385c0ca0d9cb81935de3a1d736 | Ruby | soycake/ruby-examples | /6_1_metaprogramming_eval.rb | UTF-8 | 101 | 3.296875 | 3 | [] | no_license | # Simple evaluation of ruby code in a string
ruby_code = '3.times { puts "hello" }'
eval ruby_code
| true |
172b681353d007d3de790e81f19011c8f4daf13f | Ruby | Thomas008/ruby-excel-library-examples | /reo_example.rb | UTF-8 | 526 | 2.96875 | 3 | [] | no_license | require 'robust_excel_ole'
# ============================================
# =========== Read Example ===============
# ============================================
workbook = RobustExcelOle::Workbook.open './sample_excel_files/xlsx_500_rows.xlsx'
puts "Found #{workbook.worksheets_count} worksheets"
workbook.eac... | true |
dfec295cc2a25557b0d1e2a909aec450ba3c3e02 | Ruby | johnpooley/week_2_day_2_homework | /river.rb | UTF-8 | 282 | 3.328125 | 3 | [] | no_license | class River
attr_accessor :fish
def initialize(name)
@name = name
@fish = []
end
def fishcount
return @fish.count
end
def throw_fish_in_river(new_fish)
@fish << new_fish
end
def fish_out_of_water(fish)
return @fish.delete(fish)
end
end
| true |
9232f370e1dae5b58d40764856e2007de16fb44f | Ruby | SlevinKelevra/thinknetica | /Lesson9/train.rb | UTF-8 | 1,729 | 3.203125 | 3 | [] | no_license | require_relative 'modules'
require_relative 'instance_counter'
require_relative 'validation'
class Train
include Manufacturer
include InstanceCounter
include Validation
attr_accessor :current_speed, :wagon, :numer
NUMBER_FORMAT = /^[a-z0-9]{3}-*[a-z0-9]{2}/
@@trains = {}
def self.find(numer)
@@trai... | true |
143b26e690adb71b767fa44c7ca9c3aac684bb16 | Ruby | thomthom/SketchUp-Ruby-API-Doc | /lib/materialsobserver.rb | UTF-8 | 4,845 | 2.609375 | 3 | [] | no_license | module Sketchup
# This observer interface is implemented to react to {Material}s events.
# To implement this observer, create a Ruby class of this type, override the
# desired methods, and add an instance of the observer to the objects of
# interest. The callback onMaterialRemoveAll has been deprecated, we ... | true |
e33130212b029524d2f9d212ba0ff426e94b217b | Ruby | elnura15ae/Ruby_ | /17.Comments.rb | UTF-8 | 74 | 2.71875 | 3 | [] | no_license |
puts "Comments are fun" # This line prints comments
# this a comments
| true |
7beef2b5763abe9b70ef8e4c71948c18752c2139 | Ruby | garigari-kun/til | /src/textbooks/poodir/ch5/overlooking.rb | UTF-8 | 311 | 3.03125 | 3 | [] | no_license |
class Trip
attr_reader :bicycles, :customers, :vehicle
def prepare(mechanic)
return mechanic.prepare_bicycles(bicycles)
end
end
class Mechanic
def prepare_bicycles(bicycles)
return bicycles.each { |bicycle| prepare_bicycle(bicycle)}
end
def prepare_bicycle(bicycle)
end
end
| true |
797830192ef753b9744c75b9fe02e104e996fb1c | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/08797ab021c44c2c897114d3e20b3aa8.rb | UTF-8 | 940 | 3.890625 | 4 | [] | no_license | class Hamming
def self.compute(strand_a, strand_b)
new(strand_a, strand_b).number_of_nucleotide_differences
end
def initialize(strand_a, strand_b)
@strand_a = Strand.new(strand_a)
@strand_b = Strand.new(strand_b)
end
def number_of_nucleotide_differences
nucleotide_pairs.count do |nuc_a, nuc_... | true |
6b0cd799705c4d7e23e0fdd3125f20d1df9fe973 | Ruby | dlaststark/machine-learning-projects | /Programming Language Detection/Experiment-2/Dataset/Train/Ruby/anonymous-recursion-1.rb | UTF-8 | 127 | 3.21875 | 3 | [] | no_license | def fib(n)
raise RangeError, "fib of negative" if n < 0
(fib2 = proc { |m| m < 2 ? m : fib2[m - 1] + fib2[m - 2] })[n]
end
| true |
0b93568788d221918c5b6d3a547345172276a236 | Ruby | murog/hotel | /pseudocode_wave_2.rb | UTF-8 | 685 | 3.328125 | 3 | [] | no_license | require_relative 'lib/hotel.rb'
require_relative 'lib/room.rb'
require_relative 'lib/reservation.rb'
# Wave 2
# User Stories
# => As an administrator, I can view a list of rooms that are not reserved for a given date range
Hotel.available_rooms(begin_date, end_date)
#=> returns array [Room Object.available true for d... | true |
b19da95b2b23733c67cd85885aa939e7d6df27f1 | Ruby | genometools/genometools | /scripts/gc-parse.rb | UTF-8 | 1,410 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"ISC",
"BSD-2-Clause",
"LicenseRef-scancode-mit-old-style",
"Zlib",
"MIT",
"BSD-3-Clause",
"bzip2-1.0.6"
] | permissive | #!/usr/bin/env ruby
GC_code = Struct.new("GC_code",:name,:idnum,:aa,:start)
def gc_code_pretty(gc)
l = [" {\"#{gc.name}\"",
"(unsigned int) #{gc.idnum}",
"\"#{gc.aa}\"",
"\"#{gc.start}\"}"]
return l.join(",\n ")
end
def transnum_idx_pretty(idx_map,idx)
if idx_map.has_key?(idx)
retur... | true |
63fa106962a34f65e9fe7edd49634dc053ab2d73 | Ruby | moeabdol/design-patterns-in-ruby | /iterator/internal_iterator/for_each_element.rb | UTF-8 | 139 | 3.359375 | 3 | [] | no_license | def for_each_element(array)
array = array.clone
index = 0
while index < array.length
yield array[index]
index += 1
end
end
| true |
9c41caca3953fdb72d8b23522a70408b8b87002b | Ruby | nebolsin/oj | /test/test_parser_saj.rb | UTF-8 | 5,638 | 3.015625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# encoding: UTF-8
$: << File.dirname(__FILE__)
require 'helper'
$json = %{{
"array": [
{
"num" : 3,
"string": "message",
"hash" : {
"h2" : {
"a" : [ 1, 2, 3 ]
}
}
}
],
"boolean" : true
}}
class AllSaj < Oj::Saj
attr_accessor :... | true |
42d181650d117ce8cea367b058c05a37584a1195 | Ruby | szTheory/ruby_speech | /spec/support/dtmf_helper.rb | UTF-8 | 403 | 3.140625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # encoding: utf-8
# frozen_string_literal: true
#
# Convert a simple DTMF string from "1 star 2" to "dtmf-1 dtmf-star dtmf-2".
#
# @param [Array] sequence A set of DTMF keys, such as `%w(1 star 2)`.
#
# @return [String] A string with "dtmf-" prefixed for each DTMF element.
# Example: "dtmf-1 dtmf-star... | true |
02617e87e56b2bf4193a4675ab740f2b1e8804d1 | Ruby | vpatel90/rr_mvc_blog | /app/models/comment.rb | UTF-8 | 508 | 2.640625 | 3 | [] | no_license | $id_c = 1
class Comment
attr_accessor :id, :time, :author_fn, :author_ln, :user, :body
def initialize(user, body, post)
@id = $id_c
$id_c += 1
@time = GetTime.now
@user = user
@author_fn = user.first_name
@author_ln = user.last_name
@body = body
@post_id = post.id
post.comments.u... | true |
c69fdb25432dea046890485ce2a3bfcddd7ca792 | Ruby | tylercollier/rpn_calc | /app/rpn/math.rb | UTF-8 | 1,236 | 3.421875 | 3 | [] | no_license | module RPN
class InvalidOperatorError < StandardError; end
class Math
def numeric_cast(input)
# We'd use the i18n library if internationalization is needed, e.g. to
# look for commas as the decimal separator.
# Casting to an integer, as opposed to always a float, is one simple way
# to ... | true |
8cb1e994daabda6715d1fa3fadd0aaf0322323b2 | Ruby | natedog/sportent | /vendor/plugins/semantify/lib/semantify.rb | UTF-8 | 1,462 | 2.625 | 3 | [
"MIT"
] | permissive | # Semantify
require 'open-uri'
require 'nokogiri'
module Semantify
class Semantify
def self.fetch(url)
# WORK OUT HOW TO MAKE THESE CONSTANTS
openamplify_API_key = "eup9b9epknxn6fvumtdxqprc3x4d58vr"
alchemy_API_key = "a3bbc19ddac62cf366b45c1f6f83584bbca312... | true |
b6484efd4c9ca53902607ca9a0535a485790b32d | Ruby | maguirpa/Tealeaf_exercises | /chapter7_hashes/2.rb | UTF-8 | 449 | 3.046875 | 3 | [] | no_license | my_fam = {brother: "Colin", sister: "Katie", mom: "Patti", dad: "John"}
her_fam = {cousin: "Tashay", uncle: "Melvin", aunt: "Betty"}
p my_fam.merge(her_fam)
p my_fam
p my_fam.merge!(her_fam)
p my_fam
# merge without the bang operater will merge the documents in place but will not permanently alter the original has... | true |
9ddf573d8cd6dd6b1a984573f81cb12627099313 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/grains/d7b69a76e76a44a58c3204144a577efd.rb | UTF-8 | 76 | 2.859375 | 3 | [] | no_license | class Grains
def square(a)
2**(a-1)
end
def total
(2**64)-1
end
end
| true |
70a3f3ac6a15b4cb05d7df3df66a3fb11f410ac4 | Ruby | avalonmediasystem/hyrax | /lib/wings/services/custom_queries/find_file_metadata.rb | UTF-8 | 5,032 | 2.75 | 3 | [
"Apache-2.0",
"AGPL-3.0-or-later"
] | permissive | # Custom query override specific to Wings for finding Hydra::PCDM::File and converting to Hyrax::FileMetadata.
# @example
# Hyrax.custom_queries.find_file_metadata_by(id: valkyrie_id, use_valkyrie: true)
# Hyrax.custom_queries.find_file_metadata_by_alternate_identifier(alternate_identifier: id, use_valkyrie: true)
... | true |
f53561547f9bf0292fbb464ebccc5fb1f1954567 | Ruby | matiasleidemer/validates_captcha | /lib/validates_captcha/image_generator/simple.rb | UTF-8 | 3,399 | 3.34375 | 3 | [
"MIT"
] | permissive | module ValidatesCaptcha
module ImageGenerator
# This class is responsible for creating the captcha image. It internally
# uses ImageMagick's +convert+ command to generate the image bytes. So
# ImageMagick must be installed on the system for it to work properly.
#
# In order to deliver the captch... | true |
bcfe9544cd6bb9efb17d0cfeb469c19567b9fe42 | Ruby | Friindel33/RubyLessons | /MyApp1/hwapp16.rb | UTF-8 | 221 | 3.6875 | 4 | [] | no_license | print "How many years planning to do savings: "
x = gets.to_f
print "How much every month: "
n = gets.to_i
s = 0
1.upto (x) do |mm|
1.upto (12) do |pp|
s = s + n
puts "Year #{mm} month #{pp}: #{s}"
end
end
| true |
287aa612c84da11a8320ac5e71f385c7718c42bb | Ruby | jherre/gexf.rb | /lib/gexf/json_serializer.rb | UTF-8 | 687 | 2.71875 | 3 | [] | no_license | require 'json'
class GEXF::JsonSerializer
def initialize(graph)
@graph = graph
end
def serialize!
JSON.pretty_unparse document
end
private
def nodes
@nodes ||= @graph.nodes.values
end
def document
{
'nodes' => build_nodes,
'links' => build_links,
}
end
... | true |
d699a0cd6763edbb430b5a2a99aaf65c3377090f | Ruby | nikolasco/project_euler | /036.rb | UTF-8 | 247 | 2.84375 | 3 | [] | no_license | MAX = 10**6
s = (0..MAX).inject(0) do |sum, n|
ns10 = n.to_s
ns10l = ns10.length/2
ns2 = n.to_s(2)
ns2l = ns2.length/2
(ns10[0,ns10l] == ns10[-ns10l,ns10l].reverse and
ns2[0,ns2l] == ns2[-ns2l,ns2l].reverse)? sum + n : sum
end
puts s
| true |
15b4b03d700e4548ff728de71e0d96117cf1f892 | Ruby | Sumbhodi1618/operators-online-web-prework | /lib/operations.rb | UTF-8 | 119 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def unsafe?(speed = 60)
if speed >= 60
true
elsif speed <= 40
true
else
speed == 40..60
false
end
end | true |
93911d70b31b057545b65f04f7f8165b7a853808 | Ruby | surjit/Chats-REST-Server | /test/controllers/users_controller_test.rb | UTF-8 | 2,886 | 2.53125 | 3 | [] | no_license | require 'test_helper'
class UsersTest < ChatsTest
def test_users_get
get '/users'
assert_return /\A\[\{"id":1,"name":\{"first":"Matt","last":"Di Pasquale"\},"picture_id":"[0-9a-f]{32}"\}\]\z/
end
def test_users_post
# Create code
phone = '2102390603'
Chats::TextBelt.mock({'success' => true})... | true |
1290228e470d71f717a89e8da9f24eb6e2da8184 | Ruby | toptal/archfiend | /lib/archfiend/logging.rb | UTF-8 | 2,124 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'logger'
module Archfiend
class Logging
class << self
DEFAULT_FORMATTERS = {
file: 'JSONFormatter',
stdout: 'DefaultFormatter'
}.freeze
# @param environment [String|Symbol] Current running environment, ex. :development
# @param log_directory [String,Pathname] Dire... | true |
cea5a3adc4dbeb6570a64c851e5708343b8bda12 | Ruby | christ4sam/my_recipe_app | /app/controllers/recipes_controller.rb | UTF-8 | 4,407 | 2.953125 | 3 | [] | no_license | class RecipesController < ApplicationController
before_action :set_recipe, only: [:edit, :update, :show, :like]
#here users that are NOT logged in can browse only the index (list recipe page)and the show recipe page
before_action :require_user, except: [:show, :index, :like]
#here for a user to like a recip... | true |
3391adf8c63f2922662ce1ca02c7806878b08074 | Ruby | Jliv316/module_3_diagnostic | /app/models/station.rb | UTF-8 | 327 | 2.8125 | 3 | [] | no_license | class Station
attr_reader :station_name, :street_address, :fuel_types, :distance, :access_times
def initialize(info)
@station_name = info[:station_name]
@street_address = info[:street_address]
@fuel_types = info[:fuel_type_code]
@distance = rand(5..20)
@access_times = info[:access_days_times]
... | true |
481f2e779c2a31be9c07159184dd736173087209 | Ruby | jaw772/enigma | /lib/decrypt.rb | UTF-8 | 454 | 2.9375 | 3 | [] | no_license | require_relative './enigma'
message_file = File.open(ARGV[0], "r")
key_1 = "82648"
date_1 = "240818"
encrypted_message = message_file.read
message_file.close
enigma = Enigma.new
decrypted = enigma.decrypt(encrypted_message, key_1, date_1)
decrypted_message = decrypted[:decryption]
decrypted_file = File.open(ARGV[1], "... | true |
0c112f04973a8c290b1f97f322bd6480f3d62014 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/roman-numerals/fefbe03f79d649ed8db2c26297908892.rb | UTF-8 | 816 | 3.375 | 3 | [] | no_license | module Roman
ROMAN_NUMERALS = %w(I V X L C D M)
def to_roman
return '' if zero?
highest_digit, remaining = to_s.split(//, 2).map(&:to_i)
place = to_s.length - 1
highest_digit.digit_to_roman(place) + remaining.to_roman
end
protected
# Roman numeral for (self * 10**place).
# Precondition:... | true |
35021b374861915c0401ca1df2c41e2c698a8fa1 | Ruby | Macaroni2629/Launch-School | /120_object_oriented_programming/120_exercises/debugging/wish_you_were_here.rb | UTF-8 | 2,031 | 4.3125 | 4 | [] | no_license | # Wish You Were Here
# On lines 37 and 38 of our code, we can see that grace and ada are located at the same coordinates. So why does line 39 output false? Fix the code to produce the expected output.
class Person
attr_reader :name
attr_accessor :location
def initialize(name)
@name = name
end
def tele... | true |
34a38255720f9ddaa5bdd5fc6e98e0b36019c961 | Ruby | HerbCSO/Episode3 | /models/book.rb | UTF-8 | 219 | 2.921875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Book < ActiveRecord::Base
has_many :characters
validates_presence_of :title
def to_s
"#{title}, written by #{author} has #{pages} pages, characters: [#{characters.map { |c| c.to_s }.join(', ')}]"
end
end
| true |
5b2ad62523f53973598a0bd246ae664b7f5db3ca | Ruby | karlhe/pmanagr | /app/models/user.rb | UTF-8 | 3,579 | 2.578125 | 3 | [] | no_license | require 'digest/sha1'
class User < ActiveRecord::Base
has_many :memberships
has_many :projects, :through => :memberships
has_many :assignments
has_many :tasks, :through => :assignments, :uniq => true
has_many :posts
include Authentication
include Authentication::ByPassword
include Authentication::By... | true |
25e78913245932a0c0a7c088f835e37998ad13a9 | Ruby | quantitare/quantitare-categories | /lib/quantitare/categories/tv.rb | UTF-8 | 1,017 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Quantitare
module Categories
##
# A representation of an episode of television watched by a user. Contains basic information about the episode,
# as well as a pointer with which Quantitare can gather more metadata about it.
#
class TV < Quantitare::Category
... | true |
e8a57e7b4861f3a528bd398389d22e75517c0496 | Ruby | errbit/hoptoad_zmq_notifier | /lib/hoptoad_zmq_notifier/configuration.rb | UTF-8 | 1,252 | 2.625 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
module HoptoadZmqNotifier
# Used to set up and modify settings for the notifier.
class Configuration
OPTIONS = [:mailbox_size, :uri].freeze
# Size of outgoing messages queue. All messages over this value will be dropped.
attr_accessor :mailbox_size
# The uri to connect to (0MQ s... | true |
c1633b5e2ec83307ba68ed40d9ea45bc64c3046c | Ruby | irwinchan/object_oriented_programming | /people.rb | UTF-8 | 595 | 4.59375 | 5 | [] | no_license | # Object Oriented Programming Assignments
# Exercise 1
class Person
def initialize(name)
@name = name
end
def greet
puts "Hi, my name is #{@name}"
end
end
class Student < Person
def learn
puts "I get it!"
end
end
class Instructor < Person
def teach
puts "Everything in Ruby is an Object"
end
end
in... | true |
fc753dce29160c907a1eab84929eee3458c2295c | Ruby | BreahnaDavid/pulse_music | /app/lib/best_track.rb | UTF-8 | 396 | 3.0625 | 3 | [] | no_license | class BestTrack
def initialize(emotion)
@emotion = emotion
end
def search
if ['happiness'].include? @emotion
songs = HuineaTrack.all_happy
songs[rand(songs.count)]
elsif ['neutral', 'surprise'].include? @emotion
songs = HuineaTrack.all
songs[rand(songs.count)]
else
s... | true |
6d08204326edb88be1fdbf114f7f6dda9d368de3 | Ruby | DmitryKey/nlp-spam | /src/bin/classify | UTF-8 | 481 | 3.3125 | 3 | [] | no_license | #! /usr/bin/env ruby
#
# Classify a given text file based on a training set.
#
require_relative '../lib/classifier'
abort "Usage: #{File.basename(__FILE__)} CLASSIFIER_OBJ TEST_OBJ" if ARGV.size < 2
classifier = Classifier.load(ARGV.shift)
testing = Classifier.load(ARGV.shift)
testing.each do |sample|
pred = class... | true |
70f1a41c12eb20ce6d592849bafa66101600ddc1 | Ruby | jordanhudgens/ruby-fundamentals | /datastructures/arrays.rb | UTF-8 | 150 | 2.96875 | 3 | [] | no_license | my_int_arr = [1, 2, 3, 4, 5, 6]
my_other_arr = Array.new
range_arry = (1..25).to_a
my_nested_arr = [my_int_arr, 4, 2, 5, "Hey"]
p my_nested_arr[0][3] | true |
2f53dccb69a1ec71626ad3e2ce96646b7649caee | Ruby | keomony/learn-to-program | /chap09/ex1_one_billion_seconds.rb | UTF-8 | 592 | 3.390625 | 3 | [] | no_license | # One billion seconds...
# Find out the exact second you were born (if you can).
# Figure out when you will turn (or perhaps when you did turn?) one billion seconds old.
# Then go mark your calendar.
puts "Please, tell me your date of birth."
puts "Which year were you born?"
birth_year = gets.chomp
puts "Which month w... | true |
8d820c28eedb0f23921a7995c16242a7becfe27a | Ruby | hirao19/ruby | /ruby1.rb | UTF-8 | 1,832 | 3.796875 | 4 | [] | no_license | name = "佐藤"
puts "こんにちは#{name}さん"
age = 33
puts "#{age}歳です"
puts "Hello Ruby"
puts "-----------------"
puts 33
puts 2 + 9
puts "2+9"
puts 2 - 2
puts 2 * 2
puts 2 / 2
puts 2 % 2
puts "-----------------"
puts "今日もRubyを" + "勉強します"
puts "10" + "10"
puts "-----------------"
name = "hirao"
puts name
puts "----------... | true |
93d1b44b278f3f45780a70bab362c642e63477e3 | Ruby | cawhyte/oo-basics-v-000 | /lib/book.rb | UTF-8 | 391 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Book
attr_accessor :author, :page_count, :genre
attr_reader :title
def initialize(title)
@title = title
end
def turn_page
puts "Flipping the page...wow, you read fast!"
end
end
class Shoe
attr_accessor :color, :size, :material, :condition
attr_reader :brand
def initialize(brand)
@brand ... | true |
0b707aec05f16741c0c2bab03f6db2e0a07047d0 | Ruby | MichelleMik/TIcTacToe_BV | /lib/gameboard.rb | UTF-8 | 2,365 | 3.59375 | 4 | [] | no_license | require_relative 'game.rb'
require_relative 'cell.rb'
require_relative 'player.rb'
require 'pry'
class GameBoard
attr_reader :grid, :length
attr_accessor :available_spaces
def initialize
reset_board
@length = @grid.length
end
def get_cell_coordinates(x,y)
@grid[x][y]
end
def set_cell(x,y,... | true |
cb5725c13fe5c333ab8a858ddc952fc61f769812 | Ruby | rbk/ruby_class | /examples/More_Method_Tricks/variable_parameter_lists.rb | UTF-8 | 916 | 3.203125 | 3 | [] | no_license | # variable_parameter_lists
def method_test( p1, p2, *p3 )
puts "p1 is #{p1}"
puts "p2 is #{p2}"
puts "p3 is #{p3.inspect}"
puts '-' * 30
end
method_test( 'a', 'b' )
method_test( 'a', 'b', 'c' )
method_test( 'a', 'b', 'c', 'd', 'e' )
method_test( 'a', 'b', 'c', 'd', 'e', 'f', 'g' )
def tag_writer(ta... | true |
3091837885b37fd524587d5f74ba51702d31079e | Ruby | isundaylee/clips_to_html | /item.rb | UTF-8 | 131 | 2.65625 | 3 | [] | no_license | class Item
attr_accessor :datetime, :type
def initialize(datetime, type)
@datetime = datetime
@type = type
end
end | true |
e035dbc41d7f3f3b0621ece25345cf100d7f5d7b | Ruby | stevehvaughn/coffee-shop | /app/models/customer.rb | UTF-8 | 737 | 2.6875 | 3 | [] | no_license | class Customer < ActiveRecord::Base
has_many :orders, dependent: :destroy
has_many :coffees, through: :orders
def self.names
pluck(:name)
end
def order_coffee(coffee_title, price)
coffee = Coffee.find_or_create_by(title: coffee_title)
order = Order.create(customer_id: id, c... | true |
c81a2b18a464e0ccaeef49775a3b8b835c2f5e13 | Ruby | d-actor/lunch_lady | /lunclady.rb | UTF-8 | 5,727 | 3.5 | 4 | [] | no_license | require 'pry'
@total = []
@wallet = 10
class Dish
attr_reader :name, :price
def initialize(name, price)
@name = name
@price = price
end
def info
puts "#{@name} -- #{@price}"
end
end
@meat_loaf = Dish.new('Meatloaf', '3.50')
@hamsandwich = Dish.new('Ham Sandwich', '2.25')
@mysterymeat = Dish.ne... | true |
32c226cee166258faaa60066a3fc7e1722189c3a | Ruby | avalanche123/sinatra-rabbit | /lib/sinatra/rabbit/validation.rb | UTF-8 | 1,880 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | module Sinatra
module Rabbit
module Validation
class Failure < StandardError
attr_reader :param
def initialize(param, msg='')
super(msg)
@param = param
end
def name
param.name
end
end
class Param
attr_reader :name,... | true |
69dd8ca273a237ff8b984b1067fb9c42cfb8c964 | Ruby | tonyr729/backend_prework | /day_7/fizzbuzz/fizzbuzz.rb | UTF-8 | 146 | 3.65625 | 4 | [] | no_license | (1..100).each { |num|
string = ''
string += 'Fizz' if num % 3 == 0
string += 'Buzz' if num % 5 == 0
puts(string.empty? ? num : string);
} | true |
0aed1cb3a17e7c5e7361bc41408b1193414de9f9 | Ruby | p/stint-video-assembly | /stint-video-assembly | UTF-8 | 7,493 | 2.71875 | 3 | [
"curl"
] | permissive | #!/usr/bin/env ruby
# Smartycam puts a keyframe in every second at the second.
# May be using 30 fps to make this work.
# This means as long as I am splitting & joining videos on whole seconds
# I should be splitting and joining on keyframes.
#
# ffprobe info: https://stackoverflow.com/questions/11400248/using-ffmpeg-... | true |
46d912bb00d9918ed48b2214001e565031662d25 | Ruby | PiyushNankar12/Ruby_Training | /Yash Mekhe/Day3/email_validate.rb | UTF-8 | 224 | 2.96875 | 3 | [] | no_license | def mail_validate(mail)
if /[a-zA-Z0-9\.\-\_]{1,}@[a-zA-Z].[a-z]{2,}/ =~ mail
print "Valid email id!!!\n"
else
print "Invalid email id!!!\n"
end
end
print "Enter the email - id : \n"
mail = gets
mail_validate(mail)
| true |
66dcdc55d00b85cc344b71c911c272151c9ab5a8 | Ruby | trizen/sidef | /scripts/json.sf | UTF-8 | 243 | 2.859375 | 3 | [
"Artistic-2.0"
] | permissive | #!/usr/bin/ruby
var json = require('JSON::PP').new;
# Parse JSON
var data = json.decode('{"blue": [1, 2], "ocean": "water"}');
say data;
# Change JSON
data{:ocean} = Hash.new(water => %w[fishy salty]);
# Encode JSON
say json.encode(data);
| true |
cc67314293b4c54a2296d7bc65c98fd30860067c | Ruby | lhwitherspoon/ls_rb100 | /variables/play-file.rb | UTF-8 | 78 | 3 | 3 | [] | no_license | # scope.rb
a = 5
3.times do |n|
a = 3
b = 5
end
puts a
puts b | true |
c4101f08a35859e2ef2d192f540cfb871d5f32ff | Ruby | JumpstartLab/problem_solving | /solutions/mitchell_will/lib/ex2.rb | UTF-8 | 292 | 3.53125 | 4 | [] | no_license | class Reverse
def self.execute(to_reverse)
if to_reverse.length == 1
to_reverse
else
to_reverse[-1] + execute(to_reverse[0..-2])
end
end
end
class String
# lol confusing much?
def reverse
length == 1 ? self : self[-1] + self[0..-2].reverse
end
end
| true |
c5b50bf4623c98b3859755a161cb1b5874f03792 | Ruby | Green-stripes/key-for-min-value-001-prework-web | /key_for_min.rb | UTF-8 | 615 | 3.796875 | 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
def key_for_min_value(name_hash)
lowest = []
name_hash.each do |key, value|
lowest << value
end
low = []
if lowest[0] == nil
nil
elsif lowest[0] < lowest[1] && lowest[0] < lowest[2]
... | true |
d02b25e23a30e09742c0f5ea0962c1a0f1d15634 | Ruby | benrodenhaeuser/LS_100 | /02_variables/test.rb | UTF-8 | 60 | 3.03125 | 3 | [] | no_license | (1..3).each do |i|
end
for j in (1..3)
j += 1
end
puts j
| true |
68a1cd2c6ddeb3aba899c076dee4507c1b532dd8 | Ruby | iwashi/cloudn-cli | /lib/cloudn_cli/shell.rb | UTF-8 | 8,022 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | require "readline"
require "pp"
require "termcolor" # for simple colorize
require "coderay" # for syntax highlight
require "rexml/document"
require "erb"
require "open-uri"
require "cgi"
require_relative "client"
module Cloudn
class User
def initialize(name, opt)
@name = name.freeze
@api_key ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.