Class: Alula::Content

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Content

Returns a new instance of Content.



12
13
14
15
16
17
18
19
# File 'lib/alula/content.rb', line 12

def initialize(opts = {})
  @site = opts.delete(:site)
  
  @pages = []
  @posts = []
  @attachments = []
  @statics = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &blk) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/alula/content.rb', line 30

def method_missing(meth, *args, &blk)
  if m = /^by_(\S+)$/.match(meth)
    return (self.pages + self.posts + self.attachments).find do |item|
      item.send(m[1]) == args.first
    end
  end
  
  super
end

Instance Attribute Details

#attachmentsObject (readonly)

Returns the value of attribute attachments.



9
10
11
# File 'lib/alula/content.rb', line 9

def attachments
  @attachments
end

#pagesObject (readonly)

Returns the value of attribute pages.



7
8
9
# File 'lib/alula/content.rb', line 7

def pages
  @pages
end

#postsObject (readonly)

Returns the value of attribute posts.



8
9
10
# File 'lib/alula/content.rb', line 8

def posts
  @posts
end

#staticsObject (readonly)

Returns the value of attribute statics.



10
11
12
# File 'lib/alula/content.rb', line 10

def statics
  @statics
end

Instance Method Details

#loadObject

Load our site content



22
23
24
25
26
27
28
# File 'lib/alula/content.rb', line 22

def load
  # Load everything we can have
  read_content(:posts, :pages, :attachments, :statics)
  
  # Generate our dynamic content (pages, categories, archives, etc. etc.)
  generate_content
end