Class: BCDice::DiceTable::RollResult

Inherits:
Object
  • Object
show all
Defined in:
lib/bcdice/dice_table/roll_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table_name, value, body) ⇒ RollResult

Returns a new instance of RollResult.

Parameters:

  • table_name (String)
  • value (Integer)
  • body (String, RollResult)


9
10
11
12
13
# File 'lib/bcdice/dice_table/roll_result.rb', line 9

def initialize(table_name, value, body)
  @table_name = table_name
  @value = value
  @body = body
end

Instance Attribute Details

#bodyString, RollResult (readonly)

Returns:



22
23
24
# File 'lib/bcdice/dice_table/roll_result.rb', line 22

def body
  @body
end

#table_nameString (readonly)

Returns:

  • (String)


16
17
18
# File 'lib/bcdice/dice_table/roll_result.rb', line 16

def table_name
  @table_name
end

#valueInteger (readonly)

Returns:

  • (Integer)


19
20
21
# File 'lib/bcdice/dice_table/roll_result.rb', line 19

def value
  @value
end

Instance Method Details

#empty?false

一部のゲームシステムが String#empty? を想定してチェックしているため

Returns:

  • (false)


40
41
42
# File 'lib/bcdice/dice_table/roll_result.rb', line 40

def empty?
  false
end

#last_bodyString

Returns:

  • (String)


30
31
32
33
34
35
36
# File 'lib/bcdice/dice_table/roll_result.rb', line 30

def last_body
  if @body.is_a?(RollResult)
    @body.last_body
  else
    @body
  end
end

#to_sString

Returns:

  • (String)


25
26
27
# File 'lib/bcdice/dice_table/roll_result.rb', line 25

def to_s
  "#{@table_name}(#{@value}) > #{@body}"
end