Class: WebResourceBundler::BlockData
- Inherits:
-
Object
- Object
- WebResourceBundler::BlockData
- Defined in:
- lib/web_resource_bundler/content_management/block_data.rb
Instance Attribute Summary collapse
-
#child_blocks ⇒ Object
Returns the value of attribute child_blocks.
-
#condition ⇒ Object
Returns the value of attribute condition.
-
#files ⇒ Object
Returns the value of attribute files.
-
#inline_block ⇒ Object
Returns the value of attribute inline_block.
Class Method Summary collapse
Instance Method Summary collapse
- #all_files ⇒ Object
- #apply_filters(filters) ⇒ Object
- #clone ⇒ Object
-
#initialize(condition = "") ⇒ BlockData
constructor
A new instance of BlockData.
- #scripts ⇒ Object
- #styles ⇒ Object
Constructor Details
#initialize(condition = "") ⇒ BlockData
Returns a new instance of BlockData.
5 6 7 8 9 10 |
# File 'lib/web_resource_bundler/content_management/block_data.rb', line 5 def initialize(condition = "") @inline_block = "" @files = [] @condition = condition @child_blocks = [] end |
Instance Attribute Details
#child_blocks ⇒ Object
Returns the value of attribute child_blocks.
3 4 5 |
# File 'lib/web_resource_bundler/content_management/block_data.rb', line 3 def child_blocks @child_blocks end |
#condition ⇒ Object
Returns the value of attribute condition.
3 4 5 |
# File 'lib/web_resource_bundler/content_management/block_data.rb', line 3 def condition @condition end |
#files ⇒ Object
Returns the value of attribute files.
3 4 5 |
# File 'lib/web_resource_bundler/content_management/block_data.rb', line 3 def files @files end |
#inline_block ⇒ Object
Returns the value of attribute inline_block.
3 4 5 |
# File 'lib/web_resource_bundler/content_management/block_data.rb', line 3 def inline_block @inline_block end |
Class Method Details
.all_childs(block_data) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/web_resource_bundler/content_management/block_data.rb', line 44 def self.all_childs(block_data) result = [] result << block_data block_data.child_blocks.each do |child| result += BlockData.all_childs(child) end return result end |
Instance Method Details
#all_files ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/web_resource_bundler/content_management/block_data.rb', line 36 def all_files result = self.files self.child_blocks.each do |child| result += child.all_files end result end |
#apply_filters(filters) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/web_resource_bundler/content_management/block_data.rb', line 53 def apply_filters(filters) unless filters.empty? filters.each do |filter| items = BlockData.all_childs(self) items.each do |block_data| filter.apply!(block_data) end end end end |
#clone ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/web_resource_bundler/content_management/block_data.rb', line 23 def clone clon = self.dup clon.files = self.files.map {|f| f.clone} if clon.child_blocks.size > 0 clon.child_blocks = self.child_blocks.map do |block| block.clone end else clon.child_blocks = [] end clon end |
#scripts ⇒ Object
19 20 21 |
# File 'lib/web_resource_bundler/content_management/block_data.rb', line 19 def scripts @files.select {|f| f.types.include?(WebResourceBundler::ResourceFileType::JS)} end |
#styles ⇒ Object
12 13 14 15 16 17 |
# File 'lib/web_resource_bundler/content_management/block_data.rb', line 12 def styles @files.select do |f| !([WebResourceBundler::ResourceFileType::CSS, WebResourceBundler::ResourceFileType::IE_CSS] & f.types).empty? end end |