Class: LLT::Token

Inherits:
Object
  • Object
show all
Includes:
Core::Containable, Helpers::Functions
Defined in:
lib/llt/token.rb,
lib/llt/token/word.rb,
lib/llt/token/filler.rb,
lib/llt/token/xml_tag.rb,
lib/llt/token/punctuation.rb

Direct Known Subclasses

Filler, Punctuation, Word, XmlTag

Defined Under Namespace

Classes: Filler, Punctuation, Word, XmlTag

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string, id = nil) ⇒ Token

Returns a new instance of Token.



19
20
21
22
# File 'lib/llt/token.rb', line 19

def initialize(string, id = nil)
  super
  @functions = set_functions
end

Instance Attribute Details

#functionsObject (readonly)

Returns the value of attribute functions.



15
16
17
# File 'lib/llt/token.rb', line 15

def functions
  @functions
end

#special_rolesObject (readonly)

Returns the value of attribute special_roles.



15
16
17
# File 'lib/llt/token.rb', line 15

def special_roles
  @special_roles
end

Instance Method Details

#==(other) ⇒ Object



37
38
39
# File 'lib/llt/token.rb', line 37

def ==(other)
  to_s.downcase == other.to_s.downcase
end

#add_form(form) ⇒ Object

deprecated



42
43
44
# File 'lib/llt/token.rb', line 42

def add_form(form)
  @forms << form
end

#add_forms(forms) ⇒ Object

deprecated



47
48
49
# File 'lib/llt/token.rb', line 47

def add_forms(forms)
  @forms += forms
end

#has_special_role?(role) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/llt/token.rb', line 28

def has_special_role?(role)
  special_roles.include?(role)
end

#set_functions(*args) ⇒ Object



55
56
57
# File 'lib/llt/token.rb', line 55

def set_functions(*args)
  # hook method
end

#set_special_role(*roles) ⇒ Object



32
33
34
35
# File 'lib/llt/token.rb', line 32

def set_special_role(*roles)
  @special_roles ||= []
  @special_roles += roles
end

#use(*args) ⇒ Object



51
52
53
# File 'lib/llt/token.rb', line 51

def use(*args)
  # hook method, overwritten by Word
end