Class: Laze::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/laze/item.rb

Overview

An item is a basic node in a site. It is usually not used directly, but only through one of its subclasses, like Page or Section. An item is used as a generic container for static files, such as images.

Direct Known Subclasses

Asset, Layout, Section

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(properties, content) ⇒ Item

New items should be created with a hash of options:

Item.new :title => 'Foo'


19
20
21
# File 'lib/laze/item.rb', line 19

def initialize(properties, content)
  @properties, @content, @parent = properties, content, nil
end

Instance Attribute Details

#contentObject

Contents of the file



13
14
15
# File 'lib/laze/item.rb', line 13

def content
  @content
end

#parentObject

Other item that has this item as one of its subitems.



10
11
12
# File 'lib/laze/item.rb', line 10

def parent
  @parent
end

#propertiesObject

Hash of proprties, like page title or output filename.



7
8
9
# File 'lib/laze/item.rb', line 7

def properties
  @properties
end

Instance Method Details

#ancestorsObject

An array of items, where each item is the next’s parent.



39
40
41
# File 'lib/laze/item.rb', line 39

def ancestors
  parent ? [parent, *parent.ancestors].reverse : []
end

#filenameObject

Shortcut method to the filename property.



29
30
31
# File 'lib/laze/item.rb', line 29

def filename
  @properties[:filename]
end

#has?(key) ⇒ Boolean

Test if this item has a given property.

Returns:

  • (Boolean)


24
25
26
# File 'lib/laze/item.rb', line 24

def has?(key)
  @properties.has_key?(key)
end

#inspectObject

:nodoc:



47
48
49
# File 'lib/laze/item.rb', line 47

def inspect #:nodoc:
  "#<#{self.class}:0x#{self.object_id.to_s(16)} #{filename}>"
end

#number_of_subitemsObject



33
34
35
# File 'lib/laze/item.rb', line 33

def number_of_subitems
  0
end

#to_sObject

:nodoc:



43
44
45
# File 'lib/laze/item.rb', line 43

def to_s #:nodoc:
  filename
end