Class: RVista::POA
Overview
Represents a single Vista Purchase Order Ack (POA).
Instance Attribute Summary collapse
-
#delivery_location ⇒ Object
Returns the value of attribute delivery_location.
-
#delivery_location_name ⇒ Object
Returns the value of attribute delivery_location_name.
-
#items ⇒ Object
Returns the value of attribute items.
-
#po_number ⇒ Object
Returns the value of attribute po_number.
-
#receiver_id ⇒ Object
Returns the value of attribute receiver_id.
-
#sender_id ⇒ Object
Returns the value of attribute sender_id.
Class Method Summary collapse
-
.load_from_file(input) ⇒ Object
reads a vista poa file into memory.
-
.load_from_string(input) ⇒ Object
creates a RVista::POA object from a string.
Instance Method Summary collapse
- #date ⇒ Object
- #date=(val) ⇒ Object
-
#initialize ⇒ POA
constructor
creates a new RVista::POA object.
- #supply_after ⇒ Object
- #supply_after=(val) ⇒ Object
- #supply_before ⇒ Object
- #supply_before=(val) ⇒ Object
-
#to_s ⇒ Object
print a string representation of this order that meets the spec.
Constructor Details
#initialize ⇒ POA
creates a new RVista::POA object
13 14 15 16 17 18 |
# File 'lib/rvista/poa.rb', line 13 def initialize @items = [] @date = nil @supply_before = nil @supply_after = nil end |
Instance Attribute Details
#delivery_location ⇒ Object
Returns the value of attribute delivery_location.
9 10 11 |
# File 'lib/rvista/poa.rb', line 9 def delivery_location @delivery_location end |
#delivery_location_name ⇒ Object
Returns the value of attribute delivery_location_name.
9 10 11 |
# File 'lib/rvista/poa.rb', line 9 def delivery_location_name @delivery_location_name end |
#items ⇒ Object
Returns the value of attribute items.
10 11 12 |
# File 'lib/rvista/poa.rb', line 10 def items @items end |
#po_number ⇒ Object
Returns the value of attribute po_number.
8 9 10 |
# File 'lib/rvista/poa.rb', line 8 def po_number @po_number end |
#receiver_id ⇒ Object
Returns the value of attribute receiver_id.
8 9 10 |
# File 'lib/rvista/poa.rb', line 8 def receiver_id @receiver_id end |
#sender_id ⇒ Object
Returns the value of attribute sender_id.
8 9 10 |
# File 'lib/rvista/poa.rb', line 8 def sender_id @sender_id end |
Class Method Details
.load_from_file(input) ⇒ Object
reads a vista poa file into memory. input should be a string that specifies the file path
22 23 24 25 26 |
# File 'lib/rvista/poa.rb', line 22 def self.load_from_file(input) raise InvalidFileError, 'Invalid file' unless File.exist?(input) data = CSV.read(input, :quote_char => "`") return self.(data) end |
.load_from_string(input) ⇒ Object
creates a RVista::POA object from a string. Input should be a complete vista file as a string
30 31 32 33 |
# File 'lib/rvista/poa.rb', line 30 def self.load_from_string(input) data = CSV.parse(input, :quote_char => "`") return self.(data) end |
Instance Method Details
#date ⇒ Object
35 36 37 |
# File 'lib/rvista/poa.rb', line 35 def date vista_string_to_date(@date) end |
#date=(val) ⇒ Object
39 40 41 |
# File 'lib/rvista/poa.rb', line 39 def date=(val) @date = process_date(val) end |
#supply_after ⇒ Object
43 44 45 |
# File 'lib/rvista/poa.rb', line 43 def supply_after vista_string_to_date(@supply_after) end |
#supply_after=(val) ⇒ Object
47 48 49 |
# File 'lib/rvista/poa.rb', line 47 def supply_after=(val) @supply_after = process_date(val) end |
#supply_before ⇒ Object
51 52 53 |
# File 'lib/rvista/poa.rb', line 51 def supply_before vista_string_to_date(@supply_before) end |
#supply_before=(val) ⇒ Object
55 56 57 |
# File 'lib/rvista/poa.rb', line 55 def supply_before=(val) @supply_before = process_date(val) end |
#to_s ⇒ Object
print a string representation of this order that meets the spec
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/rvista/poa.rb', line 60 def to_s # message header msg = "" msg << "H," msg << "#{sender_id}," msg << "#{receiver_id}," msg << "," msg << "," msg << "," msg << "," msg << "#{po_number}," msg << "#{@date}," msg << "," msg << "#{@supply_after}," msg << "#{@supply_before}," msg << "SP," msg << "#{delivery_location}," msg << "#{delivery_location_name}\n" # message line items @items.each { |item| msg << item.to_s << "\n"} total_qty = @items.inject(0) { |sum, item| sum+item.demand_qty } # message summary msg << "S,#{@items.size.to_s},#{total_qty}\n" return msg end |