Class: Nanoc::Int::TextualContent Private

Inherits:
Content
  • Object
show all
Defined in:
lib/nanoc/base/entities/content.rb

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.

Instance Attribute Summary

Attributes inherited from Content

#filename

Instance Method Summary collapse

Methods inherited from Content

create

Methods included from ContractsSupport

included

Constructor Details

#initialize(string, filename: nil) ⇒ TextualContent

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 TextualContent.



73
74
75
76
# File 'lib/nanoc/base/entities/content.rb', line 73

def initialize(string, filename: nil)
  super(filename)
  @string = Nanoc::Int::LazyValue.new(string)
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.

Returns:

  • (Boolean)


86
87
88
# File 'lib/nanoc/base/entities/content.rb', line 86

def binary?
  false
end

#freezeObject

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.



79
80
81
82
83
# File 'lib/nanoc/base/entities/content.rb', line 79

def freeze
  super
  @string.freeze
  self
end

#marshal_dumpObject

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.

TODO: Add contract



91
92
93
# File 'lib/nanoc/base/entities/content.rb', line 91

def marshal_dump
  [filename, string]
end

#marshal_load(array) ⇒ 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.

TODO: Add contract



96
97
98
99
# File 'lib/nanoc/base/entities/content.rb', line 96

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

#stringString

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:



68
69
70
# File 'lib/nanoc/base/entities/content.rb', line 68

def string
  @string.value
end