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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
fec2dfcc335f50055c624ae5d18fe85664427676 | Ruby | xtrmdarc/my_linter | /spec/parser_spec.rb | UTF-8 | 4,799 | 2.78125 | 3 | [] | no_license | require_relative '../lib/xml_parser.rb'
require_relative '../lib/file_reader.rb'
describe XmlParser do
let(:test_path) { './test_files/' }
let(:sample_parser) { XmlParser.new [] }
describe '#prolog_at_start?' do
it 'returns false if no well formed Prolog is found at the start of the file' do
xml_parse... | true |
9064bf6042db5ccf8d080f357a904024dca802ca | Ruby | fullfabric/occupier | /spec/lib/occupier/tenant_spec.rb | UTF-8 | 5,169 | 2.609375 | 3 | [] | no_license | describe Occupier::Tenant do
let(:handle) { Faker::Internet.domain_word }
let(:connection) { Occupier::MongoMapper::Connection.new :test }
it "returns a list of handles for all existing tenants" do
handle_1 = Faker::Internet.domain_word
handle_2 = Faker::Internet.domain_word
Occupier::Tenant.ne... | true |
7b1fa3baf15132fc051b5fad7acc8c6eb847244d | Ruby | dcaponi/blog | /app/controllers/concerns/keymaker/operation.rb | UTF-8 | 1,353 | 2.546875 | 3 | [] | no_license | module Keymaker
class Operation
attr_accessor :url, :client_id, :client_secret
def initialize( params={} )
self.url = params[ :url ]
self.client_id = params[ :client_id ]
self.client_secret = params[ :client_secret ]
end
def get( path, parameters={} )
request( path, par... | true |
f09d21c0e8ed79575051ff3b266774ab3273aa23 | Ruby | hooptie45/xiki | /menu/d3.rb | UTF-8 | 10,869 | 2.671875 | 3 | [
"MIT"
] | permissive | class D3
# v3 makes this not show the movement
# @d3/examples/movement/position/
# We're at .v2 now - go back to .v3 when this is fixed?
# <script type="text/javascript" src="http://d3js.org/d3.v2.min.js"></script>
# <script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
MENU = %`
... | true |
7834dba1122cbe9803b4763727aa4d47c134a04a | Ruby | twhitinger/skill-inventory-crud | /test/models/skill_inventory_test.rb | UTF-8 | 1,115 | 2.703125 | 3 | [] | no_license | require_relative '../test_helper'
require 'pry'
class SkillInventoryTest < Minitest::Test
include TestHelpers
def setup
skill_manager.create({ :title =>"Cook", :description => "food"})
skill_manager.create({ :title =>"Sleep", :description => "ok"})
skill_manager.create({ :title =>"DANCE", :description... | true |
0542d74726d8768f2fb72f34c6f6c14698899efb | Ruby | lexus2727/deli-counter-online-web-prework | /deli_counter.rb | UTF-8 | 799 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def line(katz_deli)
#at the beginning of the day, the deli is empty
#so the queue should be represented by an empty array
katz_deli = []
if katz_deli.empty? == true
puts "The line is currently empty."
end
def take_a_number(katz_deli, element)
katz_deli.each_with_length do |x,i|
puts "Welcome #... | true |
dc2d77433a75063af3e7e5c4acce6794bfb7e496 | Ruby | jku6/ruby | /labs/2-basic_calculator_v3.rb | UTF-8 | 898 | 3.796875 | 4 | [] | no_license | require 'pry'
def pow(num1, num2)
num1 ** num2
end
def sqrt(num1)
Math.sqrt(num1)
end
def add(num1,num2)
num1+num2
end
def subtract(num1,num2)
num1-num2
end
def multiply(num1,num2)
num1*num2
end
def divide(num1,num2)
num1/num2
end
action = "z"
while action!="q"
puts "Would you like to (a)dd, (s)ubtract, ... | true |
ee231c09a4442454cd6e54f47a1f2bbd44ed2e98 | Ruby | pallygurl/MinedMindsKata2 | /PrintAssignment.rb | UTF-8 | 486 | 4.125 | 4 | [] | no_license | =begin
this program will display numbers from 1 to 100 inclusive, with
all numbers evenly divisible by 3 displayed as THREE and all numbers
evenly divisible by 5 displayed as FIVE
in addition, if any number is divisible by both 3 and 5 the result will display
SUCCESS!
=end
number = 1
100. times do
if number % 3 == ... | true |
2553ccc5aa8a8bd781805736c18975b77c9fb961 | Ruby | lydiastepanek/Rails-Lite | /lib/controller_base.rb | UTF-8 | 1,607 | 2.53125 | 3 | [] | no_license | require_relative 'session'
require_relative 'params'
require_relative 'router'
require 'active_support'
require 'active_support/core_ext'
require 'erb'
require 'active_support/inflector'
class ControllerBase
attr_reader :req, :res, :params
def initialize(req, res, route_params = {})
@req = req
@res = res
... | true |
eb5817f3ba9ba34873b6bc04167222c2a00a39e8 | Ruby | Harkell/ve | /lib/tasks/durham.rake | UTF-8 | 2,301 | 2.5625 | 3 | [] | no_license | task :fetch_durham => :environment do
require 'rubygems'
require 'nokogiri'
require 'mechanize'
agent = Mechanize.new
page = agent.get("http://durham.escortdirectory-uk.com/")
interests = Array.new
pictures = Array.new
agent.page.links_with(text: /\d/).each do |link| # can select individual ages by (tex... | true |
821dc4366c24e260ac12437e576577e88bdb2847 | Ruby | therbin404/6-exo-ruby | /exo_2.rb | UTF-8 | 452 | 4.53125 | 5 | [] | no_license | puts "Entrez un nombre pour connaitre sa table de multiplications (jusqu'a 10)"
number = gets.chomp.to_i #The chomp to remove the carriage return. And the to_i, to convert the string entered to an integer
i = 1 #Begin of multiplication_table is 1
while (i < 11) #When i == 11, stop the loop. SO, the last number enters i... | true |
ed80494b47d29bb74be0eee8e90dfe7d39e557b5 | Ruby | yeniv/Run-Forrest-Run | /app/models/forrest_gump.rb | UTF-8 | 1,301 | 2.546875 | 3 | [] | no_license | class ForrestGump < ApplicationRecord
has_many :tweets
serialize :route, Array
serialize :quotes, Array
def self.route
Mapbox.access_token = ENV['MAPBOX_API_KEY']
route_coordinates = []
locations = [ # Running locations, first to last [long, lat]
[-85.9769900, 32.6122000], #... | true |
1a112c2e2624c9c6f8256fd9e86f625ff3bee796 | Ruby | YingCGooi/big-o-algorithmic-problems | /backtracking/letter_combinations_phone.rb | UTF-8 | 1,800 | 4.125 | 4 | [] | no_license | # Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.
# A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.
LETTERS_MAP = {
'2' => %w[a b c],
'3' => %w[d e f],
'4' =>... | true |
a2b3c4cc242a87ae9147e2052be96ba934f184d7 | Ruby | Yelp/yelp-fusion | /fusion/ruby/sample.rb | UTF-8 | 3,336 | 3.375 | 3 | [
"MIT"
] | permissive | require "json"
require "http"
require "optparse"
# Place holders for Yelp Fusion's API key. Grab it
# from https://www.yelp.com/developers/v3/manage_app
API_KEY = None
# Constants, do not change these
API_HOST = "https://api.yelp.com"
SEARCH_PATH = "/v3/businesses/search"
BUSINESS_PATH = "/v3/businesses/" # traili... | true |
e7b84ffd02e698eee18f5feda3d844df2a39ad97 | Ruby | yoppi/s3-migrator | /lib/s3/migrator.rb | UTF-8 | 2,019 | 2.515625 | 3 | [
"MIT"
] | permissive | require_relative "migrator/version"
require "aws-sdk"
require "logger"
require "optparse"
require "thread"
module S3
module Migrator
extend self
DEFAULT_THREAD_COUNT = 10
def migrate!(opts)
# use ~/.aws/credentials if without credentials opts
creds = if opts[:profile]
Aws::SharedC... | true |
e97469e13b5f6c1c1f5c61523b7b39b250cd07ce | Ruby | Brayan9105/Exercises | /largest_palindrome.rb | UTF-8 | 343 | 3.40625 | 3 | [] | no_license | # frozen_string_literal: true
def largest_palindrome(digits)
start = '9' * digits
start = start.to_i
start.downto(1) do |i|
start.downto(1) do |j|
product = i * j
return product if product == product.to_s.reverse.to_i
end
end
end
puts largest_palindrome(1)
puts largest_palindrome(2)
puts... | true |
b39449555f5b66133018241564c779e806e1e2b6 | Ruby | mmoroney01/cop-check | /app/controllers/incidents_controller.rb | UTF-8 | 2,125 | 2.53125 | 3 | [] | no_license | require 'net/http'
require 'uri'
require 'geokit'
class IncidentsController < ApplicationController
def search
if params[:address].empty?
respond_to do |f|
f.html { redirect_to root_path }
f.js { render "search_fail.js.erb" }
end
else
payload = make_payload(params[:address])... | true |
4b6ed88d4facda2fec7dbaf745988a28ffb6ee0d | Ruby | nicholalexander/shoe_clicker | /lib/rainbow/bank.rb | UTF-8 | 274 | 3.28125 | 3 | [] | no_license | class Bank
attr_reader :balance, :total_manufactured
def initialize
@balance = 0
@total_manufactured = 0
end
def credit(ammount)
@balance += ammount
@total_manufactured += ammount
end
def withdraw(ammount)
@balance -= ammount
end
end | true |
582e680526e5369d892c61ec792df9df8d3d0032 | Ruby | mylescc/falafel | /app/service_objects/profile_validation_summary.rb | UTF-8 | 493 | 2.890625 | 3 | [] | no_license | class ProfileValidationSummary
def initialize(user)
@user = user
@results = []
end
def valid?
results.reject{ | result | result.valid? }.empty?
end
def add_result(result)
results << result
end
def results_for(section_name)
results.find{ |result| result.section_name == section_name }... | true |
806404f85e077ee50d9db1c50f4fa66f5390610f | Ruby | bernardoamc/trocadecodigo | /03/class_eval.rb | UTF-8 | 246 | 3.375 | 3 | [] | no_license | class ClassEval
end
ClassEval.class_eval do
def diga_oi
puts "Oi!"
end
end
ce = ClassEval.new
ce.diga_oi
ce.instance_eval do
def meu_metodo
puts "Respondo apenas ao ce"
end
end
ce.meu_metodo
ce2 = ClassEval.new
ce2.meu_metodo
| true |
2fa440080457950c368e5ca06248400d1005faeb | Ruby | fgerlits/advent-of-code-2016 | /12/two.rb | UTF-8 | 206 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative 'one'
if __FILE__ == $0
computer = Computer.new(parse_input(ARGF.readlines))
computer.registers['c'] = 1
computer.run
puts computer.registers['a']
end
| true |
74e000fb44c6cb2d542ddfe581bebb1e4d772db4 | Ruby | booyakah/tf2.pug.na-IRC-bot | /stateLogic.rb | UTF-8 | 2,076 | 2.78125 | 3 | [] | no_license | module StateLogic
def attempt_afk
if @state == Const::State_waiting and minimum_players?
@state = Const::State_afk
@afk = check_afk @players.keys # will take a long time
start_afk unless @afk.empty?
attempt_picking
end
end
def attempt_picking
if minimum_players... | true |
c37f9dd3e316c92bd62664cf0d0cf2b18da8bae5 | Ruby | lewispb/alexa-rubykit | /lib/alexa_rubykit/audio_player_request.rb | UTF-8 | 397 | 2.53125 | 3 | [
"MIT"
] | permissive | # Session end request class.
module AlexaRubykit
class AudioPlayerRequest < Request
attr_accessor :name
def initialize(json_request)
super
@type = 'AUDIO_PLAYER_REQUEST'.freeze
@name = type.split('.').last
end
# Ouputs the request_id and the reason why.
def to_s
"Session... | true |
d0b2857fb7e7681d4dac4bbd32903b34651c19f9 | Ruby | niiccolas/aao | /03_ruby/06_data_structures/projects/05_tictactoe/lib/tic_tac_toe_node.rb | UTF-8 | 1,417 | 3.578125 | 4 | [] | no_license | require_relative 'tic_tac_toe'
class TicTacToeNode
attr_reader :board, :next_mover_mark, :prev_move_pos
def initialize(board, next_mover_mark, prev_move_pos = nil)
@board = board
@next_mover_mark = next_mover_mark
@prev_move_pos = prev_move_pos
end
def losing_node?(evaluator)
if board.over?
... | true |
830b4c74a46d3ecd216a3f02cc0cc2dbfd40d799 | Ruby | Shadow073180/tic-tac-toe-rb-online-web-sp-000 | /lib/tic_tac_toe.rb | UTF-8 | 2,849 | 4.25 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry'
WIN_COMBINATIONS =[
[0,1,2], [3,4,5], [6,7,8], [0,3,6],
[1,4,7], [2,5,8], [0,4,8], [2,4,6]]
board = [" "," "," "," "," "," "," "," "," "]
def display_board(board)
puts " #{board[0]} | #{board[1]} | #{board[2]} "
puts "-----------"
puts " #{board[3]} | #{board[4]} | #{board[5]} "
puts ... | true |
e2db61fdb9ebd56f6b8d485927a03cf3b5ca0960 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/combine_anagrams_latest/13369.rb | UTF-8 | 377 | 3.53125 | 4 | [] | no_license | def combine_anagrams(words)
signatures = {}
words.each do |word|
(signatures[word.downcase.chars.sort.join] ||= []) << word
end
signatures.values
end
# input:
words = ['cars', 'for', 'potatoes', 'racs', 'four', 'scar', 'creams', 'scream']
# => output: [["cars", "racs", "scar"], ["four"], ["for"], ["pot... | true |
b0fc94719c5d46a52eceeef06ced5f099de6d717 | Ruby | nabetani/yhpg | /e31/impl/1.rb | UTF-8 | 1,695 | 3.046875 | 3 | [
"BSD-2-Clause"
] | permissive | # frozen_string_literal: true
require "json"
def next_vals(b,n)
[n, (n+1)%b]
end
def build_number(b, head, size, states)
(size-1).times.with_object([head]) do |ix,o|
candidates = next_vals(b, o.last).sort
o.push candidates[:low==states[ix] ? 0 : 1]
end
end
def undigits(b,d)
d.reverse_each.inject(0) ... | true |
617d41c619fcf7a4c9c4634a077c43bc38037163 | Ruby | w4-pwr/studia | /semestr-v/bazy-danych-projekt/webapp/app/models/list_proxy.rb | UTF-8 | 546 | 2.6875 | 3 | [
"MIT"
] | permissive | class ListProxy
def initialize(parent, coll, pname, klazz)
@parent = parent
@coll = coll
@pname = pname
@klazz = klazz
end
def method_missing(name, *args, &block)
__coll.send(name, *args, &block)
end
def find(id)
__coll.find {|e| e.id == id.to_i }
end
def create(attrs = {})
... | true |
46fab998ccc89806adfdf3ec76f48a698813385f | Ruby | sbits/Roundabout | /lib/roundabout/crawler.rb | UTF-8 | 11,377 | 2.546875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | =begin
Copyright 2012 Tasos Laskos <tasos.laskos@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required b... | true |
43253a1146c01ee0c0d892f21154a33b76b21c14 | Ruby | wardymate/checkout_tech_test | /lib/checkout.rb | UTF-8 | 849 | 3.109375 | 3 | [] | no_license | class Checkout
def initialize(discount_options = {})
@discount_amount = discount_options[:discount_amount]
@discount_rate = discount_options[:discount_rate] ||= 0
@heart_discount = discount_options[:heart_discount] ||= 0
@heart_discount_amount = discount_options[:heart_amount] ||= 0
@basket = []
... | true |
bcf01226fbf3174b713ffc217dab59e8afadcd1e | Ruby | ericdcobb/grapevine | /lib/grapevine/notifier.rb | UTF-8 | 3,987 | 2.984375 | 3 | [] | no_license | module Grapevine
# This is an abstract base class for all notifiers in the system. The notifier
# announces the most popular topic.
class Notifier
############################################################################
# Static Attributes
##########################################################... | true |
5527258fece2e9d2de99a472edfa90296423e68c | Ruby | willfowls/launchschool | /rb_101/small_problems_exercises/easy_9/uppercase_check.rb | UTF-8 | 446 | 3.984375 | 4 | [] | no_license | # Write method that takes string argument
# Return true if all abc characters in string are uppercase
# Return false otherwise
# Ignore non alphabetic characters
def uppercase?(string)
if string == string.upcase
return true
else
return false
end
end
p uppercase?('t') == false
p uppercase?('T') == true
p... | true |
6fdf057b1520e29e8054ae5872e14b1f3f6be5c7 | Ruby | marvelaz/codea | /semana1/vocales.rb | UTF-8 | 186 | 3.3125 | 3 | [] | no_license | #Removiendo vocales
def vowels(a)
a.each do |x|
x.gsub!(/[aeiou]/, '')
end
end
p vowels(["banana", "carrot", "pineapple", "strawberry"]) == ["bnn", "crrt", "pnppl", "strwbrry"]
| true |
9f4fed5a2cf3c0d42b544f2669ca71f231e87273 | Ruby | salami-art/address_book | /lib/test.rb | UTF-8 | 1,541 | 2.859375 | 3 | [] | no_license | class Test
TESTFILE = "test.txt"
def initialize
@name = "rubytest"
@surname = "mikamai"
@email = "rubytest@mikamai.com"
@fake = "fake"
spec_chain
end
def assert condition, message
if condition
puts "* #{message}"
else
puts "ERROR: #{message}"
end
end
d... | true |
82731d714cd28d70a712dfafdd2667d84ec342cb | Ruby | LaunchAcademy/rocket_fuel | /lib/rocket_fuel/precheck/check_result.rb | UTF-8 | 329 | 2.515625 | 3 | [
"MIT"
] | permissive | module RocketFuel
module Precheck
class CheckResult
attr_reader :result
attr_reader :message
attr_reader :check_name
def initialize(result, message, check_name)
@result, @message, @check_name = result, message, check_name
end
def ok?
result
end
end
... | true |
ab6c168557034180347242f79b421dc9a7d24972 | Ruby | SCPR/prison_letters | /models/page.rb | UTF-8 | 401 | 2.640625 | 3 | [] | no_license | class Page
class << self
def all
@pages ||= YAML.load_file("fixtures/pages.yml")
end
#----------------
def total_pages
@total_pages ||= self.all.size
end
end
#----------------
attr_accessor :letter_id, :page_number, :full_url, :viewer_url, :thumb_url
#----------------
d... | true |
b63cbd90439a0fdff4aef10a958ff0bfc2d4908b | Ruby | dataphreak1001/mebious | /models/images.rb | UTF-8 | 1,927 | 2.65625 | 3 | [
"MIT"
] | permissive | require "mime/types"
require "mini_magick"
class Image < ActiveRecord::Base
def self.add(tmpfile, ip)
stamp = Time.now.to_i
url = self.filename
checksum = Digest::MD5.file(tmpfile).to_s
extension = get_ext tmpfile
if !valid?(tmpfile) or extension.empty?
return false
end
if dupl... | true |
14e644e34cc0f2a9ef0d8566879787db830c321d | Ruby | kajboj/hoplite | /lib/ruby/hoplite_move.rb | UTF-8 | 145 | 2.546875 | 3 | [] | no_license | class HopliteMove
attr_reader :coords
def initialize(coords)
@coords = coords
end
def execute
raise 'abstract method'
end
end | true |
0f7f3cba387af6e7b4e5b5a9a4ce7174bd068f57 | Ruby | hlxwell/leetcode-ruby | /39.combination-sum.rb | UTF-8 | 476 | 3.0625 | 3 | [] | no_license | #
# @lc app=leetcode id=39 lang=ruby
#
# [39] Combination Sum
#
# @lc code=start
# @param {Integer[]} candidates
# @param {Integer} target
# @return {Integer[][]}
@result = {}
def combination_sum(candidates, target)
@result = {}
dfs [], candidates.uniq, target
@result.keys
end
def dfs(result, arr, target)
ret... | true |
5cb08ab7a0d532954b3e689415c1081327a781e6 | Ruby | runticle/borrris_bikes | /lib/garage.rb | UTF-8 | 221 | 3.078125 | 3 | [] | no_license | class Garage
DEFAULT_CAPACITY = 100
def initialize(capacity = DEFAULT_CAPACITY)
@bikes = []
@capacity = capacity
end
def full?
@bikes.length >= @capacity
end
attr_accessor :bikes, :capacity
end
| true |
9d7580c40102776db4afb237f7f92560e52d593a | Ruby | botworx/botworx-ruby | /lib/mia-ruby/rhspolicy.rb | UTF-8 | 3,368 | 2.65625 | 3 | [] | no_license | require 'visitor'
require 'policy'
class RhsPolicyGroup < PolicyGroup
def initialize
@policies = {
:RhsBlock => RhsBlockPolicy.new,
:LhsBlock => LhsBlockPolicy.new,
:ClassDef => ClassDefPolicy.new,
:ClassDefShare => ClassDefSharePolicy.new,
:PredicateDef => PredicateDefPol... | true |
b4c50252e1c595640886074879709e6383b8d164 | Ruby | JulietteF2/livestorm_ex | /lib/rooms/open_space.rb | UTF-8 | 1,574 | 3.453125 | 3 | [] | no_license | # Open space's actions
class OpenSpace
def initialize(session, direction)
@session = session
@direction = direction
end
def chose_action(input)
if input == 'greet'
if @session.artefacts.count < 2
puts "\nTom says: 'Hello there! How is it going? I think I have something that could help y... | true |
2533fb6a495b6e3ded11481780486682254e5472 | Ruby | listings-xx/wayback_scraper | /app/models/grouphug_page.rb | UTF-8 | 592 | 2.625 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
class GrouphugPage
def initialize(url)
@full_page = Nokogiri::HTML(open(website))
end
def next_page_url
@full_page.css('td#nav-pages-next a').attribute('href').value
end
def confessions
out = []
confession_nodes.each do |row|
out << {
:pos... | true |
70f897a53f45e58b1b6748aaa51ebabc46f37be6 | Ruby | thefonso/UNCLEFONSO_lessons | /00-week/ruby_basics/07_classes/03-class-get-set.rb | UTF-8 | 398 | 3.96875 | 4 | [
"MIT"
] | permissive | # CLASSES: get and set
#
# another way of writing get and set
class Car
# we call methods like this a "setter"
def set_miles(miles)
@miles = miles
end
# we call methods like this a "getter"
def get_miles
@miles
end
end
car = Car.new
car.set_miles 1000
car.get_miles # => 1000
car.instance_variabl... | true |
ae10fa3546ac344ed793e77bd1a57311c772dfcd | Ruby | cshobar/edx-CS169x | /hw1/part5.rb | UTF-8 | 1,085 | 3.546875 | 4 | [] | no_license | class Class
def attr_accessor_with_history(attr_name)
attr_name = attr_name.to_s # make sure it's a string
attr_reader attr_name # create the attribute's getter
attr_reader attr_name+"_history" # create bar_history getter
class_eval %Q{
def #{attr_... | true |
80563b9a09fdfa59622eb4c2be78517bb95287c5 | Ruby | frugardc/tweetwork | /network.rb | UTF-8 | 469 | 2.953125 | 3 | [] | no_license | module Tweetwork
class Network
attr_accessor :tweets,:tweeters
def initialize(filepath)
@tweets = []
@tweeters = {}
if File.exists?(filepath)
load_from_file(filepath)
else
raise Exception.new("cannot find this file - #{filepath}")
end
end
private
def load_from_file(filepath)
File... | true |
d7da9e04f36df4bc86d24d0f5b585190e699807e | Ruby | beschwa/OO-mini-project-dumbo-web-career-031119 | /app/models/Ingredient.rb | UTF-8 | 505 | 3.40625 | 3 | [] | no_license | class Ingredient
@@all = []
attr_reader :name
def initialize (name)
@name = name
@@all << self
end
def self.all
@@all
end
def self.most_common_allergen
most_common_allergen = @@all.first
@@all.each do |ingredient|
if (get_allergens(ingredient).size > get_allergens(most_commo... | true |
fd70c8e309672b29ddf5019d636812e97bd663ac | Ruby | nagites/RoboCitizen | /lib/modules/sunlight_setup.rb | UTF-8 | 2,580 | 2.640625 | 3 | [] | no_license | module SunlightSetup
require 'sunlight/congress'
attr_accessor :legislators, :state_vars, :state_abbrs
################################################################
public
def setup
Sunlight::Congress.api_key = "e179a6973728c4dd3fb1204283aaccb5"
@legislators ||= []
all_legislators
all_st... | true |
5cfc99620c58c61cc6cd10611e44edb147574cae | Ruby | xis19/leetcode | /276.rb | UTF-8 | 428 | 3.25 | 3 | [] | no_license | def num_ways(n, k)
if n == 0 || k == 0
0
else
history = [0, k, k * k]
# w(n) = (k - 1) * (w(n-1) + w(n-2))
# for n posts, if we want n, n-1 have the same color, there are (k-1) *
# w(n-2) possibilities, if we want n,n-1 have different color, there are
# (k-1) * w(n-1) possibilities
(3..n... | true |
0838526b80ae7fd57ec06e03648e5d9941d086b3 | Ruby | Ninanihan/Dogworld_RubyOnRails | /app/models/search.rb | UTF-8 | 288 | 2.609375 | 3 | [] | no_license | class Search < ActiveRecord::Base
def search_pets
pets = Pet.all
pets = pets.where(["age LIKE ?",age]) if age.present?
pets = pets.where(["gender LIKE ?",gender]) if gender.present?
pets = pets.where(["breeds LIKE ?",breeds]) if breeds.present?
return pets
end
end
| true |
5def8570434eb74215e5984cce7d441b0bb684ab | Ruby | jotita28/desafiohashes | /ejercicio4.rb | UTF-8 | 309 | 3.25 | 3 | [] | no_license | personas = ["Carolina", "Alejandro", "Maria Jesús", "Valentín"]
edades = [32, 28, 41, 19]
mix = Hash[personas.zip(edades)]
def promedio(mix)
contador = 0
mix.each do |nombre, valor|
contador += valor
end
promedio = contador / mix.length
puts promedio
end
promedio(mix)
| true |
c365b25d3ed0fcef5e2f438029a6b253302b83ed | Ruby | javitocor/Coding-Challenges---repl.it | /isItBalanced.rb | UTF-8 | 891 | 4.21875 | 4 | [
"MIT"
] | permissive | class Node
attr_reader :data
attr_accessor :left, :right
def initialize data
@data = data
end
end
# helper function
def array_to_tree(array, index = 0)
return nil if index >= array.length || array[index] == 0
node = Node.new(array[index])
node.left = array_to_tree(array, 2*index+1)
node.r... | true |
5001173d81d70152cb15c3780157f7833a0404a3 | Ruby | nickbrowne/vivus | /app/models/block.rb | UTF-8 | 318 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'rdiscount'
class Block
def initialize (source, comment, html)
@source = source
@comment = comment
@html = html
end
def source
@source
end
def comments
RDiscount.new(@comment.join, :smart, :filter_html).to_html
end
def html
RDiscount.new(@html.join).to_html
end
end
| true |
54f73b408e5016605601176d7cc4f0b46b0710b8 | Ruby | mdl2811/ruby_casino | /single_card_poker.rb | UTF-8 | 3,377 | 3.953125 | 4 | [] | no_license | require_relative 'Deck'
require_relative 'Card'
require_relative 'card_display'
require_relative 'poker_logo'
class SingleCardPoker
# Getter and Setter methods
# attr_accessor
# Gets called when you call the new method to create an instance
# deck = Deck.new
def initialize(player)
print_poker_logo
player... | true |
79d18328c312fef8006d0ad47866d2cd59ff11a8 | Ruby | COS301-SE-2021/Escape-Room-Planner | /Backend/test/unit/er_test.rb | UTF-8 | 12,130 | 2.59375 | 3 | [] | no_license | # frozen_string_literal: true
require 'test_helper'
require './app/Services/room_services'
require './app/Services/create_escaperoom_request'
require './app/Services/create_escaperoom_response'
require './app/models/keys'
require './app/models/container'
require './app/Services/RoomSubsystem/Request/get_vertices_reque... | true |
f7858a593867b957adfb3174a2a8712423481563 | Ruby | ryanricard/rsvp | /app/models/rsvp/access_attempt.rb | UTF-8 | 719 | 2.53125 | 3 | [
"MIT"
] | permissive | module Rsvp
class AccessAttempt < ActiveRecord::Base
attr_accessible :remote_ip
ALLOWED_ATTEMPTS = 7
LOCK_DURATION = 15
def record_attempt
self.failed_attempts += 1
if failed_attempts >= allowed_attempts
self.locked_until = Time.now + lock_duration
self.locks_incurred += ... | true |
c64524e0cfb2104af32e6564b6b620e0a30e44ba | Ruby | jcasimir/slimgin | /test/customer_test.rb | UTF-8 | 2,461 | 3.015625 | 3 | [] | no_license | require_relative 'test_helper'
require_relative '../lib/sales_engine'
require_relative '../lib/customer'
class CustomerTest < Minitest::Test
attr_reader :engine
def setup
@engine = SalesEngine.new("./test/fixtures")
engine.startup
end
def test_it_can_find_its_invoices
repo = engine.customer_repo... | true |
d25fb576a8af43cae5c9842a0955657d4b9a9a0c | Ruby | ofer987/computer_science | /leetcode/integer_to_roman/solutions/roman.rb | UTF-8 | 1,148 | 3.78125 | 4 | [] | no_license | def to_roman(value)
value = value.to_i
if value < 1 || value > 3999
return nil
end
result = ''
remaining = value
if (thousands = remaining % 1000)
result += thousands.times.map { 'M' }.join
end
remaining -= result * 1000
if (400 <= remaining < 500)
result += "CD"
elsif (500 <= remai... | true |
726e1d48a2d3f1856b9b7ea7e05bb14b5398f3b8 | Ruby | uchiyu/NLP100 | /03/20.rb | UTF-8 | 471 | 2.890625 | 3 | [] | no_license | =begin
20. JSONデータの読み込み
Wikipedia記事のJSONファイルを読み込み,「イギリス」に関する記事本文を表示せよ.問題21-29では,ここで抽出した記事本文に対して実行せよ.
=end
require 'json'
json_file_path = './jawiki-country.json'
open(json_file_path).each_line do |line|
if line =~ /\"title\": \"イギリス"/
File.open('./report_britain.json', 'a') do |io|
io.puts(line)
end
... | true |
c4f88b52744f4d0a2ea17a62a32dc1cab68a381f | Ruby | martinemde/topt | /lib/topt/parser.rb | UTF-8 | 5,264 | 3.234375 | 3 | [
"MIT"
] | permissive | require 'topt/arguments'
require 'topt/argument'
require 'topt/options'
require 'topt/option'
module Topt
class Parser
attr_reader :options
attr_reader :arguments
# Create a parser for parsing ARGV input into options.
#
def initialize
@options = {}
@arguments = []
yield self if... | true |
c6566d9ed7e3778eccd4262877c75d7a21223ac7 | Ruby | amgeorge30/KWK | /loopWarmUp.rb | UTF-8 | 364 | 2.84375 | 3 | [] | no_license |
def hammer_curls
x = 0
until x == 8
x += 1
puts "Hammer Curl Right"
sleep(1)
puts "Hammer Curl Left"
sleep(1)
end
end
hammer_curls
def jump_squat
x = 0
until x == 8
x += 1
puts "Jump Squat"
sleep(1)
end
end
jump_squat
def sit_ups
x = 0
until x == 16
x += 1
puts "Sit Up"
sleep(1)... | true |
610fe99d5589dcb0e999fc23ec0f9c8d339fddaa | Ruby | EliseJane/algorithm-exercises | /algorithm_exercises/arrays/max_profit.rb | UTF-8 | 307 | 3.921875 | 4 | [] | no_license | def max_profit(prices)
min_valley = 999999
max_profit = 0
(0...prices.size).each do |i|
if prices[i] < min_valley
min_valley = prices[i]
elsif (prices[i] - min_valley) > max_profit
max_profit = prices[i] - min_valley
end
end
return max_profit
end | true |
95b369fd64ecfa4f73dde7908038c38ecf96c9f9 | Ruby | FuckBoilerplate/base_app_ios | /start_fresh/start_fresh.rb | UTF-8 | 3,221 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | require 'fileutils'
class StartFresh
def initialize
copyData
copyDomain
copyPresentation
end
def copyData
puts("Removing files in data layer")
data = '../base-app-ios/data/'
Helper.removeDir(data+'sections/user_demo')
puts("You'll need to remove /base-app-ios/data/sections/user_demo reference... | true |
02dc19b758b8e6892932036c66e9f39e9adef711 | Ruby | adam-conway/strava-dashboard | /spec/models/stat_spec.rb | UTF-8 | 2,197 | 2.640625 | 3 | [] | no_license | require 'spec_helper'
require './app/models/stat.rb'
describe Stat do
let(:attributes) {
{
biggest_ride_distance: 122334,
biggest_climb_elevation_gain: 3455,
recent_ride_totals: {
count: 13,
distance: 127467.8994140625,
moving_time: 22052,
elapsed_time: 23527,
... | true |
bb81867edda79d5807789c9a824e79888f7e65ea | Ruby | mikiyaaa/ruby_practice | /drill7.rb | UTF-8 | 339 | 4.0625 | 4 | [] | no_license | # each_with_indexメソッド
def search(target_num, input)
input.each_with_index do |num, index|
if num == target_num
puts "#{index + 1}番目にあります"
return
end
puts "その数は含まれていません"
end
end
input = [3, 5, 9 ,12, 15, 21, 29, 35, 42, 51, 62, 78, 81, 87, 92, 93]
search(3, input) | true |
8b1ae267de16e971d825773275c7f231358d0f4d | Ruby | lesliehawk/RB109 | /Small_Problems/Easy_3/02.rb | UTF-8 | 1,119 | 4.5 | 4 | [] | no_license | # Arithmetic Integer
# Write a program that prompts the user for two positive integers,
# and then prints the results of the following operations on those two numbers:
# addition, subtraction, product, quotient, remainder, and power.
# Do not worry about validating the input.
# Example
# ==> Enter the first number:
#... | true |
c760e7685dfec7f2d5f1ec7572985a9fd81388a5 | Ruby | atermenji/RubequeImpl | /elementary/injected_and_rejected.rb | UTF-8 | 382 | 3.421875 | 3 | [] | no_license | # Solution to 'Injected and Rejected' on rubeque.com
# by atermenji
# http://rubeque.com/problems/injected-and-rejected
def sum_over_50(arr)
arr.reject { |n| n <= 50}.inject(0, :+)
end
assert_equal sum_over_50([29, 52, 77, 102]), 231
assert_equal sum_over_50([5, 11, 50]), 0
assert_equal sum_over_50([4, 8, 15, 16, 2... | true |
88f5155a950d7237cc374ba353e58b9645a11bf4 | Ruby | edyoda/ruby-course | /10F/loops.rb | UTF-8 | 227 | 3.109375 | 3 | [] | no_license | Iterators
each
map
collect
SYNtax :
collection.map/each/collect do | object|
logic
end
[1,2,3,4].map do | i |
i * 2
end
loop - Explained
for object in collection
logic
end
for i in [1,2,3,4]
puts i* 3
end
| true |
91644a8a8d359ddce9e49692427f014c2a634aee | Ruby | Dalf32/Omnic-MiscHandlers | /handlers/ow_patch/blizz_track_patch_notes_response.rb | UTF-8 | 555 | 2.609375 | 3 | [
"MIT"
] | permissive | # blizz_track_patch_notes_response.rb
#
# AUTHOR:: Kyle Mullins
require_relative '../../api/http_response'
require_relative 'patch'
class BlizzTrackPatchNotesResponse < HttpResponse
def title
body[:title]
end
def patches
body[:items]&.map do |item|
Patch.new(id: item[:id], url: item[:url], title... | true |
eed191d92333f49c0a95580109fe30b50020faa2 | Ruby | rudzainy/ar_todo | /lib/util.rb | UTF-8 | 141 | 3.015625 | 3 | [] | no_license | # Clear the screen
def clear_screen!
print "\e[2J"
end
# Moves cursor to the top left of the terminal
def move_to_home!
print "\e[H"
end | true |
c1e1b73a230189dc0d1541938f750030570f9b17 | Ruby | bbbwcc333/swiss | /swiss.rb | UTF-8 | 3,792 | 3.46875 | 3 | [] | no_license | class Swiss
attr_accessor :players
attr_accessor :current_pairs
attr_accessor :current_round
attr_accessor :number_of_rounds
def initialize(opts = {})
self.current_round = 1
puts "Number of players?"
self.players = gets.chomp.to_i.times.map do |i|
puts "Name of player #{i + 1}?"
name ... | true |
bbb118ab9c4132b660de442847e1518934d388e1 | Ruby | filinivan/BlackJack | /game.rb | UTF-8 | 2,406 | 3.1875 | 3 | [] | no_license | require_relative 'interface'
require_relative 'deck'
class Game
attr_accessor :deck, :bank
def initialize
@deck = Deck.generate
@bank = 0
@hide_status = false
# @user_name = Interface.ask_name
@new_round = true
end
def start
input_name if @user.nil?
new_game if @new_round == true... | true |
6a1c1d5a7424e6f33948790e471e7a18d58ba797 | Ruby | drbrain/power_mitten | /lib/power_mitten/console.rb | UTF-8 | 3,114 | 2.96875 | 3 | [] | no_license | ##
# Monitors the active tasks and services and displays their statistics
class PowerMitten::Console < PowerMitten::Task
config = PowerMitten::Configuration.new self
config.maximum_workers = 1
attr_accessor :window # :nodoc:
def initialize options # :nodoc:
require 'curses'
require 'io/console'
... | true |
9463f148e7d6c9e4b4ee52abe10fc94272c71b29 | Ruby | RuthNjeri/problem_solving | /leetcode/defpacific_atlanti.rb | UTF-8 | 1,441 | 3.53125 | 4 | [] | no_license | require 'pry'
def pacific_atlantic(heights)
return [] if heights.empty?
pacific = Array.new(heights.length) { Array.new(heights[0].length, false) }
atlantic = Array.new(heights.length) { Array.new(heights[0].length, false) }
# left side pacific column
for i in 0...heights.length
dfs(heights, i, 0, pacif... | true |
733fa476c832624cc2e408369e20496951108ed3 | Ruby | memuller/tweetpong_server | /lib/tweetpong/player.rb | UTF-8 | 1,465 | 3 | 3 | [] | no_license | class TweetPong::Player
attr_accessor :username, :challenger
attr_reader :game_id, :logged_at
def initialize game_id, args={}
raise ArgumentError, 'Game id should be an integer.' unless game_id.is_a? Integer
@game_id = game_id
@username = args[:username] if args[:username]
@challenger = args[:cha... | true |
d8cb0556940036c1c057bccd77aec7ae7db073de | Ruby | cjhdev/dlms_trouble | /lib/dlms_trouble/dtype/d_date_time.rb | UTF-8 | 11,519 | 2.578125 | 3 | [
"MIT"
] | permissive | # Copyright (c) 2016 Cameron Harper
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, dis... | true |
389ed15a3e603694411c9e67888352e8ef67cd50 | Ruby | jtbrush56/MoreEnumerables | /challenge.rb | UTF-8 | 795 | 3.859375 | 4 | [] | no_license |
def capitalize_each_string(input)
return input.map do |n| n.capitalize end
end
def fetch_the_dog(input)
return input.select do |n| n == "dog" end
end
def no_dogs_allowed(input)
return input.select do |n| n != "dog" end
end
def count_the_animals(input)
return input.count
end
def fetch_the_first_two(input)
... | true |
f3a77f48726e116a99c9a2d802920cff8b21e19a | Ruby | 0x000000/coursera | /Algorithms Design and Analysis | Part 1/Week 4/prog_assignment.rb | UTF-8 | 7,015 | 2.96875 | 3 | [] | no_license | #
# WARNING!
#
# To run this code you must use jruby with flags:
# -J-Xmn512m -J-Xms4096m -J-Xmx4096m -J-Xss1024M -J-server
#
require 'minitest/spec'
require 'minitest/autorun'
alias context describe
class Graph
attr_reader :adjacency_list, :reversed_adjacency_list
def initialize(edges)
@adjacency_list ... | true |
57a8bc68a5b14c9dc3ccf49d3ca54c52b30d1ab5 | Ruby | tudoxukno/best | /world.rb | UTF-8 | 433 | 3.828125 | 4 | [] | no_license | class Person
attr_accessor :hair_color, :name
def initialize (hair_color, name)
@hair_color = hair_color
@name = name
end
def sing
"Lets keep swimming"
end
end
class Wyncoder < Person
def code
"I am coding!"
end
def to_s
"hello"
end
def inspect
"hello2"
end
end
sandy = Person.new("Brown", "Sandy")
jos... | true |
f1e1b4d25033d69bf7c98b5124578a0e2c2c062f | Ruby | osorubeki-fujita/odpt_tokyo_metro | /lib/tokyo_metro/api/station_facility/info/barrier_free/service_detail/info.rb | UTF-8 | 3,674 | 2.765625 | 3 | [
"MIT"
] | permissive | # 施設の詳細情報を扱うクラス
class TokyoMetro::Api::StationFacility::Info::BarrierFree::ServiceDetail::Info
include ::TokyoMetro::ClassNameLibrary::Api::StationFacility
include ::TokyoMetro::ClassNameLibrary::Api::StationFacility::BarrierFree::MetaClass
include ::TokyoMetro::Modules::ToFactory::Common::Generate::Info
inclu... | true |
786dfbca40c0a45ba8da9bc02abc8e2a245e9822 | Ruby | kelvinjhwong/ruby-exercises | /ruby-challenges/03_medium_1/03_04_protein_translation.rb | UTF-8 | 1,431 | 3.40625 | 3 | [] | no_license | =begin
***Did not watch solution video***
Input:
Output:
Examples / edge cases / assumptions:
- Invalid codon - not a String object that contains one the
specified 3-uppercase-letter combo? Raise InvalidCodonError
Algorithm:
- Codon --> amino acid: simple hash value retrieval by key
- RNA --> strand:
- Split c... | true |
eea89a316e01dabe57f54c6672329190e1cd4b6f | Ruby | Martsy/flash_cards | /test/round_test.rb | UTF-8 | 3,217 | 3.453125 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/card'
require './lib/turn'
require './lib/deck'
require './lib/round'
class RoundTest < Minitest::Test
def setup
@card1 = Card.new('What is the capital of Alaska?', 'Juneau', :Geography)
@card2 = Card.new('The Viking spacecraft sent back to E... | true |
9b8984830b25269e46875cd2785cc151fa8dd315 | Ruby | stacworks/configr | /spec/lib/configuration_spec.rb | UTF-8 | 5,087 | 2.75 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Configr
describe Configuration do
it "should have the #configure class method to instantiate the configuration" do
Configuration.should respond_to(:configure)
end
it "should return nil when a value is not set" do
configuration = Configuration.configure do |config|
conf... | true |
e010316efc52f6ff6f3a19e0a3f29ddd36c0c29c | Ruby | damaral/erp_inov | /app/models/produto.rb | UTF-8 | 792 | 2.5625 | 3 | [] | no_license | # coding: utf-8
class Produto < ActiveRecord::Base
attr_accessible :altura, :comprimento, :custo_unitario, :descricao, :nome, :preco_unitario, :unidade, :ativo
has_many :itens, :dependent => :destroy
PECA = "Peça"
METRO_COMP = "Metro Linear (Comprimento)"
METRO_ALT = "Metro Linear (Altura)"
METRO_QUADRAD... | true |
c6c9d9a80d649b5d1ad4108f64511d64a7bd13bb | Ruby | xcarpentier/ruby_game | /lib/ruby_game/static_object.rb | UTF-8 | 424 | 2.96875 | 3 | [
"MIT"
] | permissive | module RubyGame
class StaticObject
attr_writer :x,:y
def initialize(x, y, image_name)
@image_name = image_name
@x = x
@y = y
end
def draw
@image.draw_rot(@x, @y, 1, 0)
end
def touch?(object)
Math.hypot(object.x - @x, object.y - @y) <= 30
end
def init_image(window)
@window = windo... | true |
7554c1f0b54c2bf8c954b971e9909cce4e59ac23 | Ruby | avertrees/entheogen-backend | /db/data/run.rb | UTF-8 | 4,938 | 2.90625 | 3 | [] | no_license | # require 'csv'
require 'pry'
# require 'open-uri'
require 'json'
# url = 'Muse-AF00_2018-11-15--06-27-16_1542282303988.csv'
#data = CSV.new(open(url), :headers => :first_row)
#puts data.readline
# CSV.foreach(data.path) do |row|
# end
url = "db.json"
# Muse-AF00_2018-10-06--15-13-38_1538854660399.json
#Muse-A... | true |
4678945fe03b847368dd82b6d47beff6d34096d5 | Ruby | Putterhead/Code-Wars | /CW_even_or_odd.rb | UTF-8 | 1,029 | 4.625 | 5 | [] | no_license | # Create a function that takes an integer as an argument and returns
# "Even" for even numbers or "Odd" for odd numbers.
# This was my solution
def even_or_odd(number)
number % 2 == 0 ? "Even" : "Odd"
# I had read that the & operator compares each binary digit of two
# intergers and returns a new integer, with a 1 ... | true |
b55a053217c8a42b118eaa0f9703729af8d6198e | Ruby | liuxingghost/linux-tools | /usefule-cmd/get_dts.rb | UTF-8 | 2,294 | 2.921875 | 3 | [] | no_license | #!/usr/bin/ruby -w
# coding: utf-8
$dts_file_name=""
$show_all_dtsi=0 # -p
$get_all_dtsi=0 # -g
class Xddts
def set_dts_file(name)
@dts_file=name
#测试文件是否存在
return File::file?(@dts_file)
end
def get_dts_base
return @dts_file
end
def show_all_dtsi(name,num) # 打印dts文件树
@old_dir=Dir::getwd
... | true |
00f228889aa3652af05738ade57411ed311cd1ee | Ruby | ctpatey/ls-intro-ruby-exercises | /exercises_ruby_basics/return/bld1.rb | UTF-8 | 212 | 4.15625 | 4 | [] | no_license | # What will the following code print? Why? Don't run it until you've attempted to answer.
def meal
return 'Breakfast'
end
puts meal
# It will print "Breakfast" because that is what is returned by the method. | true |
5e11fe7d07f5a79ed1c156d45556ee95fe4d6a31 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/word-count/ff8423c13cf747df9b2f643cf3ae901e.rb | UTF-8 | 227 | 2.96875 | 3 | [] | no_license | Phrase = Struct.new(:phrase) do
def word_count
words.each_with_object Hash.new(0) do |word, result|
result[word] += 1
end
end
private
def words
@words ||= phrase.scan(/\w+/).map &:downcase
end
end
| true |
c01dbc6179b4fdc87bae0d95254fe966d4c74dae | Ruby | okawa14all/rubymotion_location | /app/models/venue_point_annotation.rb | UTF-8 | 360 | 2.859375 | 3 | [] | no_license | class VenuePointAnnotation
attr_accessor :title, :subtitle, :venue
def initialize(venue=nil)
@venue = venue
@coordinate = CLLocationCoordinate2DMake(venue.latitude, venue.longitude)
@title = venue.name
@subtitle = venue.categories
end
def coordinate
@coordinate
end
def setCoordinate(c... | true |
43fed8d1c9a9a4aef947111c160948f6851828d3 | Ruby | QiuzhuLu/Ruby_Praktikum | /A6-WiSe20_21/functionale/ApproximatorTest.rb | UTF-8 | 1,049 | 2.828125 | 3 | [] | no_license | require_relative 'approximator'
require 'test/unit'
# 6.1.1_f_int
class ApproximatorTest < Test::Unit::TestCase
def setup
@n_minus_1 = -1
@n_string = "a"
@n_float = 0.5
@n100 = 100
@n50 = 50
@n10 = 10
@n0 = 0
@naehrungswert = 2.0/3
@delta_n100 = 1.1102230246251565e-16
... | true |
23ba5488454a53195a9a746a4c0681f120ad0e0e | Ruby | Turing-School-Projects/enigma | /test/enigma_test.rb | UTF-8 | 1,450 | 2.796875 | 3 | [] | no_license | require_relative 'test_helper'
require 'date'
class EnigmaTest < Minitest::Test
def setup
@enigma = Enigma.new
end
def test_it_exists
assert_instance_of Enigma, @enigma
end
def test_default_date
Date.stubs(:today).returns(Date.new(2020, 04, 20))
encrypted = @enigma.encrypt("hello world", "... | true |
d2eb699362f79efd8558d638abf4a0b9ec1902d9 | Ruby | amicloud/the-odin-project | /ruby-programming/enumerables/enumerable_spec.rb | UTF-8 | 3,187 | 3.609375 | 4 | [] | no_license | require_relative 'enumerable'
describe 'my_each' do
input = [1, 2, 3, 4, 5]
it 'should produce same results as #each' do
my_result = ''
correct_result = ''
input.each {|x| correct_result << x.to_s}
input.my_each {|x| my_result << x.to_s}
expect(my_result).to eq correct_result
end
end
describ... | true |
03d2336dcd20d5b84de086a3a0932a8c9bb95c16 | Ruby | HolsDuckett/Boris_Bikes2 | /spec/docking_station_spec.rb | UTF-8 | 1,351 | 3.328125 | 3 | [] | no_license | require 'docking_station'
describe DockingStation do
it { is_expected.to respond_to(:release_bike) }
# it "should release bike" do
# DockingStation.new respond_to(release_bike)
# end
it "releases working bikes" do
bike = subject.release_bike
#creates a varaible from the return value of the method... | true |
2c63377efb629f4f375fce576934a13d3868920b | Ruby | dongraid/deployer | /deploy.rb | UTF-8 | 636 | 2.5625 | 3 | [] | no_license | require 'rubygems'
require 'redis'
require 'json'
CHANNEL = 'deploy'.freeze
ALLOWED_COMMANDS = ['deploy']
ALLOWED_PACKAGES = ['front', 'core']
$redis = Redis.new
packages = {
"front" => ['mkdir front','cd front', 'mkdir angular', 'touch readme.md', 'echo "Front" >> readme.md'],
"core" => ['mkdir core','cd core', 'm... | true |
8b29006aa1f63325ffa56292a3c9a394ded42519 | Ruby | tdeschamps/fivepoints | /app/policies/black_book_policy.rb | UTF-8 | 316 | 2.796875 | 3 | [] | no_license | class BlackBookPolicy
attr_reader :user, :black_book
def initialize(user, black_book)
@user = user
@black_book = black_book
end
def new?
user == black_book.user
end
def create?
user == black_book.user
end
def edit?
black_book.user == user
end
def update?
black_book.user == user
end
end | true |
e34f2b259d292275346a828ed148732e424318c9 | Ruby | ElenaParchevskaya/BlackJack | /game.rb | UTF-8 | 1,499 | 3.203125 | 3 | [] | no_license | class Game
STAKE = 10
attr_reader :bank, :master, :slave, :players
def initialize(name)
@slave = Player.new(name, :showed)
@master = Player.new('Крупье', :hidden)
@players = [@master, @slave]
end
def turn_new_init
@deck = Deck.new
@players.each(&:clear_hand)
2.times do
@player... | true |
a205bf1e93e26e7d2073717219bea245003bb0e7 | Ruby | crmitchelmore/briar-ios-example | /Briar/features/step_definitions/text_related.rb | UTF-8 | 5,454 | 2.5625 | 3 | [
"Beerware"
] | permissive | module Briar
module Text_Related
def swipe_on_text_field(dir, field)
if ios7? && simulator?
pending 'iOS 7 simulator detected: due to a bug in the iOS Simulator, swiping does not work'
end
tf = "#{field} tf"
wait_for_view tf, 2
swipe(dir, {:query => "textField marked:'#{tf}'"... | true |
6e4f6f848e2aa70afa1d2ae1fa23194c162eeb48 | Ruby | dhamilt18/DHCalendTest | /scenario4.rb | UTF-8 | 1,439 | 2.984375 | 3 | [] | no_license | require 'rubygems'
require 'Selenium-webdriver'
#This is 'Happy Path' scenario is for when there is an "O" 'Winner' with large table size in a diagonal
@driver = Selenium::WebDriver.for :chrome
@driver.navigate().to "https://codepen.io/CalendlyQA/full/KKPQLmV"
@driver.manage.window.maximize
#Set size of board
@tabl... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.