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.
25
26
27
28
29
30
31
|
# File 'lib/nanoc/core/content.rb', line 25
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.
22
23
24
|
# File 'lib/nanoc/core/content.rb', line 22
def filename
@filename
end
|
Class Method Details
.create(content, binary: false, filename: nil) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/nanoc/core/content.rb', line 9
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
41
42
43
|
# File 'lib/nanoc/core/content.rb', line 41
def binary?
raise NotImplementedError
end
|
#freeze ⇒ Object
34
35
36
37
38
|
# File 'lib/nanoc/core/content.rb', line 34
def freeze
super
@filename.freeze
self
end
|
#textual? ⇒ Boolean
46
47
48
|
# File 'lib/nanoc/core/content.rb', line 46
def textual?
!binary?
end
|