Class: N::Shader
- Inherits:
-
Object
- Object
- N::Shader
- Defined in:
- lib/n/shaders.rb
Overview
Shader
One shader can utilize several xsls to render different pages. the shader selection may be time consuming but is performed once when transforming the script, so its essentially for free (and anyway the xsl transoformation is orders of magnitude slower)
There is no need to keep post xsl. I can reuse the same xsl by calling transform again.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#mtime ⇒ Object
Returns the value of attribute mtime.
-
#name ⇒ Object
Returns the value of attribute name.
-
#xsl_filename ⇒ Object
Returns the value of attribute xsl_filename.
-
#xslt ⇒ Object
the xslt transoformer.
Instance Method Summary collapse
-
#initialize(name, xsl_filename) ⇒ Shader
constructor
A new instance of Shader.
- #to_s ⇒ Object
- #xsl ⇒ Object
-
#xsl_transform(document) ⇒ Object
(also: #transform)
transform the given document.
Constructor Details
#initialize(name, xsl_filename) ⇒ Shader
Returns a new instance of Shader.
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/n/shaders.rb', line 60 def initialize(name, xsl_filename) # leave this require here. only inlcude the xslt # library if the project needs it. require "xml/xslt" @name = name @xsl_filename = xsl_filename @xslt = XML::XSLT.new parse_xsl! end |
Instance Attribute Details
#mtime ⇒ Object
Returns the value of attribute mtime.
58 59 60 |
# File 'lib/n/shaders.rb', line 58 def mtime @mtime end |
#name ⇒ Object
Returns the value of attribute name.
54 55 56 |
# File 'lib/n/shaders.rb', line 54 def name @name end |
#xsl_filename ⇒ Object
Returns the value of attribute xsl_filename.
55 56 57 |
# File 'lib/n/shaders.rb', line 55 def xsl_filename @xsl_filename end |
#xslt ⇒ Object
the xslt transoformer.
57 58 59 |
# File 'lib/n/shaders.rb', line 57 def xslt @xslt end |
Instance Method Details
#to_s ⇒ Object
84 85 86 |
# File 'lib/n/shaders.rb', line 84 def to_s @name end |
#xsl ⇒ Object
79 80 81 82 |
# File 'lib/n/shaders.rb', line 79 def xsl parse_xsl! if $reload_xsl return @xsl end |
#xsl_transform(document) ⇒ Object Also known as: transform
transform the given document
73 74 75 76 |
# File 'lib/n/shaders.rb', line 73 def xsl_transform(document) @xslt.xml = document return @xslt.serve() end |