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
-
#filename ⇒ Object
Returns the value of attribute filename.
- #locale ⇒ Object
-
#name ⇒ Object
(also: #path)
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?, #equal?)
- #contents ⇒ Object
- #contents=(contents) ⇒ Object
- #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.
17 18 19 20 21 22 23 24 25 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 17 def initialize(filename, contents = nil) self.filename = filename self.name = File.basename(filename).gsub(/\.[^.]+$/, '') self.attributes = SymbolHash.new(false) @original_contents = contents @parsed = false @locale = nil ensure_parsed end |
Instance Attribute Details
#attributes ⇒ Object
29 30 31 32 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 29 def attributes ensure_parsed @attributes 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 |
#locale ⇒ Object
11 12 13 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 11 def locale @locale 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?
63 64 65 66 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 63 def ==(other) return false unless self.class === other other.filename == filename end |
#contents ⇒ Object
38 39 40 41 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 38 def contents ensure_parsed @contents end |
#contents=(contents) ⇒ Object
43 44 45 46 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 43 def contents=(contents) @original_contents = contents @parsed = false end |
#hash ⇒ Object
69 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 69 def hash; filename.hash end |
#inspect ⇒ Object Also known as: to_s
56 57 58 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 56 def inspect "#<yardoc #{type} #{filename} attrs=#{attributes.inspect}>" end |
#title ⇒ Object
34 35 36 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 34 def title attributes[:title] || name end |
#type ⇒ Object
61 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 61 def type; :extra_file end |