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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
3dd23bedd7fce560a2e0c55f7531fc2a83311bc5 | Ruby | majabu/mastermind | /mastermind.rb | UTF-8 | 2,956 | 3.5625 | 4 | [] | no_license | class Mastermind
attr_accessor :text, :input
attr_reader :rules, :start, :allowed_char, :feedback
@@count = 12
@@code = %w( R B G Y )
@@win = false
@@give_feedback = false
def initialize
@board = Board.new
@codebreaker = Player.new("Player", "codebreaker")
@codemaker = Player.new("Compute... | true |
26ca67ec1b455b36c447fb5eed77c1e6c67f3ebd | Ruby | ArunVerma/my_scripts | /array_questions.rb | UTF-8 | 1,255 | 3.953125 | 4 | [] | no_license |
### Find uniq element and number of its occurance from array
arr = [1,2,2,3,4,5,5,5,6,6,7,7]
arr_hs = {}
arr.each do |n|
nkey = n.to_s
if arr_hs.keys.include?(nkey)
arr_hs[nkey] += 1
else
arr_hs[nkey] = 1
end
end
### replace elements of the array as below
# if n % 3 == 0 -> 'Fiz'
# if n % 4 == 0 -> 'Foo'
#... | true |
2762d4994a9b96d33004b61c98133bba52f46c58 | Ruby | simsicon/leetcode | /test/cases/count_primes_test.rb | UTF-8 | 753 | 3.3125 | 3 | [] | no_license | require "minitest/autorun"
require "test_helper"
require "problems"
class TestCountPrimes < Minitest::Test
def setup
@problem = Problems::CountPrimesProblem.new
end
def test_is_prime
input = [
[2, true],
[3, true],
[5, true],
[7, true],
[97, true],
[1, false],
[... | true |
948a7f01c2926e50f6e786932e741b3ec5b636ed | Ruby | ashleynorton/nfl_standings | /lib/nfl_standings/scraper.rb | UTF-8 | 715 | 2.734375 | 3 | [
"MIT"
] | permissive | class NflStandings::Scraper
def self.get_all
doc = Nokogiri::HTML(open("https://www.foxsports.com/nfl/standings"))
index = 0
team_list = doc.css(".wisbb_fvStand .wisbb_fullTeam").each do |elem|
team = elem.css("img").attr("alt").value
result = doc.css(".wisbb_fvStand").css("td").css(".wis... | true |
5604ee4feea9cedf2c13959363d802a75af62dbb | Ruby | kindsys/woodsman | /lib/woodsman/scrubbers/generic_scrubber.rb | UTF-8 | 226 | 2.546875 | 3 | [] | no_license | module Woodsman
module Scrubbers
class GenericScrubber
attr_accessor :name, :scrub_block
def initialize(name, &scrub_block)
@name = name
@scrub_block = scrub_block
end
end
end
end | true |
9e4143734eeb05a7ef4ad9e6381df4c54c8f8f22 | Ruby | astathopoulos/adventofcode | /2017/day_3/quiz_1.rb | UTF-8 | 687 | 3.1875 | 3 | [] | no_license | input = 368078
coordinates = [0, 0]
move = :right
max_x = 0
moves = {
right: { action: ->(x, y) { [x + 1, y] }, condition: -> (x, y) { x == max_x + 1 && max_x += 1 }, next_move: :up },
up: { action: ->(x, y) { [x, y + 1] }, condition: -> (x, y) { x == y }, next_move: :left },
left: { action: ->(x, y) { [x - ... | true |
5527a35a53ea57a05806a4bd5a630602c8889e9f | Ruby | renchaorevee/Jently | /lib/helpers/config_file.rb | UTF-8 | 410 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'erb'
require 'yaml'
module ConfigFile
def ConfigFile.get_path
"#{Dir.pwd}/config/config.yaml.erb"
end
def ConfigFile.read
path = get_path
if File.exists?(path)
raw_data = IO.read path
erbified_data = ERB.new(raw_data).result
YAML.load(erbified_data) || {}
else
Lo... | true |
32ef51d16f4950c9ee8a8f9cea778c3c515ff642 | Ruby | whitered/jackal_engine | /lib/jackal_game/map.rb | UTF-8 | 1,417 | 3.15625 | 3 | [
"MIT"
] | permissive | module JackalGame
class Map
include TileConstants
def self.json_create data
new data
end
attr_reader :size
def initialize data={}
@size = data['size'] || 13
@tiles = data['tiles'] || ([0] * (@size * @size))
end
def get_outermost_location location, direction
... | true |
65e653193d3721ce10d61213f4d01fb4b23069dd | Ruby | slin12/dynamic-orm-lab-web-100817 | /lib/interactive_record.rb | UTF-8 | 1,411 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative "../config/environment.rb"
require 'active_support/inflector'
require 'pry'
class InteractiveRecord
def self.table_name
self.to_s.downcase.pluralize
end
def self.column_names #returns a list of what we need to make accessors
sql = <<-SQL
PRAGMA table_info(#{self.table_name});
... | true |
b3a265390600f0da558a237ced2dd64106381a8d | Ruby | ruby-rdf/sparql | /lib/sparql/algebra/operator/notoneof.rb | UTF-8 | 2,430 | 2.671875 | 3 | [
"Unlicense",
"LicenseRef-scancode-public-domain"
] | permissive | module SPARQL; module Algebra
class Operator
##
# The SPARQL Property Path `notoneof` (NegatedPropertySet) operator.
#
# [96] PathOneInPropertySet ::= iri | 'a' | '^' ( iri | 'a' )
#
# @example SPARQL Grammar
# PREFIX ex: <http://www.example.org/schema#>
# PREFIX in: <http://www.e... | true |
5ad2605230e337bcfe415e76751c44d659292758 | Ruby | ishouvik/practice-inmemory-cab-booking | /spec/helper/distance_spec.rb | UTF-8 | 758 | 2.953125 | 3 | [] | no_license | require 'rspec'
require 'random-location'
require_relative '../../helper/distance'
describe "Distance helper" do
let(:distance) { Distance.new }
let(:pickup_location) { RandomLocation.near_by(12.978291, 77.638594, 1000) }
let(:drop_location) { RandomLocation.near_by(12.9972469, 77.638594, 1000) }
co... | true |
bb07b0a0b6b989e1ca9aeae05d7fee693a852313 | Ruby | mzemel/iim | /spec/data_set_spec.rb | UTF-8 | 733 | 2.703125 | 3 | [
"MIT"
] | permissive | require_relative '../lib/iim/mean_generator'
require_relative '../lib/iim/data_set.rb'
require 'spec_helper'
describe IIM::DataSet do
before(:each) do
@ds = IIM::DataSet.new
@ds << 1
@ds << 2
@ds << 3
@ds << 4
end
it "has an accurate size" do
expect(@ds.size).to eq(4)
end
it "calcul... | true |
ca60066050cb404d8aa6efb6a5c3547bc8fd1e2a | Ruby | Kunal57/phase-0-tracks | /ruby/list/todo_list.rb | UTF-8 | 305 | 3.21875 | 3 | [] | no_license | # 6.6 Mandatory Pairing: Testing a Class with RSpec
class TodoList
def initialize(items)
@items = items
end
def get_items
@items
end
def add_item(item)
@items << item
end
def delete_item(item_to_delete)
@items.delete(item_to_delete)
end
def get_item(index)
@items[index]
end
end
| true |
29b247d5a6395bc3b69ad87739bc8520189f9272 | Ruby | collabnix/dockerlabs | /_site/play-with-docker/Portus/Portus.1/app/controllers/api/v2/tokens_controller.rb | UTF-8 | 4,512 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | # TokensController is used to deliver the token that the docker client should
# use in order to perform operation into the registry. This is the last step in
# the authentication process for Portus' point of view.
class Api::V2::TokensController < Api::BaseController
before_action :attempt_authentication_against_appl... | true |
cbc6bfe1843f264f2b3586a665552f00cdacb491 | Ruby | synesissoftware/xqsr3 | /test/unit/quality/tc_parameter_checking.rb | UTF-8 | 17,745 | 2.609375 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env ruby
$:.unshift File.join(File.dirname(__FILE__), '../../../..', 'lib')
require 'xqsr3/quality/parameter_checking'
require 'xqsr3/extensions/test/unit'
require 'test/unit'
class Test_check_option_multiple_option_names < Test::Unit::TestCase
include ::Xqsr3::Quality::ParameterChecking
def check_m... | true |
27a5a535ab5231e025f61fb36d9ea9c55135564b | Ruby | griffithlab/civic-server | /spec/models/chained_setter_overrides_spec.rb | UTF-8 | 1,257 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'rails_helper'
#Ex: Variant stop should both remove commas before casting
#and save empty values as null
describe 'SetterOverrideMixin' do
it 'should make whitespace or empty string NULL before saving to the db' do
variant = Fabricate(:variant)
variant.start = ""
variant.save
expect(variant... | true |
3447509c19b0596af576f8c1b95d350025b5b46b | Ruby | DChilds94/Space_Cowboy | /console.rb | UTF-8 | 677 | 2.703125 | 3 | [] | no_license | require("pry-byebug")
require_relative("../models/space_cowboys.rb")
cowboy1 = SpaceCowboy.new({
"name" => "Spike Spiegel",
"favourite_weapon" => "Jericho 941 R.",
"last_known_location" => "Titan",
"bounty_value" => 5000
})
cowboy1.save()
cowboy2 = SpaceCowboy.new({
"name" => "Jet Black",
... | true |
848e1c930c968f43b91550a1c9829abb265fe8ed | Ruby | Btate712/tasks_sinatra_web_app | /spec/controllers/tasks_controller_spec.rb | UTF-8 | 2,723 | 2.578125 | 3 | [
"MIT"
] | permissive | describe "New Task" do
before do
@boss = User.create(username: "boss", name: "boss", password: "boss")
@worker = User.create(username: "worker", name: "worker", password: "worker")
@ceo = User.create(username: "ceo", name: "ceo", password: "ceo")
@boss.subordinates << @worker
@ceo.subordinates << ... | true |
65b7b0a8e75fc61ed41576135f2dba038f4d6dde | Ruby | pushplataranjan/shoes4 | /shoes-core/spec/shoes/arc_spec.rb | UTF-8 | 8,974 | 2.703125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'spec_helper'
describe Shoes::Arc do
include_context "dsl app"
let(:parent) { app }
let(:left) { 13 }
let(:top) { 44 }
let(:width) { 200 }
let(:height) { 300 }
let(:start_angle) { 0 }
let(:end_angle) { Shoes::TWO_PI }
describe "basi... | true |
f5ce61e342077ccf7c41c614cb84faa8ace273f9 | Ruby | JDKinser/passion_project | /app/controllers/user.rb | UTF-8 | 2,238 | 2.84375 | 3 | [] | no_license | get '/users' do
@users = User.all #define instance variable for view
@hotspots = Hotspot.all
erb :'users/index' #show all users view (index)
end
get '/users/new' do
erb :'users/new' #show new users view
end
get '/users/vote' do
erb :'users/vote'
end
post '/users' do
@users = User.new(params[:user])... | true |
6f399ae9e5e3f1447822bea3e640648f1a95626c | Ruby | mindpin/pin-weibo-info-graph | /lib/weibo_api_cache_related/friends_cache.rb | UTF-8 | 2,128 | 2.515625 | 3 | [] | no_license | class FriendsCache
attr_reader :friend_weibo_users
def initialize(weibo_client, weibo_user)
@weibo_client = weibo_client
@weibo_user = weibo_user
@api_name = 'friendships/friends'
@api_params = {:uid => @weibo_user.weibo_user_id}.hash.to_s
@api_cache = WeiboApiCache.where(:api_name => @api_name,... | true |
1cb22672877926b69a81a6e58239758009e0e7bd | Ruby | jaymcgavren/rubyonacid | /examples/raw_audio.rb | UTF-8 | 723 | 2.65625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
puts "This demo writes raw 8-bit PCM data to a file. Ctrl-C to stop. Import the file to Audacity (or a similar audio editing program) to hear the results."
require 'rubyonacid/factories/example'
#This factory chooses notes, play durations, etc.
factory = RubyOnAcid::ExampleFactory.new
#Thi... | true |
6252341994d3629789369608a4783e9448a9c46b | Ruby | jcperillaj/ruby-path | /Introduction to Ruby/5-Methods and Conditionals II/statement_and_inline_modifiers.rb | UTF-8 | 181 | 3.3125 | 3 | [] | no_license | number = 5000
if number > 2500
puts "Huge number"
end
puts "Huge number!" if number > 2500
# Can be used when the expression within the body
# of the expresison is 1 line long
| true |
df1a887eabb9511fc81866684424e5d4200c7b8a | Ruby | relynch91/classwork | /Week4/W4D2/Chess/Slideable.rb | UTF-8 | 2,899 | 3.203125 | 3 | [] | no_license | require 'byebug'
module Slideable
HORIZONTAL_DIR = [
[0, 1], [0, -1], [1, 0], [-1, 0]
]
DIAGONAL_DIR = [
[1, 1], [-1, 1], [1, -1], [-1, -1]
]
def moves
all_moves = []
dirs = move_dirs(current_pos) # dirs = [[1,1],[0,1]]
dirs.each do |dir| #dirs is one move away
x0, y0 = current_... | true |
f95c515ae9755abba358db250040dc93faa52fa4 | Ruby | Mary-Castaneda/Learn_to_Program | /99bottles_words.rb | UTF-8 | 2,352 | 3.984375 | 4 | [] | no_license | def english_number number
if number == 0
return "zero"
end
if number < 0
put "Please enter a number more than 0."
end
num_string = ""
ones_place = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
teenagers = ["eleven", "twelve", "thirteen", "fourteen",... | true |
b00f18e913a798f78dfd8c27aed623e5632ed850 | Ruby | mghansen/ds | /dsi/ds_loader.rb | UTF-8 | 15,766 | 2.84375 | 3 | [] | no_license | #TODO: Loader state pre-loads values
require_relative '../dsp/ds_parser'
require_relative '../dsp/ds_elements'
require_relative 'ds_contexts'
require_relative 'ds_instructions'
$logForLoader = true
def logLoader text
puts ("L " + text) if $logForLoader
end
# LoaderState ############################################... | true |
bcc29aa8eeaaafc023449b71bfd5ee1930bb8c6d | Ruby | tsmsogn/AOJ | /Volume_001/0102_Matrix-like_Computation.rb | UTF-8 | 356 | 3.125 | 3 | [] | no_license | while n = gets.chomp.to_i
break if n == 0
a = []
n.times do
a << gets.chomp.split.map(&:to_i)
end
a.each do |i|
i << i.inject { |sum, n | sum + n }
end
a = a.transpose
a.each do |i|
i << i.inject { |sum, n | sum + n }
end
a = a.transpose
a.each do |i|
puts i.map { |item| spr... | true |
70f24d8652e0d06deb9db9d7cf3f22822e24cd17 | Ruby | kamiboers/exercism | /ruby/difference-of-squares/difference_of_squares.rb | UTF-8 | 333 | 3.3125 | 3 | [] | no_license | class Squares
VERSION = 2
def initialize(num)
@factorial = (1..num).to_a
end
def square_of_sum
(@factorial.inject(0) { |sum, number| sum + number })**2
end
def sum_of_squares
@factorial.inject(0) { |sum, number| sum + number**2 }
end
def difference
(sum_of_squares - square_of_sum).ab... | true |
0950ddc405d9d719b382fedcf5a3b3fc2652f004 | Ruby | hackervera/p2pgui | /app.rb | UTF-8 | 5,863 | 2.515625 | 3 | [] | no_license | #ShoutOut to @donpdonp for suggesting Shoes for gui
require 'rubygems'
SHOES_APP = File.expand_path(__FILE__)
require 'shoes'
require 'digest/sha1'
require 'json'
require 'socket'
class GilliesRSA
def self.mymodulus
0xcc0f26cd602216e149fe8c2b4027293cd05cd5ccb8720d48a3e50c11c4ce5402cbd3d186e05f5bf15acb078c945f3ca... | true |
90979cc308faa64d9214b8c9c708823164a20531 | Ruby | mkrahu/launchschool | /100_program_backend_prep/ruby_book/loops_iterators/perform_again.rb | UTF-8 | 116 | 3.453125 | 3 | [] | no_license | # perform_again.rb
loop do
puts "Do you want to do that again?"
again = gets.chomp
break if again != 'Y'
end | true |
a4163dc0336381e37eff0b949bd33ed3f46b7032 | Ruby | neosavvyinc/runenergy-biogasdata | /lib/modules/ajax_help.rb | UTF-8 | 172 | 2.59375 | 3 | [] | no_license | module AjaxHelp
def ajax_value_or_nil(value)
if value.nil? or value.empty? or value == 'null' or value == 'undefined'
nil
else
value
end
end
end | true |
ba0277d032f06faaf8951f4ab59f80260439b7a6 | Ruby | yukiorita1117/first-ruby | /ruby_projects/eachFor.rb | UTF-8 | 810 | 4.15625 | 4 | [] | no_license | # numbers = [1,2,3,4,5]
# # eachで取り出す
# # ||~ はjsで言う所の ()=>{}かな
# numbers.each { |number| puts number}
# # ちなみに連想配列でも変わらない
# person = {name: "yukio", age: 26}
# person.each { |key,value| puts "#{key}","#{value}" }
# # 冗長にも勿論かける
# # numbers.each do |number|
# # puts number
# # end
# puts "-----------"
# # forで取... | true |
093c57f591d146f82a979319ecb5edc16cf7c15b | Ruby | stevesaf/hair-salon | /lib/client.rb | UTF-8 | 1,262 | 3.140625 | 3 | [] | no_license | class Client
attr_reader(:name, :stylist_id) #in the scope of this project, a client only must appear under a stylist-- not have a profile. So, we will input a name and match them with a stylist's id.
define_method(:initialize) do |attributes|
@name = attributes.fetch(:name)
@stylist_id = attributes[:styl... | true |
0e00c84890eb447fbd03b625c9ab89b891a96387 | Ruby | gitluky/rails-refactoring-apis-v-000 | /app/services/github_service.rb | UTF-8 | 1,220 | 2.84375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class GithubService
attr_accessor :access_token
def initialize(hash={})
if hash.is_a?(Hash)
hash.each do |k,v|
self.send("#{k}=", v) unless hash.empty?
end
else
@access_token = hash
end
end
def authenticate!(client_id, client_secret, code)
response = Faraday.post "ht... | true |
8ccfd8aa9af81d64ee9ede771c1dcd6849c10701 | Ruby | thatrubylove/pong | /lib/pong/ball.rb | UTF-8 | 2,109 | 3.09375 | 3 | [
"MIT"
] | permissive | module Pong
class Ball
SIZE = 16
TOP = 100
BLIP1 = Gosu::Sample.new(File.expand_path("../../../media/blip1.wav", __FILE__))
BLIP2 = Gosu::Sample.new(File.expand_path("../../../media/blip2.wav", __FILE__))
attr_reader :x, :y, :angle, :speed
def initialize
@x = Court::WIDTH... | true |
0f692676e1618fbb27a515b5060df7fefab56e65 | Ruby | NikonIt/dex-oracle | /lib/dex-oracle/utility.rb | UTF-8 | 857 | 2.953125 | 3 | [
"MIT"
] | permissive | require 'zip'
class Utility
def self.which(cmd)
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
exts.each do |ext|
exe = File.join(path, "#{cmd}#{ext}")
return exe if File.executable?(exe) && !File.directory?(exe)
end... | true |
ee909a777e9340c894659697403df13b91db8c46 | Ruby | kz363/p0_unit1_submission | /1_calculate_array_total/my_solution.rb | UTF-8 | 1,936 | 4.65625 | 5 | [] | no_license | # U1.W3: Add it up!
# 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 in the file.
# I worked on this challenge by myself.
# 1. Pseudocode
# What is the input?
# What is the output? (i.e. What should the code r... | true |
4d1c8a481ac9233811cb5e8b722c9a1634a3bbe2 | Ruby | mdkent/scamp-campfire | /lib/scamp-campfire/channel.rb | UTF-8 | 670 | 2.703125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Scamp
module Campfire
class Channel
attr_reader :adapter, :message
def initialize adapter, msg
@adapter = adapter
@message = msg
end
def say msg
message.room.speak msg
end
def reply msg
message.room.speak "#{message.user.name}: #{msg}"
... | true |
ab7b3f98e3fa8a2261a3e4a2acc16b7e997671bf | Ruby | beck03076/happy_shop | /lib/core_ext/string.rb | UTF-8 | 169 | 3.40625 | 3 | [] | no_license | # opening the numberic standard class to add 1 method
class String
# convert to float and multiply by 100
def to_cents
(self.to_f * 100).round(2).to_i
end
end
| true |
315d46645fa3bb48aebc29358247908d4e37cc29 | Ruby | sakushin774/sakushin774.github.io | /puzzle/enzan.rb | UTF-8 | 829 | 3.609375 | 4 | [] | no_license | #4桁の自然数を逆順にして演算子で繋いだ結果が元の数と一致する数を求める
opArray = ["+", "-", "*", "/", ""]
for num in 1000..9999 do
str = num.to_s
for op1 in 0..4 do
for op2 in 0..4 do
for op3 in 0..4 do
val = str[3] + opArray[op3] + str[2] + opArray[op2] + str[1] + opArray[op1] + str[0]
#rubyでは0から始まる数は八進数として扱われるので飛ばす
... | true |
65486a0ffc3c0b4744ffb21b8423a9323add5fb1 | Ruby | douglas-rice/ruby_foundations | /lesson_3/medium_1/question_7.rb | UTF-8 | 932 | 4.3125 | 4 | [] | no_license | # Alyssa asked Ben to write up a basic implementation of a Fibonacci
# calculator, A user passes in two numbers, and the calculator will
# keep computing the sequence until some limit is reached.
# Ben coded up this implementation but complained that as soon as he
# ran it, he got an error. Something about the limi... | true |
e8e6558e6f8aadec49d663e60d17d648c4faf96e | Ruby | LUKERHYS/bear_river_fish_hw | /specs/bear_spec.rb | UTF-8 | 859 | 2.890625 | 3 | [] | no_license | require("minitest/autorun")
require("minitest/reporters")
MiniTest::Reporters.use! MiniTest::Reporters::SpecReporter.new
require_relative("../bear")
require_relative("../river")
require_relative("../fish")
class TestBear < MiniTest::Test
def setup
@bear1 = Bear.new("Yogi", "Grizzly")
@river1 = River.new(... | true |
fec2ff0cc39536f55c25157d87577116fdd518e5 | Ruby | vtboyarc/ruby-katas | /Day1/spec/calculator_spec.rb | UTF-8 | 876 | 3.28125 | 3 | [] | no_license | require "spec_helper"
#keep getting this error in terminal when running rspec: uninitialized constant Calculator (NameError)
describe Calculator do
it "takes an empty string" do
expect(Calculator.add(" ")).to eq(0)
end
it "takes one number" do
expect(Calculator.add("8")).to eq("8")
end
it "adds... | true |
4a2e54122363d7b04c88b01883b0fc858c05342f | Ruby | voltagead/OpenSplitTime | /app/helpers/split_times_helper.rb | UTF-8 | 1,383 | 2.59375 | 3 | [
"MIT"
] | permissive | module SplitTimesHelper
def composite_time(lap_split_row)
time_array = []
(0...lap_split_row.times_from_start.size).each do |i|
time = lap_split_row.times_from_start[i]
data_status = lap_split_row.time_data_statuses[i]
if time
element = case data_status
when 'bad... | true |
ff2b402c8785b10fd4d85cb55dbb665a32469d61 | Ruby | risgk/learning_tapl_ocaml | /simplebool_with_case_class.rb | UTF-8 | 5,357 | 2.984375 | 3 | [] | no_license | # Modifying http://www.cis.upenn.edu/~bcpierce/tapl/checkers/simplebool/ for learning TAPL.
# TYPES AND PROGRAMMING LANGUAGES by Benjamin C. Pierce Copyright (c)2002 Benjamin C. Pierce
# $ gem install case_class
# ref: http://github.com/mame/case_class
require "case_class"
# CAUTION: Monkey patching!
module CaseClass
... | true |
d40d708a5cfda1cfcc32981fbab145dc6e6d08d4 | Ruby | Fahad-Hafeez/Ruby-Project---Tutorial | /tutorial files/readingfiles.rb | UTF-8 | 472 | 3.796875 | 4 | [
"MIT"
] | permissive |
# to open file (if in another directory add full path in brackets), example below
File.open("arrays.rb", "r") do |file|
# then add puts and file in a line to print whatever is in the file
puts file
# then to read file
puts file.read()
# to check if sumthing is in the file or not
puts file.read().include?... | true |
b3649104b0e87853141770b8aab2469fc4769dcf | Ruby | CodingSoeren/client-ruby | /lib/software_challenge_client/player.rb | UTF-8 | 757 | 3.5 | 4 | [] | no_license | # encoding: UTF-8
# frozen_string_literal: true
# Ein Spieler
class Player
# @!attribute [r] name
# @return [String] der Name des Spielers, hat keine Auswirkungen auf das Spiel
attr_reader :name
# @!attribute [r] color
# @return [Color] erster (Color::RED) oder zweiter (Color::BLUE) Spieler
attr_reader :c... | true |
d63b4282931ded1325d55f005200d161d58cf048 | Ruby | thomas-yancey/phase-0 | /week-4/errors.rb | UTF-8 | 7,599 | 4.5625 | 5 | [
"MIT"
] | permissive | # Analyze the Errors
# I worked on this challenge by myself
# I spent [#] hours on this challenge.
# --- error -------------------------------------------------------
cartmans_phrase = "Screw you guys " + "I'm going home."
# This error was analyzed in the README file.
# --- error -----------------------------------... | true |
dd5ccae027462137afb7cf80b313b86d4592323d | Ruby | jonasacres/talk | /lib/contexts/enumeration.rb | UTF-8 | 554 | 2.5625 | 3 | [] | no_license | register :enumerations, :delimiter => '.'
property :name
tag_description
tag :constant, :multi => true, :unique => :name
tag :extra, :multi => true, :unique => :name
tag_end
postprocess lambda { |ctx|
# If we don't specify a constant value, use C-like implicit values
# (i.e. constant[n] = {
# constant[n-1] + 1... | true |
d039e60d67c2ef29a958498f0ef1948bb5f0dbbe | Ruby | sjlee3157/slack-cli | /lib/slack.rb | UTF-8 | 1,063 | 3 | 3 | [] | no_license | #!/usr/bin/env ruby
# Use the dotenv gem to load environment variables
# Use HTTParty to send a GET request to the channels.list endpoint
# Check that the request completed successfully, and print relevant information to the console if it didn't
# Loop through the results and print out the name of each channel
requir... | true |
9e2eba69abd1e4c4a3fd8582510dc7c69ddb3b63 | Ruby | William46503/Ruby-Substring | /Substring.rb | UTF-8 | 943 | 3.984375 | 4 | [] | no_license | dictionary = ["below","down","go","going","horn","how","howdy","it","i","low","own","part","partner","sit"]
def substring_search(keyword, wordlist)
#Split and downcase the keyword/sentence and place them into an array
search_word_list = keyword.downcase.split(" ")
#Create a new hash for pushing wor... | true |
6ec4ecec59e0cacf0dcd05f4cbc4cb392da29f0a | Ruby | TheLastSultan/Spectacular | /app/views/api/cart/index.json.jbuilder | UTF-8 | 301 | 2.515625 | 3 | [] | no_license |
@cartitems.each do |spectacle|
json.set! spectacle.id do
json.extract! spectacle, :title, :id , :fit, :price, :material
json.image_url image_path(spectacle.id.to_s + ".jpeg")
end
end
json.cart_count @cartitems.length
json.price_total @cartitems.map{|item| item.price}.sum
| true |
1759b06d6d63287fdca88f3e3ee38a226864fa40 | Ruby | mnhollandplum/little_shop_v2 | /app/models/item.rb | UTF-8 | 596 | 2.578125 | 3 | [] | no_license | class Item < ApplicationRecord
belongs_to :user
has_many :order_items
has_many :orders, through: :order_items
validates_presence_of :name, :price, :inventory, :description
validates_numericality_of :price, :greater_than => 0
validates_numericality_of :inventory, :greater_than => 0
def toggl... | true |
b0e958c6c9d7d387eb187fd5ec7a1bed643b7677 | Ruby | hwchan59/learn_ruby | /Section 5 Methods and Conditionals I/69_The_Tenary_Operator.rb | UTF-8 | 317 | 4.25 | 4 | [] | no_license | puts 1<2 ? "Yes, it is!" : "No, it's not!"
puts
puts "yes"=="no" ? "The two are equal" : "The two are not equal"
puts
def even_or_odd(number)
number.even? ? "That number is even" : "That number is odd"
end
puts even_or_odd(5)
pokemon = "Pikachu"
puts pokemon=="Charizard" ? "Fireball!" : "That is not Charizard"
| true |
b9e9862169bf42874d6497499adb49dd0902b6aa | Ruby | App-Academy-Projects/Ruby-Practice | /Data Structure/Hashes/0047.hand_score.rb | UTF-8 | 455 | 4.3125 | 4 | [] | no_license | # You can assume the letters in the string are only A, K, Q, J.
# A is worth 4 points,
# K is 3 points,
# Q is 2 points, and
# J is 1 point.
# The letters of the input string not necessarily uppercase.
def hand_score(hand)
scores = {
"A"=>4,
"K"=>3,
"Q"=>2,
"J"=>1
}
c = 0
h... | true |
e4c401ba2411374893339926480c157193bf7474 | Ruby | benjithaimmortal/Stack_a_Rack | /config.ru | UTF-8 | 1,802 | 3.265625 | 3 | [] | no_license | require 'rack/mime'
# This is where we figure out available routes and point appropriate things at them
module Router
def get(path)
# Make a root directory at path...
root = File.expand_path(File.dirname(__FILE__))
root_path = root + "/public" + path
# List some common routes...
available ... | true |
58f9702f23191c388bdb89681fbcbeb9577eedb4 | Ruby | ElizabethU/Space-Data-Conversion | /json_conversion.rb | UTF-8 | 596 | 3.078125 | 3 | [] | no_license | require 'json'
def make_arrays(datafile)
output = []
input = File.read(datafile).split("\n")
input.each do |line|
output << line.split
end
output
end
def make_hash(satellite_name, datafile, outputfile)
hash = {name: satellite_name, years: {} }
make_arrays('planetdata.txt').each do |line|
unless ... | true |
780a47cdeb30ef9e4e9927a9799cbca118b469b9 | Ruby | ruby-syntax-tree/syntax_tree | /lib/syntax_tree/with_scope.rb | UTF-8 | 8,683 | 3.0625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module SyntaxTree
# WithScope is a module intended to be included in classes inheriting from
# Visitor. The module overrides a few visit methods to automatically keep
# track of local variables and arguments defined in the current scope.
# Example usage:
#
# class MyVisito... | true |
b149dcfe6f70c86cd29012e91ae27d21423281ec | Ruby | miguelgf/oss-dashboard | /db/queries/db-cli-reportrunner.rb | UTF-8 | 1,666 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby
# Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# 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... | true |
697329938bf932bff455ce927463ccefedf18841 | Ruby | Lisa-Caton/sep-assignments | /02-algorithms/02-algorithms-searching/binary_search_recursive.rb | UTF-8 | 967 | 3.953125 | 4 | [] | no_license | def recursive_binary_searcher(array, item)
if array.include?(item)
mid_point = (array.length) / 2
if array[mid_point] == item
puts "#{item} found"
elsif array[mid_point] < item
new_array = array[mid_point..(array.length)].map{|x| x}
recursive_binary_searcher(new_array,item)
elsif arr... | true |
691ce2239ef7e2c1a7817448268a65e1d2420ca5 | Ruby | kcht/bnk | /app/helpers/program_reader_adapter.rb | UTF-8 | 1,139 | 3.46875 | 3 | [] | no_license | class ProgramReaderAdapter
include SongAdapter
attr_accessor :contents, :number, :title, :date, :description, :songs
def initialize(filename)
@contents = File.read(filename)
parse_contents(@contents)
end
private
def parse_contents(contents)
lines = @contents.split("\n")
@number, @title = number_title... | true |
fb66c2b76e147a8967912fb3eb419ed1f5cce6c0 | Ruby | vanrails/Learn-To-Program | /chapter14/betterLogger14-4.rb | UTF-8 | 528 | 3.484375 | 3 | [] | no_license | # 14.4 Program logger
# page 120
$log_depth = 0
def log log_description, &block
indent = ' '*$log_depth
puts indent + "Starting '#{log_description}'"
$log_depth += 1
result = block.call
$log_depth -= 1
puts indent + "'#{log_description}' finished result: #{result}"
end
log 'shell block' do
lo... | true |
8d0b9c8adf3a982d24c7864d609517d7b7a4bca3 | Ruby | jpkalbacher/poker | /spec/card_spec.rb | UTF-8 | 1,245 | 3.4375 | 3 | [] | no_license | require 'card'
describe Card do
subject(:example_card) { Card.new(:clubs, :four) }
describe '#initialize' do
it 'can be initialized with a value and suit' do
expect(example_card.suit).to eql(:clubs)
expect(example_card.value).to eql(:four)
end
end
describe '.suits' do
it 'should retu... | true |
26233677de0d843638576840f0361044699ee8d2 | Ruby | rohusemer/CapacitacionRuby | /capacitacion.rb | UTF-8 | 501 | 3.9375 | 4 | [] | no_license | puts "hola mundo"
puts
valor = 10
#Bloque if primer metodo
if valor == 25
puts "es igual"
else
puts "#{valor+15}"
end
puts
#sentencia if segundo metodo
puts valor==20?"es igual":"#{valor+20}"
puts
#sentencias switch-case
case valor
when 10
puts "muy bien"
end
puts
#arreglos
arreglo = ['hola', 20.5, [15,... | true |
7eeaa67e06fe28361aa1bc5c5e2e7f0e85a1195f | Ruby | canwaykalburim/MillionDreams | /GuGuDan2.rb | UTF-8 | 81 | 3.078125 | 3 | [] | no_license | def timeTable(gugu)
for i in 1..9
puts "#{gugu} * #{i} = #{gugu * i}"
end
end | true |
3c6277a24bb2060f27fd1043110b580f4e1597f5 | Ruby | nickoless/ar-exercises | /exercises/exercise_6.rb | UTF-8 | 758 | 2.953125 | 3 | [] | no_license | require_relative '../setup'
require_relative './exercise_1'
require_relative './exercise_2'
require_relative './exercise_3'
require_relative './exercise_4'
require_relative './exercise_5'
puts "Exercise 6"
puts "----------"
# Your code goes here ...
@store1.employees.create(first_name: "Kendrick", last_name: "Lamar"... | true |
ac9bee67615be51ee923584526f7a1b22e129642 | Ruby | tshelburne/leonidas-rb | /lib/leonidas/commands/command.rb | UTF-8 | 805 | 2.75 | 3 | [
"MIT"
] | permissive | module Leonidas
module Commands
class Command
attr_reader :id, :name, :data, :client_id, :timestamp
def initialize(id, name, data, client_id, timestamp)
@id = id
@name = name
@data = data
@client_id = client_id
@timestamp = timestamp
@has_run = false
@has_been_persisted = fals... | true |
7acf1dfd8020ac5361fa461168806213dfd0f61f | Ruby | vidhichander/ActionMap | /lib/task_helpers/topojson_task_helper.rb | UTF-8 | 2,282 | 2.609375 | 3 | [] | no_license | # frozen_string_literal: true
require 'csv'
require 'fileutils'
require 'open-uri'
require 'zip'
require_relative 'task_helper'
module TopojsonTaskHelper
MAPSHAPER = 'node_modules/.bin/mapshaper'
def self.output_file_for(request, output_format)
Rails.root.join({
'geojson': request.geojs... | true |
190b1ed960036e014c437c27676df614c0e9fd8b | Ruby | aussio/Journey-to-Dev | /learnrubythehardway/test_ex47-Room.rb | UTF-8 | 930 | 3.171875 | 3 | [] | no_license | require "./ex47-Room.rb"
require "minitest/autorun"
class TestGame < MiniTest::Unit::TestCase
def setup
@room = Room.new("Gold Room",
"""This room has gold within it!
You can grab the gold if you dare...
and there's a door to the Nor... | true |
19e597f95e08ecbb0df68926ef2975153db5f8d8 | Ruby | piyushawasthi/url_shortner_api | /test/models/user_test.rb | UTF-8 | 1,520 | 2.640625 | 3 | [] | no_license | require 'test_helper'
class UserTest < ActiveSupport::TestCase
test "should check whether email, name and password empty fields will throw error" do
user = User.new()
assert user.invalid?
assert user.errors[:email].any?
assert user.errors[:name].any?
assert user.errors[:password... | true |
0e74b7f6620d5d187e1f116b66e6ff73b6db147b | Ruby | amolborcar/phase_0_unit_2 | /week_6/5_refactoring/my_solution.rb | UTF-8 | 2,193 | 3.9375 | 4 | [] | no_license | # U2.W6: Refactoring for Code Readability
# I worked on this challenge with:
1. Amol Borcar
2. Alec Ashford
# Original Solution
class CreditCard
def initialize(card_number)
@card_number = card_number.to_s.split("")
raise ArgumentError.new("Must be exactly 16 digits!") if @card_number.length != 16
end
de... | true |
44dc100cb8216f0935c67c2e23721c7d8e045df1 | Ruby | BaltimorePublicArtCommons/baltimore_public_art_commons | /app/models/artist_public_data.rb | UTF-8 | 992 | 2.53125 | 3 | [] | no_license | class ArtistPublicData
def initialize(artist)
@artist = artist
end
def name(context)
name = "#{@artist.first_name} #{@artist.last_name}".strip if @artist.first_name
name ||= @artist.last_name || "Anonymous"
if context == :index && name.length > 30
name[0..30] + '...'
else
name
... | true |
ab99290bf16121a2f9c2a3a2f344019f7ce1a8cb | Ruby | radiospiel/vex | /lib/vex/active_record/serialize_hash.rb | UTF-8 | 3,044 | 2.6875 | 3 | [] | no_license | __END__
module ActiveRecord::SerializeHash
def self.included(base)
base.extend ClassMethods
base.alias_method_chain :reload, :serialize_hash
base.before_update :update_serialize_hashes
end
def self.jsonize(data)
return nil if data.nil?
return data.to_json unless data.is_a?(Hash)
"{" + d... | true |
4baf979b14f176a10acd48718362636b114b5234 | Ruby | AlexanderHenry/rubyPractice | /madLib.rb | UTF-8 | 533 | 3.203125 | 3 | [] | no_license | def madLib
puts "Provide three nouns separated commas"
nouns = gets.split(",")
puts "Provide three verbs separated by commas"
verbs = gets.split(",")
puts "Provide three adjectives separated by commas"
adjectives = gets.split(",")
puts "Provide two adverbs separated by commas"
adverbs = gets.split(",")
put... | true |
d2c6e1ac5e2b54b622d8da50f84fb407cad986c3 | Ruby | ChloeStinetorf/WDI3-Sinatra | /2013-02-06-movies/main.rb | UTF-8 | 917 | 2.515625 | 3 | [] | no_license | require 'pry'
require 'sinatra'
require 'sinatra/reloader' if development?
require 'HTTParty'
require 'json'
require 'pg'
get '/' do
erb :home
end
get '/movies' do
sql = 'select poster from movies;'
conn = PG.connect(:dbname =>'movie_app', :host => 'localhost')
@rows = conn.exec(sql)
conn.close
erb :pos... | true |
a297fe6d9a4e6fa4681e9ff399ac1c78607a22e2 | Ruby | kbsecret/kbsecret | /test/test_generators.rb | UTF-8 | 4,977 | 2.796875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative "helpers"
require "base64"
# Tests for KBSecret::Generator functionality
class KBSecretGeneratorsTest < Minitest::Test
include Helpers
def test_generators_list
# generator_labels should always be an Array
assert_instance_of Array, KBSecret::Config.generator... | true |
64958511402dbb6c32c79eb6dfa6247de3e93bb3 | Ruby | Beiancaa/hw10_1 | /1.ruby | UTF-8 | 171 | 2.875 | 3 | [] | no_license | a = ['john', 'mike', 'susan', 'matt', 'joe', 'larry', 'ken', 'samantha', 'jenny', 'Sara', 'henry'];
for i in 0..(a.length - 1) do
if i += 2
puts a[i].upcase
end
end | true |
6df4f8197776523015c3346cba7db8f657e0aa05 | Ruby | nkizito92/programming-univbasics-4-intro-to-hashes-lab-online-web-prework | /intro_to_ruby_hashes_lab.rb | UTF-8 | 453 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def new_hash
hash = {}
end
def my_hash
hash = {:blue => "car",
:red => "truck"
}
end
def pioneer
hash = { :name => "Grace Hopper"}
end
def id_generator
hash = {:id => 1}
end
def my_hash_creator(key, value)
p hash = { key => value }
end
def read_from_hash(hash, key)
... | true |
fbd04cdd0f37fcba0a0a1effadcd978d9fc47d7a | Ruby | mwagner19446/wdi_work | /w03/d03/Michael/bottle/spec/bottle_spec.rb | UTF-8 | 1,007 | 3.640625 | 4 | [] | no_license | require 'rspec'
require_relative "../lib/bottle.rb"
# You can drink from it and get water back unless the bottle is empty.
# Drinking from the bottle empties it.
describe Bottle do
context "It starts empty"do
let(:bottle) {Bottle.new}
it "bottle is created" do
expect(bottle.fill?).to be_false
... | true |
385d4d7331d89f19eb37555e47be6b1f8fafd645 | Ruby | tuckerd/codefellows_bacon_testing | /lib/bacon.rb | UTF-8 | 223 | 2.734375 | 3 | [] | no_license | class Bacon
attr_accessor :expired
def edible?
!expired
end
def expired!
@expired = true
#could also do self.expired = true
end
#class methods called by Bacon.yummy
def self.yummy?
true
end
end | true |
e6c745c275923df0b962c07dbd628eee307d1cdc | Ruby | kenchan/competitive_programming | /atcoder/abc187/c.rb | UTF-8 | 320 | 3.453125 | 3 | [] | no_license | require 'set'
N = gets.to_i
S = N.times.map { gets.chomp }
strings = Set.new
ans = S.detect {|s|
includes = s.start_with?('!') ? strings.include?(s.delete('!')) : strings.include?("!#{s}")
if includes
true
else
strings << s
false
end
}
if ans
puts ans.delete('!')
else
puts 'satisfiable'
end
| true |
8fc9b3027067f742649d2b5ee64561673f3c167b | Ruby | rogueminx/Contacts | /spec/contact_spec.rb | UTF-8 | 3,689 | 2.859375 | 3 | [] | no_license | require('rspec')
require('pry')
require('contact')
describe("Contacts")do
describe(".all") do
it("is empty at first") do
expect(Contacts.all()).to(eq([]))
end
end
describe("#save") do
it("saves a new instance of contact") do
contact = Contacts.new({:first_name=> "Anna Marie", :last_nam... | true |
bc72a47f69719ac141ce211c2d1225522fc75932 | Ruby | moroshko/connect4 | /build_game_result_8.rb | UTF-8 | 880 | 2.921875 | 3 | [] | no_license | require './connect4'
c4 = Connect4.new
my_boards = File.open('database/positions/8moves.txt').readlines.map(&:chomp)
john_results = File.open('database/8moves.txt').readlines.map(&:chomp)
john_boards = {}
john_results.each do |john_result|
john_boards[john_result[0..41]] = john_result[42]
end
result = []
my_boa... | true |
f8f7c718ec1049709e5511de2979859b58b49cab | Ruby | jonzingale/Ruby | /elo/elo_is_more_real.rb | UTF-8 | 2,673 | 3.4375 | 3 | [] | no_license | # This update can be performed after each game or each tournament,
# or after any suitable rating period. An example may help clarify.
# Suppose Player A has a rating of 1613, and plays in a five-round tournament.
# 1. He or she loses to a player rated 1609,
# 2. draws with a player rated 1477,
# 3. defeats a player ra... | true |
bab1939c1e75b64c0cd5ef4868c96b85b54746bb | Ruby | OsamaOmar322/ReCode-Ruby-Projects | /exercise_63.rb | UTF-8 | 554 | 4.59375 | 5 | [] | no_license | # Palindrome: Recursion
# Write a method, is_palindrome?, that accepts a number
# The method should use recursion to check if a number provided is a palindrome
# The method should return true or false
# You can create additional nested methods
def is_palindrome?(n)
n = n.to_s
if n.length == 1 or n.length =... | true |
45a35dee64908ef3df183a7dd81bff7922473fcf | Ruby | sigmaray/rails-rss-reader | /app/lib/reverse_pagination.rb | UTF-8 | 1,290 | 2.828125 | 3 | [] | no_license | # https://medium.com/@Flyr1Q/rails-reverse-pagination-from-scratch-74346c9ab556
class ReversePagination
attr_reader :page, :per_page, :total_count, :total_pages, :records, :scope
def initialize(scope, page, per_page)
@scope = scope
initialize_params(scope.klass, page, per_page)
# @records = scope.lim... | true |
17e431e1b49382952b08d74fe276527cc6c550fe | Ruby | rainflush7707/Mashiro-exploration-translation | /output/Mashiro-exploration/DataExtracted/scripts/Script005_tran.rb | UTF-8 | 4,038 | 3.03125 | 3 | [] | no_license | #==============================================================================
# ■ Cache
#------------------------------------------------------------------------------
# 各種グラフィックを読み込み、Bitmap オブジェクトを作成、保持するモジュール
# です。読み込みの高速化とメモリ節約のため、作成した Bitmap オブジェクトを内部
# のハッシュに保存し、同じビットマップが再度要求されたときに既存のオブジェクト
# を返すようになっています。
#===... | true |
43ae09a3ed331afc3a15d86d09340e5be2306403 | Ruby | yanyujason/Hotel | /src/lib/ridgewood_reservation.rb | UTF-8 | 209 | 2.515625 | 3 | [] | no_license | class RidgewoodReservation < Reservation
def initialize
@weekday_regular = 220
@weekday_rewards = 100
@weekend_regular = 150
@weekend_rewards = 40
end
def name
'Ridgewood'
end
end | true |
f9922eae27e56d1ecbe424c86195809d65c79d59 | Ruby | romkenet/puppet-functions | /cronrand.rb | UTF-8 | 936 | 2.53125 | 3 | [] | no_license | # vim: set ts=2 sw=2 et :
# TODO: path should not be hardcoded here
#
# USAGE:
# $minutes = cronrand("puppet-run", $fqdn, 59)
# file { "puppet-cron":
# name => /etc/cron.d/puppet-run",
# content => "$minutes * * * * root /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog > /dev/null 2>&1\n"
# }
# ---
# min... | true |
062a8d9c8303fa8151f6b78148b8c2e2cc737f70 | Ruby | takahashim/notwork-org-ipr | /1st/httpget.rb | UTF-8 | 249 | 2.703125 | 3 | [] | no_license | require 'socket'
host, port, path = "localhost", 80, "/"
if %r!http://(.*?)(?::(\d+))?(/.*)! =~ ARGV[0]
host = $1
port = $2.to_i if $2
path = $3
end
s = TCPSocket.new(host, port)
s.print "GET #{path} HTTP/1.0\r\n\r\n"
print s.read
s.close
| true |
671f0f325cfc49ab067d682e89ee270695acb42a | Ruby | trajing/compose-everything | /lib/composeeverything/refinements.rb | UTF-8 | 1,372 | 2.59375 | 3 | [
"MIT"
] | permissive | module ComposeEverything
# Adds to Hash
module HashRefine
refine Hash do
include ComposeEverything::FunctionalGoodies
end
end
# Adds to Array
module ArrayRefine
refine Array do
include ComposeEverything::FunctionalGoodies
end
end
# Adds to Proc
module ProcRefine
refine ... | true |
bb04a24800ea5370d74321e45e8422f21c831816 | Ruby | cldambrosio/fib-and-test | /spec/fib_spec.rb | UTF-8 | 517 | 2.578125 | 3 | [] | no_license | require 'spec_helper'
RSpec.describe Fib, type: :model do
describe 'fibR should work' do
it 'should return the nth digit of the Fibonacci sequence' do
expect(Fib.fibR(0)).to eq 0
expect(Fib.fibR(1)).to eq 1
expect(Fib.fibR(9)).to eq 34
end
end
describe 'fibI should work' do
... | true |
d87c72ed1c2ba7f4fe9131be1bfac1537f423039 | Ruby | binaryrain01/coderbyte | /01-10/LetterChanges.rb | UTF-8 | 144 | 3.25 | 3 | [] | no_license | def LetterChanges(str)
return str.gsub(/[a-zA-Z]/) { |w| w.next }.gsub(/[aeiou]/) { |v| v.upcase }
end
LetterChanges(STDIN.gets)
| true |
39cc6571adca6cfe8690ebbda5310ab294f4f1ff | Ruby | gtoroap/tax_calculator | /tax_handler.rb | UTF-8 | 737 | 3.265625 | 3 | [] | no_license | class TaxHandler
NOT_TAXABLE = /book|chocolate|apple|banana|pill|syringe|gloves/
def initialize(items)
@items = items
end
def classify
return unless @items
@items.each do |item|
item.tax = 0.10 unless NOT_TAXABLE =~ item.description
item.tax = (item.tax + 0.05).truncate(2) if item.imp... | true |
6ff5a1105b944cc387b127fb7a54ba400442a4ed | Ruby | martin6724/flamingo_game | /flamingoking.rb | UTF-8 | 1,449 | 3.25 | 3 | [] | no_license | require 'gosu'
require './flamingoplayer.rb'
class GameWindow < Gosu::Window
def initialize
super 800, 480
self.caption = "Flamingo Game"
@background_image = Gosu::Image.new("./flamingobackground.jpg")
@music = Gosu::Song.new("./gamemusic.mp3")
@player = Player.new
@player.warp(320, 240)
e... | true |
787312a92fde0f62ca5b859821bc1295a2233b2a | Ruby | AddisonDean/PuttPutt | /main_game.rb | UTF-8 | 1,962 | 3.03125 | 3 | [
"MIT"
] | permissive | # Require GOSU, Margo
require 'gosu'
require 'margo'
# Require Levels
require_relative 'levels/level'
require_relative 'levels/levels'
# Require Objects
require_relative 'objects/ball'
require_relative 'objects/arrow'
require_relative 'objects/hole'
require_relative 'objects/gauge'
require_relative 'objects/windmill'
r... | true |
b3823dbdf3d01147efd0a397ca5880a78e944996 | Ruby | brady-robinson/Object-Oriented-Programming | /lesson_4/practice_easy_1/10.rb | UTF-8 | 144 | 2.796875 | 3 | [] | no_license | class Bag
def initialize(color, material)
@color = color
@material = material
end
end
blue_plastic_bag = Bag.new("blue", "plastic") | true |
7ccf9491ad2d55f7263ba23d810d248016a6199c | Ruby | neha9t/launch | /backend-prep/01_introduction_to_programming/03_methods.rb | UTF-8 | 2,442 | 4.53125 | 5 | [] | no_license | # say.rb
puts "hello"
puts "hi"
puts "how are you"
puts "I am fine"
def say(words="hello")
puts words + "."
end
say("hi")
say("hello")
say("how are you")
say("I am fine")
def method_name(number)
number = 7
end
a = 5
method_name(a)
puts a
# Example of a method that modifies its argument permanently
# mutate.... | true |
5fe4388a8c06b945397efc8f1b43a7f69623b345 | Ruby | raybaxter/googledata | /lib/atom/element.rb | UTF-8 | 4,507 | 2.53125 | 3 | [] | no_license | module Atom
NAMESPACES = %w[ atom:http://www.w3.org/2005/Atom ]
class Element < LibXML::XML::Node
include LibXML
ELEMENT_DEFAULTS = { :type => :simple, :xpath => "//atom:$CONTAINER$/atom:$KEY$" }
ELEMENTS = {
:atom_id => { :xpath => '//atom:$CONTAINER$/atom:id' },
:... | true |
087c88310d3c3b5df10939da47232f3ae76895cc | Ruby | AlexDev404/adaptive_cards | /lib/adaptive_cards/adaptive_card.rb | UTF-8 | 2,352 | 2.78125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module AdaptiveCards
# An [Adaptive Card](https://docs.microsoft.com/en-us/adaptive-cards/)
# for sending to an Adaptive Card renderer (e.g. Teams)
class AdaptiveCard < Base
option :select_action, required_type: AdaptiveCards::Action::Base,
excluded_ty... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.