Module: Aardi::AbstractPageSupport
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#mtime ⇒ Object
readonly
Returns the value of attribute mtime.
Instance Method Summary collapse
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/aardi/abstract_page_support.rb', line 5 def @metadata end |
#mtime ⇒ Object (readonly)
Returns the value of attribute mtime.
5 6 7 |
# File 'lib/aardi/abstract_page_support.rb', line 5 def mtime @mtime end |
Instance Method Details
#parse_source(path) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/aardi/abstract_page_support.rb', line 7 def parse_source(path) File.open(path, encoding: 'utf-8') do |file| parts = file.read.rpartition("\n----\n") @metadata = YAML.safe_load(parts.first, permitted_classes: [Time]) || {} @src_content = parts.last @mtime = file.mtime.utc end end |
#title ⇒ Object
16 17 18 |
# File 'lib/aardi/abstract_page_support.rb', line 16 def title ['Title'] || @src_content.split("\n").first.sub(/^#+ /, '') end |