class Snap7::DataBlockRegistry
Attributes
dbs[R]
Public Class Methods
new()
click to toggle source
# File lib/ffi-snap7/data_structures/data_block_registry.rb, line 6 def initialize @dbs = {} end
Public Instance Methods
add_variable(ident, address, data_type)
click to toggle source
# File lib/ffi-snap7/data_structures/data_block_registry.rb, line 11 def add_variable(ident, address, data_type) db_addr, _, var_addr = address.partition('.') var = Snap7::Variable.new ident, var_addr, data_type db(db_addr).add_variable var end
db(db_addr)
click to toggle source
# File lib/ffi-snap7/data_structures/data_block_registry.rb, line 28 def db(db_addr) @dbs[db_addr] ||= Snap7::DataBlock.new(db_addr) end
each(&block)
click to toggle source
# File lib/ffi-snap7/data_structures/data_block_registry.rb, line 33 def each(&block) sorted_dbs.each &block end
find_variable(ident)
click to toggle source
# File lib/ffi-snap7/data_structures/data_block_registry.rb, line 18 def find_variable(ident) each do |db| found_variable = db.variables.find { |var| var.ident == ident } return found_variable if found_variable end return nil end
sorted_dbs()
click to toggle source
# File lib/ffi-snap7/data_structures/data_block_registry.rb, line 38 def sorted_dbs @dbs.values.sort { |a,b| a.number <=> b.number } end