Class: Arrow::Template::Node
- Includes:
- HTMLUtilities
- Defined in:
- lib/arrow/template/nodes.rb
Overview
The abstract base node class.
Constant Summary collapse
- SVNRev =
SVN Revision
%q$Rev$
- SVNId =
SVN Id
%q$Id$
Constants included from HTMLUtilities
HTMLUtilities::ARRAY_HTML_CONTAINER, HTMLUtilities::HASH_HTML_CONTAINER, HTMLUtilities::HASH_PAIR_HTML, HTMLUtilities::IMMEDIATE_OBJECT_HTML_CONTAINER, HTMLUtilities::IVAR_HTML_FRAGMENT, HTMLUtilities::OBJECT_HTML_CONTAINER, HTMLUtilities::THREAD_DUMP_KEY
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
The type of the node.
Instance Method Summary collapse
-
#add_to_template(template) ⇒ Object
Install the node object into the given
template
object. -
#initialize(type = 'generic') ⇒ Node
constructor
Provide initialization for all derivative Arrow::Template::Node objects.
-
#inspect ⇒ Object
Return a human-readable version of the Node object suitable for debugging messages.
-
#is_rendering_node? ⇒ Boolean
(also: #rendering?)
Returns
true
for nodes which generate output themselves (as opposed to ones which generate output through subnodes). -
#render(template, scope) ⇒ Object
Render the node to text.
-
#to_a ⇒ Object
Return the receiver and any subnodes as a flattened Array of nodes.
-
#to_html ⇒ Object
Return an HTML fragment that can be used to represent the node symbolically in a web-based introspection interface.
-
#to_s ⇒ Object
Return the node as a String.
Methods included from HTMLUtilities
escape_html, make_html_for_object, make_object_html_wrapper
Methods inherited from Object
deprecate_class_method, deprecate_method, inherited
Constructor Details
#initialize(type = 'generic') ⇒ Node
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
#type ⇒ Object (readonly)
The type of the node
39 40 41 |
# File 'lib/arrow/template/nodes.rb', line 39 def type @type end |
Instance Method Details
#add_to_template(template) ⇒ Object
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 |
#inspect ⇒ Object
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 |
#is_rendering_node? ⇒ Boolean 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 |
#render(template, scope) ⇒ Object
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 |
#to_a ⇒ Object
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 |
#to_html ⇒ Object
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 |
#to_s ⇒ Object
Return the node as a String.
58 59 60 |
# File 'lib/arrow/template/nodes.rb', line 58 def to_s "" end |