Class: Arrow::Template::TextNode
- Inherits:
-
Node
- Object
- Arrow::Object
- Node
- Arrow::Template::TextNode
- Defined in:
- lib/arrow/template/nodes.rb
Overview
The plain-content node object class. Instances of this class are nodes in a syntax tree which represents the textual contents of an Arrow::Template object.
Direct Known Subclasses
Constant Summary
- SVNRev =
SVN Revision
%q$Rev$
- SVNId =
SVN Id
%q$Id$
Constants inherited from Node
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) body
The node body.
Instance Method Summary
-
- (Object) =~(obj)
Match operator — if obj is a Regexp, use it as a pattern to match against the node’s body.
-
- (TextNode) initialize(body, type = "text")
constructor
Create a new Arrow::Template::TextNode object with the given body.
-
- (Object) inspect
Return a human-readable version of the object suitable for debugging messages.
-
- (Boolean) is_rendering_node?
Returns true for nodes which generate output themselves (as opposed to ones which generate output through subnodes).
-
- (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 inherited from Node
#add_to_template, #css_class, #render, #to_a
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
- (TextNode) initialize(body, type = "text")
Create a new Arrow::Template::TextNode object with the given body.
143 144 145 146 |
# File 'lib/arrow/template/nodes.rb', line 143 def initialize( body, type="text" ) @body = body super( type ) end |
Instance Attribute Details
- (Object) body
The node body
153 154 155 |
# File 'lib/arrow/template/nodes.rb', line 153 def body @body end |
Instance Method Details
- (Object) =~(obj)
Match operator — if obj is a Regexp, use it as a pattern to match against the node’s body. If obj is a String, look for it in the node’s body, similar to String#index. Returns the position the match starts, or nil if there is no match. Otherwise, invokes obj#=~, passing the node’s body as an argument.
161 162 163 164 165 166 167 168 169 170 |
# File 'lib/arrow/template/nodes.rb', line 161 def =~( obj ) case obj when Regexp obj.match( self.body ) when String self.body.index( obj ) else obj.=~( self.body ) end end |
- (Object) inspect
Return a human-readable version of the object suitable for debugging messages.
196 197 198 |
# File 'lib/arrow/template/nodes.rb', line 196 def inspect %Q{<%s Node: %s>} % [ @type.capitalize, @body.inspect ] end |
- (Boolean) is_rendering_node?
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.
176 177 178 |
# File 'lib/arrow/template/nodes.rb', line 176 def is_rendering_node? true end |
- (Object) to_html
Return an HTML fragment that can be used to represent the node symbolically in a web-based introspection interface.
189 190 191 |
# File 'lib/arrow/template/nodes.rb', line 189 def to_html super { self.escape_html(@body) } end |
- (Object) to_s
Return the node as a String.
182 183 184 |
# File 'lib/arrow/template/nodes.rb', line 182 def to_s self.body.to_s end |