Class: Calculator::Advanced
- Inherits:
-
Calculator
- Object
- Calculator
- Calculator::Advanced
show all
- Defined in:
- app/models/calculator/advanced.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.register ⇒ Object
7
8
9
10
11
12
13
14
|
# File 'app/models/calculator/advanced.rb', line 7
def self.register
super
ShippingMethod.register_calculator(self)
end
|
Instance Method Details
#get_rate(value) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'app/models/calculator/advanced.rb', line 28
def get_rate(value)
bucket = BucketRate.find(:first,
:conditions => [
"calculator_id = ? and floor <= ? and ceiling > ?",
self.id, value, value
])
if bucket
return(bucket.rate)
else
bucket = BucketRate.find(:last, :conditions => ['calculator_id = ?', self.id], :order => "ceiling ASC")
if bucket && value > bucket.ceiling
return(bucket.rate)
else
return(false) end
end
end
|
#name ⇒ Object
20
21
22
|
# File 'app/models/calculator/advanced.rb', line 20
def name
calculable.respond_to?(:name) ? calculable.name : calculable.to_s
end
|
#set_advanced ⇒ Object
16
17
18
|
# File 'app/models/calculator/advanced.rb', line 16
def set_advanced
self.advanced = true
end
|
#unit ⇒ Object
24
25
26
|
# File 'app/models/calculator/advanced.rb', line 24
def unit
self.class.unit
end
|