class Snap7::DataBlock
Attributes
number[R]
variables[R]
Public Class Methods
new(db_addr)
click to toggle source
# File lib/ffi-snap7/data_structures/data_block.rb, line 6 def initialize(db_addr) @number = db_addr.scan(/\d+/).first.to_i @variables = [] end
Public Instance Methods
add_variable(var)
click to toggle source
# File lib/ffi-snap7/data_structures/data_block.rb, line 12 def add_variable(var) var.db = self @variables << var end
decode(data)
click to toggle source
# File lib/ffi-snap7/data_structures/data_block.rb, line 24 def decode(data) @variables.map do |var| { :ident => var.ident, :address => var.address, :value => var.decode(data) } end end
size()
click to toggle source
# File lib/ffi-snap7/data_structures/data_block.rb, line 18 def size last_var = @variables.sort { |a,b| a.byte <=> b.byte }.last last_var.byte + last_var.byte_size end