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
bf62ee4e7462df535d6cc9db1716d8830a1454b3
Ruby
yuqiqian/ruby-leetcode
/99_recovery_BST.rb
UTF-8
938
3.375
3
[]
no_license
# Definition for a binary tree node. # class TreeNode # attr_accessor :val, :left, :right # def initialize(val) # @val = val # @left, @right = nil, nil # end # end # @param {TreeNode} root # @return {Void} Do not return anything, modify root in-place instead. def recover_tree(root) return ...
true
f5bbea828c7159111eb5cf2c2aabba643a7b1366
Ruby
mount986/advent-of-code
/2017/bin/day_6/memory_reallocation.rb
UTF-8
421
2.8125
3
[]
no_license
require './lib/advent_of_code' memory_allocation = File.read('bin/day_6/memory_reallocation.dat').strip.split("\t").map{|val| val.to_i} memory_history = Array.new count = 0 until memory_history.include? memory_allocation memory_history.push memory_allocation.clone AdventOfCode.reallocate_memory!(memory_allocatio...
true
e6034efc6527c6aa605f47fa398b5cfa616ab8ca
Ruby
department-of-veterans-affairs/va.gov-team
/scripts/migrate.rb
UTF-8
2,851
2.890625
3
[]
no_license
#!/usr/bin/env ruby require 'csv' require 'pry' # Usage ./scripts/migrate.sh FILE.csv exit unless ARGV[0] class SourceContent attr_reader :path, :ext, :full_path, :name, :url, :copy_path CONTENT_URL = "https://github.com/department-of-veterans-affairs/vets.gov-team/blob/master" REPO_PATH = "../vets.gov-...
true
95869c2905f8f1503b70d552096ba0b6e1053fe2
Ruby
asharbitz/runjs
/test/encoding_test.rb
UTF-8
1,092
2.53125
3
[ "MIT" ]
permissive
# encoding: UTF-8 require 'test_helper' describe 'encoding' do it 'handles UTF-8 characters' do skip if RunJS.runtime == RunJS::SpiderMonkey # SpiderMonkey does not support UTF-8 upcase = RunJS.run('return "ꝏå@ø\ua74f".toUpperCase();') if [RunJS::JScript, RunJS::TheRubyRhino].include?(RunJS.runtime) ...
true
f476b12e223d29f763254142f6926010e2dc7299
Ruby
ncaron/Launch-School
/Courses/Programming and Back-end Development/101 - Programming Foundations/Lesson 3 - Exercises/easy_1/question_4.rb
UTF-8
670
4.625
5
[]
no_license
############## # Question 4 # ############## # The Ruby Array class has several methods for removing items from the array. # Two of them have very similar names. Let's see how they differ: # # ``` # numbers = [1, 2, 3, 4, 5] # ``` # # What do the following method calls do (assume we reset numbers to the original array...
true
17273f550cf23fe9e26f665271d659ee3438eb59
Ruby
princelab/rubabel
/lib/rubabel/molecule_data.rb
UTF-8
1,978
3.09375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'openbabel' module Rubabel # A hash-like interface for dealing with tag data in molecules inspired by # the MoleculeData implementation in pybel. This does not actually hash the # data, it just reads it from the OBMol object each time and acts like a # hash. class MoleculeData include Enumerable...
true
0b06277e561c741c3f7932f33913adc7f6c498ef
Ruby
jimlindstrom/InteractiveMidiImproviser
/improv/specs/note_generator_spec.rb
UTF-8
1,790
2.765625
3
[]
no_license
#!/usr/bin/env ruby require 'spec_helper' describe NoteGenerator do before(:each) do m = Music::Meter.new(3, 4, 1) @notes = Music::NoteQueue.new n = Music::Note.new(Music::Pitch.new(50), Music::Duration.new(1)) n.analysis[:beat_position] = m.initial_beat_position @notes.push n n = Music:...
true
8152bf91bc8859b823e7394288425d2d3de59173
Ruby
matthewd/do
/do_oracle/lib/oci8_patch.rb
UTF-8
1,473
2.53125
3
[ "MIT" ]
permissive
class OCI8 module BindType module Util # :nodoc: # store default offset without DST @@time_offset = ::Time.now.utc_offset @@datetime_offset = ::DateTime.now.offset if ::Time.now.dst? @@time_offset -= 3600 @@datetime_offset -= Rational(1,24) end # support just ...
true
6bbea79bf5221b2d136224ed2133db33f107f04e
Ruby
inasacu/thepista
/httparty/ruby/1.9.1/gems/geokit-1.8.4/lib/geokit/geocoders/maxmind.rb
UTF-8
721
2.84375
3
[ "MIT" ]
permissive
module Geokit module Geocoders # Provides geocoding based upon an IP address. The underlying web service is MaxMind class MaxmindGeocoder < Geocoder config :geoip_data_path # path to GeoLiteCity.dat private def self.do_geocode(ip) res = GeoIP.new(geoip_data_path).city(ip) ...
true
56f6c86f2ab9aae74feeb2f9e8d48cc6a1a473a2
Ruby
dillon-co/peer60_practice
/tail_call_fib.rb
UTF-8
455
3.078125
3
[]
no_license
RubyVM::InstructionSequence.compile_option = { tailcall_optimization: true, trace_instruction: false } RubyVM::InstructionSequence.new(<<-STRING).eval def fib(n, curr=1, prev=0) if n<=1 curr else fib(n-1, (curr+prev), curr) end end num = gets.chomp.to_i p fib(num) STRING def crap_fib(n) if n...
true
92fa6001397772b92020148ed07cbbc150a308f5
Ruby
gomorpheus/morpheus-cli
/lib/morpheus/cli/expression_parser.rb
UTF-8
5,785
3.4375
3
[ "MIT" ]
permissive
require 'shellwords' # Provides parsing of user input into an Array of expressions for execution # Syntax currently supports the && and || operators, and the use of parenthesis # returns an Array of objects. # Each object might be a command (String), an operator (well known String) # or another expression (Array) mod...
true
8f8d2e2ec90831ba13f62637bfe8bfb442014d16
Ruby
mmorelo/ruby
/split.rb
UTF-8
290
3
3
[]
no_license
# Get the file as a command line argument ARGV.each do |a| # open file and parse lines File.open(a).each do |line| #split the lines with two delimiters, / and : path = line.split(/[\/,:]/) # select the files with cpp extension. path = path.select{|e| e =~ /\.cpp$/} puts path end end
true
f265a2496d3d6a0f6807f1d9c97e47ee396d5573
Ruby
edgcastillo/Programming_Challenges
/Coderbyte/Powers_Two[EASY].rb
UTF-8
369
3.96875
4
[]
no_license
#take num parameter being passed which will be an integer and return true if #it's a power of two. if it's not return false def powersOfTwo(num) return false if(num % 2 != 0) return true if( num / 2 == 1) powersOfTwo(num / 2) end p powersOfTwo(124) #false p powersOfTwo(16) #true p powersOfTwo(22) #false p powersO...
true
8284c4ed79950e666f4cd700ab022505939bc52f
Ruby
EcksZA/cd_organizer
/cd_organizer.rb
UTF-8
2,052
3.359375
3
[]
no_license
require './lib/cd_album' require './lib/cd_artist' def cd_organizer puts "Please select from the following options" puts "Press 'a' to add artist, 'l' to list artists or 'x' to exit" user_selection = gets.chomp if user_selection == 'a' add_artist elsif user_selection == 'l' list_artists elsif user_...
true
e7fe96425fd50582514508fe443044310a6332e3
Ruby
joanwolk/yodawg
/yodawg.rb
UTF-8
1,065
3.828125
4
[]
no_license
require 'rubygems' require 'sinatra' require 'linguistics' Linguistics::use( :en ) # Stick a user-chosen word into a famously ridiculous sentence. def yodawg(noun, verb=nil) if !verb verb=noun end "Yo dawg, I heard you liked #{noun.en.plural}, so I put #{noun.en.a} in your #{noun} so you can #{verb} while you #{...
true
e9b4310b536c5abe9fb92b3ff7fa6a4aade81a5f
Ruby
taakuuyaa/touchup
/app/models/video_capacity.rb
UTF-8
300
2.59375
3
[]
no_license
class VideoCapacity < ApplicationRecord belongs_to :video def self.get_monthly_capacity now = Time.zone.now target_month = Range.new( now.beginning_of_month, now.end_of_month ) VideoCapacity.where(created_at: target_month).sum(:capacity) / 1.gigabyte end end
true
10a1cc4bd6e67db645783b13b03146d43f68826c
Ruby
roylez/rtc
/cli.rb
UTF-8
13,063
2.6875
3
[]
no_license
#!/usr/bin/env ruby #Author: Roy L Zuo (roylzuo at gmail dot com) #Last Change: Tue Jun 09 16:41:58 2009 EST #Description: # This scripts emulates rtm's twitter IM commands. For more information, # go to http://www.rememberthemilk.com/services/twitter/ . # require 'api.rb' require 'time' require 'config.rb...
true
0ab6088afa699bfaf0ff4108c519d129198ebfe4
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/hamming/89a4848a20914815879480835fc64dbc.rb
UTF-8
203
3.1875
3
[]
no_license
class Hamming def self.compute str1,str2 min_length = [str1.length,str2.length].min count = 0 min_length.times do |n| count+=1 unless str1[n] == str2[n] end count end end
true
974b344ad3c7b64ac49954915b52ce25c81e708e
Ruby
bvluong/Chess
/chess/pieces/nullpiece.rb
UTF-8
301
3
3
[]
no_license
require_relative "piece" require "colorized_string" require "singleton" class NullPiece < Piece include Singleton def initialize(color = :yellow) @color = color end def to_s ColorizedString.new(" ").yellow end def empty? true end def moves(pos,board) [] end end
true
80a940658bd75f8b9f27b4899d300f6697c8172c
Ruby
lbrian357/linked_list
/linked_list.rb
UTF-8
1,756
3.734375
4
[]
no_license
class Node attr_accessor :value, :next_node def initialize(value = nil, next_node = nil) @value = value @next_node = next_node end end class LinkedList def initialize @head = Node.new('head') end def append(data) a_node = Node.new(data) tail.next_node = a_node end def prepend(dat...
true
9f1a3459ece70d26411dfdc6450538a1de1fe940
Ruby
Santiag0C/backend_prework
/day_7/10_little_monkeysIF.rb
UTF-8
3,223
3.953125
4
[]
no_license
print "how many monkey jumping on the bed would you like: " x = gets.chomp #monkeys = ["one", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"] #monkeys[2] i = x if x == "0" puts "there is not monkeys :(" elsif x == "1" puts "----------------------------------------" puts "One little...
true
0710a1cec6504eed620adc40283b64dbc796b898
Ruby
pho1n1x/codewars
/ruby/7kyu/squeaky_window/solution.rb
UTF-8
92
2.890625
3
[ "MIT" ]
permissive
def sliding (nums, k) return [] if nums.empty? || k < 0 nums.each_cons(k).map(&:max) end
true
0d0a9b131063854e072b3e56029079904c000f06
Ruby
EricLarson2020/paired_adopt_dont_shop_2003
/spec/models/shelter_spec.rb
UTF-8
3,996
2.796875
3
[]
no_license
require 'rails_helper' describe Shelter, type: :model do describe "validations" do it { should validate_presence_of :name } it { should validate_presence_of :address } it { should validate_presence_of :city } it { should validate_presence_of :state } it { should validate_presence_of :zip } end ...
true
533cb2581600f2e27de17e12a4129ff8182c048e
Ruby
ramakrishna409/hotel_automation
/spec/models/corridor_spec.rb
UTF-8
1,579
2.703125
3
[]
no_license
require 'spec_helper' RSpec.describe Corridor do describe "#power_consumption" do hotel = Hotel.new(2, 2, 2) floor = Floor.new(2, 2, hotel) corridor = Corridor.new('main', floor) it "should respond to power_consumption" do expect(corridor.respond_to?(:power_consumption)).to be_truthy...
true
38e765cf8cbd5ef6be1b298b357e058d8f079400
Ruby
marcomoura/code_challenge-order_calculator
/lib/order_calculator/discount.rb
UTF-8
528
3.3125
3
[]
no_license
module OrderCalculator class Discount def self.apply(value, quantity) new(value, quantity).apply end def initialize(value, quantity) @quantity = quantity @value = value end def apply return 0.0 if @quantity.eql? 1 @value * discount end private def disc...
true
8044fb00b71b5425b76b0ec9554725b3842e4706
Ruby
phylor/sokoban
/header.rb
UTF-8
574
2.75
3
[]
no_license
class Header HEIGHT = 50 def initialize(player, level) @player = player @level = level @phone = Gosu::Image.new('assets/phone.png') end def draw @player.undos.times do |index| @phone.draw(10 + index * 25, 10, 1, 0.4, 0.4) end Fonts[:normal].draw_text('[u] undo', 10 + @player.un...
true
d5631710cc11372ec570fa875954912f9c63bdd3
Ruby
jamesarosen/rcal
/lib/rcal/util/pluralize.rb
UTF-8
464
3.546875
4
[]
no_license
unless ''.respond_to?(:pluralize) class String # Trivial pluralization defined only if no other exists; adds 's' unless # the String already ends in 's'. def pluralize self[-1] == 's'[0] ? self.dup : "#{self}s" end # Trivial singularization defined only if no other exists; removes 's' ...
true
e026013cbc3b5c5ddc018a78076af7d52f99cd5c
Ruby
alishersadikov/headcount
/lib/district.rb
UTF-8
461
2.546875
3
[]
no_license
class District attr_reader :name, :district_repo def initialize(district_data, district_repo = nil) @name = district_data[:name].upcase @district_repo = district_repo end def enrollment district_repo.link_enrollments_to_districts(name) end def statewide_test district_rep...
true
1edb32d6a33be43646657de1e88c0c5ec83aa894
Ruby
florapetersen/ruby-collaborating-objects-lab-onl01-seng-pt-052620
/lib/artist.rb
UTF-8
1,862
3.90625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Artist attr_accessor :name, :songs @@all = [] #stores all instances of Artist def initialize(name) #initializes new instance of Artist class @name = name #sets name of artist to instance variable save #calls save method end def self.all #method operates on Artist class @@all #returns clas...
true
019cfb9c2e2be7967aeb0d77626e12d61a646447
Ruby
uemura-15/slotremake
/slot.rb
UTF-8
3,903
3.640625
4
[]
no_license
require 'io/console' # 端末上の入出力を制御する機能を IO に追加 # 基本的な入出力機能のクラス def slot_start() puts ("メダルを入れてください") puts ("1(1メダル) 2(5メダル) 3(10メダル) 4(退出)") bet = gets.chomp.to_i if bet == 1 bet_coin = 1 elsif bet == 2 bet_coin = 5 elsif bet == 3 bet_coin = 10 elsif bet == 4 ...
true
62fc40a8baef70508bb545088244124f433abc08
Ruby
philjdelong/backend_module_0_capstone
/day_6/exercises/person.rb
UTF-8
1,052
4.34375
4
[]
no_license
# Create a person class with at least 2 attributes and 2 behaviors. Call all # person methods below the class so that they print their result to the # terminal. #YOUR CODE HERE class Person attr_reader :name, :pronouns, :current_program, :age, :favorite_color, :happy def initialize(name, pronouns, current_progra...
true
0a2da4eaff4e3e42d603a9e2c29d6406a295ce7d
Ruby
mcull/P12
/app/lib/amazon_feed_manager.rb
UTF-8
1,885
2.53125
3
[]
no_license
require 'peddler' class AmazonFeedManager MESS = "SYSTEM ERROR: method missing" def get_template; raise MESS; end def get_parent_line(product,upc); raise MESS; end def get_child_line(product,upc,color,size); raise MESS; end def update_feed(product) #get the upc codes for this product upc_code...
true
adf0a7a0f5ae94e6d139ee7235985e1d21f2fe7f
Ruby
mbigman/ruby-intro-to-hashes-lab
/spec/my_first_hash_spec.rb
UTF-8
1,234
3.359375
3
[]
no_license
require_relative 'spec_helper' require_relative '../my_first_hash.rb' context "Challenge I: Instantiating Hashes" do describe "#my_hash" do it "uses the literal constructor to create a hash that contains key/value pairs" do expect(my_hash).to be_a(Hash) expect(my_hash.keys.count).to_not eq(0) e...
true
dea12ebf74a1bca65c311427834b08e4e3d36cfb
Ruby
justonemorecommit/puppet
/lib/puppet/pops/types/type_acceptor.rb
UTF-8
740
2.796875
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
module Puppet::Pops module Types # Implements a standard visitor patter for the Puppet Type system. # # An instance of this module is passed as an argument to the {PAnyType#accept} # method of a Type instance. That type will then use the {TypeAcceptor#visit} callback # on the acceptor and then pass the acceptor to the...
true
860c5560ed223b78c9c98e28575cb3ba37053abb
Ruby
ryanyogan/rubinius
/kernel/common/class.rb
UTF-8
546
2.984375
3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# -*- encoding: us-ascii -*- class Class ## # Specialized initialize_copy because Class needs additional protection def initialize_copy(other) # The code in super (Module#initialize_copy) will duplicate # the method table. Therefore do this check here to see whether # we've already initialized this ...
true
c5a5ca0effe419178f8ea963d0977a5e8ad48892
Ruby
alexch/deep-test
/lib/deep_test/null_worker_listener.rb
UTF-8
2,222
2.78125
3
[ "Ruby" ]
permissive
module DeepTest # # Listener that implements no-ops for all callbacks that DeepTest supports. # class NullWorkerListener # # Before DeepTest synchronizes any code during a distributed run, # before_sync is called. If DeepTest is not running distributed, # before_sync is never called. # ...
true
9f1ccf7dcb836741ed8f95888ae40b0ce695e0a1
Ruby
charlesbjohnson/super_happy_interview_time
/rb/lib/algorithms/substring_search/rabin_karp_search.rb
UTF-8
479
2.875
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Algorithms module SubstringSearch module RabinKarpSearch class << self def search(string, substring) i = 0 while i <= string.length - substring.length if string[i...(i + substring.length)].hash == substring.hash ret...
true
3823be510539105084999e9a90a9438582958644
Ruby
ShubhamGupta/Ruby_track
/Ex4.rb
UTF-8
210
3.625
4
[]
no_license
loop do puts "Please enter a string.(Press q/Q to exit)\n" str = gets.chomp.downcase break if str == 'q' if str==str.reverse puts "It's a pallindrome" else puts "Not a pallindrome" end end
true
614ed7815f6f7dc5a7eecfbb418e7b3319f5a60b
Ruby
jhchabran/ratp
/lib/ratp/position.rb
UTF-8
452
2.890625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
module Ratp class Position attr_accessor :location, :type def initialize location, type @location, @type = location, type end def type_as_radio_value Position.types_as_radio_values[type] end def self.types types_as_radio_values.keys end def self.types_...
true
c48e41a783824ebbeb6bb4a3bf4a211f021bbc87
Ruby
stulentsev/drebedengi-rb
/lib/drebedengi/responses/get_balance.rb
UTF-8
520
2.546875
3
[]
no_license
require 'ostruct' module Responses class GetBalance < ::Responses::Base attr_reader :places def initialize(soap_hash) @places = process(soap_hash) end private def process(soap_hash) soap_hash[:get_balance_response][:get_balance_return][:item].map do |hash| hash[:item].each_...
true
70d5663ae5898901d486314bd12dc31c632d95c5
Ruby
jubishop/rlranks
/spec/rlranks_spec.rb
UTF-8
1,711
3.015625
3
[ "MIT" ]
permissive
require 'rlranks' RSpec.describe(RLRanks) { it('is unranked when no ranks') { ranks = RLRanks.new(1, 'account') expect(ranks.unranked?).to(be(true)) } it('stores your platform or defaults to :steam') { ranks = RLRanks.new(1, 'account') expect(ranks.platform).to(eq(:steam)) ranks = RLRanks.n...
true
4db49fe9fb7ca745395e1ca8e68ac9b153c3d4dc
Ruby
seydar/chitin
/lib/chitin/sandbox.rb
UTF-8
355
2.640625
3
[ "BSD-2-Clause" ]
permissive
module Chitin class Sandbox attr_reader :previous def initialize @binding = binding @previous = nil end def inspect "(sandbox)" end def evaluate(code) self.previous = eval code, @binding end def previous=(val) @previous = val eval "_ = @prev...
true
8ef6da9086d2d83ae2e15999bb1c656f0302d54b
Ruby
devinsiphone/LS100
/intro_to_programming_with_ruby/09_more_stuff/exercise1.rb
UTF-8
373
3.90625
4
[]
no_license
# Write a program that checks if the sequence of characters "lab" exists in the # following strings. If it does exist, print out the word. # # "laboratory" # "experiment" # "Pans Labyrinth" # "elaborate" # "polar bear" words = ["laboratory", "experiment", "Pans Labyrinth", "elaborate", "polar bear"] words.each{ |word...
true
444667e8e6ce6afb17f9e311b8ca1d2dba41abae
Ruby
0000marcell/db-algorithms
/print.rb
UTF-8
271
2.859375
3
[]
no_license
require 'table_print' def print_table(table, keys) rows = [] table.each do |k, v| v.each_with_index do |item, index| if rows[index] rows[index].merge!({k => item}) else rows << {k => item} end end end tp rows, keys end
true
6f5eb9930b6243e2d6bc5b36c4cac3197310c2dc
Ruby
NB28VT/despecable
/lib/despecable/errors/despecable_error.rb
UTF-8
365
2.609375
3
[]
no_license
class Despecable::DespecableError < StandardError def despecable_message message == self.class.to_s ? nil : message end def insert_name_here(name) msg = introduction(name) msg += " " + despecable_message unless despecable_message.nil? return exception(msg) end def introduction(name) "Inv...
true
ff51878626504df7bf62109810fe6a603745000d
Ruby
staskie/api_app
/app/models/credential.rb
UTF-8
373
2.515625
3
[]
no_license
class Credential < ActiveRecord::Base attr_accessible :secret_token, :uuid validates_presence_of :secret_token, :uuid validates_uniqueness_of :uuid def self.authenticated?(uuid, secret_token) uuid_secret_token_pair = where(:uuid => uuid, :secret_token => secret_token).first uuid && secret_token && uuid...
true
0fe4b79ebff7a6b7b13a823d84736b25a412c970
Ruby
aherve/Euler
/ruby/pb64.rb
UTF-8
1,548
3.515625
4
[]
no_license
#!/usr/bin/env ruby require 'prime' class Frac # x = (a + sqrt(b))/c attr_accessor :a, :b, :c def initialize(a,b,c) @a = a @b = b @c = c end def inv Frac.new(-1*a*c, b*c*c, (b - (a**2))).simplify end def add(i) Frac.new(a + (c*i), b, c).simplify end def sub(i) add(-i) en...
true
bec715a08d00ded075684d9fd53727e04686ff38
Ruby
eth-ivan/rent-my-tie
/scripts/rename_ties.rb
UTF-8
420
2.8125
3
[]
no_license
require "faker" images_path = File.expand_path("..", Dir.pwd) + "/app/assets/images/one_hundred_ties" puts "Renaming files..." colors = %w[Red Blue Yellow Orange Black White Green Violet Indigo] Dir.glob(images_path + "/*").each do |file| name = Faker::Artist.name + " " + colors.shuffle.first new_file = images_...
true
ad19a1fb6b93dae14228a01b7fe7c9c47fc5b667
Ruby
nickcharlton/github
/update_issue_labels.rb
UTF-8
622
2.640625
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby # update_issues: For a CSV of issue numbers and labels, set to the new values # # This expects a CSV that looks like: `100,label-one,label-two,`, # the empty value at the end will be stripped out. # # Notably, this replaces all of the labels, removing any which are already # there. require "octokit...
true
86ba9a79780516cfefe98bca07eb2ab13153e90b
Ruby
rusdec/simpler
/middleware/app_logger.rb
UTF-8
1,000
2.578125
3
[]
no_license
require 'logger' module Middleware class AppLogger def initialize(app) @logger = Logger.new(Simpler.root.join('log/app.log')) @app = app end def call(env) status, headers, body = @app.call(env) log_data(env, status, headers) [status, headers, body] end priva...
true
346f2c73819806ac2ff897d8e9e249572d74cf1a
Ruby
dsun12345/badges-and-schedules-onl01-seng-pt-012120
/conference_badges.rb
UTF-8
596
3.546875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
list = ["Edsger", "Ada", 'Charles', 'Alan', 'Grace', 'Linus', 'Matz'] def badge_maker(name) badge = "Hello, my name is #{name}." return badge end def batch_badge_creator(attendees) badge=[] attendees.each {|i| badge << "Hello, my name is #{i}."} return badge end def assign_rooms(attendees) room_assignmen...
true
4b95735d53b8b4388fc9e8340b666f977324f62b
Ruby
SaulGoodman4013/Ruby-Ciclos-y-metodos
/cuenta_regresiva.rb
UTF-8
265
3.203125
3
[]
no_license
## Desafio cuenta regresiva, ciclos y metodos ## puts 'Ingrese un número para comenzar la cuenta:' cuenta_regresiva = ARGV[0].to_i puts "Contando desde #{cuenta_regresiva}..." while cuenta_regresiva >= 0 puts cuenta_regresiva cuenta_regresiva -= 1 end
true
aad46686606549f187abda4e67c98b42868cc91d
Ruby
SchmuhlFace/phase-0-tracks
/ruby/hashes.rb
UTF-8
2,922
4.125
4
[]
no_license
#Interior D- Zign Program by SchmuhlFace #Setup methods with questions to retrieve data and store in appropriate and varied values. #Store client's responses and print hash. #Ask user if they'd like to update any of their stored responses. #Update stored responses to appropriate values. #If the user doesn't want to up...
true
220ea92b19bd6b48fb5d58ebfcfd1c9d7d184c71
Ruby
schacon/cucumber
/spec/cucumber/step_mother_spec.rb
UTF-8
9,273
2.546875
3
[ "MIT" ]
permissive
require File.dirname(__FILE__) + '/../spec_helper' require 'cucumber' require 'cucumber/rb_support/rb_language' module Cucumber describe StepMother do before do @dsl = Object.new @dsl.extend(RbSupport::RbDsl) @step_mother = StepMother.new @step_mother.load_natural_language('en') @...
true
9992185c4c88c41488dcf27da5c02854fd484730
Ruby
DMscotifer/wk2_day1_homework
/partAhomework.rb
UTF-8
442
3.25
3
[]
no_license
class Student attr_accessor :name, :cohort def initialize(name, cohort) @name = name @cohort = cohort end def return_name() return @name end def return_cohort() return @cohort end def set_name(name) @name = name end def set_cohort(cohort) @cohort = cohort end def st...
true
41a4ca3cbccc48c352bc45d42de49e74df85026a
Ruby
SputterPuttRedux/sinatra-mvc-skeleton
/app/helpers/auth.rb
UTF-8
927
2.875
3
[]
no_license
def current_user if session[:user_id] return User.find(session[:user_id]) else return nil end end def temp_username current_user.email.gsub(/@\w+.\w+/, "") end def date_display(date) date.strftime('%b %-d, %Y, %l:%M:%S %P') end def note_timestamp(note) note.created_at == note.updated_at ? "Create...
true
3026fd591ad6a94e42547202b785f6539a0b00e5
Ruby
attack/weather_object
/spec/acceptance/historical_spec.rb
UTF-8
270
2.5625
3
[ "MIT" ]
permissive
require 'weather_object' RSpec.describe 'Historical weather data' do it 'holds historical weather data' do weather = WeatherObject.new weather.add_history( temperature: 20 ) expect(weather.history.first.temperature.to_s).to eq '20 C' end end
true
7a8520ec7a71c20337346957b4f317c73844a412
Ruby
taylorthurlow/redacted_better
/lib/redacted_better/upload_wizard.rb
UTF-8
10,304
2.625
3
[]
no_license
require "marcel" require "pathname" module RedactedBetter class UploadWizard # @return [Pathname] the absolute path to either a single file (in the case # of a single-file torrent) or the top-level torrent directory attr_reader :path # @return [Config] attr_reader :config # @return [Array...
true
45991b34bc8aa909feb20f7f3411286cc61e249b
Ruby
davidmorton0/snakesandladders
/interface.rb
UTF-8
6,519
3.296875
3
[]
no_license
require './config' BOARD_CONFIG = Config::BOARD_CONFIG class Counter < Circle attr_accessor :destinations, :last_pos_x, :last_pos_y, :moving, :new_pos_x, :new_pos_y, :speed end class GameBoard attr_accessor :buttons, :counters, :labels, :message, :moving_counters, :players, :square_height, :square_width def in...
true
05cd5a3033a826f47d23658c92c255294bcb4a2b
Ruby
da99/megauni.ruby
/middleware/Mu_Archive.rb
UTF-8
889
2.515625
3
[ "MIT" ]
permissive
require 'mustache' def Mu_Archive_Read path_info, vals = Hash[] content = File.read( Mu_Archive path_info ) Mustache.raise_on_context_miss = true Mustache.render( content, vals ) end class Mu_Archive Perma = 301 Public_Dir = 'Public/busy-noise' def initialize new_app @app = new_app end def cal...
true
8b3646494429bea4bcd9e0fec49abcf2e4cd47e0
Ruby
IFilonov/Ruby_basics
/9_lesson/passenger_wagon.rb
UTF-8
297
2.796875
3
[]
no_license
require_relative 'wagon' class PassengerWagon < Wagon PASSENGER_TYPE = :passenger def initialize(place, number) @type = PASSENGER_TYPE super(place, number) end def cargo? false end def occupy_place(_place) super(1) end def self.place_str 'seats' end end
true
be5cf38d326a52cb09d9b403c12af831a3431f78
Ruby
idegn/playground
/euler/51_better.rb
UTF-8
1,325
3.078125
3
[]
no_license
require 'stackprof' require 'prime' StackProf.run(out: "/tmp/profile.dump") do def family_size(j, pattern) count = 1 (j+1..9).each do |i| tmp = pattern.map {|d| d == true ? i : d }.join.to_i count += 1 if Prime.prime? tmp end count end def fill_pattern(pattern, repeate, norepeate) ...
true
4bea43922c0740c1c06aa5c65e02f93fb00ad69f
Ruby
songkick/rubium-ios
/spec/ui_automation/element_array_spec.rb
UTF-8
7,213
2.59375
3
[ "MIT" ]
permissive
require 'spec_helper' describe UIAutomation::ElementArray do let(:executor) { double } let(:parent) { double } let(:window) { double } subject { UIAutomation::ElementArray.new(executor, 'SomeClass.someArray()', UIAutomation::Element, parent, window) } it "returns element proxies of type UIAutomation::Ele...
true
aa1ad16783bb63a6f3f1e851575f74facd2559ab
Ruby
LNA/sinatra_ttt
/app.rb
UTF-8
3,326
2.671875
3
[]
no_license
$: << File.expand_path(File.dirname(__FILE__)) + '/lib' Dir[File.dirname(__FILE__) + '/lib/models/*.rb'].each {|file| require file } require 'sinatra' require 'ai' require 'board' require 'game_rules' require 'game' require 'web_game_settings' require 'web_game_store' require 'pry' configure do enable :sessions s...
true
4d6e618974cd00987a96dd863b997eebca2c81d6
Ruby
ress/stripe-ruby-mock
/spec/util_spec.rb
UTF-8
1,488
2.640625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require 'spec_helper' describe StripeMock::Util do it "recursively merges a simple hash" do dest = { x: { y: 50 }, a: 5, b: 3 } source = { x: { y: 999 }, a: 77 } result = StripeMock::Util.rmerge(dest, source) expect(result).to eq({ x: { y: 999 }, a: 77, b: 3 }) end it "recursively merges a nes...
true
e52a1df9ef7f9663901f02c01b3d45544dc75f32
Ruby
victortyau/CodeEval
/Unique Elements/unique_elements.rb
UTF-8
411
3.4375
3
[]
no_license
class UniqueElements def initialize @lines = "" fetch_data() end def fetch_data file_name = ARGV[0] if File.exist?(file_name) @lines = IO.readlines(file_name); end end def unique_elements @lines.each do |line| array_char = line.delete!("\n").split(",") array_char = array_char.uni...
true
5addda1560e80a2216bbf440b76059e9ccd6c9ad
Ruby
FundacionBlockchainChile/Ruby_Simple_Exercises
/practica_modulos/mi_Own_Methods.rb
UTF-8
1,370
3.84375
4
[]
no_license
require 'date' module MiEnumerable def mi_each & block for i in 0...self.length block.call(self[i]) end end def getSquares() for i in 0...self.length self[i] = self[i] * self[i] end return self end def returnLengths() for i in 0...self.length self[i] = self[i].len...
true
a386a17efea35c3f8d911b984c21004ba45d5aff
Ruby
Trankalinos/asg1_7005
/RubyServer/server.rb
UTF-8
1,002
2.890625
3
[]
no_license
# Assignment 1 - TCP/IP Socket Programming Server # Version 1.2 # Author: Martin Javier # Co-Author: David Tran # Date: September 22nd, 2013 # Due Date: October 1st, 2013 require 'socket' include Socket::Constants SIZE = 1024 * 1024 * 10 # This class will send a binary or a text file over a TCP/IP connection between ...
true
ba3926235b6b3e1ed898b3e824621209433a78ea
Ruby
ash0411-maker/ruby-oriented-design
/chap2.rb
UTF-8
1,072
3.765625
4
[]
no_license
class Gear #チェーリングとコグ、比。 attr_reader :cahinring, :cog, :wheel def initialize(cahinring, cog, wheel=nil) @cahinring = cahinring @cog = cog @wheel = wheel end def ratio cahinring / cog.to_f end def gear_inches ratio * wheel.diameter end end class Wheel attr_reader :rim, :tire ...
true
c14362eae6c71b77afbb93b2aefa6fb8c0af4b1e
Ruby
JonathanFerreira/kazaplab-rspec
/spec/pilha_spec.rb
UTF-8
426
2.8125
3
[]
no_license
require 'spec_helper' require 'pilha' RSpec.describe Pilha do describe '#push' do it 'coloca elemento no topo da pilha' do pilha = Pilha.new pilha.push(1) pilha.push(2) expect(pilha.top).to eq(2) end end describe '#top' do it 'retorna o elemento no topo da pilha' do pil...
true
fa1b6b3c12df10f21d47b9aa7016867cd76a0195
Ruby
liukgg/ruby-kafka
/lib/kafka/message.rb
UTF-8
250
2.640625
3
[ "Apache-2.0" ]
permissive
module Kafka class Message attr_reader :value, :key, :topic, :partition def initialize(value, topic, key:, partition:) @value = value @topic = topic @key = key @partition = partition end end end
true
20446cd906f9747e8ee3a4911bc4c9bcb9c1834e
Ruby
knoxknox/ce250-course
/materials/15/pgm15_09.rb
UTF-8
264
2.953125
3
[]
no_license
# 09 class StraightSelectionSorter < Sorter def initialize super end def doSort i = @n while i > 1 max = 0 for j in 0 ... i max = j if @array[j] > @array[max] end swap(i - 1, max) i -= 1 end end end
true
e386d29da04e151bdbc83968fd3b2d80b57b50e9
Ruby
evserykh/toy_robot
/lib/command/matcher/place.rb
UTF-8
736
2.796875
3
[]
no_license
require File.expand_path('../../direction', __dir__) require File.expand_path('base', __dir__) module Command module Matcher class Place < Base attr_reader :directions def initialize(options) super @directions = options.fetch(:directions, Direction::VALUES) end def match...
true
2d4e2b47cd68b63ff61fafb8e32693767e3be8ea
Ruby
eduardodelcastillo/Learn_to_Program
/7.5DeafGrandma.rb
UTF-8
403
3.796875
4
[]
no_license
#7.5 Deaf Grandma bye_count = 0 puts 'HUH? SPEAK UP, SONNY!' while true input = gets.chomp if input == 'BYE' bye_count = bye_count + 1 if bye_count == 3 puts 'OH, BYE!' break else puts 'HUH? SPEAK UP, SONNY!' end elsif input == input.upcase year = rand(21) + 1930 puts...
true
e9a9194c77a78afbbfd07522e39ec1944bcfc5ec
Ruby
mockjv/git_stats
/lib/git_stats/core_extensions/enumerable.rb
UTF-8
166
2.921875
3
[ "MIT" ]
permissive
module Enumerable def first!(&block) matching = find(&block) if matching.nil? raise "Sequence contains no matching elements" else matching end end end
true
3125b8c5ff128eaa8cf5e049395d9726a5f198ad
Ruby
tschmidt/jplug
/lib/jquery.rb
UTF-8
2,589
2.609375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'jquery/fillers' class JQuery include Fillers attr_accessor :author_name, :extras, :install_dir, :project_name def initialize(opts) @author_name = opts[:author_name] @extras = opts[:extras] @project_name = opts[:unclaimed].first. gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-...
true
3e2700bde0ea834a8579dbf46690c9ab30745881
Ruby
fauxparse/advent2015
/1/1b.rb
UTF-8
190
3.203125
3
[]
no_license
#!/usr/bin/env ruby VALUES = { "(" => 1, ")" => -1 } floor = 0 $stdin.read.strip.chars .each.with_index(1) do |c, index| puts "\n#{index}" or break if (floor += VALUES[c]) < 0 end
true
8c5f6cd391f743a920469818760263d33bfb5595
Ruby
DianaM10/cx3_7
/Labs/week_2/day_4/pet_shop.rb
UTF-8
557
3.546875
4
[]
no_license
require_relative('pet') class PetShop def initialize (input_pets) @pets = input_pets end def pet_type(name) pet_with_name = @pets.find do |pet| pet.name() == name end return pet_with_name.type end def get_names_of_all_pets_of_type(type) pets_of_type = @pets.select do |pet| pet.t...
true
6378377f1301df7c20b18500f7a35bc403c92183
Ruby
mbj/rbi
/lib/rbi/rewriters/nest_non_public_methods.rb
UTF-8
1,491
2.59375
3
[ "MIT" ]
permissive
# typed: strict # frozen_string_literal: true module RBI module Rewriters class NestNonPublicMethods < Visitor extend T::Sig sig { override.params(node: T.nilable(Node)).void } def visit(node) return unless node case node when Tree public_group = VisibilityGr...
true
dc4931e532727c19ac622a99a40279e536a9a3ca
Ruby
kdbanman/marge
/sorter_io.rb
UTF-8
1,414
3.421875
3
[ "Apache-2.0" ]
permissive
require "./sorter" require "./sorter_io_contracts" require 'getoptlong' # Module for using parallelized sorter with file contents module SorterIO include SorterIOContracts def sort_file(filename, time, ascending) # preconditions isString filename fileExists filename fileReadable filename isIn...
true
4e58d9970f3402ecfd59493a31ce9d6db3028869
Ruby
quanlee/codecore
/day3/labs/lab4.rb
UTF-8
118
3.703125
4
[]
no_license
print "give me a sentence: " words = gets.chomp.split(" ") puts (words.map {|word| word.capitalize}).join puts words
true
1430fd1c9f9dcf39e6f5b3693388bdd30fbc86a1
Ruby
rryand/ruby_recursion
/fibs_rec.rb
UTF-8
168
3.578125
4
[]
no_license
def fibs_rec(num) return [0, 1][0..num - 1] if num == 1 || num == 2 fibs_rec(num - 1) << fibs_rec(num - 1)[-1] + fibs_rec(num - 2)[-1] end p fibs_rec(6).join(', ')
true
554fa5dadda2dc3ce44cde3fec4b76b3703bd34b
Ruby
Brian-Triplett/tts_wilmington
/samples/loop_examples.rb
UTF-8
654
4.34375
4
[]
no_license
# Another great example is at http://www.tutorialspoint.com/ruby/ruby_loops.htm size = 10 size.times do #do some things 'size' times end my_array = [1,2,3,4] my_array.each do |x| # go over each item in my_array # and let 'x' be the current item end array_1 = [1,2,3] array_2 = [4,5,6] for i in 0...array_1.l...
true
5d8f22e476f1f2339264549f2400f734a40a3a1e
Ruby
Haadsan/bears_river_fish
/specs/river_spec.rb
UTF-8
586
3.203125
3
[]
no_license
require('minitest/autorun') require('minitest/rg') require_relative('../river.rb') require_relative('../fish.rb') class RiverTest < MiniTest::Test def setup() @river = River.new("Zambizi", 10 ) @fish = Fish.new("Nemo") @fish2 = Fish.new("Nemee") @fish3 = Fish.new("Nemoo") @fishes = [@fish, @fi...
true
6f38bda8af555b8eabf28ac3ea07637949e2cdad
Ruby
lacuchilla/Languages
/lib/game.rb
UTF-8
5,218
3.140625
3
[]
no_license
module PlanetExpress class Game def initialize @bender = PlanetExpress::Bender.new(self) @fry = PlanetExpress::Fry.new(self) @hermes = PlanetExpress::Hermes.new(self) @leela = PlanetExpress::Leela.new(self) @zoidberg = PlanetExpress::Zoidberg.new(self) @stable = true end ...
true
8fd5521139598abb856a97304df41f0f185c0fbe
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/word-count/871ee1ee7a494bb992a12e7cb94c5bde.rb
UTF-8
216
3.46875
3
[]
no_license
class Phrase def initialize(phrase) @phrase = phrase end def word_count words = @phrase.downcase.scan(/[\w']+/) count = Hash.new(0) words.each do |word| count[word] += 1 end return count end end
true
f165bf58ca9ad34b73402069286ebcf80973ef9d
Ruby
phiggins/s2-e1
/lib/hangman/request_queue.rb
UTF-8
1,210
2.671875
3
[]
no_license
module Hangman class RequestQueue def next request = Mail.find(:count => 1) # Mail.find(:count=>1) returns either: # - an empty array if there are no messages, or # - a Mail::Request or somesuch unless request.respond_to?(:empty?) and request.empty? Request.new( RequestQueue...
true
d67baecb9f6f3d9c0e856a4a49bb6f7fb6caea76
Ruby
chylirk/Intro_to_Programming
/Intro_Exercises/Exercise_Four.rb
UTF-8
169
3.21875
3
[]
no_license
ex_four_array = [] (1..10).each { |num| ex_four_array.push(num) } ex_four_answer = ex_four_array << 11 ex_four_answer = ex_four_answer.unshift(0) puts ex_four_answer
true
399420523703d498497ae490985415b3d08f8129
Ruby
AR8Stefan/CFA-TrentTracker-Project
/TrentTracker.rb
UTF-8
2,025
2.921875
3
[]
no_license
require 'terminal-table' # require_relative 'trenttrackerlove' require_relative 'TrentTrackerGeo' # require_relative 'song' rows = [] rows << ['Where is Trent?', 1] rows << ['Make a Mix Tape', 2] rows << ['Love Letter', 3] @table1 = Terminal::Table.new :title => " \u2665 Trent Tracker \u2665 ", :headings => [...
true
b9a89c56413d0137ddd1e17ae0f33bd02367253c
Ruby
tehno6111/Data-Mining
/keywords/aggregate_popularity.rb
UTF-8
992
2.78125
3
[]
no_license
require '~/Data-Mining/lib/setup.rb' @db = DB.new('test') max_kp = {:k1=>2610000000, :k2=>3800000000, :k3=>495000000, :k4=>215000000} count = 0 def get_score(scores, max_kp) scaled_scores = {} [:k1, :k2, :k3, :k4].each do |key| scaled_scores[key] = scores[key.to_s].to_f * 93 / max_kp[key] end (scaled_sco...
true
27f2a129b826af81d9e71c0b42b1cb48a0ebd0d5
Ruby
barberj/sky_grid
/app.rb
UTF-8
836
2.59375
3
[]
no_license
require 'sinatra' require 'json' require 'faker' require 'slim' transactions = (1..27).inject([]) do |t, i| record = { "id" => i, "company" => Faker::Company.name, "first_name" => Faker::Name.first_name, "last_name" => Faker::Name.last_name, "email" => Faker::Internet.email, "amount" => Faker...
true
6a06b7906f6d4fdb5847ba8b72e96271bb9b2910
Ruby
frasermckayy/Week2weekendhw
/specs/room_spec.rb
UTF-8
1,756
3.46875
3
[]
no_license
require("minitest/autorun") require("minitest/rg") require_relative("../room.rb") require_relative("../guest.rb") require_relative("../song.rb") class RoomTest < MiniTest::Test def setup() @room = Room.new("The 90's", 4, 10) @guest = Guest.new("Fraser", 50, "Under Pressure") @guest1 = Guest.new("Amy",...
true
31070e221f50f5e2bd3f9e83649f5d987c7002be
Ruby
japial/hackerrank
/InterviewPreperationKit/Warm-up/jumping_clouds.rb
UTF-8
418
3.34375
3
[]
no_license
require 'json' require 'stringio' # Complete the jumpingOnClouds function below. def jumpingOnClouds(c) i = 0 jump = 0 while i < c.length-1 if i < c.length and c[i+2] != 1 jump += 1 i += 2 else jump += 1 i += 1 end end return jump end...
true
dfb69899ed0b88eea03519993d87de4a05717eaf
Ruby
lyolland-backup/green_grocer-london-web-060319
/grocer.rb
UTF-8
1,651
3.03125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require "pry" def consolidate_cart(cart) # code here new_hash = {} cart.each do |item| if new_hash.keys.include?(item.keys[0]) new_hash[item.keys[0]][:count] += 1 else new_hash[item.keys[0]] = item.values[0] new_hash[item.keys[0]][:count] = 1 end end new_hash end # consolidate_car...
true
ce3766bd8c3233099876bcf4d0c6d74c59431243
Ruby
edpackard/fizzbuzz
/spec/fizzbuzz_spec.rb
UTF-8
1,032
3.21875
3
[]
no_license
require 'fizzbuzz' describe 'fizzbuzz' do it 'returns "fizz" when passed 3' do expect(fizzbuzz(3)).to eq 'fizz' end end describe 'fizzbuzz' do it 'returns "buzz" when passed 5' do expect(fizzbuzz(5)).to eq 'buzz' end end describe 'fizzbuzz' do it 'returns "fizzbuzz" when passed 15' do expect(fi...
true
f304a889b536b0aa384766d4e4698bacc7e3d5b6
Ruby
engineyard/simplereactor
/lib/simplereactor.rb
UTF-8
2,489
2.984375
3
[ "MIT" ]
permissive
require 'timermap' class SimpleReactor VERSION = "1.0.2" Events = [:read, :write, :error].freeze attr_reader :ios def self.run &block reactor = self.new reactor.run &block end def initialize @running = false @ios = Hash.new do |h,k| h[k] = { :events => [], :ca...
true
df7225ddc6d8b1d3685c0c8fdb24399c50382b0c
Ruby
sophiez2628/rails_lite
/lib/phase7/flash.rb
UTF-8
717
2.53125
3
[]
no_license
module Phase7 class Flash attr_reader :flash, :flash_now def initialize(req) cookie = req.cookies.find { |cook| cook.name == '_rails_lite_app_flash'} if cookie @flash_now = JSON.parse(cookie.value) else @flash_now = {} end @flash = {} end def now ...
true
af950ac9056a0772d82cf97f07f8eb1965740732
Ruby
RemedyIT/fuzzr
/fuzzers/check_fileheader.rb
UTF-8
2,700
2.59375
3
[ "MIT" ]
permissive
# encoding: utf-8 # ------------------------------------------------------------------- # check_fileheader.rb - TAOX11 file header checker # # Author: Marcel Smit # # Copyright (c) Remedy IT Expertise BV # ------------------------------------------------------------------- module Fuzzers class TAOX11FileHeaderChecke...
true
b4af49d05800c9de6793b2ceb582a69d8d352046
Ruby
iobajwa/tinker
/package/content/lib/helpers/diff_results.rb
UTF-8
1,947
3.140625
3
[]
no_license
class DiffResult attr_accessor :memory_name, :memory_size, :diff_type, :base_name def initialize(memory_name, memory_size, diff_type) @memory_name = memory_name @memory_size = memory_size @diff_type = diff_type @base_name = 'base' end def hex_to_s(value, digits=4) return value == nil ? '' : sprintf...
true
c05e8e6220a17db8fa9734783c8ced8f0d90d5f2
Ruby
TheNaoX/modbus_tcp
/modbus.rb
UTF-8
471
2.859375
3
[ "MIT" ]
permissive
require 'rmodbus' # Establish Connection client = ModBus::TCPClient.connect('hi4050.hardysolutions.com', 502) # Get the first slave connection client.with_slave(1) do |slave| # Read input registers registers = slave.input_registers[0..16] # Get net weight and gross weight net_weight = registers.values_at(1...
true