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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ccb0b124578f8e5210fb9ef92619ae1603d46893 | Ruby | yemkhaung/ruby-on-rulers | /rulers/rulers-0.0.2/lib/rulers/dependencies.rb | UTF-8 | 477 | 2.609375 | 3 | [
"MIT"
] | permissive | class Object
# Overrides Object.const_missing() which is invoked when Object.const_get()
# cannot find the dependency reference.
# Loads the dependency of Class e.g "QuotesController",
# where this fn will convert class name to "quotes_controller"
def self.const_missing(c)
out = Rulers.to_u... | true |
f9b2cc1881822a2d5ab33013a3fc2822b8fc40a1 | Ruby | pikender/my_ruby_projects | /gol/spec/game_of_life_spec.rb | UTF-8 | 4,435 | 2.53125 | 3 | [] | no_license | require 'spec_helper'
describe GameofLife do
it_should_behave_like "my observed" do
let(:observer_instances) {[GameofLifeUi.new, GameofLifeUi.new, GameofLifeUi.new]}
end
let(:sample_cell) {double(Cell)}
let(:cell_11) {Cell.new(1,1)}
let(:cell_12) {Cell.new(1,2)}
let(:cell_21) {Cell.new(2,1)}
let(... | true |
b63b5ad0ad1f16fe0c8f586a73b7f76eee965e3e | Ruby | ofk/textpants | /test/textpants_test.rb | UTF-8 | 667 | 2.578125 | 3 | [] | no_license | # coding: utf-8
require 'test_helper'
class TextpantsTest < Minitest::Test
def test_that_it_has_a_version_number
refute_nil ::Textpants::VERSION
end
def test_sanitize
assert_equal '', Textpants.sanitize('')
assert_equal 'abc', Textpants.sanitize("a\u0000b\u007Fc")
assert_equal " a\nA\nあ\n亞 !", ... | true |
b1dc6e6b70ab13050dedd400c1a48958354dbcf8 | Ruby | cwkarwisch/ruby_challenges | /medium_1/pig_latin.rb | UTF-8 | 627 | 3.25 | 3 | [] | no_license | class PigLatin
@@beginning_vowel_sound = /\A([aeiou]|y[^aeiou]|x[^aeiou])/i
@@vowel_sound = /([aeio]|u+[^aeio])/i
@@single_word = /\A\w+\Z/
def self.translate(phrase)
if phrase.match?(@@single_word)
translate_word(phrase)
else
phrase.split(" ").map do |word|
translate_word(word)
... | true |
7a20e7f90b0523fa7e6d59059ec074fda7bb29fe | Ruby | andrab/ecuacovid | /spec/ecuacovid/actions/daily_mortality_growth_spec.rb | UTF-8 | 2,218 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'ecuacovid/actions/daily_mortality'
require 'ecuacovid/utils/objectable'
require_relative "../support/prueba"
module Ecuacovid
module Nu
class << self
def nu!
Prueba.nu!
end
end
end
end
class DailyAdjustmentTest
include Ecuacovid::Actions::DailyMortality
d... | true |
713ad37cb060cfc467d2bf5f11e4aa7db8b331f0 | Ruby | tihuan/innoutmenu | /app/models/burger.rb | UTF-8 | 5,778 | 2.75 | 3 | [] | no_license | class Burger < ActiveRecord::Base
include ActionView::Helpers::TextHelper
attr_accessor :sumbeef, :sumcheese, :sumonions
require 'set'
def self.load
if Burger.where(id:1).empty?
default_burger = Burger.create(id:1, buns:"Extra Toasted")
else
end
end
def countcode
wordstring = "#{self.b... | true |
d37dbe3e2aa4cc026a6629567d498cf8d0187a54 | Ruby | anneln/fullstack-challenges | /01-Ruby/02-Flow-Array/02-Sorting-the-wagon/lib/wagon_sort.rb | UTF-8 | 257 | 3.078125 | 3 | [] | no_license | def wagon_sort(students)
# TODO: return (not print!) a copy of students, sorted alphabetically
# students.map! { |name| name.capitalize }
# students.sort_by { |name| name.upcase }
students.sort_by! { |student| student.upcase }
return students
end | true |
66774bac007bd2a0a792005973f522ddceb6cee4 | Ruby | Rmole57/ruby-basics-exercises | /loops_1/greet_your_friends.rb | UTF-8 | 180 | 4.34375 | 4 | [] | no_license | # Given an array of names, use a 'for' loop to greet each friend individually.
friends = ['Sarah', 'John', 'Hannah', 'Dave']
for friend in friends
puts "Hello, #{friend}!"
end
| true |
d347fb8e83abf6e967f1888bebaaf2c132947512 | Ruby | sco-bo/rspec-ruby | /temperature.rb | UTF-8 | 96 | 3.21875 | 3 | [] | no_license | def ftoc(temp)
((temp.to_f - 32.0)/(1.8)).ceil
end
def ctof(temp)
(temp.to_f * 1.8)+32.0
end
| true |
cd30ee5d72d7bbd27cdab4804b8b91617aa16034 | Ruby | sfiddy/Doogle | /lib/web_services/dictionary_api.rb | UTF-8 | 1,512 | 2.640625 | 3 | [] | no_license | module WebServices
class DictionaryApi
def initialize(term)
@term = term
end
def self.base_url
"https://www.dictionaryapi.com/api/v1/references/collegiate/xml/"
end
def full_url
"#{DictionaryApi.base_url}#{@term}?key=#{ENV['DICTIONARY_API_KEY_DEV']}"
end
... | true |
4eb8bc82e3da6918720609b4fb0105c615088088 | Ruby | IrasemaSerrano/ruby_ejemplos | /bloques_01.rb | UTF-8 | 123 | 3.375 | 3 | [] | no_license | arreglo = (1..50)
arreglo.each do |numero|
if numero.even?
puts "El numero #{numero} es par"
end
end | true |
8890ddc62b25fcebd54d933a9bfef5fda8bae6d3 | Ruby | vanmars/coin_combinations | /app.rb | UTF-8 | 173 | 2.5625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require ('./lib/coin_combinations')
puts "Please enter change total:"
change = gets.chomp.to_i
counter = Counter.new(change)
puts counter.change_count() | true |
c9ccf1a58883836e02f3bc081fe3e12ab8780bca | Ruby | AlphaHydrae/gitload | /spec/repo_chain_spec.rb | UTF-8 | 2,726 | 2.625 | 3 | [
"MIT"
] | permissive | require 'helper'
RSpec.describe Gitload::RepoChain do
let(:config){ double }
let(:options){ {} }
let :repos do
[
double(name: 'UltraAccounting', owner: 'Peter', source: :github, fork?: false),
double(name: 'AccountingUltra', owner: 'Peter', source: :bitbucket, fork?: true),
double(name: 'S... | true |
d027ebea230842ae20268b0b3b5c4c5833718a85 | Ruby | msarapik/irc-jabber-bridge | /i_irc.rb | UTF-8 | 1,887 | 2.96875 | 3 | [] | no_license | require 'rubygems'
require 'eventmachine'
require 'socket'
class IRC
def initialize(opts = {})
@server = opts[:server]
@port = opts[:port]
@nick = opts[:nick]
@user = opts[:user]
@name = opts[:name]
@channel = opts[:channel]
@bridge = opts[:bridge]
@connected = false
e... | true |
3574dadb5d4cee82d109f37d80b50e8a97246b09 | Ruby | ahinz/Disaster-Mapper | /db_script/create_flood.rb | UTF-8 | 2,099 | 2.8125 | 3 | [] | no_license | require 'rgeo'
require 'rgeo/shapefile'
require 'sqlite3'
db = SQLite3::Database.new( ARGV.first )
begin
db.execute("drop table flood")
db.execute("drop table flood_gis")
rescue
puts "No tables to drop"
end
db.execute("create table flood (id INTEGER PRIMARY KEY, FLD_AR_ID TEXT, FLD_ZONE TEXT, FLOODWAY TEXT, SFH... | true |
e7d4fdd89cc89c8cd8071216f1d79dae32251cc5 | Ruby | WISE-Community/WISE-Tests | /features/step_definitions/teacher_steps/teacher_steps.rb | UTF-8 | 21,234 | 2.65625 | 3 | [] | no_license |
#############
### Given ###
#############
Given /^I am logged in as teacher1$/ do
login($teacherLogin1, $teacherPassword1);
visit "/webapp/teacher/index.html"
page.should have_content("Teacher Home")
end
Given /^I am logged in as teacher2$/ do
login($teacherLogin2, $teacherPassword2);
visit "/webapp/teache... | true |
1139e24bd3734c4a4dab63bb47d8b32fbfe6d9f5 | Ruby | marcelomst/ethereum_voting_example | /app/services/get_total_votes_for_meal_service.rb | UTF-8 | 336 | 2.765625 | 3 | [] | no_license | class GetTotalVotesForMealService
def initialize(address = nil)
@address = address || Voting.last.contract_address
end
def call(meal)
get_total_votes(meal)
end
private
def get_total_votes(meal)
voting_contract = Contract::GetService.new(@address).call
voting_contract.call.total_votes_for(... | true |
1c0138723893cee51249162d2dc8f18c2632ff44 | Ruby | davidklaver/companies-client | /app/models/company.rb | UTF-8 | 2,511 | 2.8125 | 3 | [] | no_license | class Company
attr_accessor :name, :slogan, :phone, :id
def initialize(input_hash)
@id = input_hash[:id]
@name = input_hash[:name]
@slogan = input_hash[:slogan]
@phone = input_hash[:phone]
end
def self.all
companies_hash_array = Unirest.get("http://localhost:3001/companies",headers:{
"Accept" => "ap... | true |
dd832123aeee5eb9051d178f5032b9e5cce8af1e | Ruby | watsonbox/kodi | /lib/kodi/namespace_builder.rb | UTF-8 | 1,477 | 2.671875 | 3 | [
"MIT"
] | permissive | module Kodi
class NamespaceBuilder < Struct.new(:uri)
# Generates a hash of Namespaces by name for a particular URI
#
# Params
# +method_groups+ (optional):: A Hash where the key is the name of the created namespace and the value is an Array
# of the desired methods.... | true |
2d735c522c9a76a6b11e3dcb95ad39f4e930fd34 | Ruby | katrinalui/chess | /display.rb | UTF-8 | 1,724 | 3.546875 | 4 | [] | no_license | require 'colorize'
require_relative 'board'
require_relative 'cursor'
require_relative 'piece'
require "byebug"
class Display
attr_reader :cursor
DISPLAY = {
null: " ",
pawn: "♟ ",
king: "♚ ",
queen: "♛ ",
rook: "♜ ",
bishop: "♝ ",
knight: "♞ "
}.freeze
def initialize(board)
... | true |
d2e86399ac74d1adab6f9f687939232a51346a0f | Ruby | DiUS/project-health | /app/presenters/indicator_measure.rb | UTF-8 | 2,185 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | class IndicatorMeasure
attr_reader :name
attr_reader :ratings
attr_reader :comments
attr_reader :indicator_id
attr_reader :category
def initialize(map = {})
map.each do |key, value|
instance_variable_set("@#{key}", value)
end
end
def mean
@mean ||= calculate_mean @ratings.map(&:scor... | true |
2c4883f5a1cfad2864777451ce3e23b26c8c2523 | Ruby | grothet/fit4af | /Ruby/Code/studio_game_5.rb | UTF-8 | 1,335 | 4.0625 | 4 | [] | no_license | jahreszeiten = ["Sommer", "Herbst", "Winter"] #Array erzeugen
jahreszeiten.length # jahreszeiten.count
jahreszeiten[2] # Ausgabe des dritten Eintrages
jahreszeiten.push("Frühjahr") #Eintrag Hinzufügen
jahreszeiten.pop # jahreszeite.delete_at(3) #Löscht den 4ten Eintrag
jahreszeiten.join(" und ") #Ausgabe aller Inhalte ... | true |
88b2b479fd3062e135b1dadef2a5889e3bc0bdab | Ruby | plaidlock/pro-digital-photos | /lib/custom_auth.rb | UTF-8 | 1,072 | 2.5625 | 3 | [] | no_license | module CustomAuth
def self.included(controller)
controller.send :helper_method, :current_user, :logged_in?
end
# gets the current user via caching. Assumes you have a `User` model and that the
# primary key is `id`. To force another call to the database, pass force_session_reload=true
# in the params (... | true |
0357aae3b2a78065679e911b1c335fffc4ffeb9c | Ruby | swfz/ri-inventory | /app.rb | UTF-8 | 3,623 | 2.765625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'aws-sdk'
require 'json'
require 'awesome_print'
require 'csv'
# TODO: RDS Elasticache 出力
class EC2Client
attr_reader :ec2, :region, :autoscaling
def initialize(region)
@region = region
credentials = Aws::Credentials.new(ENV['ACCESS_KEY'], ENV['SECRET_KEY'])
@ec2 = Aws::... | true |
837a1833b01e21c2c65c6c94fa4e0139bba7f3ec | Ruby | NicHaley/learn_ruby | /temperature.rb | UTF-8 | 70 | 2.515625 | 3 | [] | no_license | def ftoc(f_temp)
0
end
# def ctof(c_temp)
# c_temp * 9/5 + 32
# end | true |
ab64efa97d079910658dfaa28322dc93c589daa6 | Ruby | demery/misc | /ruby/template.rb | UTF-8 | 1,868 | 2.75 | 3 | [] | no_license | #!/usr/bin/env ruby
################################################################################
# Name: name.rb
#
# Usage: #{execuable_name} [FOLDER]
#
# Do something.
#
# [ARG] Optional argument.
#
# OPTIONS
#
# -f, --format FORMAT Choose ouput format: pretty [default],
# ... | true |
428191d2e40bf74e8c71556381768cb3d85a67c3 | Ruby | brainwane/chatterbot | /lib/chatterbot/search.rb | UTF-8 | 1,194 | 2.53125 | 3 | [
"WTFPL",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Chatterbot
#
# handle Twitter searches
module Search
@skip_retweets = true
#
# modify a query string to exclude retweets from searches
#
def exclude_retweets
@skip_retweets = true
end
def include_retweets
@skip_retweets = false
end
def skippable_retw... | true |
9e9f0dce654f1b52fb49b3efb9425788c552fcd6 | Ruby | etscrivner/cast_hexagram | /bin/cast_hexagram | UTF-8 | 306 | 2.625 | 3 | [] | no_license | #!/usr/bin/ruby
# Add the lib directory to the load path
LIB_DIRECTORY = File.expand_path('../../lib', __FILE__)
$LOAD_PATH.unshift(LIB_DIRECTORY)
require 'iching'
if ARGV.length != 1
puts "USAGE: cast_hexagram <QUESTION>"
exit
else
question = ARGV[0]
Iching::CastHexagram.new.run(question)
end
| true |
b488ab1569f47109cd9a6757b44432a7e5fe7eea | Ruby | NathanGE/Queues | /priority-queue.rb | UTF-8 | 746 | 3.671875 | 4 | [] | no_license | class PriorityQueue
attr_reader :items
def initialize
@items = []
end
class QueueItem
attr_reader :item, :priority
def initialize(item, priority)
@item = item
@priority = priority
end
end
def enqueue(item, priority)
queue_item = QueueItem.new(item, priority)
added = f... | true |
a5833c5a3338ad51359e8eb1e949742bff7285d8 | Ruby | andrewjleavitt/team_track | /app/models/week.rb | UTF-8 | 595 | 3.453125 | 3 | [
"Unlicense"
] | permissive | class Week
def self.weeks
(-2..4).map {|i| Date.today.beginning_of_week + i.weeks}
end
def self.current
Date.today.beginning_of_week
end
def self.for_date date
new(Date.parse(date).beginning_of_week)
end
def self.between start_date, end_date
(start_date..end_date).select(&:monday?).map ... | true |
5a46b076c0a4100f6149fff9a407761418fe423f | Ruby | sojastar/curses-geometry | /samples/polygon.rb | UTF-8 | 1,619 | 2.71875 | 3 | [
"MIT"
] | permissive | require 'curses/geometry'
include Curses
Signal.trap("INT") { close_screen; exit 0 }
init_screen
timeout=0
begin
# Screen setup :
start_color
curs_set 0
max_x = cols - 1
max_y = lines - 1
# Graphic context ( color ) setup :
register_color_pair(:black_on_white, COLOR_WHITE, COLOR_BLACK )
regis... | true |
5ad5811dc728f540ffe1581fc8710e05a74e0409 | Ruby | Jeremykw/dnd_5e | /app/models/cleric.rb | UTF-8 | 330 | 2.5625 | 3 | [] | no_license | class Cleric < Character
def saving_throws
{:wis => ['Wisdom:', ability_modifier(self.ability.wis) + proficency_bonuse ], :char => ['Charisma:', ability_modifier(self.ability.char) + proficency_bonuse ] }
end
def number_of_skill
2
end
def skill_choices
[:history, :medicine, :insight, :religion, :persuasion... | true |
827d0c85352ea3ea0493dfdc3611be37f77aaa48 | Ruby | rubyninjas/geo-distance | /lib/geo-distance/formula.rb | UTF-8 | 1,766 | 3.0625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | class GeoDistance
include GeoUnits
class DistanceFormula
extend Math
extend GeoUnits
def initialize
raise NotImplementedError
end
# use underlying distance formula
def self.geo_distance *args
GeoDistance.new distance(args), get_units(args.last_option)
end
# u... | true |
1eb3b8c7155f9084889c05aab8207e36c4f9dc66 | Ruby | globegit/simple-navigation | /lib/simple_navigation/helpers.rb | UTF-8 | 5,169 | 2.84375 | 3 | [
"MIT"
] | permissive | module SimpleNavigation
# View helpers to render the navigation.
#
# Use render_navigation as following to render your navigation:
# * call <tt>render_navigation</tt> without :level option to render your navigation as nested tree.
# * call <tt>render_navigation(:level => x)</tt> to render a specific naviga... | true |
01245599889b2ee27417f300f0ca3c6eef9bb8c1 | Ruby | fayadh/software_testing | /contact.rb | UTF-8 | 414 | 3.8125 | 4 | [] | no_license | class Contact
def initialize(full_name)
@full_name = full_name
end
def first_name
split_name.first
end
def last_name
split_name.last
end
private #everything below private is a private method. You can't call these methods outside of the class.
def split_name
@full_name.split('')
end
end
contact = Co... | true |
0e0cb02619fd996514e337cf8d8a57ab05030463 | Ruby | ganmacs/caly | /lib/parser.rb | UTF-8 | 1,623 | 3.265625 | 3 | [] | no_license | require 'ast'
module Caly
class Parser
def call(tokens)
@tokens = tokens
@i = 0
ret = []
ret << state while @tokens.size > @i
ret
end
# state = IDEN "=" expr EOL | expr EOL
def state
iden = nil
op = nil
if @tokens[@i].type == :iden
iden = Caly:... | true |
1a360f4546705e534347b64e60391e783d9b4638 | Ruby | aeposten/SENG-LIVE-092021 | /phase-3/03-OO-ruby-pt2/donation_tracker/lib/donation.rb | UTF-8 | 448 | 3.609375 | 4 | [] | no_license | class Donation
attr_accessor :amount, :organization, :date, :completed
def initialize(organization, amount, date, completed)
@organization = organization
@amount = amount
@date = date
@completed = completed
end
def read_donation
puts "Organization: #{@orga... | true |
7dc2724fe8373ad6239bbfdeb094007e77ae073c | Ruby | BLaurenB/hu | /spec/models/google_search_weekly_spec.rb | UTF-8 | 611 | 2.65625 | 3 | [] | no_license | require 'rails_helper'
describe " Google Search Weekly" do
it "creates new GoogleSearchWeekly instances from a hash" do
row_hash =
{"Week"=>"2017-02-26", "news: (United States)"=>"76", "backpack: (United States)"=>"2", "commuter: (United States)"=>"1", "bus: (United States)"=>"12", "laptop: (United ... | true |
b25b3e7ba3bfa4eda25e783e3a9eb5c926f0d942 | Ruby | jdfrens/calvincs | /app/models/image.rb | UTF-8 | 2,061 | 2.8125 | 3 | [] | no_license | # == Schema Information
# Schema version: 20100315182611
#
# Table name: images
#
# id :integer not null, primary key
# url :string(255)
# caption :text(255)
# width :integer
# height :integer
#
class Image < ActiveRecord::Base
has_many :image_tags, :dependent => :delete_all
before_valid... | true |
d9c35890b59c6f8deaf7a77b3226d2c32c286e35 | Ruby | macintorch/pairbnb | /app/models/booking.rb | UTF-8 | 680 | 2.609375 | 3 | [] | no_license | class Booking < ActiveRecord::Base
validates_presence_of :check_in, :check_out
belongs_to :user
belongs_to :listing
#to calculate day booked
def day
(self.check_out - self.check_in).to_i
end
# Check if a given interval overlaps this interval
def overlaps?(other)
(self.check_in - other.check_out)... | true |
3a299a7b4f7067722abb9bf05d8ff9b9f854551e | Ruby | zpalmquist/black_thursday | /lib/invoice_item.rb | UTF-8 | 685 | 2.9375 | 3 | [] | no_license | require 'time'
class InvoiceItem
attr_reader :id,
:item_id,
:invoice_id,
:quantity,
:unit_price,
:created_at,
:updated_at
def initialize(data, repository)
@id = data[:id].to_i
@item_id = data[:item_id... | true |
2dc357539d1ffa12c24e1955c235b30dfba4ee26 | Ruby | singflan/101_programming_foundations | /small_problems/advanced/seeing_stars.rb | UTF-8 | 685 | 3.625 | 4 | [] | no_license | def print_star(total_number)
num_of_max_mid_spaces = (total_number / 2) - 1
outside_spaces = 0
loop do
puts (" " * outside_spaces) + '*' + (" " * num_of_max_mid_spaces) + '*' + (" " * num_of_max_mid_spaces) + '*'
break if num_of_max_mid_spaces == 0
num_of_max_mid_spaces -= 1
outside_spaces += 1
end
p... | true |
46790a8736c1934802bbd496e2c70dc153f4d34c | Ruby | vertige/grocery-store | /lib/online_order.rb | UTF-8 | 1,564 | 3.03125 | 3 | [] | no_license | require 'pry'
module Grocery
require_relative 'order'
class OnlineOrder < Order
attr_reader :c_id, :status
def initialize(id, products, customer_id, status)
super(id, products)
@c_id = customer_id
@status = status
end
#CLASS METHODS
def self.all
all_online_orders = Ar... | true |
57d50f7a99e415c868ef8d56bf3052fad9bc3255 | Ruby | ZeleiAdi/law_check | /path.rb | UTF-8 | 484 | 2.78125 | 3 | [] | no_license | module LawCheck
class Path
def initialize(path)
@path = path
end
def first_name
first, *_ = @path
first
end
def rest_names
_, *rest = @path
Path.new(rest)
end
def toplevel?
rest_names.empty?
end
def empty?
@path.empty?
end
... | true |
bf224c810f8a41c93f06f88373cb4db45206e566 | Ruby | teachshits/systems-aggregation-tool | /vendor/plugins/open_flash_chart/lib/ofc/examples/stacked_bar_chart.rb | UTF-8 | 3,502 | 2.90625 | 3 | [
"MIT"
] | permissive | module OFC
module Examples
module StackedBarChart
# http://teethgrinder.co.uk/open-flash-chart-2/stacked-bar-chart.php
def stacked_bar_chart
#$title = new title( 'Stuff I\'m thinking about, '.date("D M d Y") );
#$title->set_style( "{font-size: 20px; color: #F24062; text-align: center... | true |
5993fc251eec7430575d9aa92cf78832c49c8d4b | Ruby | elevati0n/batphoneWebApp | /path/ruby/2.1.0/gems/byebug-3.4.0/test/commands/break_test.rb | UTF-8 | 10,944 | 3.078125 | 3 | [
"BSD-2-Clause"
] | permissive | module Byebug
class BreakExample
def self.a(num)
4
end
def b
3
end
end
class BreakTestCase < TestCase
def setup
@example = -> do
y = 3
# A comments
byebug
z = 5
BreakExample.new.b
BreakExample.a(y+z)
end
super
... | true |
28e367af371efa5f8b9d1ff1c80dc6aa1b299cdc | Ruby | ivir/MEDvidek | /modules/json.rb | UTF-8 | 3,130 | 2.859375 | 3 | [] | no_license | require_relative('../module_med')
require_relative('../db_storage')
require 'json'
class ExportJson < ModuleMED
def initialize
@db = Dataset.new
end
def properties(memory,fdata)
# navraci seznam podporovanych vstupu a vystupu
@store = fdata["source"]
@memory = memory
#@store = Dataset.new i... | true |
cc598580f571fcc6a7978c168e3876f4f00cb84c | Ruby | gthall1/systemscheck4 | /lib/bounding_area.rb | UTF-8 | 398 | 3.359375 | 3 | [] | no_license | require_relative 'bounding_box.rb'
class BoundingArea
def initialize(binding_area)
@binding_area = binding_area
end
def contains_point?(x, y)
if @binding_area == []
return false
end
@binding_area.each do |rectangle|
return rectangle.contains_point?(x, y)
end
#returns true if ... | true |
9fda4c359f558c7f7551fc24e3dcb108202a8bd7 | Ruby | linduxed/filterfind.rb | /lib/filterfind/command_line_output.rb | UTF-8 | 1,741 | 2.90625 | 3 | [
"MIT"
] | permissive | module Filterfind
class MissingOptionError < StandardError; end
class CommandLineOutput
def initialize(options={})
@filenames = options.fetch(:filenames) { raise MissingOptionError }
@regexes = options.fetch(:regexes)
.map { |regex| Regexp.new(regex, false) }
@case_insensitive_regexes... | true |
d9b2f037af70d7ead3abb850887b5012ad1cebee | Ruby | victorperezcotapos/desafios_Intro_Ruby | /Desafio_ciclos/patronesyciclosanidados.rb | UTF-8 | 1,767 | 3.515625 | 4 | [] | no_license |
patron1=""
ARGV[0].to_i.times do |i|
puts patron1+=(i+1).to_s
end
def letra_o(n)
n.times do |i|
n.times do |j|
if i==0||i==n-1||j==0||j==n-1
print "*"
else print " "
end
end
print "\n"
end
end
def letra_i(n)
n.times do |i|
n.times do |j|
if i==0||i==n-1||j==(n... | true |
bfed06cc8686ff6736d25e9991cc39d366c9dba7 | Ruby | jrc0rey/ruby-reps-101 | /reps.rb | UTF-8 | 841 | 4.15625 | 4 | [] | no_license | # write your reps here
# makes sure to either `p my_output` or `puts my_output`.
# `p _variablename_` prints the full Object
# `puts _variablename_` prints the Object.to_s (.toString())
# to run, just `ruby reps.rb`
#1.
words = ["hello", "what", "is", "up", "dude"]
def lengths(input)
puts input.map{|words| words.l... | true |
5cbc4f1de72c36154464bfb8a9edc6e3f749034e | Ruby | rzane/baby_squeel | /spec/baby_squeel/dsl_spec.rb | UTF-8 | 2,199 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'shared_examples/table'
require 'shared_examples/relation'
require 'baby_squeel/dsl'
describe BabySqueel::DSL do
subject(:dsl) { create_dsl Post }
it_behaves_like 'a relation' do
subject(:table) { dsl }
end
it_behaves_like 'a table' do
subject(:table) { dsl }
end
de... | true |
1972d30f103047ea0faecdc033ceaa7a51e3ee7e | Ruby | railsware/rspec-example_steps | /spec/example_steps_spec.rb | UTF-8 | 2,815 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe "example steps" do
describe "Given/When/Then" do
Steps "should execute blocks" do
Given "thing" do
@thing = "Given value"
end
When "action" do
@action = "When value"
end
Then "result" do
@result = "Then value"
end
... | true |
b252698aab3b2cc80220b47ed60ff8527e7d891f | Ruby | funwithcthulhu/project-euler | /ruby/073_counting_fractions_in_a_range.rb | UTF-8 | 920 | 3.671875 | 4 | [] | no_license | # Project Euler Problem 73 Counting Fractions in a Range
# Consider the fraction, n/d, where n and d are positive
# integers. If n<d and HCF(n,d)=1, it is called a reduced
# proper fraction.
# If we list the set of reduced proper fractions for d ≤ 8
# in ascending order of size, we get:
# 1/8, 1/7, 1/6, 1/5, 1/4, 2/... | true |
451df9a002c9f63fa8837f39985f633551b92153 | Ruby | SK-Sam/RubyAlgos | /caesar_cipher.rb | UTF-8 | 1,651 | 3.71875 | 4 | [] | no_license | class CeasarCipher
def initialize
@encoded_string = ""
@arr_of_ascii = []
@input_string = ""
@left_shift = 0
end
def encode(str, shift_by)
@input_string = str.downcase
@left_shift = shift_by
@input_string.each_byte do |c|
if c == 32
@arr_of_ascii << c
else
... | true |
b2f2b5e9ad751fbc24b79cdd4160843923fd0326 | Ruby | reizist/hatena_blog_scraper | /lib/hatena_blog_scraper/article.rb | UTF-8 | 343 | 2.640625 | 3 | [
"MIT"
] | permissive | require "reverse_markdown"
module HatenaBlogScraper
class Article
attr_reader :url, :title, :text, :html, :markdown
def initialize(url: nil, title: nil, text: nil, html: nil)
@url = url
@title = title
@text = text
@html = html
@markdown = ReverseMarkdown.convert(... | true |
effc3c9a38f3802004c09d24aa32363f95d032e1 | Ruby | mitya/rabotnegi | /app/models/currency_converter.rb | UTF-8 | 272 | 2.90625 | 3 | [] | no_license | module CurrencyConverter
module_function
def convert(value, source_currency_sym, target_currency_sym)
value * rate(source_currency_sym) / rate(target_currency_sym)
end
def rate(currency)
@@rates[currency]
end
@@rates = { rub: 1.0, usd: 28, eur: 40 }
end
| true |
279403ffa71d79516809b77c1eae7d9313d3a707 | Ruby | chrisjpowers/rdoc_metric | /lib/rdoc_metric.rb | UTF-8 | 4,221 | 3.34375 | 3 | [
"MIT"
] | permissive | # Developed by Chris Powers (http://github.com/chrisjpowers)
# Version 0.1 -- September 10, 2009
#
# The RdocMetric class parses through ruby files and determines how
# well documented they are. It looks for a comment on the line before
# each class, module, method, attribute and constant declaration to
# determine i... | true |
cd679121107e1a45d2a4ecb6e2ee88cd431ed230 | Ruby | NyaFurtick/crochet_graph | /image_handler.rb | UTF-8 | 571 | 2.78125 | 3 | [] | no_license | class ImageHandler
attr_reader :original_file_name, :processed_file_name
def initialize(original_file_name, processed_file_name)
@original_file_name = original_file_name
@processed_file_name = processed_file_name
end
def process
set_size
reduce_colors
end
private
def set_size
cmd = ... | true |
1a42cef8f2127aee8528aa18e3dc1cbc6a4aacca | Ruby | RasMachineMan/poro_generator | /lib/poro_generator/dir_handler.rb | UTF-8 | 1,150 | 2.734375 | 3 | [
"MIT"
] | permissive | module PoroGenerator
class DirHandler
def initialize(namespaces)
@namespaces = namespaces
@namespace_errors = []
end
def call
validate_top_namespace
return_path_or_error
end
private
attr_reader :namespaces, :namespace_errors
def return_path_or_error
names... | true |
eb5738593d2b13176af9aaef5fe4c014dc568c4b | Ruby | dylan8902/bros-analytics | /lib/bros_analytics.rb | UTF-8 | 665 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | require 'elasticsearch'
require_relative 'bros-analytics/message.rb'
client = Elasticsearch::Client.new(
log: true,
url: ENV["ELASTIC_URL"],
user: ENV["ELASTIC_USER"],
password: ENV["ELASTIC_PASSWORD"]
)
id = 0
messages = []
puts "Opening #{ENV["FACEBOOK_MESSAGES"]}"
html = Nokogiri::HTML(open(ENV["FACEBOOK_... | true |
9ea3bb4030679fa8f394e318672af9e40ee0b1b5 | Ruby | jorgemolinan/lab | /bloque_con_parametro.rb | UTF-8 | 182 | 3.78125 | 4 | [] | no_license | # 2- Bloque con parametro
def saludar(name)
puts "Hola #{name}"
yield(name)
puts "Hasta pronto"
end
saludar("Jorge") do |name|
puts "Que tengas buenas tardes #{name}"
end
| true |
cdabd3c4f7f514b93e2914ad4f77dc8be5747cb4 | Ruby | ffaker/ffaker | /lib/ffaker/gender_pl.rb | UTF-8 | 325 | 2.53125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
module FFaker
# Inspirations:
# https://pl.wikipedia.org/wiki/P%C5%82e%C4%87
module GenderPL
extend ModuleUtils
extend self
GENDERS = %w[kobieta mężczyzna].freeze
def random
fetch_sample(GENDERS)
end
alias maybe random
alias sample random
end
e... | true |
5e04e44877c021471c2a657dd4c1306d63890e95 | Ruby | julmeier/grocery-store | /lib/online_order.rb | UTF-8 | 3,814 | 3.5625 | 4 | [] | no_license | require 'csv'
require 'awesome_print'
require 'pry'
require_relative 'order'
require_relative 'customer'
module Grocery
class OnlineOrder < Order
# The OnlineOrder class will inherit behavior from the Order class and include additional data to track the customer and order status.
attr_reader :id, :products, :... | true |
61d807055f32eaf75f4aef448ac970a0e211fc75 | Ruby | NLanese/ruby-objects-has-many-through-lab-online-web-sp-000 | /lib/doctor.rb | UTF-8 | 719 | 3.5 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Doctor
attr_accessor :name, :appointments
@@all = []
def initialize(inputName)
@name = inputName
@@all << self
@appointments = []
@patients = []
end
def new_appointment(date, patient)
newApp = Appointment.new(date, patient, self)
self.add_appointment(newApp)
self.add_patien... | true |
f23026601567eef844c7ba3ca86fa1e1120be152 | Ruby | sf-coyotes-2016/phase-1-checkpoint-challenge-3-teacher-refactoring | /student.rb | UTF-8 | 707 | 3.71875 | 4 | [] | no_license | class Student
attr_reader :age, :phase
attr_accessor :name
def initialize(options = {})
@phase = 1
@age = options.fetch(:age, 0)
@name = options.fetch(:name, "")
end
def offer_high_five
"High five!"
end
def set_phase(num)
response = ""
if num == @phase
response += "I'm doi... | true |
1c5ab41cc22fb6771862c2e9c20f1f89efa36e0d | Ruby | dtrift/simpler | /lib/simpler/router/route.rb | UTF-8 | 879 | 2.75 | 3 | [] | no_license | module Simpler
class Router
class Route
attr_reader :controller, :action
def initialize(method, path, controller, action)
@method = method
@path = path
@controller = controller
@action = action
end
def match?(method, path)
@method == method && pat... | true |
d71f221b0cff992acc3dbb4fd9afbd0c05b7f8f5 | Ruby | justonemorecommit/puppet | /lib/puppet/pops/functions/function.rb | UTF-8 | 5,618 | 3.015625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | # @note WARNING: This new function API is still under development and may change at
# any time
#
# A function in the puppet evaluator.
#
# Functions are normally defined by another system, which produces subclasses
# of this class as well as constructing delegations to call the appropriate methods.
#
# This class sho... | true |
74824ced19268316f3642cba562d691d8fc65d55 | Ruby | iazigit/thp-homework | /rubyDay1/exo_10.rb | UTF-8 | 114 | 3.3125 | 3 | [] | no_license | puts "Ténékelané?"
print "> Ané: "
birthyear = gets.chomp
puts "Tavé #{2017- birthyear.to_i()} an an 2017!"
| true |
ffdeb04e308ed5b682f7de6b8b91dc3b4d13fe4d | Ruby | dtinianow/http | /lib/parser.rb | UTF-8 | 1,311 | 3.21875 | 3 | [] | no_license |
class Parser
attr_reader :request, :request_info, :all_request_lines, :path
def initialize(request)
@request = request
@path = request[0].split(" ")[1].split('?')[0]
end
def word
if request[0].split(" ")[1].split('?')[1].split('=')[0] == 'word'
word = request[0].split(" ... | true |
d2023a685bffae909f6e939f9c86d4623dbedbc0 | Ruby | Kite0301/atcoder | /Regular/026/a.rb | UTF-8 | 125 | 2.84375 | 3 | [] | no_license | n,a,b = gets.chomp.split.map(&:to_i)
ans = 0
for i in 1..n do
case i
when 1..5
ans += b
else
ans += a
end
end
p ans | true |
8465883c80a94d016ceaf759f388799361f6c87e | Ruby | bmcdonald05/ruby-spring16 | /pemdas.rb | UTF-8 | 711 | 4.3125 | 4 | [] | no_license | def add(x, y)
sum = x+y
puts sum
end
def subtract(x, y)
sum = x-y
puts sum
end
def multiply(x, y)
sum = x*y
puts sum
end
def divide(x, y)
sum = x/y
puts sum
end
puts "Please give me a number."
num1 = gets.chomp.to_i
puts "And one more."
num2 = gets.chomp.to_i
puts "What would you like to do: add, subtract, mu... | true |
89f4c1b7a3d38b8f21681541c43ce630496db6ef | Ruby | squeedee/pymn | /lib/pymn/chain_of_responsibility.rb | UTF-8 | 986 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'active_support/concern'
require 'pymn/chain_of_responsibility/command_not_handled_error'
require 'pymn/chain_of_responsibility/responsibility_method_undefined_error'
require 'pymn/chain_of_responsibility/has_handlers'
module Pymn
module ChainOfResponsibility
extend ActiveSupport::Concern
included d... | true |
0e3e8364c5570f7da8a855a79aa51c6aebabd122 | Ruby | Zatom01/school-domain-onl01-seng-ft-030220 | /lib/school.rb | UTF-8 | 447 | 3.265625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class School
def initialize(name)
@name=name
@roster=Hash.new
end
def roster
@roster
end
def add_student(student,grade)
if @roster[grade]== nil
@roster[grade]=[student]
else
@roster[grade]<<student
end
end
def grade(grade)
@roster[grade... | true |
4d66f97df8cf645fc6b55b00d1f80cd9e41d1c3b | Ruby | llunaplanet/VLCTechHub-api | /app/event/twitter.rb | UTF-8 | 938 | 2.796875 | 3 | [] | no_license | require 'active_support'
require 'active_support/core_ext'
module VLCTechHub
module Event
class Twitter
include VLCTechHub::TwitterClient
def self.new_event(event)
new.new_event(event)
end
def new_event(event)
tweet("Nuevo Evento: #{hashtag event} #{event['title']} #{dat... | true |
71784c412fc687cc7b0c7f3ae31765562cf3f16b | Ruby | cmur2/munin-github-traffic | /github-traffic_ | UTF-8 | 1,760 | 2.890625 | 3 | [] | no_license | #!/usr/bin/env ruby
# Source: https://github.com/cmur2/munin-github-traffic
#
# Example usage:
# Do
# ln -s /path/to/github-traffic_ github-traffic_<user:::project>
# where <user:::project> encodes the user and project to monitor.
# They should be delimited by a triple colon ::: in order to be
# parsed correct... | true |
bf2ee5c12f36b3379217528107693ec152f77f7a | Ruby | sevperez/code_fights | /arc_15_add_border.rb | UTF-8 | 406 | 3.359375 | 3 | [] | no_license | # Code Fights - Arcade - Problem 15 - Add Border
def addBorder(picture)
width = picture.first.length
picture.unshift("*" * width)
picture.push("*" * width)
picture.map { |str| "*" + str + "*" }
end
picture = ["abc",
"ded"]
p addBorder(picture) # == ["*****",
... | true |
2f3fee85503adc45f2951b772c9ccec074344bee | Ruby | farmerchuk/180_db_expense_tracker | /expense | UTF-8 | 3,715 | 3.296875 | 3 | [] | no_license | #! /usr/bin/env ruby
require 'pg'
require 'io/console'
require 'date'
class CLI
attr_reader :expense_data
def initialize
@expense_data = ExpenseData.new
end
def run(args)
command = args.first
case command
when 'list'
expense_data.list_all_expenses
when 'add'
amount, memo = a... | true |
f0b66877523af87ca53f67c1d89704baacca8a43 | Ruby | JMazzy/ruby-heap-and-heapsort | /lib/array.rb | UTF-8 | 206 | 3.1875 | 3 | [
"MIT"
] | permissive | require_relative 'heapsortable'
class Array
include Heapsortable
def heapsort
heap_sort(self.dup)
end
def heapsort!
replace(heapsort)
end
end
arr = [3,4,5,2,8,1]
p arr.heapsort
p arr
| true |
b05798949e8b451f3839476d62f5769416a3add0 | Ruby | jas0nmjames/jas0nmjames.github.io | /vendor/bundle/ruby/3.2.0/gems/ttfunk-1.7.0/lib/ttfunk/table/glyf/simple.rb | UTF-8 | 1,084 | 2.59375 | 3 | [
"GPL-2.0-only",
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"LicenseRef-scancode-warranty-disclaimer",
"GPL-2.0-or-later",
"GPL-3.0-only",
"Ruby",
"MIT"
] | permissive | # frozen_string_literal: true
require_relative '../../reader'
module TTFunk
class Table
class Glyf
class Simple
attr_reader :id, :raw
attr_reader :number_of_contours
attr_reader :x_min, :y_min, :x_max, :y_max
attr_reader :end_points_of_contours
attr_reader :instruct... | true |
04e5a147f973e997d0059b1b85e50dbbcf09121a | Ruby | lazoxco/regex-lab-onl01-seng-pt-110319 | /lib/regex_lab.rb | UTF-8 | 673 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # word = ["Excellent", "incredible", "Absolute", "unreal", "Inconceivable" "octopus", "crazy"]
def starts_with_a_vowel?(word)
if word.match(/^[aeiouAEIOU]\w+/)
true
else
false
end
end
def words_starting_with_un_and_ending_with_ing(text)
text.scan(/\b[Uu]n[a-z]*ing\b/)
end
def words_five_letters_lon... | true |
3e133c6c896bdd4210bb96b77a72e0a0422489eb | Ruby | martinlevesque/codewars | /ruby/array_diff.rb | UTF-8 | 247 | 3.75 | 4 | [] | no_license | # Your goal in this kata is to implement a difference function, which subtracts one list
# from another and returns the result.
def array_diff(a, b)
a.select { |a_element| !b.include?(a_element) }
end
puts array_diff([1,2,2,4,5], [2]).inspect | true |
05928c8510816fa4cbe0ccae2754ed2f5a2512bb | Ruby | cshtdd/ruby-pgp | /lib/pgp/signer.rb | UTF-8 | 489 | 2.75 | 3 | [
"MIT"
] | permissive | module PGP
class Signer
attr_accessor :passphrase
def initialize(gpg_engine=nil)
@gpg_engine = gpg_engine || GPG::Engine.new
end
def sign(data)
result = @gpg_engine.sign(data, self.passphrase)
result[1]
end
def sign_file(file_path)
sign File.read(file_path)
end
... | true |
2158f0f2c0b5acb9f5da2094052658d19ba3846b | Ruby | mbigras/ruby_exploring | /strategies.rb | UTF-8 | 419 | 3.828125 | 4 | [] | no_license | class S1
def self.foo(bar)
"#{bar}...1"
end
end
class S2
def self.foo(bar)
"#{bar}...2"
end
end
class S3
def self.foo(bar)
"#{bar}...3"
end
end
class Thing
def initialize
@strategies = {
"s1" => S1,
"s2" => S2,
"s3" => S3,
}
end
def go(s, bar)
@strategies[... | true |
f46c2cf278d6af9f2fe2de854d4f2c42acd2c5a3 | Ruby | francois/trbl-api-sample | /lib/logging.rb | UTF-8 | 920 | 2.515625 | 3 | [] | no_license | require "logger"
begin
require "debugger"
rescue LoadError
# NOP: Ignore in non-dev environment
end
# Respect the command-line parameters
ENV["QUIET"] = ARGV.delete("--quiet") ? "yes" : ENV["QUIET"]
ENV["VERBOSE"] = ARGV.delete("--verbose") ? "yes" : ENV["VERBOSE"]
# Then use that information to correctly co... | true |
76ebe15178dd553f30b8ae6ba4f3e37d74d716a1 | Ruby | escholz/blizzard-community-api-rubygem | /spec/guild_profile_request_spec.rb | UTF-8 | 2,989 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require "rspec_helper"
require "../lib/guild_profile_request"
include WOW
describe GuildProfileRequest do
describe "::new" do
it "should create a new GuildProfileRequest if valid" do
request = GuildProfileRequest.new("Little Urban Elites","Draenor",:fields => [:members, :achievements])
request.shoul... | true |
8b4f39c0ffd6c5d15d95334086483ad196f9469a | Ruby | jayqui/capstone_backend | /app/models/player.rb | UTF-8 | 588 | 2.59375 | 3 | [] | no_license | class Player < ApplicationRecord
#validations
has_secure_password
validates :name, presence: true
validates :email, presence: true, uniqueness: true
validates :address, presence: true
validates :position, presence: true
validates :dob, presence: true
validates :level, presence: true
# associations
... | true |
d3ea6ac7c6894d05c7d20e0a099f1a532674cad7 | Ruby | suganyas/Toy-robot | /spec/table_spec.rb | UTF-8 | 813 | 2.671875 | 3 | [] | no_license | # -*- encoding: utf-8 -*-
require 'spec_helper'
require './lib/table'
require './lib/position_robot'
describe Table do
describe '#new' do
it 'works' do
length = 5
width = 6
result = Table.new(length, width)
expect(result).not_to be_nil
end
end
describe '#position_valid?' do
... | true |
75310bc46090490d1c419b23713ee41545a1c33e | Ruby | sparkgene/check-opsworks-deploy | /check-opsworks-deploy.rb | UTF-8 | 2,543 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env ruby
#
# Check Opsworks deploy status
# ===
#
# This script check opsworks deploy status.
#
# requirements
# * aws cli
# http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html
# set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables before using this script.
# The ... | true |
649bb96d1ce0c640b05c9fb3af0136f635d13751 | Ruby | blaksmatic/Interface_no_name | /src/graph.rb | UTF-8 | 13,482 | 3.625 | 4 | [] | no_license | require 'json'
require '../src/metro'
#This graph class is the dictionary of our CSAIR system. it keeps all the information about the graph
class Graph
#Make all the attributes visible to all other classes.
attr_accessor :longest_dist, :shortest_dist, :avg_dist, :biggest_pop, :biggest_city, :avg_dist, :avg_pop
... | true |
2dc79e97f448674d17316d97253782c0551599ec | Ruby | hiroshima-t1/Nomikai | /vendor/gems/ri_cal-0.8.7/lib/ri_cal/floating_timezone.rb | UTF-8 | 787 | 2.5625 | 3 | [
"MIT"
] | permissive | module RiCal
#- ©2009 Rick DeNatale
#- All rights reserved. Refer to the file README.txt for the license
#
# FloatingTimezone represents the 'time zone' for a time or date time with no timezone
# Times with floating timezones are always interpreted in the timezone of the observer
class FloatingTimezone
... | true |
e74d3621fd29922864e8f607c4bf474a556efcbf | Ruby | saddacracker/show_up | /lib/tasks/fetch_meetings.rake | UTF-8 | 4,495 | 2.609375 | 3 | [] | no_license | namespace :meetings do
namespace :fetch do
desc "Scrape Seattle Meetings"
task :seattle => :environment do
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'time'
@meetings = Array.new
@halls = {
"Ed Lynn Fellowship" => "5800 198th SW, Suite 1, ... | true |
46ad1c2be388727cf1804d623b2bc1640d57f9ec | Ruby | soveran/remoto | /test/remoto_test.rb | UTF-8 | 554 | 2.546875 | 3 | [
"MIT"
] | permissive | require "cutest"
require_relative "../lib/remoto"
def expect(port, str)
server = TCPServer.new('localhost', port)
s = server.accept
msg = s.read
assert_equal msg, str
s.write("{}")
s.close
end
def check(port, str)
t = Thread.new { expect(port, "#{str}()") }
env = { "PATH_INFO" => "/#{str}", "SCR... | true |
4e0449a414999a297dfd1bde58f9209ebe966397 | Ruby | quandl/quandl_operation | /lib/quandl/operation/transform.rb | UTF-8 | 5,763 | 2.734375 | 3 | [
"MIT"
] | permissive | module Quandl
module Operation
class Transform
class << self
def perform(data, type)
assert_valid_arguments!(data, type)
# nothing to do with an empty array
return data unless data.compact.present?
# original order
order = Sort.order?(data)
... | true |
9c9a2ee9123c437a3a8ee5b22108f483f0e2b496 | Ruby | Dadario23/Ruby | /Ejercicios/ej_todos_son_5.rb | UTF-8 | 297 | 3.4375 | 3 | [] | no_license | def todos_son_5(arr)
return false if arr.length==0
arr.each do |e|
return false if e != 5
end
true
end
puts todos_son_5([5, 5, 5]) # true
puts todos_son_5([5, 5, 5, 5, 5, 5]) # true
puts todos_son_5([5, 4, 5]) # false
puts todos_son_5([]) # false
puts todos_son_5([5, "5", 5]) # false
| true |
addb41156dc768e736edf1f5b505aa79e886fe8c | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/grade-school/489b2f23b9184bbeb2f46dd1d2342ff3.rb | UTF-8 | 382 | 3.453125 | 3 | [] | no_license | class School
def initialize
@students = {}
end
def add name, grade
@students[grade] ? @students[grade] << name : @students[grade] = [name]
@students = _sort(@students)
end
def to_hash
@students
end
def grade grade
@students[grade] || []
end
def _sort students
Hash[@students.map {|grade, names|... | true |
edb6cd25c2404a8c100b59ce773cf86fb628a9e3 | Ruby | ankitbhardwaj78/PlayerVsComputerTicTacToe | /Player_Computer.rb | UTF-8 | 7,351 | 3.3125 | 3 | [] | no_license | puts "ENTER THE SIZE OF THE SQUARE"
a=gets
b= Array.new(a.to_i){Array.new(a.to_i)}
for i in 0...(a.to_i)
for j in 0...(a.to_i)
b[i][j]=" "
end
end
def printBoard b , a ,check
for i in 0...(a.to_i)
for j in 0...(a.to_i)
print b[i][j].to_s+"|"
end
puts "\n"
for j in 0...(a.to_i)
print "--"
en... | true |
213bab25afa22955f06e661eab07ca20da2c73f9 | Ruby | leonthemisfit/SudokuSolver | /square.rb | UTF-8 | 667 | 3.109375 | 3 | [] | no_license | # frozen_string_literal: true
module Sudoku
class Square
attr_reader :value
attr_accessor :pencil, :row, :column, :box
def initialize(value, constant = false)
@value = value
@constant = constant
@complete = constant
@pencil = []
end
def check
return false if @cons... | true |
b9318fa16046ecc533c78ea88e766c78b5b6b702 | Ruby | csoreff/bounding_area | /lib/bounding_area.rb | UTF-8 | 225 | 3.171875 | 3 | [] | no_license | class BoundingArea
attr_reader :bounding_boxes
def initialize(bounding_boxes)
@bounding_boxes = bounding_boxes
end
def contains_point?(x, y)
bounding_boxes.any? { |box| box.contains_point?(x, y) }
end
end
| true |
dd37aefb4f63f53d53672c563d929ce0d700ad23 | Ruby | yyang-src/monitor | /lib/daemons/engine.rb | UTF-8 | 2,319 | 3.296875 | 3 | [] | no_license | require File.dirname(__FILE__) + "/task"
require 'thread'
class Engine
IDLE = 0
RUNNING = 1
PAUSED = 2
STOPPING = 3
attr_accessor :error_occurred
attr_accessor :pre_run
attr_accessor :post_run
attr_reader :status
attr_accessor :working_mode
def initialize
@status = I... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.