Class: BCDice::CommonCommand::AddDice::Node::Number

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

Overview

数値のノード

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(literal) ⇒ Number

ノードを初期化する

Parameters:

  • literal (Integer)



625
626
627
# File 'lib/bcdice/common_command/add_dice/node.rb', line 625

def initialize(literal)
  @literal = literal
end

Instance Attribute Details

#literalInteger (readonly)

Returns:

  • (Integer)


621
622
623
# File 'lib/bcdice/common_command/add_dice/node.rb', line 621

def literal
  @literal
end

Instance Method Details

#eval(_game_system, _randomizer) ⇒ Integer

ノードを評価する

Returns:

  • (Integer)

    格納している値



637
638
639
# File 'lib/bcdice/common_command/add_dice/node.rb', line 637

def eval(_game_system, _randomizer)
  @literal
end

#expr(_game_system) ⇒ String

文字列に変換する

Returns:

  • (String)


648
649
650
# File 'lib/bcdice/common_command/add_dice/node.rb', line 648

def expr(_game_system)
  @literal.to_s
end

#include_dice?Boolean

Returns:

  • (Boolean)


642
643
644
# File 'lib/bcdice/common_command/add_dice/node.rb', line 642

def include_dice?
  false
end

#negateNumber

符号を反転した結果の数値ノードを返す

Returns:



631
632
633
# File 'lib/bcdice/common_command/add_dice/node.rb', line 631

def negate
  Number.new(-@literal)
end

#outputObject Also known as: s_exp



652
653
654
# File 'lib/bcdice/common_command/add_dice/node.rb', line 652

def output
  @literal.to_s
end