Class: Emf::Model::Emr::Records::WireAdapter

Inherits:
Record
  • Object
show all
Defined in:
lib/emf/model/emr/records.rb

Overview

Adapter that wraps a bindata wire record so the Metafile container can hold domain-shape objects even for record types whose dedicated domain class hasn't been written yet (TODO 10). When a real domain class exists, the parser uses it instead.

wire is the parsed Emf::Emr::Binary::Records::* instance. offset is the byte offset within the source stream (for diagnostics).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wire:, offset: nil) ⇒ WireAdapter

Returns a new instance of WireAdapter.



17
18
19
20
# File 'lib/emf/model/emr/records.rb', line 17

def initialize(wire:, offset: nil)
  @wire = wire
  @offset = offset
end

Instance Attribute Details

#offsetObject (readonly)

Returns the value of attribute offset.



22
23
24
# File 'lib/emf/model/emr/records.rb', line 22

def offset
  @offset
end

#wireObject (readonly)

Returns the value of attribute wire.



22
23
24
# File 'lib/emf/model/emr/records.rb', line 22

def wire
  @wire
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



32
33
34
# File 'lib/emf/model/emr/records.rb', line 32

def ==(other)
  other.is_a?(self.class) && wire.to_binary_s == other.wire.to_binary_s
end

#accept(visitor) ⇒ Object



28
29
30
# File 'lib/emf/model/emr/records.rb', line 28

def accept(visitor)
  visitor.visit_emr_wire_record(self)
end

#hashObject



37
38
39
# File 'lib/emf/model/emr/records.rb', line 37

def hash
  [self.class, wire.to_binary_s].hash
end

#inspectObject



41
42
43
# File 'lib/emf/model/emr/records.rb', line 41

def inspect
  "#<#{self.class.name} type_id=#{type_id} (#{(@wire.class.name || '').split('::').last})>"
end

#type_idObject



24
25
26
# File 'lib/emf/model/emr/records.rb', line 24

def type_id
  @wire.i_type
end