Class: Mayu::VDOM::DOM::Node

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/mayu/vdom/dom.rb

Direct Known Subclasses

Comment, Element, Text

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document) ⇒ Node

Returns a new instance of Node.



64
65
66
67
68
# File 'lib/mayu/vdom/dom.rb', line 64

def initialize(document)
  @document = T.let(document, DOM)
  @id = T.let(@document.next_id!, Integer)
  @parent = T.let(nil, T.nilable(Element))
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



52
53
54
# File 'lib/mayu/vdom/dom.rb', line 52

def id
  @id
end

#parentObject

Returns the value of attribute parent.



55
56
57
# File 'lib/mayu/vdom/dom.rb', line 55

def parent
  @parent
end

Instance Method Details

#append_child(node) ⇒ Object

Raises:



87
88
89
# File 'lib/mayu/vdom/dom.rb', line 87

def append_child(node)
  raise DOMException, "Can't append children to #{self.class.name}"
end

#element?Boolean

Returns:

  • (Boolean)


73
# File 'lib/mayu/vdom/dom.rb', line 73

def element? = false

#insert_before(new_node, reference_node = nil) ⇒ Object

Raises:



94
95
96
# File 'lib/mayu/vdom/dom.rb', line 94

def insert_before(new_node, reference_node = nil)
  raise DOMException, "Can't insert children to #{self.class.name}"
end

#next_siblingObject



61
# File 'lib/mayu/vdom/dom.rb', line 61

def next_sibling = parent&.find_next_sibling(self)

#previous_siblingObject



58
# File 'lib/mayu/vdom/dom.rb', line 58

def previous_sibling = parent&.find_previous_sibling(self)

#remove_child(node) ⇒ Object

Raises:



99
100
101
# File 'lib/mayu/vdom/dom.rb', line 99

def remove_child(node)
  raise DOMException, "Can't remove children from #{self.class.name}"
end

#text?Boolean

Returns:

  • (Boolean)


71
# File 'lib/mayu/vdom/dom.rb', line 71

def text? = false

#to_sObject



76
# File 'lib/mayu/vdom/dom.rb', line 76

def to_s = ""