Method: Natter::Rule#initialize

Defined in:
lib/natter/rule.rb

#initialize(name, pattern = //, skill = NO_SKILL, *entities) ⇒ Rule

Public: Constructor.

name - The name of this intent. Names do not need to be unique

within a parser.

pattern - The regular expression that matches the contents of an

utterance. If this intent contains entities then the regex 
must capture the entities within the utterance as named 
capture groups. See examples below. Default: //

skill - The name of the skill that this rule belongs to. The first

letter will be capitalised (e.g. `sonos` => `Sonos`). If none 
is passed then is set to Rule::NO_SKILL

entities - Optional array of Entity objects in the form:

Each entity must have a correspondingly named capture group 
within the regex.


33
34
35
36
37
38
# File 'lib/natter/rule.rb', line 33

def initialize(name, pattern = //, skill = NO_SKILL, *entities)
  @name = name
  @pattern = pattern
  skill == NO_SKILL ? @skill = NO_SKILL : @skill = skill.capitalize
  @entities = entities || []
end