Class: Pubba::Page
- Inherits:
-
Object
- Object
- Pubba::Page
- Defined in:
- lib/pubba/page.rb
Instance Attribute Summary collapse
-
#assets ⇒ Object
readonly
Returns the value of attribute assets.
-
#body_tags ⇒ Object
readonly
Returns the value of attribute body_tags.
-
#head_tags ⇒ Object
readonly
Returns the value of attribute head_tags.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #add_asset(type, section) ⇒ Object
- #assetize ⇒ Object
-
#initialize(name, global_configuration = {}) ⇒ Page
constructor
A new instance of Page.
- #method_missing(meth, *args) ⇒ Object
- #tagify ⇒ Object
Constructor Details
#initialize(name, global_configuration = {}) ⇒ Page
Returns a new instance of Page.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/pubba/page.rb', line 6 def initialize(name, global_configuration = {}) @name = name @assets = {"styles" => {}, "scripts" => {}} @head_tags = [] @body_tags = [] global_configuration["styles"].each do |key, value| @assets["styles"][key] = value.dup end script_groups do |group| @assets["scripts"][group] = global_configuration["scripts"][group] || [] end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Instance Attribute Details
#assets ⇒ Object (readonly)
Returns the value of attribute assets.
4 5 6 |
# File 'lib/pubba/page.rb', line 4 def assets @assets end |
#body_tags ⇒ Object (readonly)
Returns the value of attribute body_tags.
4 5 6 |
# File 'lib/pubba/page.rb', line 4 def @body_tags end |
#head_tags ⇒ Object (readonly)
Returns the value of attribute head_tags.
4 5 6 |
# File 'lib/pubba/page.rb', line 4 def @head_tags end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/pubba/page.rb', line 3 def name @name end |
Instance Method Details
#add_asset(type, section) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/pubba/page.rb', line 21 def add_asset(type, section) if type == "styles" section.each do |section_name, hash| hash.each do |key, value| if key == "urls" @assets[type][section_name][key] += value else @assets[type][section_name][key] = value end end end else script_groups do |group| @assets["scripts"][group] += section[group] if section[group] end end end |
#assetize ⇒ Object
39 40 41 42 |
# File 'lib/pubba/page.rb', line 39 def assetize create_style_assets create_script_assets end |
#tagify ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/pubba/page.rb', line 44 def tagify style_groups do |group, hash| style_urls(group) do |url| add_style_tag(group, hash, url) end end script_groups do |group| script_urls(group) do |url| add_script_tag(group, url) end end end |