Class: ODDB::Util::Comparison
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- ODDB::Util::Comparison
- Defined in:
- lib/oddb/util/comparison.rb
Instance Attribute Summary collapse
-
#absolute ⇒ Object
readonly
Returns the value of attribute absolute.
-
#absolute_exfactory ⇒ Object
readonly
Returns the value of attribute absolute_exfactory.
-
#difference ⇒ Object
readonly
Returns the value of attribute difference.
-
#difference_exfactory ⇒ Object
readonly
Returns the value of attribute difference_exfactory.
-
#factor ⇒ Object
readonly
Returns the value of attribute factor.
-
#factor_exfactory ⇒ Object
readonly
Returns the value of attribute factor_exfactory.
Instance Method Summary collapse
-
#initialize(package, original) ⇒ Comparison
constructor
A new instance of Comparison.
- #is_a?(mod) ⇒ Boolean
Constructor Details
#initialize(package, original) ⇒ Comparison
Returns a new instance of Comparison.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/oddb/util/comparison.rb', line 11 def initialize(package, original) @package = package psize = package.size.to_f pprice = package.price(:public).to_f osize = original.size.to_f oprice = original.price(:public).to_f unless((psize * pprice * osize * oprice) == 0) @factor = psize / osize @absolute = pprice - oprice @difference = ((osize * pprice) / (psize * oprice) - 1) * 100 end pprice = package.price(:exfactory).to_f oprice = original.price(:exfactory).to_f unless((psize * pprice * osize * oprice) == 0) @factor_exfactory = psize / osize @absolute_exfactory = pprice - oprice @difference_exfactory = ((osize * pprice) / (psize * oprice) - 1) * 100 end super(package) end |
Instance Attribute Details
#absolute ⇒ Object (readonly)
Returns the value of attribute absolute.
9 10 11 |
# File 'lib/oddb/util/comparison.rb', line 9 def absolute @absolute end |
#absolute_exfactory ⇒ Object (readonly)
Returns the value of attribute absolute_exfactory.
9 10 11 |
# File 'lib/oddb/util/comparison.rb', line 9 def absolute_exfactory @absolute_exfactory end |
#difference ⇒ Object (readonly)
Returns the value of attribute difference.
9 10 11 |
# File 'lib/oddb/util/comparison.rb', line 9 def difference @difference end |
#difference_exfactory ⇒ Object (readonly)
Returns the value of attribute difference_exfactory.
9 10 11 |
# File 'lib/oddb/util/comparison.rb', line 9 def difference_exfactory @difference_exfactory end |
#factor ⇒ Object (readonly)
Returns the value of attribute factor.
9 10 11 |
# File 'lib/oddb/util/comparison.rb', line 9 def factor @factor end |
#factor_exfactory ⇒ Object (readonly)
Returns the value of attribute factor_exfactory.
9 10 11 |
# File 'lib/oddb/util/comparison.rb', line 9 def factor_exfactory @factor_exfactory end |
Instance Method Details
#is_a?(mod) ⇒ Boolean
31 32 33 |
# File 'lib/oddb/util/comparison.rb', line 31 def is_a?(mod) super || @package.is_a?(mod) end |