Class: Munge::Application
- Inherits:
-
Object
- Object
- Munge::Application
- Defined in:
- lib/munge/application.rb
Overview
This class is one of the main interfaces users would interact with. This provides methods to create and iterate through items.
Instance Method Summary collapse
-
#build_virtual_item(relpath, content, **frontmatter) ⇒ Item
Builds an Item.
-
#create(*args) ⇒ Array<Item>
Creates an Item and inserts it into the registry of Items.
-
#initialize(conglomerate) ⇒ Application
constructor
A new instance of Application.
- #items ⇒ Array<Item>
- #nonrouted ⇒ Array<Item>
- #routed ⇒ Array<Item>
-
#vomit(component_name) ⇒ Object
Returns parts of Conglomerate.
Constructor Details
#initialize(conglomerate) ⇒ Application
Returns a new instance of Application.
5 6 7 |
# File 'lib/munge/application.rb', line 5 def initialize(conglomerate) @conglomerate = conglomerate end |
Instance Method Details
#build_virtual_item(relpath, content, **frontmatter) ⇒ Item
Builds an Item
27 28 29 |
# File 'lib/munge/application.rb', line 27 def build_virtual_item(relpath, content, **frontmatter) @conglomerate.item_factory.build(relpath: relpath, content: content, frontmatter: frontmatter) end |
#create(*args) ⇒ Array<Item>
Creates an Item and inserts it into the registry of Items.
38 39 40 41 42 |
# File 'lib/munge/application.rb', line 38 def create(*args) item = build_virtual_item(*args) @conglomerate.items.push(item) [item] end |
#items ⇒ Array<Item>
10 11 12 |
# File 'lib/munge/application.rb', line 10 def items @conglomerate.items end |
#nonrouted ⇒ Array<Item>
15 16 17 |
# File 'lib/munge/application.rb', line 15 def nonrouted items.select { |item| item.route.nil? } end |
#routed ⇒ Array<Item>
20 21 22 |
# File 'lib/munge/application.rb', line 20 def routed items.select(&:route) end |
#vomit(component_name) ⇒ Object
Returns parts of Conglomerate
47 48 49 |
# File 'lib/munge/application.rb', line 47 def vomit(component_name) @conglomerate.public_send(component_name) end |