class LLT::Token::Word

Public Instance Methods

delimiter() click to toggle source
# File lib/llt/token/word.rb, line 48
def delimiter
  " | ".cyan
end
enumeration(i) click to toggle source
# File lib/llt/token/word.rb, line 44
def enumeration(i)
  "#{i}: ".light_yellow
end
forms_to_s() click to toggle source
# File lib/llt/token/word.rb, line 31
def forms_to_s
  # was each_with_index_and_object, which is currently not available
  @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() click to toggle source
# File lib/llt/token/word.rb, line 26
def inspect
  "#{"Word token".green}: #{@string}\n" +
  "\tForms: #{forms_to_s}\n"
end
no_forms?() click to toggle source
# File lib/llt/token/word.rb, line 10
def no_forms?
  @container.empty?
end
set_functions() click to toggle source
# File lib/llt/token/word.rb, line 14
def set_functions
  [:word]
end
stripped_form(form) click to toggle source
# File lib/llt/token/word.rb, line 40
def stripped_form(form)
  form.to_s.sub(@string, "").strip
end
use(i = nil) { |f| ... } click to toggle source
# 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() click to toggle source
# File lib/llt/token/word.rb, line 6
def word
  @string
end