Class: ParaDice::Results::SplitFaces
- Inherits:
-
Object
- Object
- ParaDice::Results::SplitFaces
- Defined in:
- lib/para_dice/results/split_faces.rb
Overview
Results class to take faces and split them given a string or regexp
Constant Summary collapse
- DEFAULT_SPLIT_TOKEN =
when performing the split, use this regexp by default
/-|_/
Instance Attribute Summary collapse
-
#default_split_token ⇒ Regexp, String
Used by split to separate token into pieces.
Instance Method Summary collapse
-
#initialize(default_split_token = DEFAULT_SPLIT_TOKEN) ⇒ SplitFaces
constructor
A new instance of SplitFaces.
- #resolve(faces, split_token = default_split_token) ⇒ Array<String>
Constructor Details
#initialize(default_split_token = DEFAULT_SPLIT_TOKEN) ⇒ SplitFaces
Returns a new instance of SplitFaces.
11 12 13 |
# File 'lib/para_dice/results/split_faces.rb', line 11 def initialize(default_split_token = DEFAULT_SPLIT_TOKEN) @default_split_token = default_split_token end |
Instance Attribute Details
#default_split_token ⇒ Regexp, String
Returns used by split to separate token into pieces.
7 8 9 |
# File 'lib/para_dice/results/split_faces.rb', line 7 def default_split_token @default_split_token end |
Instance Method Details
#resolve(faces, split_token = default_split_token) ⇒ Array<String>
18 19 20 |
# File 'lib/para_dice/results/split_faces.rb', line 18 def resolve(faces, split_token = default_split_token) faces.map { |f| f.to_s.split(split_token) }.flatten(1) end |