Class: SebElink::Message

Inherits:
Object
  • Object
show all
Includes:
Communications
Defined in:
lib/seb_elink/message.rb

Constant Summary collapse

SUPPORTED_VERSIONS =
["001"].freeze
SUPPORTED_MESSAGES =
["0002"].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gateway_instance, message_code, data_hash) ⇒ Message

Returns a new instance of Message.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/seb_elink/message.rb', line 9

def initialize(gateway_instance, message_code, data_hash)
  @gateway_instance = gateway_instance

  @message_code = message_code

  validate_message_code

  @data_hash = gateway_instance.defaults.
    merge(IB_SERVICE: @message_code).merge(data_hash)

  validate_version
end

Instance Attribute Details

#data_hashObject (readonly)

Returns the value of attribute data_hash.



7
8
9
# File 'lib/seb_elink/message.rb', line 7

def data_hash
  @data_hash
end

#gateway_instanceObject (readonly)

Returns the value of attribute gateway_instance.



7
8
9
# File 'lib/seb_elink/message.rb', line 7

def gateway_instance
  @gateway_instance
end

#message_codeObject (readonly)

Returns the value of attribute message_code.



7
8
9
# File 'lib/seb_elink/message.rb', line 7

def message_code
  @message_code
end

Instance Method Details

#digital_signatureObject



22
23
24
# File 'lib/seb_elink/message.rb', line 22

def digital_signature
  @digital_signature ||= to_h[:IB_CRC]
end

#to_hObject



26
27
28
# File 'lib/seb_elink/message.rb', line 26

def to_h
  @to_h ||= send("message_#{message_code}")
end