Module: IEgrip::ElementChild

Included in:
Document, HTMLElement
Defined in:
lib/iegrip.rb

Instance Method Summary collapse

Instance Method Details

#childElementsObject



108
109
110
111
# File 'lib/iegrip.rb', line 108

def childElements
  raw_childNodes = @raw_object.childNodes
  raw_childNodes ? HTMLElementCollection.new(raw_childNodes, @ie_obj) : nil
end

#childNodesObject



103
104
105
106
# File 'lib/iegrip.rb', line 103

def childNodes
  raw_childNodes = @raw_object.childNodes
  raw_childNodes ? NodeList.new(raw_childNodes, @ie_obj) : nil
end

#contains(node) ⇒ Object



144
145
146
# File 'lib/iegrip.rb', line 144

def contains(node)
  @raw_object.contains(toRaw(node))
end

#firstChildObject



123
124
125
126
# File 'lib/iegrip.rb', line 123

def firstChild
  raw_node = @raw_object.firstChild()
  raw_node ? HTMLElement.new(raw_node, @ie_obj) : nil
end

#hasChildElementsObject



137
138
139
140
141
142
# File 'lib/iegrip.rb', line 137

def hasChildElements()
  @raw_object.childNodes.each {|subnode|
    return true if (subnode.nodeType != 3) and (subnode.nodeType != 8)
  }
  false
end

#hasChildNodesObject



133
134
135
# File 'lib/iegrip.rb', line 133

def hasChildNodes()
  @raw_object.childNodes.length > 0
end

#isEqualNode(node) ⇒ Object



148
149
150
# File 'lib/iegrip.rb', line 148

def isEqualNode(node)
  @raw_object.isEqualNode(toRaw(node))
end

#lastChildObject



128
129
130
131
# File 'lib/iegrip.rb', line 128

def lastChild
  raw_node = @raw_object.lastChild()
  raw_node ? HTMLElement.new(raw_node, @ie_obj) : nil
end

#nextSiblingObject



118
119
120
121
# File 'lib/iegrip.rb', line 118

def nextSibling
  raw_node = @raw_object.nextSibling()
  raw_node ? HTMLElement.new(raw_node, @ie_obj) : nil
end

#previousSiblingObject



113
114
115
116
# File 'lib/iegrip.rb', line 113

def previousSibling
  raw_node = @raw_object.previousSibling()
  raw_node ? HTMLElement.new(raw_node, @ie_obj) : nil
end

#struct(level = 0) ⇒ Object



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/iegrip.rb', line 152

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