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.
18 19 20 21 22 23 24 25 26 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 18 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
30 31 32 33 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 30 def attributes ensure_parsed @attributes end |
#filename ⇒ Object
Returns the value of attribute filename.
8 9 10 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 8 def filename @filename end |
#locale ⇒ Object
12 13 14 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 12 def locale @locale end |
#name ⇒ Object Also known as: path
Returns the value of attribute name.
10 11 12 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 10 def name @name end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?, equal?
64 65 66 67 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 64 def ==(other) return false unless self.class === other other.filename == filename end |
#contents ⇒ Object
39 40 41 42 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 39 def contents ensure_parsed @contents end |
#contents=(contents) ⇒ Object
44 45 46 47 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 44 def contents=(contents) @original_contents = contents @parsed = false end |
#hash ⇒ Object
70 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 70 def hash; filename.hash end |
#inspect ⇒ Object Also known as: to_s
57 58 59 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 57 def inspect "#<yardoc #{type} #{filename} attrs=#{attributes.inspect}>" end |
#title ⇒ Object
35 36 37 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 35 def title attributes[:title] || name end |
#type ⇒ Object
62 |
# File 'lib/yard/code_objects/extra_file_object.rb', line 62 def type; :extra_file end |