Module: RollPartString

Included in:
DiceBag::RollPart
Defined in:
lib/dicebag/roll_part_string.rb

Overview

This encapsulates the RollPart string generation methods.

Instance Method Summary collapse

Instance Method Details

#inspectObject



23
24
25
# File 'lib/dicebag/roll_part_string.rb', line 23

def inspect
  "<#{self.class.name} #{self}>"
end

#to_s(no_spaces = false) ⇒ Object

This takes the @parts hash and recreates the xDx string. Optionally, passing true to the method will remove spaces from the finished string.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dicebag/roll_part_string.rb', line 6

def to_s(no_spaces = false)
  @parts = []

  to_s_xdx
  to_s_explode
  to_s_drop
  to_s_keep
  to_s_keeplowest
  to_s_reroll
  to_s_target
  to_s_failure

  join_str = no_spaces ? '' : ' '

  @parts.join join_str
end