Class: Blogical::Content::Repository

Inherits:
Object
  • Object
show all
Defined in:
app/blogical/content.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Repository

Returns a new instance of Repository.



15
16
17
18
# File 'app/blogical/content.rb', line 15

def initialize(path)
  @path, @index, @articles, @attachments = path, [], {}, {}
  scan
end

Instance Attribute Details

#articlesObject

Returns the value of attribute articles.



13
14
15
# File 'app/blogical/content.rb', line 13

def articles
  @articles
end

#pathObject

Returns the value of attribute path.



13
14
15
# File 'app/blogical/content.rb', line 13

def path
  @path
end

Instance Method Details

#find_by_attachment(attachment) ⇒ Object



24
25
26
# File 'app/blogical/content.rb', line 24

def find_by_attachment(attachment)
  @attachments[attachment]
end


20
21
22
# File 'app/blogical/content.rb', line 20

def find_by_permalink(link)
  @articles[link]
end

#latestObject



33
34
35
# File 'app/blogical/content.rb', line 33

def latest
  @index[0]
end

#paginated(page_number = 1) ⇒ Object



41
42
43
# File 'app/blogical/content.rb', line 41

def paginated(page_number = 1)
  @index.page(page_number)
end

#recent(count = 3) ⇒ Object



28
29
30
31
# File 'app/blogical/content.rb', line 28

def recent(count = 3)
  count = @index.size if count > @index.size
  @index[0..(count - 1)]
end

#total_pagesObject



37
38
39
# File 'app/blogical/content.rb', line 37

def total_pages
  @index.total_pages
end