class BCDice::CommonCommand::AddDice::Node::Negate

符号反転のノード

Attributes

body[R]

符号反転の対象 @return [Object]

Public Class Methods

new(body) click to toggle source

ノードを初期化する @param [Object] body 符号反転の対象

# File lib/bcdice/common_command/add_dice/node.rb, line 334
def initialize(body)
  @body = body
end

Public Instance Methods

eval(game_system, randomizer) click to toggle source

ノードを評価する

対象オペランドを再帰的に評価した後、評価結果の符号を反転する。

@param [Randomizer] randomizer ランダマイザ @return [Integer] 評価結果

# File lib/bcdice/common_command/add_dice/node.rb, line 344
def eval(game_system, randomizer)
  -@body.eval(game_system, randomizer)
end
expr(game_system) click to toggle source

文字列に変換する @return [String]

# File lib/bcdice/common_command/add_dice/node.rb, line 355
def expr(game_system)
  "-#{@body.expr(game_system)}"
end
include_dice?() click to toggle source

@return [Boolean]

# File lib/bcdice/common_command/add_dice/node.rb, line 349
def include_dice?
  @body.include_dice?
end
output() click to toggle source

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

# File lib/bcdice/common_command/add_dice/node.rb, line 361
def output
  "-#{@body.output}"
end
s_exp() click to toggle source

ノードのS式を返す @return [String]

# File lib/bcdice/common_command/add_dice/node.rb, line 367
def s_exp
  "(- #{@body.s_exp})"
end