Class: Silly::PageModel
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Silly::PageModel
- Defined in:
- lib/silly/page_model.rb
Constant Summary collapse
- DateMatcher =
/^(.+\/)*(\d+-\d+-\d+)-(.*)(\.[^.]+)$/- Matcher =
/^(.+\/)*(.*)(\.[^.]+)$/
Class Attribute Summary collapse
-
.after_content ⇒ Object
Returns the value of attribute after_content.
-
.after_data ⇒ Object
Returns the value of attribute after_data.
-
.before_content ⇒ Object
Returns the value of attribute before_content.
-
.before_data ⇒ Object
Returns the value of attribute before_data.
Instance Method Summary collapse
Class Attribute Details
.after_content ⇒ Object
Returns the value of attribute after_content.
7 8 9 |
# File 'lib/silly/page_model.rb', line 7 def after_content @after_content end |
.after_data ⇒ Object
Returns the value of attribute after_data.
7 8 9 |
# File 'lib/silly/page_model.rb', line 7 def after_data @after_data end |
.before_content ⇒ Object
Returns the value of attribute before_content.
7 8 9 |
# File 'lib/silly/page_model.rb', line 7 def before_content @before_content end |
.before_data ⇒ Object
Returns the value of attribute before_data.
7 8 9 |
# File 'lib/silly/page_model.rb', line 7 def before_data @before_data end |
Instance Method Details
#content ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/silly/page_model.rb', line 30 def content result = Silly::Parse.page_file(realpath)["content"] if self.class.before_content.respond_to?(:call) result = self.class.before_content.call(result) end self.class.before_content.respond_to?(:call) ? self.class.before_content.call(result) : result end |
#data ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/silly/page_model.rb', line 10 def data return {} unless file? data = Silly::Parse.page_file(realpath)["data"] data['id'] = id if self.class.before_data.respond_to?(:call) data = self.class.before_data.call(data) end filename_data = parse_page_filename(id) data['title'] ||= filename_data['title'] data['date'] = parse_date(data['date'] || filename_data['date']) data['_url'] = make_url(data) self.class.after_data.respond_to?(:call) ? self.class.after_data.call(data) : data end |