class TwitterCldr::Segmentation::RuleSet

Attributes

locale[R]
state_machine[R]
use_uli_exceptions[RW]
use_uli_exceptions?[RW]

Public Class Methods

create(locale, boundary_type, options = {}) click to toggle source
# File lib/twitter_cldr/segmentation/rule_set.rb, line 11
def create(locale, boundary_type, options = {})
  new(locale, StateMachine.instance(boundary_type, locale), options)
end
new(locale, state_machine, options) click to toggle source
# File lib/twitter_cldr/segmentation/rule_set.rb, line 21
def initialize(locale, state_machine, options)
  @locale = locale
  @state_machine = state_machine
  @use_uli_exceptions = options.fetch(
    :use_uli_exceptions, false
  )
end

Public Instance Methods

boundary_type() click to toggle source
# File lib/twitter_cldr/segmentation/rule_set.rb, line 38
def boundary_type
  state_machine.boundary_type
end
each_boundary(cursor, stop = cursor.length) { |position| ... } click to toggle source
# File lib/twitter_cldr/segmentation/rule_set.rb, line 29
def each_boundary(cursor, stop = cursor.length)
  return to_enum(__method__, cursor, stop) unless block_given?

  until cursor.position >= stop || cursor.eos?
    state_machine.handle_next(cursor)
    yield cursor.position if suppressions.should_break?(cursor)
  end
end

Private Instance Methods

suppressions() click to toggle source
# File lib/twitter_cldr/segmentation/rule_set.rb, line 44
def suppressions
  @suppressions ||= if use_uli_exceptions?
    Suppressions.instance(boundary_type, locale)
  else
    NullSuppressions.instance
  end
end