Class: Arbre::TextNode
Overview
A ‘raw’ text node - it just outputs the HTML escaped version of the string it’s built with.
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
-
.from_string(string) ⇒ Object
Builds a raw element from a string.
Instance Method Summary collapse
Methods inherited from Element
#+, #<<, #ancestors, #arbre_context, #assigns, #content, #content=, #descendants, #empty?, #has_children?, #helpers, #indent_level, #initialize, #inspect, #orphan?, #parent, #parent=, #remove!, #respond_to?, #to_html
Methods included from Html::Querying
#child_tags, #descendant_tags, #find, #find_by_classes, #find_by_id, #find_by_tag, #find_by_tag_and_classes, #find_first
Methods included from Element::Building
#append_within, #build, #current_element, #current_flow, included, #insert, #insert_child, #prepend_within, #temporary
Constructor Details
This class inherits a constructor from Arbre::Element
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Arbre::Element
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
23 24 25 |
# File 'lib/arbre/text_node.rb', line 23 def text @text end |
Class Method Details
.from_string(string) ⇒ Object
Builds a raw element from a string.
11 12 13 |
# File 'lib/arbre/text_node.rb', line 11 def self.from_string(string) new.tap { |node| node.build!(string) } end |
Instance Method Details
#build!(text) ⇒ Object
25 26 27 |
# File 'lib/arbre/text_node.rb', line 25 def build!(text) @text = text.to_s end |
#children ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/arbre/text_node.rb', line 15 def children @children ||= ElementCollection.new.tap do |children| def children.<<(*) raise NotImplementedError end def children.add(*) raise NotImplementedError end def children.concat(*) raise NotImplementedError end end end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/arbre/text_node.rb', line 29 def to_s text end |