Class: OpenMarket::DR
- Inherits:
-
Object
- Object
- OpenMarket::DR
- Defined in:
- lib/open_market/dr.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#note ⇒ Object
readonly
Returns the value of attribute note.
-
#parent_ticket_id ⇒ Object
readonly
Returns the value of attribute parent_ticket_id.
-
#segment_number ⇒ Object
readonly
Returns the value of attribute segment_number.
-
#state_description ⇒ Object
readonly
Returns the value of attribute state_description.
-
#state_id ⇒ Object
readonly
Returns the value of attribute state_id.
-
#ticket_id ⇒ Object
readonly
Returns the value of attribute ticket_id.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#initialize(data) ⇒ DR
constructor
A new instance of DR.
Constructor Details
#initialize(data) ⇒ DR
Returns a new instance of DR.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/open_market/dr.rb', line 6 def initialize(data) (class << self; self; end).class_eval do # Defining a member variable for xml would pollute #inspect # This solution is inspired by https://github.com/jordansissel/software-patterns/tree/master/dont-log-secrets/ruby define_method(:xml) { REXML::Document.new(data).root } private :xml end @ticket_id = xml.attributes["ticketId"] @parent_ticket_id = xml.attributes["parentTicketId"] @note = xml.attributes["note"] response = xml.elements["response"] @description = response.attributes["description"] @code = response.attributes["code"].to_i = xml.elements["message"] @segment_number = .attributes["segmentNumber"] = DateTime.strptime(.attributes["deliveryDate"] + "+0000", '%FT%T.%LZ%z').utc state = .elements["state"] @state_id = state.attributes["id"].to_i @state_description = state.attributes["description"] end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/open_market/dr.rb', line 5 def code @code end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/open_market/dr.rb', line 5 def description @description end |
#note ⇒ Object (readonly)
Returns the value of attribute note.
5 6 7 |
# File 'lib/open_market/dr.rb', line 5 def note @note end |
#parent_ticket_id ⇒ Object (readonly)
Returns the value of attribute parent_ticket_id.
5 6 7 |
# File 'lib/open_market/dr.rb', line 5 def parent_ticket_id @parent_ticket_id end |
#segment_number ⇒ Object (readonly)
Returns the value of attribute segment_number.
5 6 7 |
# File 'lib/open_market/dr.rb', line 5 def segment_number @segment_number end |
#state_description ⇒ Object (readonly)
Returns the value of attribute state_description.
5 6 7 |
# File 'lib/open_market/dr.rb', line 5 def state_description @state_description end |
#state_id ⇒ Object (readonly)
Returns the value of attribute state_id.
5 6 7 |
# File 'lib/open_market/dr.rb', line 5 def state_id @state_id end |
#ticket_id ⇒ Object (readonly)
Returns the value of attribute ticket_id.
5 6 7 |
# File 'lib/open_market/dr.rb', line 5 def ticket_id @ticket_id end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
5 6 7 |
# File 'lib/open_market/dr.rb', line 5 def end |