Sha256: 7f97a1a815fa5d7670212df51a08070b06ca5b4a33337dcaa2125252bbf903ab
Contents?: true
Size: 722 Bytes
Versions: 1
Compression:
Stored size: 722 Bytes
Contents
module PackageTracker class Response attr_reader :statuses attr_reader :tracking_number def initialize(tracking_number, carrier, statuses=[]) @tracking_number = tracking_number @carrier = carrier @statuses = statuses sort_statuses! end def add_status(message, time, location="") @statuses << { :message => message, :time => time, :location => location } sort_statuses! end def current_status @statuses.first end def delivered? current_status[:message] == @carrier.delivered_status end private def sort_statuses! @statuses.sort_by! { |status| status[:time] }.reverse! end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
package_tracker-0.0.2 | lib/package_tracker/response.rb |