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