class TwitterCldr::Segmentation::BreakIterator
Attributes
locale[R]
options[R]
Public Class Methods
new(locale = TwitterCldr.locale, options = {})
click to toggle source
# File lib/twitter_cldr/segmentation/break_iterator.rb, line 11 def initialize(locale = TwitterCldr.locale, options = {}) @locale = locale @options = options end
Public Instance Methods
each_grapheme_cluster(str, &block)
click to toggle source
# File lib/twitter_cldr/segmentation/break_iterator.rb, line 26 def each_grapheme_cluster(str, &block) iter = iterator_for('grapheme') iter.each_segment(str, &block) end
each_line(str, &block)
click to toggle source
# File lib/twitter_cldr/segmentation/break_iterator.rb, line 31 def each_line(str, &block) iter = iterator_for('line') iter.each_segment(str, &block) end
each_sentence(str, &block)
click to toggle source
# File lib/twitter_cldr/segmentation/break_iterator.rb, line 16 def each_sentence(str, &block) iter = iterator_for('sentence') iter.each_segment(str, &block) end
each_word(str, &block)
click to toggle source
# File lib/twitter_cldr/segmentation/break_iterator.rb, line 21 def each_word(str, &block) iter = iterator_for('word') iter.each_segment(str, &block) end
Private Instance Methods
iterator_cache()
click to toggle source
# File lib/twitter_cldr/segmentation/break_iterator.rb, line 53 def iterator_cache @iterator_cache ||= {} end
iterator_for(boundary_type)
click to toggle source
# File lib/twitter_cldr/segmentation/break_iterator.rb, line 38 def iterator_for(boundary_type) iterator_cache[boundary_type] ||= begin rule_set = RuleSet.create(locale, boundary_type, options) case boundary_type when 'line' LineIterator.new(rule_set) when 'word' WordIterator.new(rule_set) else SegmentIterator.new(rule_set) end end end