Class: Arbre::HTML::TextNode

Inherits:
Element
  • Object
show all
Defined in:
lib/arbre/html/text_node.rb

Instance Attribute Summary

Attributes inherited from Element

#arbre_context, #children, #parent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Element

#+, #<<, #ancestors, #assigns, #children?, #content, #content=, #each, #find_first_ancestor, #get_elements_by_class_name, #get_elements_by_tag_name, #helpers, #html_safe, #indent_level, #initialize, #inspect, #parent?, #remove_child, #to_ary, #to_str

Methods included from Rails::Rendering

#render

Methods included from Element::BuilderMethods

#build_tag, #current_arbre_element, included, #insert_tag, #with_current_arbre_element

Constructor Details

This class inherits a constructor from Arbre::Element

Class Method Details

.from_string(string) ⇒ Object

Builds a text node from a string



11
12
13
14
15
# File 'lib/arbre/html/text_node.rb', line 11

def self.from_string(string)
  node = new
  node.build(string)
  node
end

Instance Method Details

#add_child(*args) ⇒ Object



17
18
19
# File 'lib/arbre/html/text_node.rb', line 17

def add_child(*args)
  raise "TextNodes do not have children"
end

#build(string) ⇒ Object



21
22
23
# File 'lib/arbre/html/text_node.rb', line 21

def build(string)
  @content = string
end

#class_listObject



25
26
27
# File 'lib/arbre/html/text_node.rb', line 25

def class_list
  []
end

#tag_nameObject



29
30
31
# File 'lib/arbre/html/text_node.rb', line 29

def tag_name
  nil
end

#to_sObject



33
34
35
# File 'lib/arbre/html/text_node.rb', line 33

def to_s
  ERB::Util.html_escape(@content.to_s)
end