Class: TwitterCldr::Segmentation::RuleSet

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter_cldr/segmentation/rule_set.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(locale, state_machine, options) ⇒ RuleSet

Returns a new instance of RuleSet.



21
22
23
24
25
26
27
# 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

Instance Attribute Details

#localeObject (readonly)

Returns the value of attribute locale.



16
17
18
# File 'lib/twitter_cldr/segmentation/rule_set.rb', line 16

def locale
  @locale
end

#state_machineObject (readonly)

Returns the value of attribute state_machine.



16
17
18
# File 'lib/twitter_cldr/segmentation/rule_set.rb', line 16

def state_machine
  @state_machine
end

#use_uli_exceptionsObject Also known as: use_uli_exceptions?

Returns the value of attribute use_uli_exceptions.



17
18
19
# File 'lib/twitter_cldr/segmentation/rule_set.rb', line 17

def use_uli_exceptions
  @use_uli_exceptions
end

Class Method Details

.create(locale, boundary_type, options = {}) ⇒ Object



11
12
13
# 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

Instance Method Details

#boundary_typeObject



38
39
40
# File 'lib/twitter_cldr/segmentation/rule_set.rb', line 38

def boundary_type
  state_machine.boundary_type
end

#each_boundary(cursor, stop = cursor.length) ⇒ Object



29
30
31
32
33
34
35
36
# 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