Class: Nuntius::Envelope

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/nuntius/envelope.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Envelope

Returns a new instance of Envelope.



6
7
8
9
10
# File 'lib/nuntius/envelope.rb', line 6

def initialize(attributes)
  self.data      = attributes[:raw_data]      ? encode(attributes[:raw_data])      : attributes[:data]
  self.key       = attributes[:raw_key]       ? encode(attributes[:raw_key])       : attributes[:key]
  self.signature = attributes[:raw_signature] ? encode(attributes[:raw_signature]) : attributes[:signature]
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



4
5
6
# File 'lib/nuntius/envelope.rb', line 4

def data
  @data
end

#keyObject

Returns the value of attribute key.



4
5
6
# File 'lib/nuntius/envelope.rb', line 4

def key
  @key
end

#signatureObject

Returns the value of attribute signature.



4
5
6
# File 'lib/nuntius/envelope.rb', line 4

def signature
  @signature
end

Instance Method Details

#each(&block) ⇒ Object



32
33
34
# File 'lib/nuntius/envelope.rb', line 32

def each(&block)
  self.to_hash.each(&block)
end

#raw_dataObject



20
21
22
# File 'lib/nuntius/envelope.rb', line 20

def raw_data
  decode data
end

#raw_keyObject



24
25
26
# File 'lib/nuntius/envelope.rb', line 24

def raw_key
  decode key
end

#raw_signatureObject



28
29
30
# File 'lib/nuntius/envelope.rb', line 28

def raw_signature
  decode signature
end

#to_hashObject



12
13
14
15
16
17
18
# File 'lib/nuntius/envelope.rb', line 12

def to_hash
  {
    :data => data,
    :key => key,
    :signature => signature
  }
end