Class: Layout
- Inherits:
-
Object
- Object
- Layout
- Defined in:
- lib/engine_of_war/layout.rb
Instance Attribute Summary collapse
-
#page ⇒ Object
readonly
Returns the value of attribute page.
Instance Method Summary collapse
- #default_layout ⇒ Object
-
#initialize(page) ⇒ Layout
constructor
A new instance of Layout.
- #layout_from_directory ⇒ Object
- #layout_from_meta ⇒ Object
- #name ⇒ Object
- #potential_layouts ⇒ Object
Constructor Details
#initialize(page) ⇒ Layout
Returns a new instance of Layout.
4 5 6 |
# File 'lib/engine_of_war/layout.rb', line 4 def initialize(page) @page = page end |
Instance Attribute Details
#page ⇒ Object (readonly)
Returns the value of attribute page.
2 3 4 |
# File 'lib/engine_of_war/layout.rb', line 2 def page @page end |
Instance Method Details
#default_layout ⇒ Object
26 27 28 |
# File 'lib/engine_of_war/layout.rb', line 26 def default_layout "application" end |
#layout_from_directory ⇒ Object
18 19 20 |
# File 'lib/engine_of_war/layout.rb', line 18 def layout_from_directory File.dirname(page.request_path).sub!(%r{^[/.]}, "") end |
#layout_from_meta ⇒ Object
22 23 24 |
# File 'lib/engine_of_war/layout.rb', line 22 def page.[:layout] end |
#name ⇒ Object
8 9 10 |
# File 'lib/engine_of_war/layout.rb', line 8 def name potential_layouts.first + ".html" end |
#potential_layouts ⇒ Object
12 13 14 15 16 |
# File 'lib/engine_of_war/layout.rb', line 12 def potential_layouts [layout_from_directory, , default_layout].reject(&:blank?).compact.select do |f| File.exists?(File.join(page.views_root, "layouts", "#{f}.html.haml")) end end |