Class: BCDice::Arithmetic::Node::Parenthesis

Inherits:
Object
  • Object
show all
Defined in:
lib/bcdice/arithmetic/node.rb

Overview

カッコで式をまとめるノード

Instance Method Summary collapse

Constructor Details

#initialize(expr) ⇒ Parenthesis

Returns a new instance of Parenthesis.

Parameters:

  • expr (Object) —

    カッコ内のノード



184
185
186
# File 'lib/bcdice/arithmetic/node.rb', line 184

def initialize(expr)
  @expr = expr
end

Instance Method Details

#eval(round_type) ⇒ Integer

Returns 評価結果.

Parameters:

  • round_type (Symbol) —

    端数処理方法

Returns:

  • (Integer) —

    評価結果



190
191
192
# File 'lib/bcdice/arithmetic/node.rb', line 190

def eval(round_type)
  @expr.eval(round_type)
end

#output ⇒ String

Returns メッセージへの出力.

Returns:

  • (String) —

    メッセージへの出力



195
196
197
# File 'lib/bcdice/arithmetic/node.rb', line 195

def output
  "(#{@expr.output})"
end

#s_exp ⇒ String

Returns S式.

Returns:

  • (String) —

    S式



200
201
202
# File 'lib/bcdice/arithmetic/node.rb', line 200

def s_exp
  "(Parenthesis #{@expr.s_exp})"
end