Class: BBMB::Model::Promotion
Instance Attribute Summary collapse
Instance Method Summary
collapse
append_features
Methods inherited from Subject
#migrate_to_subject, multilingual
Instance Attribute Details
#end_date ⇒ Object
Returns the value of attribute end_date.
12
13
14
|
# File 'lib/bbmb/model/promotion.rb', line 12
def end_date
@end_date
end
|
#start_date ⇒ Object
Returns the value of attribute start_date.
12
13
14
|
# File 'lib/bbmb/model/promotion.rb', line 12
def start_date
@start_date
end
|
Instance Method Details
#current? ⇒ Boolean
18
19
20
21
22
23
|
# File 'lib/bbmb/model/promotion.rb', line 18
def current?
today = Date.today
!!(@start_date || @end_date) \
&& (@start_date.nil? || today >= @start_date) \
&& (@end_date.nil? || today <= @end_date)
end
|
#discount(qty) ⇒ Object
24
25
26
|
# File 'lib/bbmb/model/promotion.rb', line 24
def discount(qty)
data_qty(qty, "discount")
end
|
#freebies(qty) ⇒ Object
27
28
29
|
# File 'lib/bbmb/model/promotion.rb', line 27
def freebies(qty)
data_qty(qty, "free")
end
|
#has_price_qty? ⇒ Boolean
30
31
32
|
# File 'lib/bbmb/model/promotion.rb', line 30
def has_price_qty?
!@l1_price.nil?
end
|
#price_qty(qty) ⇒ Object
33
34
35
|
# File 'lib/bbmb/model/promotion.rb', line 33
def price_qty(qty)
data_qty(qty, "price")
end
|
#qty_level(level) ⇒ Object
36
37
38
|
# File 'lib/bbmb/model/promotion.rb', line 36
def qty_level(level)
instance_variable_get("@l#{level}_qty")
end
|