Class: Nanoc::Core::Content
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
enabled?, included, setup_once, warn_about_performance
Constructor Details
#initialize(filename) ⇒ Content
Returns a new instance of Content.
29
30
31
32
33
34
35
|
# File 'lib/nanoc/core/content.rb', line 29
def initialize(filename)
if filename && Pathname.new(filename).relative?
raise ArgumentError, "Content filename #{filename} is not absolute"
end
@filename = filename
end
|
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
26
27
28
|
# File 'lib/nanoc/core/content.rb', line 26
def filename
@filename
end
|
Class Method Details
.create(content, binary: false, filename: nil) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/nanoc/core/content.rb', line 13
def self.create(content, binary: false, filename: nil)
if content.nil?
raise ArgumentError, 'Cannot create nil content'
elsif content.is_a?(Nanoc::Core::Content)
content
elsif binary
Nanoc::Core::BinaryContent.new(content)
else
Nanoc::Core::TextualContent.new(content, filename:)
end
end
|
Instance Method Details
#binary? ⇒ Boolean
45
46
47
|
# File 'lib/nanoc/core/content.rb', line 45
def binary?
raise NotImplementedError
end
|
#freeze ⇒ Object
38
39
40
41
42
|
# File 'lib/nanoc/core/content.rb', line 38
def freeze
super
@filename.freeze
self
end
|
#textual? ⇒ Boolean
50
51
52
|
# File 'lib/nanoc/core/content.rb', line 50
def textual?
!binary?
end
|