Class: Arrow::Template::Node
- Inherits:
-
Arrow::Object
- Object
- Arrow::Object
- Arrow::Template::Node
- Includes:
- Arrow::HTMLUtilities
- Defined in:
- lib/arrow/template/nodes.rb
Overview
The abstract base node class.
Constant Summary
- SVNRev =
SVN Revision
%q$Rev$
- SVNId =
SVN Id
%q$Id$
Constants included from Arrow::HTMLUtilities
ARRAY_HTML_CONTAINER, HASH_HTML_CONTAINER, HASH_PAIR_HTML, IMMEDIATE_OBJECT_HTML_CONTAINER, IVAR_HTML_FRAGMENT, OBJECT_HTML_CONTAINER, THREAD_DUMP_KEY
Instance Attribute Summary
-
- (Object) type
readonly
The type of the node.
Instance Method Summary
-
- (Object) add_to_template(template)
Install the node object into the given template object.
-
- (Object) css_class
protected
Return the HTML element class attribute that corresponds to this node.
-
- (Node) initialize(type = 'generic')
constructor
Provide initialization for all derivative Arrow::Template::Node objects.
-
- (Object) inspect
Return a human-readable version of the Node object suitable for debugging messages.
-
- (Boolean) is_rendering_node?
(also: #rendering?)
Returns true for nodes which generate output themselves (as opposed to ones which generate output through subnodes).
-
- (Object) render(template, scope)
Render the node to text.
-
- (Object) to_a
Return the receiver and any subnodes as a flattened Array of nodes.
-
- (Object) to_html
Return an HTML fragment that can be used to represent the node symbolically in a web-based introspection interface.
-
- (Object) to_s
Return the node as a String.
Methods included from Arrow::HTMLUtilities
#escape_html, #make_html_for_object, #make_object_html_wrapper
Methods inherited from Arrow::Object
deprecate_class_method, deprecate_method, inherited
Methods included from Arrow::Loggable
Constructor Details
- (Node) initialize(type = 'generic')
Provide initialization for all derivative Arrow::Template::Node objects.
28 29 30 31 |
# File 'lib/arrow/template/nodes.rb', line 28 def initialize( type='generic' ) # :notnew: @type = type super() end |
Instance Attribute Details
- (Object) type (readonly)
The type of the node
39 40 41 |
# File 'lib/arrow/template/nodes.rb', line 39 def type @type end |
Instance Method Details
- (Object) add_to_template(template)
Install the node object into the given template object.
52 53 54 |
# File 'lib/arrow/template/nodes.rb', line 52 def add_to_template( template ) template.install_node( self ) end |
- (Object) css_class (protected)
Return the HTML element class attribute that corresponds to this node.
110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/arrow/template/nodes.rb', line 110 def css_class nodeclass = self.class.name. sub(/Arrow::Template::/, ''). gsub( /::/, '-' ). gsub( /([a-z])([A-Z])/, "\\1-\\2" ). gsub( /[^-\w]+/, '' ). downcase nodeclass << "-node" unless /-node$/.match( nodeclass ) return nodeclass end |
- (Object) inspect
Return a human-readable version of the Node object suitable for debugging messages.
77 78 79 |
# File 'lib/arrow/template/nodes.rb', line 77 def inspect "<%s Node>" % @type.capitalize end |
- (Boolean) is_rendering_node? Also known as: rendering?
Returns true for nodes which generate output themselves (as opposed to ones which generate output through subnodes). This is used for eliding blank lines from the node tree.
45 46 47 |
# File 'lib/arrow/template/nodes.rb', line 45 def is_rendering_node? false end |
- (Object) render(template, scope)
Render the node to text.
70 71 72 |
# File 'lib/arrow/template/nodes.rb', line 70 def render( template, scope ) return [ self.to_s ] end |
- (Object) to_a
Return the receiver and any subnodes as a flattened Array of nodes.
64 65 66 |
# File 'lib/arrow/template/nodes.rb', line 64 def to_a [self] end |
- (Object) to_html
Return an HTML fragment that can be used to represent the node symbolically in a web-based introspection interface.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/arrow/template/nodes.rb', line 84 def to_html content = nil if block_given? content = yield else content = "" end nodeclass = self.css_class %q{<div class="node %s"><div class="node-head %s-head">%s</div> <div class="node-body %s-body">%s</div></div>} % [ nodeclass, nodeclass, self.class.name.sub(/Arrow::Template::/, ''), nodeclass, content, ] end |
- (Object) to_s
Return the node as a String.
58 59 60 |
# File 'lib/arrow/template/nodes.rb', line 58 def to_s "" end |