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
- #base64_styles ⇒ Object
- #clone ⇒ Object
-
#initialize(condition = "") ⇒ BlockData
constructor
A new instance of BlockData.
- #mhtml_styles ⇒ Object
- #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
43 44 45 46 47 48 49 50 |
# File 'lib/web_resource_bundler/content_management/block_data.rb', line 43 def self.all_childs(block_data) result = [] result << block_data block_data.child_blocks.each do |child| result += BlockData.all_childs(child) end result end |
Instance Method Details
#all_files ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/web_resource_bundler/content_management/block_data.rb', line 35 def all_files result = self.files self.child_blocks.each do |child| result += child.all_files end result end |
#apply_filters(filters) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/web_resource_bundler/content_management/block_data.rb', line 52 def apply_filters(filters) if filters.any? filters.each do |filter| items = BlockData.all_childs(self) items.each { |block_data| filter.apply!(block_data) } end end end |
#base64_styles ⇒ Object
20 21 22 |
# File 'lib/web_resource_bundler/content_management/block_data.rb', line 20 def base64_styles @files.select { |f| WebResourceBundler::ResourceFileType::CSS_TYPES.include?(f.type)} end |
#clone ⇒ Object
28 29 30 31 32 33 |
# File 'lib/web_resource_bundler/content_management/block_data.rb', line 28 def clone clon = self.dup clon.files = self.files.map {|f| f.clone} clon.child_blocks = clon.child_blocks.any? ? self.child_blocks.map { |block| block.clone } : [] clon end |
#mhtml_styles ⇒ Object
24 25 26 |
# File 'lib/web_resource_bundler/content_management/block_data.rb', line 24 def mhtml_styles @files.select { |f| WebResourceBundler::ResourceFileType::MHTML_TYPES.include?(f.type)} end |
#scripts ⇒ Object
16 17 18 |
# File 'lib/web_resource_bundler/content_management/block_data.rb', line 16 def scripts @files.select { |f| f.type[:ext] == 'js'} end |
#styles ⇒ Object
12 13 14 |
# File 'lib/web_resource_bundler/content_management/block_data.rb', line 12 def styles @files.select { |f| f.type[:ext] == 'css' } end |