Class: USPS::TrackDetail
- Inherits:
-
Struct
- Object
- Struct
- USPS::TrackDetail
- Defined in:
- lib/usps/track_detail.rb
Overview
TODO: Documentation
Instance Attribute Summary collapse
-
#authorized_agent ⇒ Object
Returns the value of attribute authorized_agent.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#event ⇒ Object
Returns the value of attribute event.
-
#event_city ⇒ Object
(also: #city)
Returns the value of attribute event_city.
-
#event_country ⇒ Object
(also: #country)
Returns the value of attribute event_country.
-
#event_date ⇒ Object
Returns the value of attribute event_date.
-
#event_state ⇒ Object
(also: #state)
Returns the value of attribute event_state.
-
#event_time ⇒ Object
Returns the value of attribute event_time.
-
#event_zip_code ⇒ Object
(also: #zip_code)
Returns the value of attribute event_zip_code.
-
#firm_name ⇒ Object
Returns the value of attribute firm_name.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #date ⇒ Object
-
#initialize(options = {}, &block) ⇒ TrackDetail
constructor
A new instance of TrackDetail.
-
#replace(other) ⇒ Object
Similar to Hash#replace, overwrite the values of this object with the other.
Constructor Details
#initialize(options = {}, &block) ⇒ TrackDetail
Returns a new instance of TrackDetail.
18 19 20 21 22 23 24 |
# File 'lib/usps/track_detail.rb', line 18 def initialize( = {}, &block) .each_pair do |k, v| self.send("#{k}=", v) end block.call(self) if block end |
Instance Attribute Details
#authorized_agent ⇒ Object
Returns the value of attribute authorized_agent
4 5 6 |
# File 'lib/usps/track_detail.rb', line 4 def @authorized_agent end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
16 17 18 |
# File 'lib/usps/track_detail.rb', line 16 def error @error end |
#event ⇒ Object
Returns the value of attribute event
4 5 6 |
# File 'lib/usps/track_detail.rb', line 4 def event @event end |
#event_city ⇒ Object Also known as: city
Returns the value of attribute event_city
4 5 6 |
# File 'lib/usps/track_detail.rb', line 4 def event_city @event_city end |
#event_country ⇒ Object Also known as: country
Returns the value of attribute event_country
4 5 6 |
# File 'lib/usps/track_detail.rb', line 4 def event_country @event_country end |
#event_date ⇒ Object
Returns the value of attribute event_date
4 5 6 |
# File 'lib/usps/track_detail.rb', line 4 def event_date @event_date end |
#event_state ⇒ Object Also known as: state
Returns the value of attribute event_state
4 5 6 |
# File 'lib/usps/track_detail.rb', line 4 def event_state @event_state end |
#event_time ⇒ Object
Returns the value of attribute event_time
4 5 6 |
# File 'lib/usps/track_detail.rb', line 4 def event_time @event_time end |
#event_zip_code ⇒ Object Also known as: zip_code
Returns the value of attribute event_zip_code
4 5 6 |
# File 'lib/usps/track_detail.rb', line 4 def event_zip_code @event_zip_code end |
#firm_name ⇒ Object
Returns the value of attribute firm_name
4 5 6 |
# File 'lib/usps/track_detail.rb', line 4 def firm_name @firm_name end |
#name ⇒ Object
Returns the value of attribute name
4 5 6 |
# File 'lib/usps/track_detail.rb', line 4 def name @name end |
Instance Method Details
#date ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/usps/track_detail.rb', line 26 def date time = "#{event_date} #{event_time}".strip begin Time.parse(time) unless time.empty? rescue ArgumentError return nil end end |
#replace(other) ⇒ Object
Similar to Hash#replace, overwrite the values of this object with the other. It will not replace a provided key on the original object that does not exist on the replacing object (such as name with verification requests).
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/usps/track_detail.rb', line 38 def replace(other) raise ArgumentError unless other.is_a?(USPS::Address) other.each_pair do |key, val| # Do not overwrite values that may exist on the original but not on # the replacement. self[key] = val unless val.nil? end self end |