Class: JAPR::Converter
- Inherits:
-
Object
- Object
- JAPR::Converter
- Extended by:
- SubclassTracking
- Defined in:
- lib/japr/converter.rb
Overview
Base class for asset converters See github.com/janosrusiczki/japr#asset-preprocessing
Instance Attribute Summary collapse
-
#converted ⇒ Object
readonly
Returns the value of attribute converted.
Class Method Summary collapse
-
.filetype ⇒ Object
Filetype to process (e.g. ‘.coffee’).
-
.klass(filename) ⇒ Object
Finds a converter class based on a filename.
Instance Method Summary collapse
-
#convert ⇒ Object
Logic to convert assets.
-
#initialize(asset) ⇒ Converter
constructor
A new instance of Converter.
Methods included from SubclassTracking
Constructor Details
#initialize(asset) ⇒ Converter
Returns a new instance of Converter.
7 8 9 10 11 12 |
# File 'lib/japr/converter.rb', line 7 def initialize(asset) @content = asset.content @type = File.extname(asset.filename).downcase @dirname = asset.dirname @converted = convert end |
Instance Attribute Details
#converted ⇒ Object (readonly)
Returns the value of attribute converted.
14 15 16 |
# File 'lib/japr/converter.rb', line 14 def converted @converted end |
Class Method Details
.filetype ⇒ Object
Filetype to process (e.g. ‘.coffee’)
17 18 19 |
# File 'lib/japr/converter.rb', line 17 def self.filetype '' end |
.klass(filename) ⇒ Object
Finds a converter class based on a filename
22 23 24 25 26 |
# File 'lib/japr/converter.rb', line 22 def self.klass(filename) JAPR::Converter.subclasses.select do |c| c.filetype == File.extname(filename).downcase end.last end |
Instance Method Details
#convert ⇒ Object
Logic to convert assets
Available instance variables: Returns converted string
36 37 38 |
# File 'lib/japr/converter.rb', line 36 def convert @content end |