Class: ODDB::Util::Comparison

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/oddb/util/comparison.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#absoluteObject (readonly)

Returns the value of attribute absolute.



9
10
11
# File 'lib/oddb/util/comparison.rb', line 9

def absolute
  @absolute
end

#absolute_exfactoryObject (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

#differenceObject (readonly)

Returns the value of attribute difference.



9
10
11
# File 'lib/oddb/util/comparison.rb', line 9

def difference
  @difference
end

#difference_exfactoryObject (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

#factorObject (readonly)

Returns the value of attribute factor.



9
10
11
# File 'lib/oddb/util/comparison.rb', line 9

def factor
  @factor
end

#factor_exfactoryObject (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

Returns:

  • (Boolean)


31
32
33
# File 'lib/oddb/util/comparison.rb', line 31

def is_a?(mod)
  super || @package.is_a?(mod)
end