Class: Jamef::Package

Inherits:
OpenStruct
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/jamef/package.rb

Constant Summary collapse

PRODUCTS_TYPES =
[:nf, :livros, :alimentos, :confeccoes, :comesticos, :cirugicos, :jornais, :material_escolar]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Package

Returns a new instance of Package.

Raises:

  • (ArgumentError)


16
17
18
19
20
21
# File 'lib/jamef/package.rb', line 16

def initialize *args
  super
  self.type ||= :nf
  raise ArgumentError, errors.first unless self.valid?
  self
end

Class Method Details

.type_map(package_type) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/jamef/package.rb', line 23

def self.type_map package_type
  value = {
  
    #	CONFORME NOTA FISCAL
    nf: '000004',
    
    #	LIVROS
    livros: '000005',
    
    #	ALIMENTOS INDUSTRIALIZADOS
    alimentos: '000010',
    
    #	CONFECCOES
    confeccoes: '000008',
    
    #	COSMETICOS
    comesticos: '000011',
    
    #	MATERIAL CIRURGICO
    cirugicos: '000011',
    
    #	JORNAIS / REVISTAS
    jornais: '000006',
    
    #	MATERIAL ESCOLAR
    material_escolar: '000013'
  
  }[package_type]
  value ? value : raise(ArgumentError,"Unknown Jamef Package Type: #{package_type}")
end

Instance Method Details

#priceObject



54
55
56
# File 'lib/jamef/package.rb', line 54

def price
  package_price
end

#price=(value) ⇒ Object



58
59
60
# File 'lib/jamef/package.rb', line 58

def price= value
  self.package_price = value
end