Class: Opulent::Filters::Filter
- Inherits:
-
Object
- Object
- Opulent::Filters::Filter
- Defined in:
- lib/opulent/filters.rb
Direct Known Subclasses
CData, CoffeeScript, Css, Escaped, JavaScript, Markdown, Maruku, RedCloth, Sass, Scss
Instance Attribute Summary collapse
-
#loaded ⇒ Object
Returns the value of attribute loaded.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#gem_name ⇒ Object
RubyGems name for explicit library require.
-
#initialize(name, options) ⇒ Filter
constructor
Set tag and attribute options for filter.
-
#install_error ⇒ Object
Error message to be shown in order to provide installation instructions for the developer.
-
#load_filter ⇒ Object
Error output in case the filter does not exist.
-
#render(_code, _options = {}) ⇒ Object
Process input code using this filter and return the output to the evaluation method from the Filter Node.
Constructor Details
#initialize(name, options) ⇒ Filter
Set tag and attribute options for filter
33 34 35 36 37 |
# File 'lib/opulent/filters.rb', line 33 def initialize(name, ) @name = name = @loaded = false end |
Instance Attribute Details
#loaded ⇒ Object
Returns the value of attribute loaded.
29 30 31 |
# File 'lib/opulent/filters.rb', line 29 def loaded @loaded end |
#name ⇒ Object
Returns the value of attribute name.
29 30 31 |
# File 'lib/opulent/filters.rb', line 29 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
29 30 31 |
# File 'lib/opulent/filters.rb', line 29 def end |
Instance Method Details
#gem_name ⇒ Object
RubyGems name for explicit library require
70 71 72 73 |
# File 'lib/opulent/filters.rb', line 70 def gem_name fail NoMethodError # "gem_name" end |
#install_error ⇒ Object
Error message to be shown in order to provide installation instructions for the developer
57 58 59 |
# File 'lib/opulent/filters.rb', line 57 def install_error "gem install #{gem_name}" end |
#load_filter ⇒ Object
Error output in case the filter does not exist
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/opulent/filters.rb', line 41 def load_filter return if gem_name.nil? || @loaded # Try to load the library associated to the chosen filter begin require gem_name @loaded = true rescue LoadError # Error output with filter name and installation instructions Logger.error :compile, :filter_load, @name, install_error end end |
#render(_code, _options = {}) ⇒ Object
Process input code using this filter and return the output to the evaluation method from the Filter Node
64 65 66 |
# File 'lib/opulent/filters.rb', line 64 def render(_code, = {}) fail NoMethodError end |