class Nanoc::Core::Content

Attributes

filename[R]

Public Class Methods

create(content, binary: false, filename: nil) click to toggle source
# File lib/nanoc/core/content.rb, line 28
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: filename)
  end
end
new(filename) click to toggle source
# File lib/nanoc/core/content.rb, line 12
def initialize(filename)
  if filename && Pathname.new(filename).relative?
    raise ArgumentError, 'Content filename is not absolute'
  end

  @filename = filename
end

Public Instance Methods

binary?() click to toggle source
# File lib/nanoc/core/content.rb, line 41
def binary?
  raise NotImplementedError
end
freeze() click to toggle source
Calls superclass method
# File lib/nanoc/core/content.rb, line 21
def freeze
  super
  @filename.freeze
  self
end
textual?() click to toggle source
# File lib/nanoc/core/content.rb, line 46
def textual?
  !binary?
end