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.
4 5 6 7 |
# File 'lib/encomenda.rb', line 4 def initialize(numero) @numero = numero @status = Array.new end |
Instance Attribute Details
#numero ⇒ Object (readonly)
Returns the value of attribute numero.
2 3 4 |
# File 'lib/encomenda.rb', line 2 def numero @numero end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
2 3 4 |
# File 'lib/encomenda.rb', line 2 def status @status end |
Instance Method Details
#<<(status) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/encomenda.rb', line 9 def <<(status) @status << status @status.sort! do |a,b| a.data <=> b.data end end |
#primeiro_status_disponivel ⇒ Object
20 21 22 |
# File 'lib/encomenda.rb', line 20 def primeiro_status_disponivel @status.first end |
#to_xml ⇒ Object
TODO: refactor - nao sei se deveria estar aqui…
25 26 27 28 29 30 31 |
# File 'lib/encomenda.rb', line 25 def to_xml xml = "<encomenda numero=\"#{@numero}\">" @status.each do |status| xml += status.to_xml end xml += "</encomenda>" end |
#ultimo_status_disponivel ⇒ Object
16 17 18 |
# File 'lib/encomenda.rb', line 16 def ultimo_status_disponivel @status.last end |