Class: TwitterCldr::Segmentation::BreakIterator
- Inherits:
-
Object
- Object
- TwitterCldr::Segmentation::BreakIterator
- Defined in:
- lib/twitter_cldr/segmentation/break_iterator.rb
Instance Attribute Summary collapse
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #each_grapheme_cluster(str, &block) ⇒ Object
- #each_line(str, &block) ⇒ Object
- #each_sentence(str, &block) ⇒ Object
- #each_word(str, &block) ⇒ Object
-
#initialize(locale = TwitterCldr.locale, options = {}) ⇒ BreakIterator
constructor
A new instance of BreakIterator.
Constructor Details
#initialize(locale = TwitterCldr.locale, options = {}) ⇒ BreakIterator
Returns a new instance of BreakIterator.
24 25 26 27 |
# File 'lib/twitter_cldr/segmentation/break_iterator.rb', line 24 def initialize(locale = TwitterCldr.locale, = {}) @locale = locale @options = end |
Instance Attribute Details
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
22 23 24 |
# File 'lib/twitter_cldr/segmentation/break_iterator.rb', line 22 def locale @locale end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
22 23 24 |
# File 'lib/twitter_cldr/segmentation/break_iterator.rb', line 22 def @options end |
Class Method Details
.iterator_for(boundary_type, locale = nil, options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/twitter_cldr/segmentation/break_iterator.rb', line 10 def iterator_for(boundary_type, locale = nil, = {}) rule_set = RuleSet.create(locale, boundary_type, ) case boundary_type when 'word' WordIterator.new(rule_set) else SegmentIterator.new(rule_set) end end |
Instance Method Details
#each_grapheme_cluster(str, &block) ⇒ Object
39 40 41 42 |
# File 'lib/twitter_cldr/segmentation/break_iterator.rb', line 39 def each_grapheme_cluster(str, &block) iter = iterator_for('grapheme') iter.each_segment(str, &block) end |
#each_line(str, &block) ⇒ Object
44 45 46 47 |
# File 'lib/twitter_cldr/segmentation/break_iterator.rb', line 44 def each_line(str, &block) iter = iterator_for('line') iter.each_segment(str, &block) end |
#each_sentence(str, &block) ⇒ Object
29 30 31 32 |
# File 'lib/twitter_cldr/segmentation/break_iterator.rb', line 29 def each_sentence(str, &block) iter = iterator_for('sentence') iter.each_segment(str, &block) end |
#each_word(str, &block) ⇒ Object
34 35 36 37 |
# File 'lib/twitter_cldr/segmentation/break_iterator.rb', line 34 def each_word(str, &block) iter = iterator_for('word') iter.each_segment(str, &block) end |