Class: Centra::Rule::OrderCompare

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/centra/rule/order_compare.rb

Constant Summary collapse

@@allowed_delay_in_minutes =
90.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order, allowed_delay_in_minutes: self.class.allowed_delay_in_minutes) ⇒ OrderCompare

Returns a new instance of OrderCompare.



18
19
20
21
# File 'lib/centra/rule/order_compare.rb', line 18

def initialize(order, allowed_delay_in_minutes: self.class.allowed_delay_in_minutes)
  @order = order
  @allowed_delay_in_minutes = allowed_delay_in_minutes
end

Instance Attribute Details

#orderObject (readonly)

Returns the value of attribute order.



16
17
18
# File 'lib/centra/rule/order_compare.rb', line 16

def order
  @order
end

Class Method Details

.allowed_delay_in_minutesObject



6
7
8
# File 'lib/centra/rule/order_compare.rb', line 6

def self.allowed_delay_in_minutes
  @@allowed_delay_in_minutes
end

.allowed_delay_in_minutes=(mins) ⇒ Object



10
11
12
# File 'lib/centra/rule/order_compare.rb', line 10

def self.allowed_delay_in_minutes=(mins)
  @@allowed_delay_in_minutes = mins
end

Instance Method Details

#==(other) ⇒ Object



23
24
25
26
27
28
# File 'lib/centra/rule/order_compare.rb', line 23

def ==(other)
  return false if order.email != other.email
  return false if order.delay_in_seconds(other) > allowed_delay_in_seconds

  true
end

#allowed_delay_in_secondsObject



30
31
32
# File 'lib/centra/rule/order_compare.rb', line 30

def allowed_delay_in_seconds
  60 * @allowed_delay_in_minutes
end