Class: Nfe::Cane

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Cane

Returns a new instance of Cane.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/nfe_reader/product/cane.rb', line 6

def initialize(attrs = {})
  @harvest = attrs[:safra]
  @month = attrs[:ref]
  @month_amount = attrs[:qTotMes]
  @previous_amount = attrs[:qTotAnt]
  @amount = attrs[:qTotGer]
  @value = attrs[:vFor]
  @deduction_value = attrs[:vTotDed]
  @net_value = attrs[:vLiqFor]

  @days = []
  
  if attrs[:forDia]
    @days = to_array(attrs[:forDia])
  end

  if attrs[:deduc]
    @deductions = to_array(attrs[:deduc])
  end
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



3
4
5
# File 'lib/nfe_reader/product/cane.rb', line 3

def amount
  @amount
end

#daysObject (readonly)

Returns the value of attribute days.



3
4
5
# File 'lib/nfe_reader/product/cane.rb', line 3

def days
  @days
end

#deduction_valueObject (readonly)

Returns the value of attribute deduction_value.



3
4
5
# File 'lib/nfe_reader/product/cane.rb', line 3

def deduction_value
  @deduction_value
end

#deductionsObject (readonly)

Returns the value of attribute deductions.



3
4
5
# File 'lib/nfe_reader/product/cane.rb', line 3

def deductions
  @deductions
end

#harvestObject (readonly)

Returns the value of attribute harvest.



3
4
5
# File 'lib/nfe_reader/product/cane.rb', line 3

def harvest
  @harvest
end

#monthObject (readonly)

Returns the value of attribute month.



3
4
5
# File 'lib/nfe_reader/product/cane.rb', line 3

def month
  @month
end

#month_amountObject (readonly)

Returns the value of attribute month_amount.



3
4
5
# File 'lib/nfe_reader/product/cane.rb', line 3

def month_amount
  @month_amount
end

#net_valueObject (readonly)

Returns the value of attribute net_value.



3
4
5
# File 'lib/nfe_reader/product/cane.rb', line 3

def net_value
  @net_value
end

#previous_amountObject (readonly)

Returns the value of attribute previous_amount.



3
4
5
# File 'lib/nfe_reader/product/cane.rb', line 3

def previous_amount
  @previous_amount
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/nfe_reader/product/cane.rb', line 3

def value
  @value
end

Instance Method Details

#to_array(attrs = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/nfe_reader/product/cane.rb', line 27

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