Class: Alula::Content
- Inherits:
-
Object
- Object
- Alula::Content
- Defined in:
- lib/alula/content.rb,
lib/alula/contents/item.rb,
lib/alula/contents/page.rb,
lib/alula/contents/post.rb,
lib/alula/contents/metadata.rb,
lib/alula/contents/attachment.rb
Defined Under Namespace
Classes: Attachment, Item, Metadata, Page, Post
Instance Attribute Summary collapse
-
#attachments ⇒ Object
readonly
Returns the value of attribute attachments.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
-
#posts ⇒ Object
readonly
Returns the value of attribute posts.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
-
#statics ⇒ Object
readonly
Returns the value of attribute statics.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Content
constructor
A new instance of Content.
-
#load ⇒ Object
Load our site content.
- #method_missing(meth, *args, &blk) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Content
Returns a new instance of Content.
15 16 17 18 19 20 21 22 23 |
# File 'lib/alula/content.rb', line 15 def initialize(opts = {}) @site = opts.delete(:site) @config = @site.config @pages = [] @posts = [] @attachments = [] @statics = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &blk) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/alula/content.rb', line 38 def method_missing(meth, *args, &blk) if m = /^by_(\S+)$/.match(meth) return (self.pages + self.posts + self.).find do |item| item.send(m[1]) == args.first end end super end |
Instance Attribute Details
#attachments ⇒ Object (readonly)
Returns the value of attribute attachments.
12 13 14 |
# File 'lib/alula/content.rb', line 12 def @attachments end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/alula/content.rb', line 8 def config @config end |
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
10 11 12 |
# File 'lib/alula/content.rb', line 10 def pages @pages end |
#posts ⇒ Object (readonly)
Returns the value of attribute posts.
11 12 13 |
# File 'lib/alula/content.rb', line 11 def posts @posts end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
7 8 9 |
# File 'lib/alula/content.rb', line 7 def site @site end |
#statics ⇒ Object (readonly)
Returns the value of attribute statics.
13 14 15 |
# File 'lib/alula/content.rb', line 13 def statics @statics end |
Instance Method Details
#load ⇒ Object
Load our site content
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/alula/content.rb', line 26 def load # Load everything we can have read_content(:posts, :pages, :attachments, :statics) # Generate our dynamic content (pages, categories, archives, etc. etc.) generate_content # Write slugs to config self.config.slugs = (@posts + @pages).collect{|c| c..slug} self.config.slugs.count end |