Class: TwitterCldr::Parsers::SegmentationParser::BreakRule
- Defined in:
- lib/twitter_cldr/parsers/segmentation_parser.rb
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Attributes inherited from Rule
Instance Method Summary collapse
- #boundary_symbol ⇒ Object
-
#initialize(left, right) ⇒ BreakRule
constructor
A new instance of BreakRule.
- #match(str) ⇒ Object
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
#left ⇒ Object (readonly)
Returns the value of attribute left.
19 20 21 |
# File 'lib/twitter_cldr/parsers/segmentation_parser.rb', line 19 def left @left end |
#right ⇒ Object (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_symbol ⇒ Object
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 |