Class: RsrGroup::DataRow
Constant Summary
Constants inherited from Base
Base::DEFAULT_CATALOG_FILENAME, Base::DEFAULT_DIR, Base::KEYDEALER_CATALOG_FILENAME, Base::KEYDEALER_DIR, Base::MAP_FILENAME, Base::QTY_FILENAME
Instance Attribute Summary collapse
-
#committed ⇒ Object
readonly
Returns the value of attribute committed.
-
#date_shipped ⇒ Object
readonly
Returns the value of attribute date_shipped.
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#handling_fee ⇒ Object
readonly
Returns the value of attribute handling_fee.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#license_number ⇒ Object
readonly
Returns the value of attribute license_number.
-
#line_type ⇒ Object
readonly
Returns the value of attribute line_type.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#ordered ⇒ Object
readonly
Returns the value of attribute ordered.
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
-
#rsr_order_number ⇒ Object
readonly
Returns the value of attribute rsr_order_number.
-
#ship_to_name ⇒ Object
readonly
Returns the value of attribute ship_to_name.
-
#shipped ⇒ Object
readonly
Returns the value of attribute shipped.
-
#shipping_carrier ⇒ Object
readonly
Returns the value of attribute shipping_carrier.
-
#shipping_cost ⇒ Object
readonly
Returns the value of attribute shipping_cost.
-
#shipping_method ⇒ Object
readonly
Returns the value of attribute shipping_method.
-
#stock_id ⇒ Object
readonly
Returns the value of attribute stock_id.
-
#tracking_number ⇒ Object
readonly
Returns the value of attribute tracking_number.
-
#zip ⇒ Object
readonly
Returns the value of attribute zip.
Instance Method Summary collapse
-
#initialize(line, has_errors: false) ⇒ DataRow
constructor
A new instance of DataRow.
- #to_h ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(line, has_errors: false) ⇒ DataRow
Returns a new instance of DataRow.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rsr_group/data_row.rb', line 10 def initialize(line, has_errors: false) points = line.split(";").map { |point| point.chomp } @identifier = points[0] @line_type = LINE_TYPES[points[1]] case @line_type when :file_header get_errors(points[-1]) if has_errors && points[-1] != "00000" when :order_header get_errors(points[-1]) if has_errors && points[-1] != "00000" @ship_to_name = points[2] @zip = points[8] when :ffl_dealer # 11 get_errors(points[-1]) if has_errors && points[-1] != "00000" @license_number = points[2] @name = points[3] @zip = points[4] when :order_detail # 20 get_errors(points[6]) if has_errors && points[6] != "00000" @quantity = points[3].to_i @stock_id = points[2] @shipping_carrier = points[4] @shipping_method = SHIPPING_METHODS[points[5]] when :confirmation_header # 30 @rsr_order_number = points[2] when :confirmation_detail # 40 @committed = points[4].to_i @ordered = points[3].to_i @stock_id = points[2] when :confirmation_trailer # 50 @committed = points[3].to_i @ordered = points[2].to_i when :shipping_header # 60 @date_shipped = points[5] @handling_fee = points[7].to_i.to_s @rsr_order_number = points[4] @ship_to_name = points[2] @shipping_carrier = points[8] @shipping_cost = points[6].to_i.to_s @shipping_method = points[9] @tracking_number = points[3] when :shipping_detail # 70 @ordered = points[3].to_i @shipped = points[4].to_i @stock_id = points[2] when :shipping_trailer # 80 @ordered = points[2].to_i @shipped = points[3].to_i when :order_trailer # 90 @quantity = points[2].to_i end end |
Instance Attribute Details
#committed ⇒ Object (readonly)
Returns the value of attribute committed.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def committed @committed end |
#date_shipped ⇒ Object (readonly)
Returns the value of attribute date_shipped.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def date_shipped @date_shipped end |
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def error_code @error_code end |
#handling_fee ⇒ Object (readonly)
Returns the value of attribute handling_fee.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def handling_fee @handling_fee end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def identifier @identifier end |
#license_number ⇒ Object (readonly)
Returns the value of attribute license_number.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def license_number @license_number end |
#line_type ⇒ Object (readonly)
Returns the value of attribute line_type.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def line_type @line_type end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def @message end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def name @name end |
#ordered ⇒ Object (readonly)
Returns the value of attribute ordered.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def ordered @ordered end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def quantity @quantity end |
#rsr_order_number ⇒ Object (readonly)
Returns the value of attribute rsr_order_number.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def rsr_order_number @rsr_order_number end |
#ship_to_name ⇒ Object (readonly)
Returns the value of attribute ship_to_name.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def ship_to_name @ship_to_name end |
#shipped ⇒ Object (readonly)
Returns the value of attribute shipped.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def shipped @shipped end |
#shipping_carrier ⇒ Object (readonly)
Returns the value of attribute shipping_carrier.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def shipping_carrier @shipping_carrier end |
#shipping_cost ⇒ Object (readonly)
Returns the value of attribute shipping_cost.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def shipping_cost @shipping_cost end |
#shipping_method ⇒ Object (readonly)
Returns the value of attribute shipping_method.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def shipping_method @shipping_method end |
#stock_id ⇒ Object (readonly)
Returns the value of attribute stock_id.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def stock_id @stock_id end |
#tracking_number ⇒ Object (readonly)
Returns the value of attribute tracking_number.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def tracking_number @tracking_number end |
#zip ⇒ Object (readonly)
Returns the value of attribute zip.
4 5 6 |
# File 'lib/rsr_group/data_row.rb', line 4 def zip @zip end |
Instance Method Details
#to_h ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/rsr_group/data_row.rb', line 64 def to_h @to_h ||= Hash[ instance_variables.map do |name| [name.to_s.gsub("@", "").to_sym, instance_variable_get(name).to_s] end ] end |