module HydroponicBean
Constants
- VERSION
Public Class Methods
add_connection(connection)
click to toggle source
# File lib/hydroponic_bean/data.rb, line 41 def self.add_connection(connection) connections.push(connection) end
clear()
click to toggle source
# File lib/hydroponic_bean/data.rb, line 7 def self.clear tubes.clear jobs.clear connections.clear commands.clear end
commands()
click to toggle source
Keep track of commands for stats
# File lib/hydroponic_bean/data.rb, line 50 def self.commands @commands ||= Hash.new{|h, k| h[k] = 0} end
connections()
click to toggle source
# File lib/hydroponic_bean/data.rb, line 37 def self.connections @connections ||= [] end
find_job(id)
click to toggle source
# File lib/hydroponic_bean/data.rb, line 18 def self.find_job(id) id = id.to_i if id == 0 return nil else job = jobs[id - 1] job&.update_time! return job end end
jobs()
click to toggle source
# File lib/hydroponic_bean/data.rb, line 29 def self.jobs @jobs ||= [] end
remove_connection(connection)
click to toggle source
# File lib/hydroponic_bean/data.rb, line 45 def self.remove_connection(connection) connections.delete(connection) end
tubes()
click to toggle source
# File lib/hydroponic_bean/data.rb, line 14 def self.tubes @tubes ||= Hash.new{|h, k| h[k] = Tube.new(k)} end
update_time!()
click to toggle source
# File lib/hydroponic_bean/data.rb, line 33 def self.update_time! jobs.each(&:update_time!) end
Public Instance Methods
establish_connection()
click to toggle source
# File lib/hydroponic_bean.rb, line 9 def establish_connection # Keep all variables initialized as if normal connection @address = address.first if address.is_a?(Array) match = address.split(':') @host, @port = match[0], Integer(match[1] || DEFAULT_PORT) @connection = Connection.new end