class RsrGroup::DataRow
Attributes
committed[R]
date_shipped[R]
error_code[R]
handling_fee[R]
identifier[R]
license_number[R]
line_type[R]
message[R]
name[R]
ordered[R]
quantity[R]
rsr_order_number[R]
ship_to_name[R]
shipped[R]
shipping_carrier[R]
shipping_cost[R]
shipping_method[R]
stock_id[R]
tracking_number[R]
zip[R]
Public Class Methods
new(line, has_errors: false)
click to toggle source
# 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
Public Instance Methods
to_h()
click to toggle source
# 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
Private Instance Methods
get_errors(code)
click to toggle source
# File lib/rsr_group/data_row.rb, line 74 def get_errors(code) @error_code = code @message = ERROR_CODES[code] end