Class: EndiciaLabelServer::Parsers::PostageLabelParser
- Inherits:
-
ParserBase
- Object
- Ox::Sax
- ParserBase
- EndiciaLabelServer::Parsers::PostageLabelParser
- Defined in:
- lib/endicia_label_server/parsers/postage_label_parser.rb
Instance Attribute Summary collapse
-
#cost_center ⇒ Object
Returns the value of attribute cost_center.
-
#final_postage ⇒ Object
Returns the value of attribute final_postage.
-
#label ⇒ Object
Returns the value of attribute label.
-
#pic ⇒ Object
Returns the value of attribute pic.
-
#postage_balance ⇒ Object
Returns the value of attribute postage_balance.
-
#postmark_date ⇒ Object
Returns the value of attribute postmark_date.
-
#requester_id ⇒ Object
Returns the value of attribute requester_id.
-
#tracking_number ⇒ Object
Returns the value of attribute tracking_number.
-
#transaction_date_time ⇒ Object
Returns the value of attribute transaction_date_time.
-
#transaction_id ⇒ Object
Returns the value of attribute transaction_id.
Attributes inherited from ParserBase
#error_description, #status_code, #switches
Instance Method Summary collapse
- #parse_label(encoded_label) ⇒ Object
- #start_element(name) ⇒ Object
- #underscore(value) ⇒ Object
- #value(value) ⇒ Object
Methods inherited from ParserBase
#element_tracker_switch, #end_element, #initialize, #success?, #switch_active?
Constructor Details
This class inherits a constructor from EndiciaLabelServer::Parsers::ParserBase
Instance Attribute Details
#cost_center ⇒ Object
Returns the value of attribute cost_center.
6 7 8 |
# File 'lib/endicia_label_server/parsers/postage_label_parser.rb', line 6 def cost_center @cost_center end |
#final_postage ⇒ Object
Returns the value of attribute final_postage.
6 7 8 |
# File 'lib/endicia_label_server/parsers/postage_label_parser.rb', line 6 def final_postage @final_postage end |
#label ⇒ Object
Returns the value of attribute label.
6 7 8 |
# File 'lib/endicia_label_server/parsers/postage_label_parser.rb', line 6 def label @label end |
#pic ⇒ Object
Returns the value of attribute pic.
6 7 8 |
# File 'lib/endicia_label_server/parsers/postage_label_parser.rb', line 6 def pic @pic end |
#postage_balance ⇒ Object
Returns the value of attribute postage_balance.
6 7 8 |
# File 'lib/endicia_label_server/parsers/postage_label_parser.rb', line 6 def postage_balance @postage_balance end |
#postmark_date ⇒ Object
Returns the value of attribute postmark_date.
6 7 8 |
# File 'lib/endicia_label_server/parsers/postage_label_parser.rb', line 6 def postmark_date @postmark_date end |
#requester_id ⇒ Object
Returns the value of attribute requester_id.
6 7 8 |
# File 'lib/endicia_label_server/parsers/postage_label_parser.rb', line 6 def requester_id @requester_id end |
#tracking_number ⇒ Object
Returns the value of attribute tracking_number.
6 7 8 |
# File 'lib/endicia_label_server/parsers/postage_label_parser.rb', line 6 def tracking_number @tracking_number end |
#transaction_date_time ⇒ Object
Returns the value of attribute transaction_date_time.
6 7 8 |
# File 'lib/endicia_label_server/parsers/postage_label_parser.rb', line 6 def transaction_date_time @transaction_date_time end |
#transaction_id ⇒ Object
Returns the value of attribute transaction_id.
6 7 8 |
# File 'lib/endicia_label_server/parsers/postage_label_parser.rb', line 6 def transaction_id @transaction_id end |
Instance Method Details
#parse_label(encoded_label) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/endicia_label_server/parsers/postage_label_parser.rb', line 43 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) ⇒ Object
17 18 19 20 |
# File 'lib/endicia_label_server/parsers/postage_label_parser.rb', line 17 def start_element(name) super @current_element = name.to_s end |
#underscore(value) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/endicia_label_server/parsers/postage_label_parser.rb', line 35 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) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/endicia_label_server/parsers/postage_label_parser.rb', line 22 def value(value) super element = underscore(@current_element) string_value = value.as_s if switch_active? :Base64LabelImage parse_label(string_value) else function_name = "#{element}=" send(function_name, string_value) if respond_to?(function_name) end end |