Class: XmlConv::I2::Order
- Inherits:
-
Object
- Object
- XmlConv::I2::Order
- Defined in:
- lib/xmlconv/i2/order.rb
Constant Summary collapse
- I2_DELIVERY_CODES =
{ ## janico :pickup => '070', :delivery => '060', :camion => '010', ## globopharm :default => '1', :before_9 => '3', :before_21 => '4', :before_16 => '5', :extracted => '13', }
Instance Attribute Summary collapse
-
#addresses ⇒ Object
readonly
Returns the value of attribute addresses.
-
#ade_id ⇒ Object
Returns the value of attribute ade_id.
-
#agent ⇒ Object
Returns the value of attribute agent.
-
#dates ⇒ Object
readonly
Returns the value of attribute dates.
-
#delivery_id ⇒ Object
Returns the value of attribute delivery_id.
-
#free_text ⇒ Object
Returns the value of attribute free_text.
-
#interface ⇒ Object
Returns the value of attribute interface.
-
#positions ⇒ Object
readonly
Returns the value of attribute positions.
-
#sender_id ⇒ Object
Returns the value of attribute sender_id.
-
#terms_cond ⇒ Object
Returns the value of attribute terms_cond.
-
#transport_cost ⇒ Object
Returns the value of attribute transport_cost.
Instance Method Summary collapse
- #add_address(address) ⇒ Object
- #add_date(date) ⇒ Object
- #add_position(position) ⇒ Object
-
#initialize ⇒ Order
constructor
A new instance of Order.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Order
Returns a new instance of Order.
22 23 24 25 26 27 |
# File 'lib/xmlconv/i2/order.rb', line 22 def initialize @addresses = [] @dates = [] @positions = [] @interface = "61" end |
Instance Attribute Details
#addresses ⇒ Object (readonly)
Returns the value of attribute addresses.
21 22 23 |
# File 'lib/xmlconv/i2/order.rb', line 21 def addresses @addresses end |
#ade_id ⇒ Object
Returns the value of attribute ade_id.
19 20 21 |
# File 'lib/xmlconv/i2/order.rb', line 19 def ade_id @ade_id end |
#agent ⇒ Object
Returns the value of attribute agent.
19 20 21 |
# File 'lib/xmlconv/i2/order.rb', line 19 def agent @agent end |
#dates ⇒ Object (readonly)
Returns the value of attribute dates.
21 22 23 |
# File 'lib/xmlconv/i2/order.rb', line 21 def dates @dates end |
#delivery_id ⇒ Object
Returns the value of attribute delivery_id.
19 20 21 |
# File 'lib/xmlconv/i2/order.rb', line 19 def delivery_id @delivery_id end |
#free_text ⇒ Object
Returns the value of attribute free_text.
19 20 21 |
# File 'lib/xmlconv/i2/order.rb', line 19 def free_text @free_text end |
#interface ⇒ Object
Returns the value of attribute interface.
19 20 21 |
# File 'lib/xmlconv/i2/order.rb', line 19 def interface @interface end |
#positions ⇒ Object (readonly)
Returns the value of attribute positions.
21 22 23 |
# File 'lib/xmlconv/i2/order.rb', line 21 def positions @positions end |
#sender_id ⇒ Object
Returns the value of attribute sender_id.
19 20 21 |
# File 'lib/xmlconv/i2/order.rb', line 19 def sender_id @sender_id end |
#terms_cond ⇒ Object
Returns the value of attribute terms_cond.
19 20 21 |
# File 'lib/xmlconv/i2/order.rb', line 19 def terms_cond @terms_cond end |
#transport_cost ⇒ Object
Returns the value of attribute transport_cost.
19 20 21 |
# File 'lib/xmlconv/i2/order.rb', line 19 def transport_cost @transport_cost end |
Instance Method Details
#add_address(address) ⇒ Object
28 29 30 |
# File 'lib/xmlconv/i2/order.rb', line 28 def add_address(address) @addresses.push(address) end |
#add_date(date) ⇒ Object
31 32 33 |
# File 'lib/xmlconv/i2/order.rb', line 31 def add_date(date) @dates.push(date) end |
#add_position(position) ⇒ Object
34 35 36 |
# File 'lib/xmlconv/i2/order.rb', line 34 def add_position(position) @positions.push(position) end |
#to_s ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/xmlconv/i2/order.rb', line 37 def to_s output = "100:\#{@sender_id}\n101:\#{@delivery_id}\n EOS\n @addresses.each { |addr| output << addr.to_s }\n numerals = [ 231, 236, 237, 238, 242 ]\n [\n @agent, @free_text, @interface, I2_DELIVERY_CODES[@terms_cond],\n @transport_cost,\n ].each_with_index { |value, idx|\n unless(value.nil?)\n output << sprintf(\"%s:%s\\n\", numerals[idx], value)\n end\n }\n if(@ade_id)\n output << sprintf(\"250:ADE\\n251:%s\\n\", @ade_id)\n end\n @dates.each { |date| output << date.to_s }\n @positions.each { |pos| output << pos.to_s }\n output\nend\n" |