Class: Mgmg::IR::Compose

Inherits:
Object
  • Object
show all
Defined in:
lib/mgmg/ir.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#coefObject

Returns the value of attribute coef.



53
54
55
# File 'lib/mgmg/ir.rb', line 53

def coef
  @coef
end

#denObject

Returns the value of attribute den.



53
54
55
# File 'lib/mgmg/ir.rb', line 53

def den
  @den
end

#equip9Object

Returns the value of attribute equip9.



53
54
55
# File 'lib/mgmg/ir.rb', line 53

def equip9
  @equip9
end

#mainObject

Returns the value of attribute main.



53
54
55
# File 'lib/mgmg/ir.rb', line 53

def main
  @main
end

#subObject

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_sObject



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