Class: PragmaticSegmenter::Rule

Inherits:
Struct
  • Object
show all
Defined in:
lib/pragmatic_segmenter/types.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#patternObject

Returns the value of attribute pattern

Returns:

  • (Object)

    the current value of pattern



4
5
6
# File 'lib/pragmatic_segmenter/types.rb', line 4

def pattern
  @pattern
end

#replacementObject

Returns the value of attribute replacement

Returns:

  • (Object)

    the current value of replacement



4
5
6
# File 'lib/pragmatic_segmenter/types.rb', line 4

def replacement
  @replacement
end

Class Method Details

.apply(str, *rules) ⇒ Object



6
7
8
9
10
11
# File 'lib/pragmatic_segmenter/types.rb', line 6

def apply(str, *rules)
  rules.flatten.each do |rule|
    str.gsub!(rule.pattern, rule.replacement)
  end
  str
end