Class: PackageTracker::Response
- Inherits:
-
Object
- Object
- PackageTracker::Response
- Defined in:
- lib/package_tracker/response.rb
Instance Attribute Summary collapse
-
#statuses ⇒ Object
readonly
Returns the value of attribute statuses.
-
#tracking_number ⇒ Object
readonly
Returns the value of attribute tracking_number.
Instance Method Summary collapse
- #add_status(message, time, location = "") ⇒ Object
- #current_location ⇒ Object
- #current_status ⇒ Object
- #delivered? ⇒ Boolean
-
#initialize(tracking_number, carrier, statuses = []) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(tracking_number, carrier, statuses = []) ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 11 |
# File 'lib/package_tracker/response.rb', line 6 def initialize(tracking_number, carrier, statuses=[]) @tracking_number = tracking_number @carrier = carrier @statuses = statuses sort_statuses! end |
Instance Attribute Details
#statuses ⇒ Object (readonly)
Returns the value of attribute statuses.
3 4 5 |
# File 'lib/package_tracker/response.rb', line 3 def statuses @statuses end |
#tracking_number ⇒ Object (readonly)
Returns the value of attribute tracking_number.
4 5 6 |
# File 'lib/package_tracker/response.rb', line 4 def tracking_number @tracking_number end |
Instance Method Details
#add_status(message, time, location = "") ⇒ Object
13 14 15 16 |
# File 'lib/package_tracker/response.rb', line 13 def add_status(, time, location="") @statuses << { :message => , :time => time, :location => location } sort_statuses! end |
#current_location ⇒ Object
22 23 24 |
# File 'lib/package_tracker/response.rb', line 22 def current_location current_status[:location] end |
#current_status ⇒ Object
18 19 20 |
# File 'lib/package_tracker/response.rb', line 18 def current_status @statuses.first end |
#delivered? ⇒ Boolean
26 27 28 |
# File 'lib/package_tracker/response.rb', line 26 def delivered? current_status[:message] == @carrier.delivered_status end |