class BCDice::Arithmetic::Node::BinaryOp

Public Class Methods

new(lhs, op, rhs) click to toggle source
# File lib/bcdice/arithmetic/node.rb, line 7
def initialize(lhs, op, rhs)
  @lhs = lhs
  @op = op
  @rhs = rhs
end

Public Instance Methods

eval(round_type) click to toggle source
# File lib/bcdice/arithmetic/node.rb, line 13
def eval(round_type)
  l = @lhs.eval(round_type)
  r = @rhs.eval(round_type)
  l.send(@op, r)
end
op_for_s_exp() click to toggle source

@return [String] S式で使う演算子の表現

# File lib/bcdice/arithmetic/node.rb, line 30
def op_for_s_exp
  @op
end
output() click to toggle source

@return [String] メッセージへの出力

# File lib/bcdice/arithmetic/node.rb, line 20
def output
  "#{@lhs.output}#{@op}#{@rhs.output}"
end
s_exp() click to toggle source

@return [String] ノードのS式

# File lib/bcdice/arithmetic/node.rb, line 25
def s_exp
  "(#{op_for_s_exp} #{@lhs.s_exp} #{@rhs.s_exp})"
end