Class: Nfe::Information

Inherits:
Object
  • Object
show all
Defined in:
lib/nfe_reader/information.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Information

Returns a new instance of Information.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/nfe_reader/information.rb', line 7

def initialize(attrs = {})
  @information = attrs[:infAdFisco]
  @information_taxpayer = attrs[:infCpl]

  if attrs[:procRef]
    @references = to_array(attrs[:procRef])
  end

  if attrs[:obsCont]
    @taxpayer_messages = to_array(attrs[:obsCont])
  end

  if attrs[:obsFisco]
    @messages = to_array(attrs[:obsFisco])
  end
end

Instance Attribute Details

#informationObject (readonly)

Returns the value of attribute information.



4
5
6
# File 'lib/nfe_reader/information.rb', line 4

def information
  @information
end

#information_taxpayerObject (readonly)

Returns the value of attribute information_taxpayer.



4
5
6
# File 'lib/nfe_reader/information.rb', line 4

def information_taxpayer
  @information_taxpayer
end

#messagesObject (readonly)

Returns the value of attribute messages.



4
5
6
# File 'lib/nfe_reader/information.rb', line 4

def messages
  @messages
end

#referencesObject (readonly)

Returns the value of attribute references.



4
5
6
# File 'lib/nfe_reader/information.rb', line 4

def references
  @references
end

#taxpayer_messagesObject (readonly)

Returns the value of attribute taxpayer_messages.



4
5
6
# File 'lib/nfe_reader/information.rb', line 4

def taxpayer_messages
  @taxpayer_messages
end

Instance Method Details

#to_array(attrs = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/nfe_reader/information.rb', line 24

def to_array(attrs = {})
  array = []

  if attrs.is_a? Array
    attrs.each do |hash|
      array << hash.map { |key, value| value }
    end
  else
    array << attrs.map { |key, value| value }
  end

  array
end