Class: LLT::Token::Word
Instance Attribute Summary
Attributes inherited from LLT::Token
#functions, #special_roles
Instance Method Summary
collapse
Methods inherited from LLT::Token
#add_form, #add_forms, #has_special_role?, #initialize, #set_special_role
Constructor Details
This class inherits a constructor from LLT::Token
Instance Method Details
#delimiter ⇒ Object
48
49
50
|
# File 'lib/llt/token/word.rb', line 48
def delimiter
" | ".cyan
end
|
#enumeration(i) ⇒ Object
44
45
46
|
# File 'lib/llt/token/word.rb', line 44
def enumeration(i)
"#{i}: ".light_yellow
end
|
31
32
33
34
35
36
37
38
|
# File 'lib/llt/token/word.rb', line 31
def forms_to_s
@container.each_with_index.each_with_object("") do |(f, i), str|
str << enumeration(i) << stripped_form(f)
str << delimiter unless f == @container.last
str
end
end
|
#inspect ⇒ Object
26
27
28
29
|
# File 'lib/llt/token/word.rb', line 26
def inspect
"#{"Word token".green}: #{@string}\n" +
"\tForms: #{forms_to_s}\n"
end
|
10
11
12
|
# File 'lib/llt/token/word.rb', line 10
def no_forms?
@container.empty?
end
|
#set_functions ⇒ Object
14
15
16
|
# File 'lib/llt/token/word.rb', line 14
def set_functions
[:word]
end
|
40
41
42
|
# File 'lib/llt/token/word.rb', line 40
def stripped_form(form)
form.to_s.sub(@string, "").strip
end
|
#use(i = nil) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/llt/token/word.rb', line 18
def use(i = nil)
if i
return @container[i - 1]
elsif block_given?
@container.find { |f| yield(f) }
end
end
|
#word ⇒ Object
6
7
8
|
# File 'lib/llt/token/word.rb', line 6
def word
@string
end
|