123456789_123456789_123456789_123456789_123456789_

Class: YARD::Parser::Ruby::Legacy::Statement

Relationships & Source Files
Inherits: Object
Defined in: lib/yard/parser/ruby/legacy/statement.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(tokens, block = nil, comments = nil) ⇒ Statement

[ GitHub ]

  
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 14

def initialize(tokens, block = nil, comments = nil)
  @tokens = tokens
  @block  = block
  @comments = comments
  @comments_hash_flag = false
end

Instance Attribute Details

#block (readonly)

[ GitHub ]

  
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 5

attr_reader :tokens, :comments, :block

#comments (readonly)

[ GitHub ]

  
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 5

attr_reader :tokens, :comments, :block

#comments_hash_flag (rw)

[ GitHub ]

  
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 12

attr_accessor :comments_hash_flag

#comments_range (rw)

[ GitHub ]

  
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 6

attr_accessor :comments_range

#group (rw)

Deprecated.

Groups are now defined by directives

[ GitHub ]

  
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 10

attr_accessor :group

#tokens (readonly)

[ GitHub ]

  
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 5

attr_reader :tokens, :comments, :block

Instance Method Details

#clean_tokens(tokens) (private)

[ GitHub ]

  
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 58

def clean_tokens(tokens)
  last_tk = nil
  tokens.reject do |tk|
    tk.is_a?(RubyToken::TkNL) ||
      (last_tk.is_a?(RubyToken::TkSPACE) &&
      last_tk.class == tk.class) && last_tk = tk
  end
end

#first_line Also known as: #signature

[ GitHub ]

  
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 21

def first_line
  to_s.split(/\n/)[0]
end

#inspect

[ GitHub ]

  
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 34

def inspect
  l = line - 1
  to_s(false).split(/\n/).map do |text|
    "\t#{l += 1}:  #{text}"
  end.join("\n")
end

#lineFixnum

Returns:

[ GitHub ]

  
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 46

def line
  tokens.first.line_no
end

#line_rangeRange<Fixnum>

Returns:

Since:

  • 0.5.4

[ GitHub ]

  
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 52

def line_range
  tokens.first.line_no..tokens.last.line_no
end

#show

[ GitHub ]

  
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 41

def show
  "\t#{line}: #{first_line}"
end

#signature

Alias for #first_line.

[ GitHub ]

  
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 25

alias signature first_line

#source(include_block = true)

Alias for #to_s.

[ GitHub ]

  
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 32

alias source to_s

#to_s(include_block = true) Also known as: #source

[ GitHub ]

  
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 27

def to_s(include_block = true)
  tokens.map do |token|
    RubyToken::TkBlockContents === token ? (include_block ? block.to_s : '') : token.text
  end.join
end