Parent

Class/Module Index [+]

Quicksearch

YARD::Parser::Ruby::Legacy::TokenList

Public Class Methods

new(content = nil) click to toggle source
# File lib/yard/parser/ruby/legacy/token_list.rb, line 6
def initialize(content = nil)
  self << content if content
end

Public Instance Methods

<<(*tokens) click to toggle source
Alias for: push
push(*tokens) click to toggle source

@param [TokenList, Token, String] tokens

A list of tokens. If the token is a string, it
is parsed with {RubyLex}.
# File lib/yard/parser/ruby/legacy/token_list.rb, line 25
def push(*tokens)
  tokens.each do |tok|
    if tok.is_a?(TokenList) || tok.is_a?(Array)
      concat tok
    elsif tok.is_a?(Token)
      super tok
    elsif tok.is_a?(String)
      parse_content(tok)
    else
      raise ArgumentError, "Expecting token, list of tokens or string of code to be tokenized. Got #{tok.class}"
    end
  end
  self
end
Also aliased as: <<
squeeze(type = TkSPACE) click to toggle source
# File lib/yard/parser/ruby/legacy/token_list.rb, line 41
def squeeze(type = TkSPACE)
  last = nil
  TokenList.new(map {|t| x = t.is_a?(type) && last.is_a?(type) ? nil : t; last = t; x })
end
to_s(full_statement = false, show_block = true) click to toggle source
# File lib/yard/parser/ruby/legacy/token_list.rb, line 10
def to_s(full_statement = false, show_block = true)
  inject([]) do |acc, token|
    break acc if !full_statement && TkStatementEnd === token
    if !show_block && TkBlockContents === token
      acc << ""
    else
      acc << token.text
    end
    acc
  end.join
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.