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:, content: nil, filename: 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.



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/nanoc/data_sources/filesystem.rb', line 83

def initialize(is_binary:, content: nil, filename: 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
  @checksum_data = 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.



78
79
80
# File 'lib/nanoc/data_sources/filesystem.rb', line 78

def attributes
  @attributes
end

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



79
80
81
# File 'lib/nanoc/data_sources/filesystem.rb', line 79

def checksum_data
  @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.



80
81
82
# File 'lib/nanoc/data_sources/filesystem.rb', line 80

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.



95
96
97
98
99
100
101
# File 'lib/nanoc/data_sources/filesystem.rb', line 95

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.



103
104
105
106
107
108
109
# File 'lib/nanoc/data_sources/filesystem.rb', line 103

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