Module: IEgrip::ElementChild
- Included in:
- Document, HTMLElement
- Defined in:
- lib/iegrip.rb
Instance Method Summary collapse
- #childElements ⇒ Object
- #childNodes ⇒ Object
- #contains(node) ⇒ Object
- #firstChild ⇒ Object
- #hasChildElements ⇒ Object
- #hasChildNodes ⇒ Object
- #isEqualNode(node) ⇒ Object
- #lastChild ⇒ Object
- #nextSibling ⇒ Object
- #previousSibling ⇒ Object
- #struct(level = 0) ⇒ Object
Instance Method Details
#childElements ⇒ Object
144 145 146 147 |
# File 'lib/iegrip.rb', line 144 def childElements raw_childNodes = @raw_object.childNodes raw_childNodes ? HTMLElementCollection.new(raw_childNodes, @ie_obj) : nil end |
#childNodes ⇒ Object
139 140 141 142 |
# File 'lib/iegrip.rb', line 139 def childNodes raw_childNodes = @raw_object.childNodes raw_childNodes ? NodeList.new(raw_childNodes, @ie_obj) : nil end |
#contains(node) ⇒ Object
180 181 182 |
# File 'lib/iegrip.rb', line 180 def contains(node) @raw_object.contains(toRaw(node)) end |
#firstChild ⇒ Object
159 160 161 162 |
# File 'lib/iegrip.rb', line 159 def firstChild raw_node = @raw_object.firstChild() raw_node ? HTMLElement.new(raw_node, @ie_obj) : nil end |
#hasChildElements ⇒ Object
173 174 175 176 177 178 |
# File 'lib/iegrip.rb', line 173 def hasChildElements() @raw_object.childNodes.each {|subnode| return true if (subnode.nodeType != 3) and (subnode.nodeType != 8) } false end |
#hasChildNodes ⇒ Object
169 170 171 |
# File 'lib/iegrip.rb', line 169 def hasChildNodes() @raw_object.childNodes.length > 0 end |
#isEqualNode(node) ⇒ Object
184 185 186 |
# File 'lib/iegrip.rb', line 184 def isEqualNode(node) @raw_object.isEqualNode(toRaw(node)) end |
#lastChild ⇒ Object
164 165 166 167 |
# File 'lib/iegrip.rb', line 164 def lastChild raw_node = @raw_object.lastChild() raw_node ? HTMLElement.new(raw_node, @ie_obj) : nil end |
#nextSibling ⇒ Object
154 155 156 157 |
# File 'lib/iegrip.rb', line 154 def nextSibling raw_node = @raw_object.nextSibling() raw_node ? HTMLElement.new(raw_node, @ie_obj) : nil end |
#previousSibling ⇒ Object
149 150 151 152 |
# File 'lib/iegrip.rb', line 149 def previousSibling raw_node = @raw_object.previousSibling() raw_node ? HTMLElement.new(raw_node, @ie_obj) : nil end |
#struct(level = 0) ⇒ Object
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/iegrip.rb', line 188 def struct(level=0) struct = [] self.childElements.each {|subelement| inner,outer = get_inner(subelement) if subelement.hasChildElements() sub_struct = subelement.struct(level+1) if sub_struct.size > 0 struct.push (" " * level) + "<#{inner}>" struct += sub_struct struct.push (" " * level) + "</#{subelement.tagName}>" else struct.push (" " * level) + "<#{inner} />" end else if outer struct.push (" " * level) + "<#{inner}>#{outer}</#{subelement.tagName}>" else struct.push (" " * level) + "<#{inner} />" end end } return struct end |