Class: Blogical::Content::Repository
- Inherits:
-
Object
- Object
- Blogical::Content::Repository
- Defined in:
- app/blogical/content.rb
Instance Attribute Summary collapse
-
#articles ⇒ Object
Returns the value of attribute articles.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #find_by_attachment(attachment) ⇒ Object
- #find_by_permalink(link) ⇒ Object
-
#initialize(path) ⇒ Repository
constructor
A new instance of Repository.
- #latest ⇒ Object
- #paginated(page_number = 1) ⇒ Object
- #recent(count = 3) ⇒ Object
- #total_pages ⇒ Object
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
#articles ⇒ Object
Returns the value of attribute articles.
13 14 15 |
# File 'app/blogical/content.rb', line 13 def articles @articles end |
#path ⇒ Object
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 () @attachments[] end |
#find_by_permalink(link) ⇒ Object
20 21 22 |
# File 'app/blogical/content.rb', line 20 def find_by_permalink(link) @articles[link] end |
#latest ⇒ Object
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_pages ⇒ Object
37 38 39 |
# File 'app/blogical/content.rb', line 37 def total_pages @index.total_pages end |