Method: YARD::CodeObjects::ExtraFileObject#initialize

Defined in:
lib/yard/code_objects/extra_file_object.rb

#initialize(filename, contents = nil) ⇒ ExtraFileObject

Creates a new extra file object.

Parameters:

  • filename (String)

    the location on disk of the file

  • contents (String) (defaults to: nil)

    the file contents. If not set, the contents will be read from disk using the filename.


16
17
18
19
20
21
# File 'lib/yard/code_objects/extra_file_object.rb', line 16

def initialize(filename, contents = nil)
  self.filename = filename
  self.name = File.basename(filename).gsub(/\.[^.]+$/, '')
  self.attributes = SymbolHash.new(false)
  parse_contents(contents || File.read(@filename))
end