Class: YARD::CodeObjects::ExtraFileObject

Inherits:
Object
  • Object
show all
Defined in:
lib/yard/code_objects/extra_file_object.rb

Overview

An ExtraFileObject represents an extra documentation file (README or other file). It is not strictly a CodeObject (does not inherit from Base) although it implements path, name and type, and therefore should be structurally compatible with most CodeObject interfaces.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, contents = nil) ⇒ ExtraFileObject

Creates a new extra file object.



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

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



8
9
10
# File 'lib/yard/code_objects/extra_file_object.rb', line 8

def attributes
  @attributes
end

#contentsObject

Returns the value of attribute contents.



10
11
12
# File 'lib/yard/code_objects/extra_file_object.rb', line 10

def contents
  @contents
end

#filenameObject

Returns the value of attribute filename.



7
8
9
# File 'lib/yard/code_objects/extra_file_object.rb', line 7

def filename
  @filename
end

#nameObject Also known as: path

Returns the value of attribute name.



9
10
11
# File 'lib/yard/code_objects/extra_file_object.rb', line 9

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?, equal?



36
37
38
39
# File 'lib/yard/code_objects/extra_file_object.rb', line 36

def ==(other)
  return false unless self.class === other
  other.filename == filename
end

#hashObject



42
# File 'lib/yard/code_objects/extra_file_object.rb', line 42

def hash; filename.hash end

#inspectObject Also known as: to_s



29
30
31
# File 'lib/yard/code_objects/extra_file_object.rb', line 29

def inspect
  "#<yardoc #{type} #{filename} attrs=#{attributes.inspect}>"
end

#titleObject



25
26
27
# File 'lib/yard/code_objects/extra_file_object.rb', line 25

def title
  attributes[:title] || name
end

#typeObject



34
# File 'lib/yard/code_objects/extra_file_object.rb', line 34

def type; 'extra_file' end