Class: TFHppleElement
- Inherits:
-
Object
- Object
- TFHppleElement
- Defined in:
- lib/motion-hpple/hpple.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #inner_html ⇒ Object
- #inner_text ⇒ Object
- #tag ⇒ Object
- #text ⇒ Object
-
#to_html ⇒ Object
a hack to return html.
- #to_s ⇒ Object
Instance Method Details
#[](key) ⇒ Object
31 32 33 |
# File 'lib/motion-hpple/hpple.rb', line 31 def [](key) self.objectForKey(key) end |
#inner_html ⇒ Object
46 47 48 49 50 |
# File 'lib/motion-hpple/hpple.rb', line 46 def inner_html return self.children.map do |sub_node| sub_node.to_html end.join end |
#inner_text ⇒ Object
39 40 41 42 43 44 |
# File 'lib/motion-hpple/hpple.rb', line 39 def inner_text return self.content if self.content return self.children.collect do |sub_node| sub_node.inner_text end.join("") end |
#tag ⇒ Object
27 28 29 |
# File 'lib/motion-hpple/hpple.rb', line 27 def tag self.tagName end |
#text ⇒ Object
35 36 37 |
# File 'lib/motion-hpple/hpple.rb', line 35 def text self.inner_text end |
#to_html ⇒ Object
a hack to return html
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/motion-hpple/hpple.rb', line 53 def to_html if self.content self.content else = [] << "<#{self.tag}" self.attributes.each do |key, value| value = value.gsub('"', '"') << "#{key}=\"#{value}\"" end .join(" ") + ">" + self.inner_html + "</#{self.tag}>" end end |
#to_s ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/motion-hpple/hpple.rb', line 67 def to_s if self.content self.content else self.inner_text end end |