Class: YARD::CodeObjects::ExtraFileObject
- Inherits:
-
Object
- Object
- YARD::CodeObjects::ExtraFileObject
- 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
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#name ⇒ Object
(also: #path)
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?, #equal?)
- #hash ⇒ Object
-
#initialize(filename, contents = nil) ⇒ ExtraFileObject
constructor
Creates a new extra file object.
- #inspect ⇒ Object (also: #to_s)
- #title ⇒ Object
- #type ⇒ Object
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
#attributes ⇒ Object
Returns the value of attribute attributes.
8 9 10 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 8 def attributes @attributes end |
#contents ⇒ Object
Returns the value of attribute contents.
10 11 12 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 10 def contents @contents end |
#filename ⇒ Object
Returns the value of attribute filename.
7 8 9 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 7 def filename @filename end |
#name ⇒ Object 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 |
#hash ⇒ Object
42 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 42 def hash; filename.hash end |
#inspect ⇒ Object 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 |
#title ⇒ Object
25 26 27 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 25 def title attributes[:title] || name end |
#type ⇒ Object
34 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 34 def type; 'extra_file' end |