Class: Mgmg::IR::Compose
- Inherits:
-
Object
- Object
- Mgmg::IR::Compose
- Defined in:
- lib/mgmg/ir.rb
Instance Attribute Summary collapse
-
#coef ⇒ Object
Returns the value of attribute coef.
-
#den ⇒ Object
Returns the value of attribute den.
-
#equip9 ⇒ Object
Returns the value of attribute equip9.
-
#main ⇒ Object
Returns the value of attribute main.
-
#sub ⇒ Object
Returns the value of attribute sub.
Instance Method Summary collapse
- #evaluate(s, c) ⇒ Object
- #evaluate3(s, a, c) ⇒ Object
-
#initialize(main, sub, equip9, coef, den) ⇒ Compose
constructor
A new instance of Compose.
- #initialize_copy(other) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(main, sub, equip9, coef, den) ⇒ Compose
Returns a new instance of Compose.
50 51 52 |
# File 'lib/mgmg/ir.rb', line 50 def initialize(main, sub, equip9, coef, den) @main, @sub, @equip9, @coef, @den = main, sub, equip9, coef, den end |
Instance Attribute Details
#coef ⇒ Object
Returns the value of attribute coef.
53 54 55 |
# File 'lib/mgmg/ir.rb', line 53 def coef @coef end |
#den ⇒ Object
Returns the value of attribute den.
53 54 55 |
# File 'lib/mgmg/ir.rb', line 53 def den @den end |
#equip9 ⇒ Object
Returns the value of attribute equip9.
53 54 55 |
# File 'lib/mgmg/ir.rb', line 53 def equip9 @equip9 end |
#main ⇒ Object
Returns the value of attribute main.
53 54 55 |
# File 'lib/mgmg/ir.rb', line 53 def main @main end |
#sub ⇒ Object
Returns the value of attribute sub.
53 54 55 |
# File 'lib/mgmg/ir.rb', line 53 def sub @sub end |
Instance Method Details
#evaluate(s, c) ⇒ Object
58 59 60 |
# File 'lib/mgmg/ir.rb', line 58 def evaluate(s, c) @main.evaluate(s, c) + ( ( @sub.evaluate(s, c) * (c+@equip9).div(2) ).cdiv(100) * @coef ).cdiv(@den) end |
#evaluate3(s, a, c) ⇒ Object
61 62 63 |
# File 'lib/mgmg/ir.rb', line 61 def evaluate3(s, a, c) @main.evaluate3(s, a, c) + ( ( @sub.evaluate3(s, a, c) * (c+@equip9).div(2) ).cdiv(100) * @coef ).cdiv(@den) end |
#initialize_copy(other) ⇒ Object
54 55 56 57 |
# File 'lib/mgmg/ir.rb', line 54 def initialize_copy(other) @main, @sub = other.main.dup, other.sub.dup @equip9, @coef, @den = other.equip9, other.coef, other.den end |
#to_s ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/mgmg/ir.rb', line 64 def to_s ms, ss = @main.to_s, @sub.to_s if ss == '0' ms else if ms == '0' "[[#{ss}[(c+#{@equip9})/2]/100](#{@coef})/#{@den}]" else "#{ms}+[[#{ss}[(c+#{@equip9})/2]/100](#{@coef})/#{@den}]" end end end |