Class: 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 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
-
#body ⇒ Object
The node body.
Attributes inherited from Node
Instance Method Summary collapse
-
#=~(obj) ⇒ Object
Match operator – if
obj
is a Regexp, use it as a pattern to match against the node’s body. -
#initialize(body, type = "text") ⇒ TextNode
constructor
Create a new Arrow::Template::TextNode object with the given
body
. -
#inspect ⇒ Object
Return a human-readable version of the object suitable for debugging messages.
-
#is_rendering_node? ⇒ Boolean
Returns
true
for nodes which generate output themselves (as opposed to ones which generate output through subnodes). -
#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 inherited from Node
#add_to_template, #render, #to_a
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(body, type = "text") ⇒ TextNode
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
#body ⇒ Object
The node body
153 154 155 |
# File 'lib/arrow/template/nodes.rb', line 153 def body @body end |
Instance Method Details
#=~(obj) ⇒ Object
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 |
#inspect ⇒ Object
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 |
#is_rendering_node? ⇒ Boolean
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 |
#to_html ⇒ Object
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 |
#to_s ⇒ Object
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 |