Class: BCDice::CommonCommand::TallyDice::Node::Notation

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

Overview

個数カウントダイス:ダイス表記のノード

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(times:, sides:, show_zeros:) ⇒ Notation

Returns a new instance of Notation.

Parameters:

  • times (#eval)

    振る回数

  • sides (#eval)

    面数

  • show_zeros (Boolean)

    個数0を表示するか



79
80
81
82
83
# File 'lib/bcdice/common_command/tally_dice/node.rb', line 79

def initialize(times:, sides:, show_zeros:)
  @times = times
  @sides = sides
  @show_zeros = show_zeros
end

Instance Attribute Details

#show_zerosBoolean (readonly)

Returns 個数0を表示するか.

Returns:

  • (Boolean)

    個数0を表示するか



74
75
76
# File 'lib/bcdice/common_command/tally_dice/node.rb', line 74

def show_zeros
  @show_zeros
end

#sidesInteger (readonly)

Returns 面数.

Returns:

  • (Integer)

    面数



72
73
74
# File 'lib/bcdice/common_command/tally_dice/node.rb', line 72

def sides
  @sides
end

#timesInteger (readonly)

Returns 振る回数.

Returns:

  • (Integer)

    振る回数



70
71
72
# File 'lib/bcdice/common_command/tally_dice/node.rb', line 70

def times
  @times
end

Instance Method Details

#to_dice(round_type) ⇒ Dice

Parameters:

  • round_type (Symbol)

    除算の端数処理方法

Returns:



87
88
89
90
91
92
# File 'lib/bcdice/common_command/tally_dice/node.rb', line 87

def to_dice(round_type)
  times = @times.eval(round_type)
  sides = @sides.eval(round_type)

  Dice.new(times: times, sides: sides, show_zeros: @show_zeros)
end