Class: Laze::Item
- Inherits:
-
Object
- Object
- Laze::Item
- 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.
Instance Attribute Summary collapse
-
#content ⇒ Object
Contents of the file.
-
#parent ⇒ Object
Other item that has this item as one of its subitems.
-
#properties ⇒ Object
Hash of proprties, like page title or output filename.
Instance Method Summary collapse
-
#ancestors ⇒ Object
An array of items, where each item is the next’s parent.
-
#filename ⇒ Object
Shortcut method to the filename property.
-
#has?(key) ⇒ Boolean
Test if this item has a given property.
-
#initialize(properties, content) ⇒ Item
constructor
New items should be created with a hash of options:.
-
#inspect ⇒ Object
:nodoc:.
- #number_of_subitems ⇒ Object
-
#to_s ⇒ Object
:nodoc:.
Constructor Details
Instance Attribute Details
#content ⇒ Object
Contents of the file
13 14 15 |
# File 'lib/laze/item.rb', line 13 def content @content end |
#parent ⇒ Object
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 |
#properties ⇒ Object
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
#ancestors ⇒ Object
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 |
#filename ⇒ Object
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.
24 25 26 |
# File 'lib/laze/item.rb', line 24 def has?(key) @properties.has_key?(key) end |
#inspect ⇒ Object
: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_subitems ⇒ Object
33 34 35 |
# File 'lib/laze/item.rb', line 33 def number_of_subitems 0 end |
#to_s ⇒ Object
:nodoc:
43 44 45 |
# File 'lib/laze/item.rb', line 43 def to_s #:nodoc: filename end |