class ParaDice::Results::SplitFaces
Results
class to take faces and split them given a string or regexp
Constants
- DEFAULT_SPLIT_TOKEN
when performing the split, use this regexp by default
Attributes
default_split_token[RW]
@!attribute default_split_token
@return [Regexp, String] used by split to separate token into pieces
Public Class Methods
new(default_split_token = DEFAULT_SPLIT_TOKEN)
click to toggle source
@param [Regex,String] split_token defaults to DEFAULT_SPLIT_TOKEN
=/-|_/
# 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
Public Instance Methods
resolve(faces, split_token = default_split_token)
click to toggle source
@param [Array<#to_s>] faces @param [Regex,String] split_token defaults to default_split_token
@return [Array<String>]
# 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