Method: RDoc::Parser::Ruby#initialize

Defined in:
lib/rdoc/parser/ruby.rb

#initialize(top_level, file_name, content, options, stats) ⇒ Ruby

Creates a new Ruby parser.



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/rdoc/parser/ruby.rb', line 164

def initialize(top_level, file_name, content, options, stats)
  super

  if /\t/ =~ content then
    tab_width = @options.tab_width
    content = content.split(/\n/).map do |line|
      1 while line.gsub!(/\t+/) {
        ' ' * (tab_width*$&.length - $`.length % tab_width)
      }  && $~
      line
    end.join("\n")
  end

  @size = 0
  @token_listeners = nil
  content = RDoc::Encoding.remove_magic_comment content
  @scanner = RDoc::Parser::RipperStateLex.parse(content)
  @content = content
  @scanner_point = 0
  @prev_seek = nil
  @markup = @options.markup
  @track_visibility = :nodoc != @options.visibility
  @encoding = @options.encoding

  reset
end