Class: Nanoc::Core::TextualContent

Inherits:
Content
  • Object
show all
Defined in:
lib/nanoc/core/textual_content.rb

Instance Attribute Summary

Attributes inherited from Content

#filename

Instance Method Summary collapse

Methods inherited from Content

create, #textual?

Methods included from ContractsSupport

enabled?, included, setup_once, warn_about_performance

Constructor Details

#initialize(string, filename: nil) ⇒ TextualContent

Returns a new instance of TextualContent.



7
8
9
10
# File 'lib/nanoc/core/textual_content.rb', line 7

def initialize(string, filename: nil)
  super(filename)
  @string = Nanoc::Core::LazyValue.new(string)
end

Instance Method Details

#binary?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/nanoc/core/textual_content.rb', line 25

def binary?
  false
end

#freezeObject



18
19
20
21
22
# File 'lib/nanoc/core/textual_content.rb', line 18

def freeze
  super
  @string.freeze
  self
end

#marshal_dumpObject



30
31
32
# File 'lib/nanoc/core/textual_content.rb', line 30

def marshal_dump
  [filename, string]
end

#marshal_load(array) ⇒ Object



35
36
37
38
# File 'lib/nanoc/core/textual_content.rb', line 35

def marshal_load(array)
  @filename = array[0]
  @string = Nanoc::Core::LazyValue.new(array[1])
end

#stringObject



13
14
15
# File 'lib/nanoc/core/textual_content.rb', line 13

def string
  @string.value
end