Class: EngineOfWar::Page
- Inherits:
-
Object
- Object
- EngineOfWar::Page
- Defined in:
- lib/engine_of_war/page.rb
Constant Summary collapse
- YAML_REGEXP =
/^(---\s*\n.*?\n?)^(---\s*$\n?)/m
Instance Attribute Summary collapse
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#request_path ⇒ Object
readonly
Returns the value of attribute request_path.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#views_root ⇒ Object
readonly
Returns the value of attribute views_root.
Instance Method Summary collapse
- #engine ⇒ Object
- #github_edit_url ⇒ Object
-
#initialize(request_path) ⇒ Page
constructor
A new instance of Page.
- #layout ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(request_path) ⇒ Page
Returns a new instance of Page.
6 7 8 9 10 11 12 |
# File 'lib/engine_of_war/page.rb', line 6 def initialize(request_path) @views_root = EngineOfWar::App.settings.views @root = EngineOfWar::App.settings.root @request_path = normalize_path(request_path) @entire_source = File.read(template_path) @meta, @source = split_body end |
Instance Attribute Details
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
4 5 6 |
# File 'lib/engine_of_war/page.rb', line 4 def @meta end |
#request_path ⇒ Object (readonly)
Returns the value of attribute request_path.
4 5 6 |
# File 'lib/engine_of_war/page.rb', line 4 def request_path @request_path end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
4 5 6 |
# File 'lib/engine_of_war/page.rb', line 4 def root @root end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
4 5 6 |
# File 'lib/engine_of_war/page.rb', line 4 def source @source end |
#views_root ⇒ Object (readonly)
Returns the value of attribute views_root.
4 5 6 |
# File 'lib/engine_of_war/page.rb', line 4 def views_root @views_root end |
Instance Method Details
#engine ⇒ Object
22 23 24 |
# File 'lib/engine_of_war/page.rb', line 22 def engine template_path.split(".").last.to_sym end |
#github_edit_url ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/engine_of_war/page.rb', line 26 def github_edit_url snippet = EngineOfWar::App.settings.github_info if snippet.blank? raise RuntimeError, "We don't know your github info. Fix with: EngineOfWar::App.set :github_info, 'foo/bar'" end "https://github.com/#{snippet}/edit/master#{template_path.sub(root, '')}" end |
#layout ⇒ Object
14 15 16 |
# File 'lib/engine_of_war/page.rb', line 14 def layout Layout.new(self).name end |
#url ⇒ Object
18 19 20 |
# File 'lib/engine_of_war/page.rb', line 18 def url request_path end |