Class: Nanoc::Int::Content Abstract Private
- Inherits:
-
Object
- Object
- Nanoc::Int::Content
- Includes:
- ContractsSupport
- Defined in:
- lib/nanoc/base/entities/content.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Abstract content.
The filename is the full filename on the default filesystem. It can be nil. It is used by filters such as Sass, which look up items on the filesystem.
Direct Known Subclasses
Instance Attribute Summary collapse
- #filename ⇒ String? readonly private
Class Method Summary collapse
Instance Method Summary collapse
- #binary? ⇒ Boolean abstract private
- #freeze ⇒ Object private
-
#initialize(filename) ⇒ Content
constructor
private
A new instance of Content.
Methods included from ContractsSupport
Constructor Details
#initialize(filename) ⇒ Content
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Content.
20 21 22 23 24 25 26 |
# File 'lib/nanoc/base/entities/content.rb', line 20 def initialize(filename) if filename && Pathname.new(filename).relative? raise ArgumentError, 'Content filename is not absolute' end @filename = filename end |
Instance Attribute Details
#filename ⇒ String? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
16 17 18 |
# File 'lib/nanoc/base/entities/content.rb', line 16 def filename @filename end |
Class Method Details
.create(content, binary: false, filename: nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/nanoc/base/entities/content.rb', line 44 def self.create(content, binary: false, filename: nil) if content.nil? raise ArgumentError, 'Cannot create nil content' elsif content.is_a?(Nanoc::Int::Content) content elsif binary Nanoc::Int::BinaryContent.new(content) else Nanoc::Int::TextualContent.new(content, filename: filename) end end |
Instance Method Details
#binary? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
59 60 61 |
# File 'lib/nanoc/base/entities/content.rb', line 59 def binary? raise NotImplementedError end |
#freeze ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 32 33 |
# File 'lib/nanoc/base/entities/content.rb', line 29 def freeze super @filename.freeze self end |