class EndiciaLabelServer::Parsers::PostageLabelParser
Attributes
cost_center[RW]
customs_number[RW]
final_postage[RW]
label[RW]
pic[RW]
postage_balance[RW]
postmark_date[RW]
requester_id[RW]
tracking_number[RW]
transaction_date_time[RW]
transaction_id[RW]
Public Instance Methods
label_switch_active?()
click to toggle source
# File lib/endicia_label_server/parsers/postage_label_parser.rb, line 36 def label_switch_active? switch_active?(:Base64LabelImage) || (switch_active?(:Label, :Image) && current_attributes[:PartNumber] == '1') end
parse_label(encoded_label)
click to toggle source
# File lib/endicia_label_server/parsers/postage_label_parser.rb, line 48 def parse_label(encoded_label) label_file = Tempfile.new(['endicia', '.png']) label_file.binmode label_file.write(Base64.decode64(encoded_label)) label_file.rewind self.label = label_file end
start_element(name)
click to toggle source
Calls superclass method
EndiciaLabelServer::Parsers::ParserBase#start_element
# File lib/endicia_label_server/parsers/postage_label_parser.rb, line 18 def start_element(name) super @current_element = name.to_s end
underscore(value)
click to toggle source
# File lib/endicia_label_server/parsers/postage_label_parser.rb, line 40 def underscore(value) value.gsub(/::/, '/') .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('-', '_') .downcase end
value(value)
click to toggle source
Calls superclass method
EndiciaLabelServer::Parsers::ParserBase#value
# File lib/endicia_label_server/parsers/postage_label_parser.rb, line 23 def value(value) super element = underscore(@current_element) string_value = value.as_s if label_switch_active? parse_label(string_value) else function_name = "#{element}=" send(function_name, string_value) if respond_to?(function_name) end end