Class: Nanoc::DataSources::Filesystem::ProtoDocument Private

Inherits:
Object
  • Object
show all
Defined in:
lib/nanoc/data_sources/filesystem.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 collapse

Instance Method Summary collapse

Constructor Details

#initialize(is_binary:, attributes:, content: nil, filename: nil, content_checksum_data: nil, attributes_checksum_data: nil) ⇒ ProtoDocument

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



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/nanoc/data_sources/filesystem.rb', line 124

def initialize(
  is_binary:, attributes:, content: nil, filename: nil,
  content_checksum_data: nil,
  attributes_checksum_data: nil
)
  if content.nil? && filename.nil?
    raise ArgumentError, '#initialize needs at least content or filename'
  end

  @is_binary = is_binary
  @content = content
  @filename = filename
  @attributes = attributes
  @content_checksum_data = content_checksum_data
  @attributes_checksum_data = attributes_checksum_data
end

Instance Attribute Details

#attributesObject (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.



118
119
120
# File 'lib/nanoc/data_sources/filesystem.rb', line 118

def attributes
  @attributes
end

#attributes_checksum_dataObject (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.



120
121
122
# File 'lib/nanoc/data_sources/filesystem.rb', line 120

def attributes_checksum_data
  @attributes_checksum_data
end

#content_checksum_dataObject (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.



119
120
121
# File 'lib/nanoc/data_sources/filesystem.rb', line 119

def content_checksum_data
  @content_checksum_data
end

#is_binaryObject (readonly) Also known as: binary?

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.



121
122
123
# File 'lib/nanoc/data_sources/filesystem.rb', line 121

def is_binary
  @is_binary
end

Instance Method Details

#contentObject

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.



141
142
143
144
145
146
147
# File 'lib/nanoc/data_sources/filesystem.rb', line 141

def content
  if binary?
    raise ArgumentError, 'cannot fetch content of binary item'
  else
    @content
  end
end

#filenameObject

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.



149
150
151
152
153
154
155
# File 'lib/nanoc/data_sources/filesystem.rb', line 149

def filename
  if binary?
    @filename
  else
    raise ArgumentError, 'cannot fetch filename of non-binary item'
  end
end