Class: LuxAssets::Asset
- Inherits:
-
Object
- Object
- LuxAssets::Asset
- Defined in:
- lib/lux_assets/asset.rb
Overview
Asset group, single asset that produces target css or js
Instance Method Summary collapse
- #compile ⇒ Object
- #css? ⇒ Boolean
- #files ⇒ Object
-
#initialize(ext, name) ⇒ Asset
constructor
A new instance of Asset.
- #js? ⇒ Boolean
Constructor Details
#initialize(ext, name) ⇒ Asset
5 6 7 8 9 10 |
# File 'lib/lux_assets/asset.rb', line 5 def initialize ext, name @ext = ext == :js ? :js : :css @name = name.to_s @files = LuxAssets.to_h[ext][@name] @target = "#{@ext}/#{@name}" end |
Instance Method Details
#compile ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/lux_assets/asset.rb', line 20 def compile @data = [] LuxAssets::Cli.die "No files found for [#{@ext}/#{@name}]" unless @files[0] for file in @files if file.is_a?(Proc) @data.push file.call else @data.push LuxAssets::Element.new(file).compile end end send 'compile_%s' % @ext @asset_file end |
#css? ⇒ Boolean
16 17 18 |
# File 'lib/lux_assets/asset.rb', line 16 def css? @ext == :css end |
#files ⇒ Object
38 39 40 |
# File 'lib/lux_assets/asset.rb', line 38 def files @files end |
#js? ⇒ Boolean
12 13 14 |
# File 'lib/lux_assets/asset.rb', line 12 def js? @ext == :js end |