Module: Attentive::Tokens

Included in:
Tokenizer
Defined in:
lib/attentive/tokens.rb,
lib/attentive/tokens/word.rb,
lib/attentive/tokens/emoji.rb,
lib/attentive/tokens/any_of.rb,
lib/attentive/tokens/regexp.rb,
lib/attentive/tokens/invocation.rb,
lib/attentive/tokens/whitespace.rb,
lib/attentive/tokens/punctuation.rb

Defined Under Namespace

Classes: AnyOf, Emoji, Invocation, Punctuation, Regexp, Whitespace, Word

Instance Method Summary collapse

Instance Method Details

#any_of(string, possibilities, pos: nil) ⇒ Object



4
5
6
# File 'lib/attentive/tokens.rb', line 4

def any_of(string, possibilities, pos: nil)
  Attentive::Tokens::AnyOf.new string, possibilities, pos
end

#emoji(string, pos: nil) ⇒ Object



8
9
10
# File 'lib/attentive/tokens.rb', line 8

def emoji(string, pos: nil)
  Attentive::Tokens::Emoji.new string, pos
end

#entity(string, pos: nil) ⇒ Object



12
13
14
15
# File 'lib/attentive/tokens.rb', line 12

def entity(string, pos: nil)
  entity_name, variable_name = *string.split(":").reverse
  Attentive::Entity[entity_name.to_sym].new(variable_name || entity_name)
end

#invocation(string, pos: nil) ⇒ Object



17
18
19
# File 'lib/attentive/tokens.rb', line 17

def invocation(string, pos: nil)
  Attentive::Tokens::Invocation.new string, pos
end

#punctuation(string, pos: nil) ⇒ Object



21
22
23
# File 'lib/attentive/tokens.rb', line 21

def punctuation(string, pos: nil)
  Attentive::Tokens::Punctuation.new string, pos
end

#regexp(string, pos: nil) ⇒ Object



25
26
27
# File 'lib/attentive/tokens.rb', line 25

def regexp(string, pos: nil)
  Attentive::Tokens::Regexp.new string, pos
end

#whitespace(string, pos: nil) ⇒ Object



29
30
31
# File 'lib/attentive/tokens.rb', line 29

def whitespace(string, pos: nil)
  Attentive::Tokens::Whitespace.new string, pos
end

#word(string, pos: nil) ⇒ Object



33
34
35
# File 'lib/attentive/tokens.rb', line 33

def word(string, pos: nil)
  Attentive::Tokens::Word.new string, pos
end