Class: Correios::Frete::Pacote
- Inherits:
-
Object
- Object
- Correios::Frete::Pacote
- Defined in:
- lib/correios/frete/pacote.rb
Constant Summary collapse
- MIN_DIMENSIONS =
{ :comprimento => 16.0, :largura => 11.0, :altura => 2.0 }
Instance Attribute Summary collapse
-
#altura ⇒ Object
readonly
Returns the value of attribute altura.
-
#comprimento ⇒ Object
readonly
Returns the value of attribute comprimento.
-
#largura ⇒ Object
readonly
Returns the value of attribute largura.
-
#peso ⇒ Object
readonly
Returns the value of attribute peso.
-
#volume ⇒ Object
readonly
Returns the value of attribute volume.
Instance Method Summary collapse
- #adicionar_item(item) ⇒ Object (also: #add_item)
- #formato ⇒ Object
-
#initialize(itens = nil) ⇒ Pacote
constructor
A new instance of Pacote.
- #itens ⇒ Object (also: #items)
Constructor Details
#initialize(itens = nil) ⇒ Pacote
Returns a new instance of Pacote.
13 14 15 16 17 18 |
# File 'lib/correios/frete/pacote.rb', line 13 def initialize(itens = nil) @peso = @comprimento = @largura = @altura = @volume = 0.0 @itens = [] itens.each { |item| adicionar_item(item) } if itens end |
Instance Attribute Details
#altura ⇒ Object (readonly)
Returns the value of attribute altura.
5 6 7 |
# File 'lib/correios/frete/pacote.rb', line 5 def altura @altura end |
#comprimento ⇒ Object (readonly)
Returns the value of attribute comprimento.
5 6 7 |
# File 'lib/correios/frete/pacote.rb', line 5 def comprimento @comprimento end |
#largura ⇒ Object (readonly)
Returns the value of attribute largura.
5 6 7 |
# File 'lib/correios/frete/pacote.rb', line 5 def largura @largura end |
#peso ⇒ Object (readonly)
Returns the value of attribute peso.
5 6 7 |
# File 'lib/correios/frete/pacote.rb', line 5 def peso @peso end |
#volume ⇒ Object (readonly)
Returns the value of attribute volume.
5 6 7 |
# File 'lib/correios/frete/pacote.rb', line 5 def volume @volume end |
Instance Method Details
#adicionar_item(item) ⇒ Object Also known as: add_item
29 30 31 32 33 34 35 36 37 |
# File 'lib/correios/frete/pacote.rb', line 29 def adicionar_item(item) return unless item item = Correios::Frete::PacoteItem.new(item) if item.is_a?(Hash) @itens << item calcular_medidas(item) item end |
#formato ⇒ Object
20 21 22 |
# File 'lib/correios/frete/pacote.rb', line 20 def formato :caixa_pacote end |
#itens ⇒ Object Also known as: items
24 25 26 |
# File 'lib/correios/frete/pacote.rb', line 24 def itens @itens end |