Class: ReactiveShipping::ShipmentEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/reactive_shipping/shipment_event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, time, location, message = nil, type_code = nil) ⇒ ShipmentEvent

Returns a new instance of ShipmentEvent.



5
6
7
# File 'lib/reactive_shipping/shipment_event.rb', line 5

def initialize(name, time, location, message = nil, type_code = nil)
  @name, @time, @location, @message, @type_code = name, time, location, message, type_code
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



3
4
5
# File 'lib/reactive_shipping/shipment_event.rb', line 3

def location
  @location
end

#messageObject (readonly)

Returns the value of attribute message.



3
4
5
# File 'lib/reactive_shipping/shipment_event.rb', line 3

def message
  @message
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/reactive_shipping/shipment_event.rb', line 3

def name
  @name
end

#timeObject (readonly)

Returns the value of attribute time.



3
4
5
# File 'lib/reactive_shipping/shipment_event.rb', line 3

def time
  @time
end

#type_codeObject (readonly)

Returns the value of attribute type_code.



3
4
5
# File 'lib/reactive_shipping/shipment_event.rb', line 3

def type_code
  @type_code
end

Instance Method Details

#==(other) ⇒ Object



17
18
19
20
# File 'lib/reactive_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

Returns:

  • (Boolean)


9
10
11
# File 'lib/reactive_shipping/shipment_event.rb', line 9

def delivered?
  status == :delivered
end

#statusObject



13
14
15
# File 'lib/reactive_shipping/shipment_event.rb', line 13

def status
  @status ||= name.downcase.gsub("\s", "_").to_sym
end