Class: RVista::PO
Overview
Represents a single Vista message (purchase order).
Instance Attribute Summary collapse
-
#buying_location ⇒ Object
Returns the value of attribute buying_location.
-
#buying_location_name ⇒ Object
Returns the value of attribute buying_location_name.
-
#delivery_location ⇒ Object
Returns the value of attribute delivery_location.
-
#delivery_location_name ⇒ Object
Returns the value of attribute delivery_location_name.
-
#department ⇒ Object
Returns the value of attribute department.
-
#internal_control_number ⇒ Object
Returns the value of attribute internal_control_number.
-
#items ⇒ Object
Returns the value of attribute items.
-
#label_code ⇒ Object
Returns the value of attribute label_code.
-
#myer_code ⇒ Object
Returns the value of attribute myer_code.
-
#po_number ⇒ Object
Returns the value of attribute po_number.
-
#po_subset_code ⇒ Object
Returns the value of attribute po_subset_code.
-
#purpose_code ⇒ Object
Returns the value of attribute purpose_code.
-
#purpose_desc ⇒ Object
Returns the value of attribute purpose_desc.
-
#receiver_id ⇒ Object
Returns the value of attribute receiver_id.
-
#sender_id ⇒ Object
Returns the value of attribute sender_id.
-
#supplier_ref ⇒ Object
Returns the value of attribute supplier_ref.
Class Method Summary collapse
-
.load_from_file(input) ⇒ Object
reads a vista text file into memory.
-
.load_from_string(input) ⇒ Object
creates a RVista::Message object from a string.
Instance Method Summary collapse
- #advertised_date ⇒ Object
- #advertised_date=(val) ⇒ Object
- #date ⇒ Object
- #date=(val) ⇒ Object
-
#initialize ⇒ PO
constructor
creates a new RVista::PO 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 ⇒ PO
creates a new RVista::PO object
16 17 18 19 20 21 22 |
# File 'lib/rvista/po.rb', line 16 def initialize @items = [] @date = nil @supply_before = nil @supply_after = nil @advertised_date = nil end |
Instance Attribute Details
#buying_location ⇒ Object
Returns the value of attribute buying_location.
10 11 12 |
# File 'lib/rvista/po.rb', line 10 def @buying_location end |
#buying_location_name ⇒ Object
Returns the value of attribute buying_location_name.
11 12 13 |
# File 'lib/rvista/po.rb', line 11 def @buying_location_name end |
#delivery_location ⇒ Object
Returns the value of attribute delivery_location.
11 12 13 |
# File 'lib/rvista/po.rb', line 11 def delivery_location @delivery_location end |
#delivery_location_name ⇒ Object
Returns the value of attribute delivery_location_name.
12 13 14 |
# File 'lib/rvista/po.rb', line 12 def delivery_location_name @delivery_location_name end |
#department ⇒ Object
Returns the value of attribute department.
10 11 12 |
# File 'lib/rvista/po.rb', line 10 def department @department end |
#internal_control_number ⇒ Object
Returns the value of attribute internal_control_number.
8 9 10 |
# File 'lib/rvista/po.rb', line 8 def internal_control_number @internal_control_number end |
#items ⇒ Object
Returns the value of attribute items.
13 14 15 |
# File 'lib/rvista/po.rb', line 13 def items @items end |
#label_code ⇒ Object
Returns the value of attribute label_code.
12 13 14 |
# File 'lib/rvista/po.rb', line 12 def label_code @label_code end |
#myer_code ⇒ Object
Returns the value of attribute myer_code.
10 11 12 |
# File 'lib/rvista/po.rb', line 10 def myer_code @myer_code end |
#po_number ⇒ Object
Returns the value of attribute po_number.
8 9 10 |
# File 'lib/rvista/po.rb', line 8 def po_number @po_number end |
#po_subset_code ⇒ Object
Returns the value of attribute po_subset_code.
9 10 11 |
# File 'lib/rvista/po.rb', line 9 def po_subset_code @po_subset_code end |
#purpose_code ⇒ Object
Returns the value of attribute purpose_code.
9 10 11 |
# File 'lib/rvista/po.rb', line 9 def purpose_code @purpose_code end |
#purpose_desc ⇒ Object
Returns the value of attribute purpose_desc.
9 10 11 |
# File 'lib/rvista/po.rb', line 9 def purpose_desc @purpose_desc end |
#receiver_id ⇒ Object
Returns the value of attribute receiver_id.
8 9 10 |
# File 'lib/rvista/po.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/po.rb', line 8 def sender_id @sender_id end |
#supplier_ref ⇒ Object
Returns the value of attribute supplier_ref.
10 11 12 |
# File 'lib/rvista/po.rb', line 10 def supplier_ref @supplier_ref end |
Class Method Details
.load_from_file(input) ⇒ Object
reads a vista text file into memory. input should be a string that specifies the file path
26 27 28 29 30 |
# File 'lib/rvista/po.rb', line 26 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::Message object from a string. Input should be a complete vista file as a string
34 35 36 37 |
# File 'lib/rvista/po.rb', line 34 def self.load_from_string(input) data = CSV.parse(input, :quote_char => "`") return self.(data) end |
Instance Method Details
#advertised_date ⇒ Object
63 64 65 |
# File 'lib/rvista/po.rb', line 63 def advertised_date vista_string_to_date(@advertised_date) end |
#advertised_date=(val) ⇒ Object
67 68 69 |
# File 'lib/rvista/po.rb', line 67 def advertised_date=(val) @advertised_date = process_date(val) end |
#date ⇒ Object
39 40 41 |
# File 'lib/rvista/po.rb', line 39 def date vista_string_to_date(@date) end |
#date=(val) ⇒ Object
43 44 45 |
# File 'lib/rvista/po.rb', line 43 def date=(val) @date = process_date(val) end |
#supply_after ⇒ Object
47 48 49 |
# File 'lib/rvista/po.rb', line 47 def supply_after vista_string_to_date(@supply_after) end |
#supply_after=(val) ⇒ Object
51 52 53 |
# File 'lib/rvista/po.rb', line 51 def supply_after=(val) @supply_after = process_date(val) end |
#supply_before ⇒ Object
55 56 57 |
# File 'lib/rvista/po.rb', line 55 def supply_before vista_string_to_date(@supply_before) end |
#supply_before=(val) ⇒ Object
59 60 61 |
# File 'lib/rvista/po.rb', line 59 def supply_before=(val) @supply_before = process_date(val) end |
#to_s ⇒ Object
print a string representation of this order that meets the spec
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/rvista/po.rb', line 72 def to_s # message header msg = "" msg << "H," msg << "#{sender_id}," msg << "#{receiver_id}," msg << "#{internal_control_number}," msg << "#{po_number}," msg << "#{po_subset_code}," msg << "#{purpose_code}," msg << "#{purpose_desc}," msg << "#{@date}," msg << "#{myer_code}," msg << "#{@supply_after}," msg << "#{@supply_before}," msg << "#{@advertised_date}," msg << "#{department}," msg << "#{supplier_ref}," msg << "#{}," msg << "#{}," msg << "#{delivery_location}," msg << "#{delivery_location_name}," msg << "#{label_code}\n" # message line items @items.each { |item| msg << item.to_s << "\n"} # message summary msg << "S,#{@items.size.to_s},,\n" return msg end |