Class: Kotoshu::Readers::PhonetTable::Rule

Inherits:
Struct
  • Object
show all
Defined in:
lib/kotoshu/readers/aff_data.rb

Overview

Rule class for phonetic transformations.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#endBoolean

Match at end

Returns:

  • (Boolean)

    the current value of end



301
302
303
# File 'lib/kotoshu/readers/aff_data.rb', line 301

def end
  @end
end

#followupBoolean

Follow-up rule

Returns:

  • (Boolean)

    the current value of followup



301
302
303
# File 'lib/kotoshu/readers/aff_data.rb', line 301

def followup
  @followup
end

#priorityInteger

Rule priority

Returns:

  • (Integer)

    the current value of priority



301
302
303
# File 'lib/kotoshu/readers/aff_data.rb', line 301

def priority
  @priority
end

#replacementString

Replacement string

Returns:

  • (String)

    the current value of replacement



301
302
303
# File 'lib/kotoshu/readers/aff_data.rb', line 301

def replacement
  @replacement
end

#searchRegexp

Search pattern

Returns:

  • (Regexp)

    the current value of search



301
302
303
# File 'lib/kotoshu/readers/aff_data.rb', line 301

def search
  @search
end

#startBoolean

Match at start

Returns:

  • (Boolean)

    the current value of start



301
302
303
# File 'lib/kotoshu/readers/aff_data.rb', line 301

def start
  @start
end

Instance Method Details

#match?(word, pos) ⇒ Boolean

Check if rule matches at position.

Parameters:

  • word (String)

    Word to check

  • pos (Integer)

    Position in word

Returns:

  • (Boolean)

    True if matches



307
308
309
310
311
# File 'lib/kotoshu/readers/aff_data.rb', line 307

def match?(word, pos)
  return false if @start && pos > 0
  return @search.match?(word, pos) if @end
  @search.match?(word, pos)
end