Class: ActiveShipping::ShipmentEvent
- Inherits:
-
Object
- Object
- ActiveShipping::ShipmentEvent
- Defined in:
- lib/active_shipping/shipment_event.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#type_code ⇒ Object
readonly
Returns the value of attribute type_code.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #delivered? ⇒ Boolean
-
#initialize(name, time, location, message = nil, type_code = nil) ⇒ ShipmentEvent
constructor
A new instance of ShipmentEvent.
- #status ⇒ Object
Constructor Details
#initialize(name, time, location, message = nil, type_code = nil) ⇒ ShipmentEvent
Returns a new instance of ShipmentEvent.
5 6 7 |
# File 'lib/active_shipping/shipment_event.rb', line 5 def initialize(name, time, location, = nil, type_code = nil) @name, @time, @location, @message, @type_code = name, time, location, , type_code end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
3 4 5 |
# File 'lib/active_shipping/shipment_event.rb', line 3 def location @location end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/active_shipping/shipment_event.rb', line 3 def @message end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/active_shipping/shipment_event.rb', line 3 def name @name end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
3 4 5 |
# File 'lib/active_shipping/shipment_event.rb', line 3 def time @time end |
#type_code ⇒ Object (readonly)
Returns the value of attribute type_code.
3 4 5 |
# File 'lib/active_shipping/shipment_event.rb', line 3 def type_code @type_code end |
Instance Method Details
#==(other) ⇒ Object
17 18 19 20 |
# File 'lib/active_shipping/shipment_event.rb', line 17 def ==(other) attributes = %i(name time location message type_code) attributes.all? { |attr| self.public_send(attr) == other.public_send(attr) } end |
#delivered? ⇒ Boolean
9 10 11 |
# File 'lib/active_shipping/shipment_event.rb', line 9 def delivered? status == :delivered end |
#status ⇒ Object
13 14 15 |
# File 'lib/active_shipping/shipment_event.rb', line 13 def status @status ||= name.downcase.gsub("\s", "_").to_sym end |