Class: N::Shader

Inherits:
Object
  • Object
show all
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

NilShader

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#mtimeObject

Returns the value of attribute mtime.



58
59
60
# File 'lib/n/shaders.rb', line 58

def mtime
  @mtime
end

#nameObject

Returns the value of attribute name.



54
55
56
# File 'lib/n/shaders.rb', line 54

def name
  @name
end

#xsl_filenameObject

Returns the value of attribute xsl_filename.



55
56
57
# File 'lib/n/shaders.rb', line 55

def xsl_filename
  @xsl_filename
end

#xsltObject

the xslt transoformer.



57
58
59
# File 'lib/n/shaders.rb', line 57

def xslt
  @xslt
end

Instance Method Details

#to_sObject



84
85
86
# File 'lib/n/shaders.rb', line 84

def to_s
	@name
end

#xslObject



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