Class: Centra::Order
- Inherits:
-
Object
show all
- Defined in:
- lib/centra/order.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data) ⇒ Order
Returns a new instance of Order.
5
6
7
8
|
# File 'lib/centra/order.rb', line 5
def initialize(data)
@email = data.delivery_email.strip.downcase
@data = data
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
35
36
37
|
# File 'lib/centra/order.rb', line 35
def method_missing(method, *args, &block)
@data.public_send(method, *args, &block)
end
|
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
3
4
5
|
# File 'lib/centra/order.rb', line 3
def email
@email
end
|
Instance Method Details
#captured_date ⇒ Object
14
15
16
17
|
# File 'lib/centra/order.rb', line 14
def captured_date
@captured_date ||= Time.parse(@data.captured_date)
rescue ArgumentError => _e
end
|
#delay_in_minutes(other) ⇒ Object
27
28
29
|
# File 'lib/centra/order.rb', line 27
def delay_in_minutes(other)
delay_in_seconds(other) / 60.0
end
|
#delay_in_seconds(other) ⇒ Object
31
32
33
|
# File 'lib/centra/order.rb', line 31
def delay_in_seconds(other)
(order_date - other.order_date).abs
end
|
#inspect ⇒ Object
39
40
41
|
# File 'lib/centra/order.rb', line 39
def inspect
"#<Order:#{"0x00%x" % (object_id << 1)}(email: #{@email}, order_date: #{@order_date})"
end
|
#order_date ⇒ Object
10
11
12
|
# File 'lib/centra/order.rb', line 10
def order_date
@order_date ||= Time.parse(@data.order_date)
end
|
#pcs ⇒ Object
19
20
21
|
# File 'lib/centra/order.rb', line 19
def pcs
@pcs ||= Integer(@data.pcs)
end
|
#total_order_value_sek ⇒ Object
23
24
25
|
# File 'lib/centra/order.rb', line 23
def total_order_value_sek
@total_order_value_sek ||= Float(@data.total_order_value_sek)
end
|