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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
7d27b60747356cef920b5ec542d1b810104e1572 | Ruby | emiliano1987/aydoo2016-tpfinal | /model/nave.rb | UTF-8 | 780 | 2.8125 | 3 | [] | no_license | require_relative '../model/objeto_espacial'
require_relative '../model/efecto_constructivo'
require_relative '../model/efecto_destructivo_unidades'
require_relative '../model/efecto_masa_disminuye_porcentaje'
class Nave < ObjetoEspacial
def initialize (*argumento)
super(*argumento)
generar_efectos_segun_obj... | true |
3a7f7103b4cb014430bca00270c9e901c9c3e0a8 | Ruby | jdleesmiller/twenty48 | /bin/thin | UTF-8 | 2,682 | 2.71875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# frozen_string_literal: true
require_relative '../lib/twenty48'
include Twenty48
include Twenty48::ActionDeduplication
puts %w[
board_size max_exponent resolve_strategy_name max_resolve_depth
total_actions total_deduplicated_actions
num_single_action_states
num_single_successor_actions
]... | true |
4e8d1d1360f7722ce76ab74b04642d070f74a573 | Ruby | serendipitist/bootcamp-geometry-problem | /lib/geometry/point.rb | UTF-8 | 273 | 2.890625 | 3 | [
"MIT"
] | permissive | class Geometry::Point
attr_reader :abscissa, :ordinate
def initialize(abscissa, ordinate)
@abscissa = abscissa
@ordinate = ordinate
end
def distance(other)
Math.sqrt((self.abscissa - other.abscissa)**2 + (self.ordinate - other.ordinate)**2)
end
end | true |
333654820590ff1b879482752467309763762b14 | Ruby | jaymcaliley/yettings | /test_app/spec/yettings_spec.rb | UTF-8 | 3,000 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'spec_helper'
describe Yettings do
YETTINGS_DIR = "#{Rails.root}/config/yettings"
YETTING_FILE = "#{Rails.root}/config/yetting.yml"
BLANK_YETTING_FILE = "#{Rails.root}/config/yettings/blank.yml"
it "should load yettings in the rails app" do
assert defined?(Yettings)
end
describe ".find_yml_fi... | true |
50480291b2ea4be2f360126735823a14f13974f6 | Ruby | kputnam/detritus | /ruby/nl/tests/test-number.rb | UTF-8 | 3,389 | 3.234375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'test/unit'
require 'kputnam/nl/number.rb'
# not covered
# half a million
# quarter of a billion
# (<fraction> of a) ...
#
# 2E3
# 4E-2
class TestNLNumber < Test::Unit::TestCase
def test_integer
data = {
'one' => 1,
'seventy' => 70,
'one hundred' => 100,
... | true |
a78c8b5f16052395ed1225bc4fbfbc4ca2bb8d8c | Ruby | radu-constantin/ls210 | /js_book/fibonacci.rb | UTF-8 | 127 | 3.21875 | 3 | [] | no_license | require 'pry'
def fibonacci(num)
return num if num < 2
fibonacci(num - 1) + fibonacci(num - 2)
end
p fibonacci(6)
| true |
03f93dcea146f64851fb2842b9adfbe93c7e4c36 | Ruby | add2point71dots/ride-share-two | /lib/validation.rb | UTF-8 | 927 | 3.15625 | 3 | [] | no_license | module Validation
private
def validate_int(field, field_name)
if field.class != Integer || field < 0
raise ArgumentError.new("Required field #{field_name} must be a non-negative integer.")
end
return field
end
def validate_int_range(field, field_name, min, max)
valid_int = validate_int(f... | true |
153c6469e987b635eaeae8793ea9d5634c9b35e9 | Ruby | hbrodsk1/web_server | /web_server.rb | UTF-8 | 1,169 | 3.046875 | 3 | [] | no_license | #A simple server
require 'socket'
require 'json'
server = TCPServer.open(2000)
loop { #server runs forever
client = server.accept
#loops until whole header is grabbed
header = ""
while line = client.gets
header << line
break if header =~ /\r\n\r\n$/
end
#parses out method and path from status line
method... | true |
58b9911c2e6470388632cba448d05104c50fc212 | Ruby | rubemalmeida/Ruby-Fundamentals-Course | /05 - Blocks, Constants and Modules/51_modules.rb | UTF-8 | 1,415 | 2.640625 | 3 | [] | no_license | module SpaceStuff
class Spaceship
end
end
module API
def self.hatch_list
# retrieve hatch list
end
end
hatches = API.hatch_list
ship = SpaceStuff::Spaceship.new
module SecondSpaceStuff
module API
def self.hatch_list
# retrieve hatch list
end
end
end
hatches ... | true |
5d5d2454d171d42f129e8b7764ec6740003120ec | Ruby | annalaise/makers-week1-pairing | /lib/arraypairing.rb | UTF-8 | 372 | 4 | 4 | [] | no_license | array1 = [1, 2, 3, 4, 5]
array2 = [1, 3, 5, 4, 2]
array3 = [1, 3, 5, 4, 2]
array4 = [1, 2, 3, 4, 5]
array5 = [1, 2, 3, 4, 5]
# removes 0th element, adds another to the end
def array_1(array1)
array1.shift
array1.push(6)
return array1
end
# Re-orders array, taking 4th element and inserting it as 1st element.
def... | true |
adbba90dc0c447ce06f80979ef832b13c1488154 | Ruby | osak/ICFPC2016 | /vis/compile.rb | UTF-8 | 2,171 | 3.1875 | 3 | [] | no_license | require 'rational'
module Compiler
Point = Struct.new(:x, :y)
class << self
def compile(input_file)
polygons = []
n = input_file.gets.to_i
n.times do
nv = input_file.gets.to_i
poly = nv.times.map{Point.new(*input_file.gets.split(',').map(&:to_r))}
polygons << poly
... | true |
cd298ebfff5abb082b0ef6e632ad92808d92caab | Ruby | xyc0562/struct_parser | /lib/struct_parser/parsers/db_id_parser.rb | UTF-8 | 1,158 | 2.65625 | 3 | [
"MIT"
] | permissive | module StructParser::Parsers
# Determine id of a row in DB table based on column values of that table
class DbIdParser < StructParser::Parser
##
# options:
# +col+ column
# +model+ ActiveRecord model class of table from which to fetch id
def initialize(options)
options = {
error... | true |
3332f99243900668ce43b0158ff5eb548ab18d8e | Ruby | highwaybobbery/codeval | /email.rb | UTF-8 | 224 | 2.8125 | 3 | [] | no_license | file_name = ARGV.first
file = File.open(file_name, "r").each_line do |line|
unless line.match(/^$/)
if line.match(/^[\w.]+@[\w]+.[a-zA-z]+$/)
puts 'true'
else
puts 'false'
end
end
end
file.close
| true |
2e37c57f12b730210c0c5a94a178890c29594d91 | Ruby | ConwayWest/Programming-Foundations | /final_redo/ruby_basics/loops_2/exercise_1.rb | UTF-8 | 171 | 3.546875 | 4 | [] | no_license | count = 1
even_or_odd = ''
loop do
count.odd? ? even_or_odd = 'odd' : even_or_odd = 'even'
puts "#{count} is #{even_or_odd}!"
break if count == 5
count += 1
end
| true |
d5f3bfdefff0db827b7d57293a29b39799fafe23 | Ruby | mikeludemann/helperFunctions_Ruby | /src/Boolean/equalTwoArray.rb | UTF-8 | 163 | 2.984375 | 3 | [
"MIT"
] | permissive | def equalTwoArray(firstArray, secondArray)
return (firstArray[0] == secondArray[0] || firstArray[firstArray.length-1] == secondArray[secondArray.length-1])
end | true |
712bb032f266bcbd8734e40c997f7a9b3c60060d | Ruby | SketchUp/sketchup-developer-tools | /src/sketchup-developer-tools/testup/tests/ruby_classes/TC_Edge.rb | UTF-8 | 29,753 | 2.84375 | 3 | [
"Apache-2.0",
"Ruby"
] | permissive | # Copyright:: Copyright 2012 Trimble Navigation Ltd.
# License:: Apache License version 2.0
# Original Author:: Scott Lininger
#
# Tests the SketchUp Ruby API Edge object.
#
# This file was originally generated by ourdoc.rb, an internal tool we developed
# specifically for outputting support files (documentation, unit... | true |
2419165c714fbeeed8fe466fc7cb0632fbc46124 | Ruby | raquel0508/Ruby-On-Rails-HW1 | /hw1.rb | UTF-8 | 430 | 2.765625 | 3 | [] | no_license | def squared_sum(a, b)
# Q1 CODE HERE
c = a + b
return c*c
end
def sort_array_plus_one(a)
# Q2 CODE HERE
#a is an array of integers
a = a.sort
i = 0
c = a.length
while i < c
a[i] += 1
i += 1
end
return a
end
def combine_name(first_name, last_name)
# Q3 CODE HERE
return first_name + ' '... | true |
66f217c75947ea4e75584fbbf6c65bb40cc37103 | Ruby | Santiago5050/GatitoVoladorCasa | /flying_hero/end_game.rb | UTF-8 | 1,272 | 2.875 | 3 | [] | no_license | require 'gosu'
require_relative 'boton'
class EndGame < Gosu::Window
attr_accessor :option
def initialize
super(900,550, fullscreen: true)
self.caption = 'Flying hero!'
@titulo = Gosu::Image.from_text(self, "Fin del \n juego", Gosu.default_font_name, 150)
@titulo_x = ((self.width / 2) - (@titulo... | true |
212469aad3c4b025dc1c2f882c774b86b27f98a4 | Ruby | kfarst/resolute | /spec/models/contest_entry_spec.rb | UTF-8 | 2,146 | 2.90625 | 3 | [] | no_license | require 'spec_helper'
describe ContestEntry do
before(:each) do
@contest = ContestEntry.new(:name => "John Smith", :email => "john@example.com",
:age => "22", :school => "James Woods High School",
:position => "Defense")
end
it "should not save the contes... | true |
3c28c5bd2c44554c8a0f2f377c306fde92830cc9 | Ruby | msands/ruby | /apps/second_app/square.rb | UTF-8 | 305 | 3.40625 | 3 | [] | no_license | class Square
def initialize
if defined?(@@number_of_squares)
@@number_of_squares += 1
else
@@number_of_squares = 1
end
end
def Square.count
@@number_of_squares
end
end
a = Square.new
puts Square.count
b = Square.new
puts Square.count
c = Square.new
puts Square.count
| true |
115ac7f5cba253ad66353f0c97f759631217aab4 | Ruby | aksheethas/launchschool_rubyex | /IntroProgramRuby/Ch5_Loops_ex.rb | UTF-8 | 560 | 4.5625 | 5 | [] | no_license | #Loops & Iterators Exercises
#Q1
x = [1, 2, 3, 4, 5]
x.each do |a|
x = a + 1 #prints last element of array + 1
end
puts x #returns 6
#Q2
word = ''
while word != 'STOP'
puts 'How is today?'
word = gets.chomp.to_s
puts 'Want to continue? If not enter STOP'
word = gets.chomp.to_s
end
#Q3
array = [2, 4... | true |
c9bdf0bcc4f2fff64ffe253a07d9ce4deb2eb636 | Ruby | kikidawson/scrabble | /lib/scrabble.rb | UTF-8 | 281 | 3.5 | 4 | [] | no_license | class Scrabble
SCORES = {
'a' => 1,
'f' => 4
}
def initialize(word)
@word = word
@total = 0
end
def score
if @word.length > 0
@word.chars.each do |letter|
@total += SCORES[letter]
end
else
0
end
@total
end
end
| true |
926092beddec9ea4f15954b162918913a58a2527 | Ruby | gormanjp/partial-locals-lab-v-000 | /app/models/student.rb | UTF-8 | 720 | 2.796875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # == Schema Information
#
# Table name: students
#
# id :integer not null, primary key
# name :string
# hometown :string
# birthday :datetime
# created_at :datetime not null
# updated_at :datetime not null
#
class Student < ActiveRecord::Base
has_many :classroom_stude... | true |
376ec7af89b39946680134b4de51d04639c08edf | Ruby | kelaraj/design_patterns_in_ruby | /patterns/strategy.rb | UTF-8 | 455 | 3.859375 | 4 | [
"Unlicense"
] | permissive | #
# Below is an example of the Strategy design pattern.
#
# Examples: rdoc parsers
#
class Animal
attr_accessor :species
def initialize(species)
@species = species
end
def describe
@species.make_sound
end
end
class Dog
def make_sound
puts "Woof! Woof!"
end
end
class Cat
def make_soun... | true |
0cd6322be845f9f28f9539fe6e80af7274781b29 | Ruby | safreiberg/saf_proj2 | /app/models/product.rb | UTF-8 | 901 | 2.71875 | 3 | [] | no_license | # == Schema Information
#
# Table name: products
#
# id :integer not null, primary key
# inventory :integer
# price :float
# name :string(255)
# description :text
# created_at :datetime not null
# updated_at :datetime not null
#
class Product < ActiveRecord::Ba... | true |
eefa2fb01212c2acc6d67420b778acb9552e3623 | Ruby | joaofnds/exercism | /ruby/luhn/luhn.rb | UTF-8 | 768 | 3.75 | 4 | [] | no_license | class Luhn
def self.valid?(numerical_string)
new(numerical_string).valid?
end
def valid?
multiple_digits? && luhn_sum_divisble_by_10?
end
private
attr_reader :numerical_string
def initialize(numerical_string)
@numerical_string = numerical_string
end
def multiple_digits?
numerical_... | true |
67ff163425ddd5446077b3ad15dd27259ff0bdd7 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/raindrops/95f701c93ea94ebabf2bad33d58c9b04.rb | UTF-8 | 262 | 3.0625 | 3 | [] | no_license | class Raindrops
def self.convert(number)
output = String.new
output += 'Pling' if number % 3 == 0
output += 'Plang' if number % 5 == 0
output += 'Plong' if number % 7 == 0
if output == ''
return number.to_s
else
return output
end
end
end
| true |
aa7bd8eb5418b3cec39e00d14dea893229bf0442 | Ruby | aokolish/ruby-katas | /thirteen/one.rb | UTF-8 | 769 | 3.28125 | 3 | [] | no_license | class CodeCounter
attr_reader :current_line, :code, :in_comment
alias_method :in_comment?, :in_comment
def initialize(code)
@code = code
@in_comment = false
end
def count_lines
count = 0
code.each_line do |line|
@current_line = line
comment_starting?
count += 1 if line_of_c... | true |
3cb5d5d6aa85f2eed28e5b2d68f675ffe1df2d2c | Ruby | marcwright/WDI_ATL_1_Instructors | /REPO - Los Angeles 7-8/Ruby-Homework-Solutions/gem-stones.rb | UTF-8 | 197 | 3.375 | 3 | [] | no_license | require 'set'
def gems comps
s = comps[0]
comps.each { |comp| s &= comp }
s.length
end
comps = []
gets.chomp.to_i.times do
comps.push(Set.new(gets.chomp.scan(/\w/)))
end
puts gems comps
| true |
6a1e3f1eab3ae06ac68deed17dc488aa04b33679 | Ruby | ksilin/crumbs | /spec/array_splicing_spec.rb | UTF-8 | 1,264 | 3.734375 | 4 | [] | no_license | describe 'trying array conjunction by splicing' do
let(:a1) { [1, 2, 3, 4, 5] }
let(:a2) { [4, 5, 6] }
it 'should splice' do
p "a1[a1.length, 0] #{a1[a1.length, 0]}"
# the syntax a[1, 2] means a subarray of length 2, satrting at index 1
# here, we grab an empty array that consists of 0 elements
... | true |
7f9dacc56580562047a362013ffeef8034e676e8 | Ruby | DCHitch092/wk2_day4_planets_lab | /star_system.rb | UTF-8 | 1,505 | 3.5 | 4 | [] | no_license | class StarSystem
attr_reader :name, :planets
def initialize(name, planets)
@name = name
@planets = planets
end
def planet_names
@planets.map { |planet| p planet.name }
end
def get_planet_by_name(planet)
@planets.find { |planet| planet.name == "Mars"}
end
def get_largest_planet
@planet... | true |
0fb4e734cbcc7914fcf383c4ad78d42b626d65b3 | Ruby | kontena/kontena-plugin-cloud | /lib/kontena/cli/models/master_api_model.rb | UTF-8 | 465 | 2.65625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Kontena::Cli::Models
module MasterApiModel
attr_reader :api_data
def initialize(api_data)
@api_data = api_data || {}
end
def method_missing(method, *args, &block)
key = method.to_s
return @api_data.has_key?(key) && @api_data[key] if key.end_with?('?'.freeze)
if @api... | true |
1a41c4f081a6b2a460e999a9194cf0b860aace43 | Ruby | albertobonhomme/week2 | /Week2/Webapps/Class/Password/lib/passwords.rb | UTF-8 | 1,174 | 3.421875 | 3 | [] | no_license | class User
attr_accessor :email, :pass
def initialize(email,pass)
@email = email
@pass = pass
end
def checkall
if [checklength,containsymbol,containnumber,containletter,containuppercase,containlowercase,usernamecheck].include?(false)
"Invalid password. Try again. Remember:
The password must be longer... | true |
57e9e6a1812647e54570e4cc4442635cba8f0b69 | Ruby | mariovisic/ruby2d-games | /05 - Platformer game/platformer-game.rb | UTF-8 | 701 | 2.578125 | 3 | [] | no_license | require 'ruby2d'
set width: 800
set height: 600
WALK_SPEED = 4
background = Image.new('background.png', y: -920)
hero = Sprite.new(
'hero.png',
width: 256,
height: 256,
clip_width: 256,
y: 194
)
on :key_held do |event|
case event.key
when 'left'
hero.play flip: :horizontal
if hero.x > 0
... | true |
db71e48c7af88579a7fc287d025663c2a7ed36db | Ruby | wabilin/OJSols | /leetcode/product-of-array-except-self.rb | UTF-8 | 489 | 3.234375 | 3 | [
"Unlicense"
] | permissive | # @param {Integer[]} nums
# @return {Integer[]}
def product_except_self(nums)
return [] if nums.empty?
zore_count = nums.reduce(0) { |sum, x| sum + (x == 0 ? 1 : 0) }
if zore_count > 1
[0] * nums.length
elsif zore_count == 1
all_product = nums.reduce(1) { |p, x| p * (x == 0... | true |
0d6b268d58721cc8467bfd61bd5195d40be84f86 | Ruby | patilsameer/ruby | /oop/oo1.rb | UTF-8 | 992 | 3.75 | 4 | [] | no_license | class Course
def initialize(name, students)
@name = name
@students = students
end
end
saas = Course.new("SaaS 201", [
Student.new(715, "Raj"),
Student.new(716, "Sai")
])
class Course
def initialize(name, students)
@name = name
@students = students
end
#... | true |
3163ef227f7750b911cb27c2905e66fd7816effb | Ruby | davidjeddy/learning_ruby | /ruby-learning/p023codeblock2.rb | UTF-8 | 720 | 4.15625 | 4 | [] | no_license | # You can provide parameters to the call to yield:
# these will be passed to the block
def call_block
yield('hello', 99)
end
call_block {|str, num| puts str + ' ' + num.to_s}
def try
if block_given?
yield
else
puts "no block"
end
end
try # => "no block"
try { puts "hello" ... | true |
df1c5cfa8b17ede623385c06e2572848c4b75ce8 | Ruby | ykaito21/rails-longest-word-game | /app/controllers/games_controller.rb | UTF-8 | 820 | 3.125 | 3 | [] | no_license | require 'open-uri'
require 'json'
class GamesController < ApplicationController
def new
# @letters = (0...10).map{ ('A'..'Z').to_a[rand(26)] }
letters = ('A'..'Z').to_a.sample(10)
@grid = letters.join(' ')
end
def score
grid = params[:grid]
word = params[:word].upcase
@message = ''
... | true |
5031221f4dc238ddb84c99b9ac1c2cc0b1c101ea | Ruby | nikosd/roodi | /lib/roodi/checks/abc_metric_method_check.rb | UTF-8 | 2,217 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'roodi/checks/check'
module Roodi
module Checks
# TODO: Add summary
#
# TODO: Add detail
class AbcMetricMethodCheck < Check
# ASSIGNMENTS = [:attrasgn, :attrset, :dasgn_curr, :iasgn, :lasgn, :masgn]
ASSIGNMENTS = [:lasgn]
# BRANCHES = [:if, :else, :while, :until, :for, :r... | true |
8e25f5b3b0e97f1223ee72f42eb56e203bc9325f | Ruby | hkopijcode/smart-pension-recruitment-task | /lib/log_parser.rb | UTF-8 | 602 | 2.984375 | 3 | [] | no_license | class LogParser
def process
validate_file_path
generate_views_hash
end
private
attr_reader :file_path, :views
def initialize(file_path)
@file_path = file_path
@views = Hash.new { |k, v| k[v] = [] }
end
def validate_file_path
raise StandardError.new 'Filename can not be blank' if fi... | true |
f94f6701e58212806a09db0f0bde75b324c66f38 | Ruby | ruby-syntax-tree/syntax_tree | /lib/syntax_tree/search.rb | UTF-8 | 529 | 2.78125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module SyntaxTree
# Provides an interface for searching for a pattern of nodes against a
# subtree of an AST.
class Search
attr_reader :pattern
def initialize(pattern)
@pattern = pattern
end
def scan(root)
return to_enum(__method__, root) unless block_g... | true |
2205bcb7dbe33bacbac219889dff4c139b1d1970 | Ruby | xlts/gosu-sample | /lib/enemy.rb | UTF-8 | 275 | 2.640625 | 3 | [] | no_license | require_relative 'game_object'
class Enemy < GameObject
def initialize
super
@sprite = Gosu::Image.new("media/img/enemy.png", :tileable => true)
@x = rand(800)
end
def update
move('down')
end
def draw
@sprite.draw_rot(@x, @y, 1, 0)
end
end | true |
4e610852dc23759974e451e4380426fbec880a75 | Ruby | guidance-guarantee-programme/signonotron2 | /test/integration/passphrase_change_test.rb | UTF-8 | 4,770 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | #encoding: utf-8
require 'test_helper'
require 'helpers/passphrase_support'
class PassphraseChangeTest < ActionDispatch::IntegrationTest
include PassPhraseSupport
context "normal user" do
setup do
@original_password = "some v3ry s3cure passphrase"
@user = create(:user, email: "jane.user@example.co... | true |
deed80e0fca27620540092c0f2c8b293373d5146 | Ruby | woodylucas/simple-blackjack-cli-dumbo-web-121018 | /lib/blackjack.rb | UTF-8 | 1,270 | 3.921875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def welcome
puts "Welcome to the Blackjack Table"
end
def deal_card
rand(1..11)
end
def display_card_total(total)
puts "Your cards add up to #{total}"
end
def prompt_user
puts "Type 'h' to hit or 's' to stay"
end
def get_user_input
h = gets.chomp
end
def end_game(total)
puts "Sorry, you hit #{total}. Th... | true |
281fb5113a75425b03dc703c45f73f85510e6c78 | Ruby | Tranncors/hobby | /app/models/airport_search_term.rb | UTF-8 | 1,205 | 3.078125 | 3 | [] | no_license | class AirportSearchTerm
attr_reader :where_clause, :where_args, :order
def initialize(search_term)
@where_clause = ""
@where_args = {}
if search_term =~ /^\w{1,3}$/
search_term = search_term.downcase
build_for_iata_search(search_term)
else
search_term = sear... | true |
8763b340c86c59024f51acf6fcdead2a7c870593 | Ruby | lshapz/sinatra-project-web-0916 | /app/controllers/restaurants_controller.rb | UTF-8 | 5,118 | 2.625 | 3 | [] | no_license | class RestaurantsController < ApplicationController
require_all ('app/adapters')
get '/restaurants' do
rest = Restaurant.all
if !Restaurant.all.empty?
@last_id = Restaurant.last.id
end
#last_id is for the "New!" feature
@restaurants = rest.sort_by {|x| x.name}
#alphabetizing
erb :'/restaurants/i... | true |
ba09579c41cb023c11f0da9e603746868edeb76e | Ruby | ICRAR/TSN_alpha | /spec/features/pages_spec.rb | UTF-8 | 7,461 | 2.609375 | 3 | [] | no_license | require 'spec_helper'
feature "Pages" do
describe "Viewing on website", :js => true do
scenario "with no parent or children" do
new_page = Fabricate(:page, slug: 'Test Page').reload
visit page_path(new_page)
#display title
expect(page).to have_css('h1', :text => new_page.title)
#di... | true |
47813d8625fa794c4b3f86993c6c68074b3e5416 | Ruby | johncarter352/key-for-min-value-onl01-seng-pt-032320 | /key_for_min.rb | UTF-8 | 252 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash)
n = nil
name_hash.collect do |k, v|
n ||= k
n = k if v < name_hash[n]
end
n
end
| true |
28cac9f33c3ab6049a41d75a125025e6c339b220 | Ruby | nog/atcoder | /contests/abc268/d/main.rb | UTF-8 | 909 | 2.828125 | 3 | [] | no_license | N, M = gets.split.map(&:to_i)
S = Array.new N
N.times do |i|
S[i] = gets.chomp
end
@exists = {}
M.times do
t = gets.chomp
@exists[t] = true
end
warn @exists.inspect
maxc = (N > 9) ? 9 : N
if N == 1
S.each do |s|
next if s.size < 3
unless @exists[s]
puts s
exit
end
end
puts -1
exi... | true |
38f8a7c81c5184681ff6d61f104ec4f8b1082ccb | Ruby | milenoss/orm-mapping-to-table-lab-london-web-082619 | /lib/student.rb | UTF-8 | 1,423 | 3.21875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Student
attr_accessor :name, :grade
attr_reader :id
@@all = []
#when initialized with a name and a grade
#the name attribute can be accessed
#the grade attribute can be accessed.
def initialize ( name, grade, id = nil)
@name = name
@id = id
@grade = grade
@@all ... | true |
c715840dd13ff780bcb51361c31f6effa95729e7 | Ruby | urbantumbleweed/urbantumbleweed | /w01/d05/Dave_Miller/Homework/apartment.rb | UTF-8 | 706 | 3.234375 | 3 | [] | no_license | #dave miller
#hw w01d05
#rental app
class Apartment
attr_accessor :name, :price, :sqft, :num_beds, :num_baths
attr_reader :renters
def initialize( options = {} )
@name = options[:name]
@price = options[:price]
@sqft = options[:sqft]
@num_beds = options[:num_beds]
@num_baths = options[:num_ba... | true |
8d11725fa86a7fd2d27ddb58d24dc1eb537daeb3 | Ruby | abuhabuh/healthProj | /app/models/ethnicity.rb | UTF-8 | 1,051 | 2.75 | 3 | [] | no_license | class Ethnicity < ActiveRecord::Base
include EncryptionKey
# Encryption: encryption_key comes from encryption_key.rb concern
attr_encrypted :name, :key => :encryption_key
###
# Static variables
###
# Hash of database id to name
@@ETHNICITIES = nil
###
# Static methods
###
def self.get_eth... | true |
48598f8641d9aa7dbc8add7df7942daee8cc88b5 | Ruby | MarciClark/square_array-online-web-pt-011419 | /square_array.rb | UTF-8 | 121 | 3.203125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array) do
numbers = [1,2,3]
numbers.each do |number|
puts "numbers #{number} is #color.sqrt"
end | true |
c13615287640a00a8f43f22f2a03f347ad905e22 | Ruby | AndresAL10/PDOO | /PDOO/NapakalakiRuby.ruby/lib/player.rb | UTF-8 | 7,699 | 3.140625 | 3 | [] | no_license | #encoding: utf-8
require_relative 'treasure'
require_relative 'combat_result'
require_relative 'card_dealer'
require_relative 'bad_consequence'
require_relative 'dice'
module NapakalakiGame
class Player
@@MAXLEVEL = 10
def self.getMAXLEVEL
@@MAXLEVEL
end
private
def... | true |
dbb436a3cae1ff9a614ca3df8bceb113a4e60150 | Ruby | manishchaks/payback-service | /lib/user.rb | UTF-8 | 918 | 3.296875 | 3 | [] | no_license | require_relative 'validator'
class User
attr_reader :name, :email
attr_accessor :credit_limit, :available_credit
def initialize(name, email, credit_limit)
# NOTE:
# I'm using a custom Validator class below
# In real life, we would be using ActiveRecord Validations or something similar
Validator.v... | true |
bf3f39aa263367c35f26f2b4330b18d69939cf7f | Ruby | gadial/BibleCode | /lib/auxiliary.rb | UTF-8 | 96 | 2.796875 | 3 | [] | no_license | class String
def clean
split("").reject{|x| not x=~/[a-zA-Z]/}.join("").downcase
end
end | true |
ebeebaac30b05a46d1a8333af4fda2ddce9f68de | Ruby | davidor/project-euler | /ruby/019.rb | UTF-8 | 282 | 3.5 | 4 | [] | no_license | # How many Sundays fell on the first of the month during the
# twentieth century (1 Jan 1901 to 31 Dec 2000)?
require 'date'
start_date = Date.parse('01-01-1901')
end_date = Date.parse('31-12-2000')
puts (start_date..end_date).to_a.count { |date| date.sunday? and date.day == 1 } | true |
559f0668c3481990a2439898de934147ac5f1ccd | Ruby | ykumawat/ruby-music-library-cli-v-000 | /lib/music_library_controller.rb | UTF-8 | 1,251 | 3.078125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MusicLibraryController
def initialize(path = "./db/mp3s")
new_music = MusicImporter.new(path)
new_music.import
end
def call
user_input = ""
until user_input == "exit"
user_input = gets.chomp
case user_input
when "list songs"
sorted = Song.all.sort_by!{|s| s.artist.... | true |
3e0f3b4b5160250d1ae087917b0c17e4a54b9c89 | Ruby | jnunemaker/prey | /lib/prey/server.rb | UTF-8 | 1,437 | 2.703125 | 3 | [
"MIT"
] | permissive | require "socket"
module Prey
class Server
ValidTypes = [:thrift, :memcache, "thrift", "memcache"]
FloatValueRegex = /^\d+\.\d+$/
IntegerValueRegex = /^\d+$/
StatLineRegex = /^STAT (\w+) (\S+)/
EndLineRegex = /^END/
attr_reader :host, :thrift_port, :memcache_port
def initialize(opti... | true |
fc77b0bda53470cb59504577f902c61fd34a9c5c | Ruby | TANEJS4/CS3MI3 | /h7/h7t.rb | UTF-8 | 689 | 2.984375 | 3 | [] | no_license | require_relative "h7"
x = ULVar.new(0)
y = ULVar.new(1)
z = ULVar.new(2)
u = ULVar.new(3)
appvars = ULApp.new(ULApp.new(x,y), ULApp.new(z,u))
lappvars = ULAbs.new(appvars)
lllappvars = ULAbs.new(ULAbs.new(lappvars))
# puts "a Sample"
# puts x.prettify
# puts "b ... | true |
c3d7380928108e488bac7d72c286ea1fab376ad9 | Ruby | charitywater/release-notifier-and-metrics-dashboard | /app/pivotal_tracker_story.rb | UTF-8 | 811 | 2.546875 | 3 | [] | no_license | require 'json'
class PivotalTrackerStory < Rack::App
def initialize pt_story_number
@pt_story_number = pt_story_number
end
def id
response_body['id']
end
def labels
response_body['labels']
end
def name
response_body['name']
end
def description
response_body['description']
en... | true |
4e350ae7bd8f272eb4ed1dd8d6855a24c870319a | Ruby | lujanfernaud/exercism | /ruby/beer-song/beer_song.rb | UTF-8 | 226 | 3.046875 | 3 | [] | no_license | require "./verse"
require "./book_keeping"
class BeerSong
def verse(number)
Verse.new(number).build
end
def verses(initial, final)
initial.downto(final).to_a.map { |number| verse(number) }.join("\n")
end
end
| true |
6a4db0d11e149f941874e901a59678b998d6acfc | Ruby | Kashiwara0205/Pokotarou | /lib/pokotarou/parser/loop_expression_parser.rb | UTF-8 | 626 | 2.515625 | 3 | [
"MIT"
] | permissive | require "pokotarou/parser/parser.rb"
# for loop data
module Pokotarou
class LoopExpressionParser < ExpressionParser
class << self
private
def array_procees val
val.size
end
def foreign_key_process val, maked_col
# remove 'F|'
str_model = val.sub(FOREIGN_KEY_SYMBOL... | true |
8b9dc827e849ae6ca564c127b60203795fd569a4 | Ruby | DenRebrov/blackjack | /game_controller.rb | UTF-8 | 2,969 | 3.40625 | 3 | [] | no_license | require_relative 'bank.rb'
require_relative 'card.rb'
require_relative 'deck.rb'
require_relative 'player.rb'
require_relative 'dealer.rb'
require_relative 'user.rb'
require_relative 'hand.rb'
require_relative 'game_interface.rb'
class GameController
attr_reader :bank, :deck, :dealer, :user, :interface
attr_access... | true |
12107235c5d37fa82d6c464db4b439db3d472358 | Ruby | ritchiey/deploy-utils | /lib/dir_tree.rb | UTF-8 | 1,032 | 2.984375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | #!/usr/bin/ruby
require 'fileutils'
class DirTree
attr_accessor :base
def initialize(base)
self.base = base
end
def each_node(&blk)
@base = Dir.new(@base) unless @base.kind_of?(Dir)
recurse('', &blk)
end
def self.link src, dst, options={}
copy = options[:copy] || []
FileUtils.mkd... | true |
807c4fc154526b1bcb85d10614af2c989bc4c2d4 | Ruby | Casey0689/Beginning-Ruby-Projects | /arrays.rb | UTF-8 | 201 | 3.40625 | 3 | [] | no_license | a = ["Dave", "Casey", "Chaz", 42, 3.14]
#puts a[0]
#a[0] = "Jones"
#puts a[0]
#
#index = 4
#a[index]
#puts a.inspect
#puts a
counter = 0
while counter < a.length
puts a[counter]
counter += 1
end
| true |
b11c9bab4d3b19d231266b9b01c8e4710499ebeb | Ruby | addagger/html_slicer | /lib/html_slicer/config.rb | UTF-8 | 2,231 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'active_support/configurable'
module HtmlSlicer
# Configures global settings for HtmlSlicer
#
# === Default global configuration options
#
# window = 4
# outer_window = 0
# left = 0
# right = 0
# param_name = :slice
#
# === Override/complete global configuration
#
# HtmlSl... | true |
39c74d92ca7ef648d30fe81aaf51ee76d5f98630 | Ruby | neilpw/flapjack-stack-sort | /spec/flapjack_stack_sorter_spec.rb | UTF-8 | 484 | 2.90625 | 3 | [] | no_license | require 'rspec'
require 'flapjack_stack_sorter'
RSpec.describe FlapjackStackSorter do
describe '#sort' do
it 'returns a sorted FlapjackStack' do
test_arrays = [
[1],
[1, 1],
[1, 2],
[2, 1],
[5, 4, 3, 2, 1]
]
test_arrays.each do |array|
stack = Fl... | true |
0eb1e9b902d204b6c4aecc6be807864cb2981930 | Ruby | lavikoder/badges-and-schedules-london-web-career-040119 | /conference_badges.rb | UTF-8 | 699 | 3.4375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | speakers = ["Edseger", "Ada", "Charles", "Alan", "Grace", "Linus", "Matt"]
def badge_maker(speaker)
puts "Hello, my name is #{speaker}"
end
badge_maker("speaker")
def batch_badge_creator()
speakers = ["Edseger", "Ada", "Charles", "Alan", "Grace", "Linus", "Matt"]
speakers.each do |speaker|
puts "Hello my na... | true |
18c765fa5a1a07ce1f69372bc60da2fda737fbc0 | Ruby | andrew-t-james/backend_prework | /day_1/ex4.rb | UTF-8 | 959 | 3.578125 | 4 | [] | no_license | # cars assigned the value of 100
cars = 100
# space_in_a_car assigned the value of 4
space_in_a_car = 4
# drivers assigned the value of 30
drivers = 30
# passengers assigned the value of 90
passengers = 90
# cars_not_driven assigned the value = cars - drivers evaluates to 70
cars_not_driven = cars - drivers
# cars_driv... | true |
228f0ead940252e89c2c8d54bc793b4d98e01002 | Ruby | aagooden/coin_flip | /coin_changer.rb | UTF-8 | 950 | 3.703125 | 4 | [] | no_license | def changer(cents)
change = {"quarters"=>0, "dimes"=>0, "nickels"=>0, "pennies"=>0}
quarters = cents / 25
change["quarters"]= quarters
cents = cents % 25
dimes = cents / 10
change["dimes"]= dimes
cents = cents % 10
nickels = cents / 5
change["nickels"]= nickels
cents = cents % 5
change["pennies"] = cents
... | true |
a528274a3a3d1ac51f2ccdadfb57e275a0805b96 | Ruby | kazuhirodk/parking-management-api | /app/services/parking_entrance_service.rb | UTF-8 | 730 | 2.6875 | 3 | [] | no_license | # frozen_string_literal: true
class ParkingEntranceService
def initialize(vehicle_params = {})
@vehicle = CreateVehicleService.new(vehicle_params).create
end
def enter_parking
return invalid_vehicle_response if @vehicle.blank?
parking_ticket = CreateParkingService.new(@vehicle.id).create
enter... | true |
7a2194e82d76b03590621ec16b586ea0df6a690c | Ruby | Murphydbuffalo/99_bottles | /lib/verse.rb | UTF-8 | 960 | 3.953125 | 4 | [] | no_license | class Verse
GENERIC_VERSE_PART_ONE = 'NUM_BOTTLES of beer on the wall, NUM_BOTTLES of beer.'.freeze
GENERIC_VERSE_PART_TWO = 'Take TAKE_AMOUNT down and pass it around, NUM_BOTTLES of beer on the wall.'.freeze
ENDING_VERSE = 'Go to the store and buy some more, 99 bottles of beer on the wall.'.freeze
d... | true |
c85a2683331c768c037fc66ce8c043326934a4ed | Ruby | innozonkishore/carmandi | /spec/models/link_spec.rb | UTF-8 | 3,251 | 2.53125 | 3 | [] | no_license | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
module LinkSpecHelper
def valid_link_attributes
{ :name_english => 'first link',
:name_hindi => 'pehla link',
:name_urdu => 'first link in urdu',
:name_punjabi => 'first link in punjabi' ,
:position => 0,
:useful =... | true |
b1020a0685ed8e3ba458ef3a917e82a8481984de | Ruby | ma2saka/pppt | /lib/pppt/helpers.rb | UTF-8 | 990 | 2.703125 | 3 | [
"MIT"
] | permissive | class Pppt::Helpers
def self.truncate_screen_width(str, width, suffix = '...')
i = 0
str.each_char.inject(0) do |c, x|
c += x.ascii_only? ? 1 : 2
i += 1
next c if c < width
return str[0, i] + suffix
end
str
end
def self.split_screen_width(str, width = 40)
s = i = r = 0... | true |
e446d43ac113fc6e4674ac3d23ec0a73c7f155d6 | Ruby | tonyheadford/uk_validators | /lib/uk_validators/passport_number_validator.rb | UTF-8 | 586 | 2.515625 | 3 | [
"MIT"
] | permissive | class PassportNumberValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, invalid_message(record, attribute)) unless valid_passport_number?(value)
end
private
# UK format is simply 9 digits
def valid_passport_number?(value)
value =~ /^[0-9]{9}... | true |
c331443ef27f264005929d7aa13f3605f51786a3 | Ruby | Yumeee/reinforcement_tdd_simon | /simon_says.rb | UTF-8 | 371 | 3.828125 | 4 | [] | no_license | def echo(word)
return word
end
def shout(word)
return word.upcase
end
def repeat(word, times)
sentence = (word + " ") * times
return sentence.strip
end
def start_of_word(word, index)
if index == 1
return word[index-1]
elsif index == 2
return word[0..index-1]
end
end
def first_word(sentence)
... | true |
2cc52de13ff9887f6148fa54aa18b860ac8ed496 | Ruby | AyupovFN/Kanoby | /kanoby.rb | UTF-8 | 1,018 | 3.890625 | 4 | [] | no_license |
def who_won(user_choice, computer_choice)
if user_choice == computer_choice
return 0
end
win_condition =
(user_choice == 0 && computer_choice == 1) ||
(user_choice == 1 && computer_choice == 2) ||
(user_choice == 2 && computer_choice == 0)
if win_condition
return 1
end
return 2
e... | true |
f1edc6d16f655a9dc22648183b9f5aafae15d936 | Ruby | Shopify/measured | /lib/measured/arithmetic.rb | UTF-8 | 1,007 | 3.109375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Measured::Arithmetic
extend Forwardable
def_delegators :@value, :zero?, :positive?, :negative?, :finite?, :infinite?
def +(other)
arithmetic_operation(other, :+)
end
def -(other)
arithmetic_operation(other, :-)
end
def -@
self.class.new(-self.value, self... | true |
467e2ec0c674fe6be773dcad52f33b8178bfd945 | Ruby | mimi0879/nico-artisan | /artisan/app/models/comment.rb | UTF-8 | 571 | 2.53125 | 3 | [] | no_license | class Comment < ActiveRecord::Base
belongs_to :art
attr_accessor :time
def time=(s)
self.vpos = case s
when /(\d+):(\d+\.\d+|\d+)/
($1.to_i * 6000) + ($2.to_f * 100).to_i
when /(\d+\.\d+|\d+)/
($1.to_f * 100).to_i
else
... | true |
fdda4e68d3906abb1d3973959603052414db29a4 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/anagram/bf625e1ba6934fad90347236e3ddcca8.rb | UTF-8 | 488 | 3.46875 | 3 | [] | no_license | class Anagram
def initialize word
@word = word
@anagrams = @word.split('')
.permutation
.map &:join
end
def match test_words
test_words.delete_if { |word| word.length != @word.length || @word =~ /#{word}/i }
test_words.select do |word|
counter = 0
... | true |
5b59ee6e8b9a402f38e71e9740be9dfa5c9a6151 | Ruby | ehedaoo/ascension | /spec/game_spec.rb | UTF-8 | 2,283 | 2.515625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require File.dirname(__FILE__) + "/spec_helper"
class File
def self.pp(file,obj)
require 'pp'
File.open(file,"w") do |f|
PP.pp(obj,f)
end
end
end
def logging_it(name,&b)
it(name) do
Debug.log "starting #{name}"
begin
instance_eval(&b)
ensure
Debug.log "ending #{name}\n... | true |
2c9ba3a4283ca69dca3811158621ad318e58b72f | Ruby | RoystonHenson/oyster_card_refresher | /spec/station_spec.rb | UTF-8 | 305 | 2.515625 | 3 | [] | no_license | require 'station'
describe Station do
subject { described_class.new('Aldgate East', 1) }
describe '#initialize' do
it 'initialises with a name' do
expect(subject.name).to eq('Aldgate East')
end
it 'initialises with a zone' do
expect(subject.zone).to eq(1)
end
end
end
| true |
b1bd9b819abc8a70eed30e9ef2ce901a33f11b6a | Ruby | Mozl/banktechtest | /spec/statement_spec.rb | UTF-8 | 478 | 2.765625 | 3 | [] | no_license | require './lib/statement'
require './lib/bank_account'
require './lib/transaction'
describe Statement do
date = Time.new.strftime('%d-%m-%Y')
it 'prints a transaction' do
transactions = []
transactions << double(date: date, debit: nil, credit: 2000.99, balance: 2000.99 )
statement = described_class.n... | true |
f44273ef5d9815b382fbd9b2a9a319894c3590e2 | Ruby | turboladen/rosh | /lib/rosh/file_system.rb | UTF-8 | 5,216 | 3.015625 | 3 | [
"MIT"
] | permissive | require_relative 'kernel_refinements'
require_relative 'changeable'
require_relative 'observer'
require_relative 'observable'
require_relative 'file_system/block_device'
require_relative 'file_system/character_device'
require_relative 'file_system/directory'
require_relative 'file_system/file'
require_relative 'file_s... | true |
f22e3af7d4f8ed20f1265aec93c0dc512ff8493d | Ruby | JFVF/cucumber_022015 | /Pedro/practice_control_statement/class_age_manager.rb | UTF-8 | 1,379 | 4.75 | 5 | [] | no_license | =begin
Create a class that is going to receive :
name, age (use getter and setter concept)
Method to calculate years in hours only if years is lower than 35, otherwise return a message that age cannot be calculated
Method that consider the values obtained from the previous. Use short-if expression method,
when value i... | true |
4233d414c5fc217c32dac886e2a6549524c175a9 | Ruby | yihangho/SimpleCMS | /spec/models/concerns/input_parser_spec.rb | UTF-8 | 1,641 | 3.390625 | 3 | [] | no_license | require 'rails_helper'
class String
def last
self[self.size()-1]
end
end
describe InputParser do
describe "the normalize_input(arg) method" do
let(:overall_test_string){ "this is funny \nlol a a \t crap crap i love dinosaurs \n\t\t\t\t\t\t\t\t\t\t\na s d f \nthis is\n" }
... | true |
59a0d482093c3f219d1338895286c38352000779 | Ruby | rusg77/sbt | /queue/jobs.rb | UTF-8 | 5,956 | 2.671875 | 3 | [] | no_license | require 'rmagick'
require_relative '../db/db'
require_relative '../tests/messages'
require_relative '../tests/login'
module Analyse
@queue = :analyse
# фукнкция для сравнения двух изображений и вычисления расхождения в %
# @param [String] img1 первое изображение
# @param [String] img2 второе изображение
# @... | true |
425cc7154de6a9dd8e6dbf7e873983e92165c469 | Ruby | shripadjoshi/leetcode | /AnagramStrings/Ruby/anagram_of_strings.rb | UTF-8 | 273 | 4.15625 | 4 | [] | no_license | ###Anagram of two words
str1 = 'LISTEN'
str2 = 'SILENT'
def anagram(str1, str2)
return sort_string(str1).eql?(sort_string(str2)) ? 'Anagram Success' : 'Anagram Failure'
end
def sort_string(str)
return str.chars.sort_by(&:downcase).join
end
puts anagram(str1, str2)
| true |
ecfb03c70381ca17f36c729e357652ad46b63505 | Ruby | ppmasa8/lifeGame | /lifeGame.rb | UTF-8 | 1,063 | 3.546875 | 4 | [] | no_license | require 'pp'
def cls
print "\033[2J"
end
def pos(x, y)
print "\033[#{y+1};#{x+1}H"
end
def init_table(size_x, size_y)
Array.new(size_y) do
Array.new(size_x) do
(rand * 1.5).to_i
end
end
end
def round(table)
size_x, size_y = table.first.size, table.size
Array.new(size_y) do |y|
Array.n... | true |
649275910a7101833cf03affc95e2441daa0f3cb | Ruby | kerryb/enigma | /spec/integration_spec.rb | UTF-8 | 2,371 | 2.734375 | 3 | [] | no_license | require "machine"
require "input_wheel"
require "plugboard"
require "rotor"
require "reflector"
describe "Integration" do
subject(:machine) {
Machine.new(
plugboard: plugboard,
input_wheel: input_wheel,
rotors: rotors,
reflector: reflector,
)
}
let(:plugboard) { Plugboard.new }
... | true |
b758a3e5d11ae40e23b4adc0de3c40a14e9f2837 | Ruby | subhan/Ruby-Code | /lists.rb | UTF-8 | 568 | 3.828125 | 4 | [] | no_license | #!/usr/local/bin/ruby
fruties = ['apple','orange','mango']
#for loop based on index
print "#"*30,"\n"
for f in 0...fruties.length
puts "frutie : %s"%fruties[f]
#print "frutie : ",fruties[f],"\n"
end
print "#"*30,"\n"
#for loop based on list items
for f in fruties
puts "frutie : %s\n"%f
#print "frutie : ",f,"\n"... | true |
d71691181bbd68755703b6dbaecf03588f4770b0 | Ruby | HaopengLiu-1992/leetcode-ruby | /leetcode/897_Increasing_Order_Search_Tree.rb | UTF-8 | 343 | 3.265625 | 3 | [
"ICU",
"Ruby"
] | permissive | # leetcode 897
class IncreasingOrderSearchTree
def increasing_bst(root)
order = in_order(root)
(1...order.length).each { |i| order[i - 1].right = order[i] }
order[0]
end
def in_order(root)
return [] if root.nil?
left = in_order(root.left)
left << TreeNode.new(root.val)
left + in_order... | true |
2c1f98fa66d57f9dc16ae92d05618fdf35fc11ca | Ruby | gladstone13/lojalivro | /lib/biblioteca.rb | UTF-8 | 1,270 | 2.984375 | 3 | [] | no_license | module VendaFacil
class Biblioteca
include Enumerable
attr_reader :midia
def initialize
@banco_de_arquivos = BancoDeArquivos.new
end
def adiciona(midia)
salva midia do
midias << midia
end
end
=begin
ret... | true |
1406677997e9fe97a718da7ae2be4fac39bb242d | Ruby | airbnb/trebuchet | /lib/trebuchet/feature/stubbing.rb | UTF-8 | 492 | 2.515625 | 3 | [] | no_license | class Trebuchet
class Feature
module Stubbing
def stub(state)
self.class.stubbed_features[name] = state
end
def stubbed?
!!self.class.stubbed_features[name]
end
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
... | true |
fe63d2435a20b957a3f7f905cfb205e9e881d974 | Ruby | bogdan/datagrid | /lib/datagrid/renderer.rb | UTF-8 | 4,223 | 2.734375 | 3 | [
"MIT"
] | permissive | require "action_view"
module Datagrid
# @!visibility private
class Renderer
def self.for(template)
new(template)
end
def initialize(template)
@template = template
end
def format_value(grid, column, asset)
if column.is_a?(String) || column.is_a?(Symbol)
column = grid... | true |
a0475f4637ed8082c9c1ee0c9b20ad4f0325db91 | Ruby | dqmrf/dive-in-ruby | /sandbox/hashes/merge.rb | UTF-8 | 129 | 2.875 | 3 | [] | no_license | options = { name: 'Misha' }
defaults = {
name: 'Michael',
age: 20,
iq: 70
}
options = defaults.merge(options)
p options
| true |
353696b6323486fc29d47527ba6016c99809ed0c | Ruby | iox/hobo | /hobo_support/lib/hobo_support/string.rb | UTF-8 | 728 | 3.046875 | 3 | [
"MIT"
] | permissive | class String
def remove(string_or_rx)
sub(string_or_rx, '')
end
def remove!(string_or_rx)
sub!(string_or_rx, '')
end
def remove_all(string_or_rx)
gsub(string_or_rx, '')
end
def remove_all!(string_or_rx)
gsub!(string_or_rx, '')
end
# Return the constant that this string refers to, ... | true |
ee55259bbe086c3eebbf72f32395ddd72af26bae | Ruby | nickcen/ruby-course | /ch12/batch_insert_2.rb | UTF-8 | 383 | 2.78125 | 3 | [] | no_license | require 'mysql2'
require 'benchmark'
client = Mysql2::Client.new(host: 'localhost', username: 'test', password: 'test', database: 'test')
def prepare_statement(client)
statement = client.prepare("insert into users (name, age) values (?, ?)")
1.upto(100000).each do |i|
statement.execute("user_#{i}", i)
end... | true |
f75c112440a4ffe8c5aa84892d5b9c29527527e8 | Ruby | doches/rwordnet | /lib/rwordnet/pointer.rb | UTF-8 | 1,176 | 3.421875 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | module WordNet
# Pointers represent the relations between the words in one synset and another.
class Pointer
# The symbol that devices the relationship this pointer represents, e.g. "!" for verb antonym. Valid
# pointer symbols are defined in pointers.rb
attr_reader :symbol
# The offset, in bytes, ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.