Class: TwitterCldr::Parsers::SegmentationParser::BreakRule

Inherits:
Rule
  • Object
show all
Defined in:
lib/twitter_cldr/parsers/segmentation_parser.rb

Instance Attribute Summary collapse

Attributes inherited from Rule

#id, #string

Instance Method Summary collapse

Constructor Details

#initialize(left, right) ⇒ BreakRule

Returns a new instance of BreakRule.



21
22
23
24
# File 'lib/twitter_cldr/parsers/segmentation_parser.rb', line 21

def initialize(left, right)
  @left = left
  @right = right
end

Instance Attribute Details

#leftObject (readonly)

Returns the value of attribute left.



19
20
21
# File 'lib/twitter_cldr/parsers/segmentation_parser.rb', line 19

def left
  @left
end

#rightObject (readonly)

Returns the value of attribute right.



19
20
21
# File 'lib/twitter_cldr/parsers/segmentation_parser.rb', line 19

def right
  @right
end

Instance Method Details

#boundary_symbolObject



43
44
45
# File 'lib/twitter_cldr/parsers/segmentation_parser.rb', line 43

def boundary_symbol
  :break
end

#match(str) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/twitter_cldr/parsers/segmentation_parser.rb', line 26

def match(str)
  if left && left_match = left.match(str)
    match_pos = left_match.offset(0).last

    if right
      if right_match = right.match(str[match_pos..-1])
        RuleMatchData.new(
          left_match[0] + right_match[0],
          match_pos
        )
      end
    else
      RuleMatchData.new(str, str.size)
    end
  end
end