Class: Nanoc3::Item
Nanoc3::Item is represents all compileable items in a site. It has content and attributes, as well as an identifier. It can also store the modification time to speed up compilation.
Attributes
Instance Attributes
| attributes | [RW] | public |
A hash containing this item’s attributes. |
|---|---|---|---|
| children | [RW] | public |
The child items of this item. |
| dependencies_outdated | [RW] | public |
A boolean indicating whether or not this item is outdated because of its dependencies are outdated. |
| identifier | [RW] | public |
This item’s identifier. |
| mtime | [R] | public |
The time when this item was last modified. |
| parent | [RW] | public |
The parent item of this item. |
| raw_content | [R] | public |
This item’s raw, uncompiled content. |
| reps | [R] | public |
This item’s list of item representations. |
| site | [RW] | public |
The Nanoc3::Site this item belongs to. |
Constructor Summary
Creates a new item.
| raw_content: | The uncompiled item content. |
| attributes: | A hash containing this item’s attributes. |
| identifier: | This item’s identifier. |
| mtime: | The time when this item was last modified. |
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/nanoc3/base/item.rb', line 46 def initialize(raw_content, attributes, identifier, mtime=nil) @raw_content = raw_content @attributes = attributes.symbolize_keys @identifier = identifier.cleaned_identifier @mtime = mtime @parent = nil @children = [] @reps = [] end |
Public Visibility
Public Instance Method Summary
| #[](key) |
Requests the attribute with the given key. |
|---|---|
| #[]=(key, value) |
Sets the attribute with the given key to the given value. |
| #dependencies_outdated? |
Alias for #dependencies_outdated. |
| #inspect | |
| #outdated? |
True if any reps are outdated; false otherwise. |
Public Instance Method Details
[]
Requests the attribute with the given key.
59 60 61 62 63 64 |
# File 'lib/nanoc3/base/item.rb', line 59 def [](key) Nanoc3::NotificationCenter.post(:visit_started, self) Nanoc3::NotificationCenter.post(:visit_ended, self) @attributes[key] end |
[]=
Sets the attribute with the given key to the given value.
67 68 69 |
# File 'lib/nanoc3/base/item.rb', line 67 def []=(key, value) @attributes[key] = value end |
dependencies_outdated?
Alias for #dependencies_outdated.
77 78 79 |
# File 'lib/nanoc3/base/item.rb', line 77 def dependencies_outdated? self.dependencies_outdated end |
inspect
81 82 83 |
# File 'lib/nanoc3/base/item.rb', line 81 def inspect "<#{self.class}:0x#{self.object_id.to_s(16)} identifier=#{self.identifier}>" end |
outdated?
True if any reps are outdated; false otherwise.
72 73 74 |
# File 'lib/nanoc3/base/item.rb', line 72 def outdated? @reps.any? { |r| r.outdated? } end |