Class: Encomenda
- Inherits:
-
Object
- Object
- Encomenda
- Defined in:
- lib/encomenda.rb
Instance Attribute Summary collapse
-
#numero ⇒ Object
readonly
Returns the value of attribute numero.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #<<(status) ⇒ Object
-
#initialize(numero) ⇒ Encomenda
constructor
A new instance of Encomenda.
- #primeiro_status_disponivel ⇒ Object
-
#to_xml ⇒ Object
TODO: refactor - nao sei se deveria estar aqui…
- #ultimo_status_disponivel ⇒ Object
Constructor Details
#initialize(numero) ⇒ Encomenda
Returns a new instance of Encomenda.
6 7 8 9 |
# File 'lib/encomenda.rb', line 6 def initialize(numero) @numero = numero @status = Array.new end |
Instance Attribute Details
#numero ⇒ Object (readonly)
Returns the value of attribute numero.
4 5 6 |
# File 'lib/encomenda.rb', line 4 def numero @numero end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/encomenda.rb', line 4 def status @status end |
Instance Method Details
#<<(status) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/encomenda.rb', line 11 def <<(status) @status << status @status.sort! do |a,b| a.data <=> b.data end end |
#primeiro_status_disponivel ⇒ Object
22 23 24 |
# File 'lib/encomenda.rb', line 22 def primeiro_status_disponivel @status.first end |
#to_xml ⇒ Object
TODO: refactor - nao sei se deveria estar aqui…
27 28 29 30 31 32 33 |
# File 'lib/encomenda.rb', line 27 def to_xml xml = "<encomenda numero=\"#{@numero}\">" @status.each do |status| xml += status.to_xml end xml += "</encomenda>" end |
#ultimo_status_disponivel ⇒ Object
18 19 20 |
# File 'lib/encomenda.rb', line 18 def ultimo_status_disponivel @status.last end |