Class: TwitterCldr::Segmentation::Rule
- Inherits:
-
Object
- Object
- TwitterCldr::Segmentation::Rule
- Defined in:
- lib/twitter_cldr/segmentation/rule.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
-
#string ⇒ Object
Returns the value of attribute string.
Instance Method Summary collapse
-
#initialize(left, right) ⇒ Rule
constructor
A new instance of Rule.
- #match(cursor) ⇒ Object
Constructor Details
#initialize(left, right) ⇒ Rule
Returns a new instance of Rule.
17 18 19 20 |
# File 'lib/twitter_cldr/segmentation/rule.rb', line 17 def initialize(left, right) @left = left @right = right end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
15 16 17 |
# File 'lib/twitter_cldr/segmentation/rule.rb', line 15 def id @id end |
#left ⇒ Object (readonly)
Returns the value of attribute left.
14 15 16 |
# File 'lib/twitter_cldr/segmentation/rule.rb', line 14 def left @left end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
14 15 16 |
# File 'lib/twitter_cldr/segmentation/rule.rb', line 14 def right @right end |
#string ⇒ Object
Returns the value of attribute string.
15 16 17 |
# File 'lib/twitter_cldr/segmentation/rule.rb', line 15 def string @string end |
Instance Method Details
#match(cursor) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/twitter_cldr/segmentation/rule.rb', line 22 def match(cursor) left_match = match_side(left, cursor.text, cursor.position) return nil unless left_match left_match_offset = offset(left_match, cursor.position) right_match = match_side(right, cursor.text, left_match_offset.last) return nil unless right_match right_match_offset = offset(right_match, left_match_offset.last) offset = [left_match_offset.first, right_match_offset.last] position = left_match_offset.last RuleMatchData.new(self, offset, position) end |