Class: Browser::DOM::CharacterData

Inherits:
Node show all
Defined in:
opal/browser/dom/character_data.rb

Direct Known Subclasses

Comment, Text

Constant Summary

Constants inherited from Node

Node::ATTRIBUTE_NODE, Node::CDATA_SECTION_NODE, Node::COMMENT_NODE, Node::DOCUMENT_FRAGMENT_NODE, Node::DOCUMENT_NODE, Node::DOCUMENT_TYPE_NODE, Node::ELEMENT_NODE, Node::ENTITY_NODE, Node::ENTITY_REFERENCE_NOCE, Node::NOTATION_NODE, Node::PROCESSING_INSTRUCTION_NODE, Node::TEXT_NODE

Instance Attribute Summary collapse

Attributes inherited from Node

#child, #children, #document, #element_children, #first_element_child, #inner_html, #last_element_child, #name, #namespace, #next, #next_element, #node_type, #parent, #previous, #previous_element, #value

Instance Method Summary collapse

Methods inherited from Node

#<<, #==, #>>, #add_child, #add_next_sibling, #add_previous_sibling, #ancestors, #append_to, #blank?, #cdata?, #clear, #comment?, #content, #content=, #document?, #elem?, #fragment?, new, #parse, #path, #prepend_to, #remove, #remove_child, #text?, #traverse

Instance Attribute Details

#dataString (readonly)

Returns the data of the node.

Returns:

  • (String)

    the data of the node



17
18
19
# File 'opal/browser/dom/character_data.rb', line 17

def data
  `#@native.data`
end

#lengthInteger (readonly)

Returns the length of the node.

Returns:

  • (Integer)

    the length of the node



47
# File 'opal/browser/dom/character_data.rb', line 47

alias_native :length

Instance Method Details

#append(string) ⇒ self

Append data to the node.

Parameters:

  • string (String)

    the data to add

Returns:

  • (self)


9
10
11
12
13
# File 'opal/browser/dom/character_data.rb', line 9

def append(string)
  `#@native.appendData(string)`

  self
end

#delete(count, offset = 0) ⇒ self

Delete data from the node.

Parameters:

  • count (Integer)

    how much data to delete

  • offset (Integer) (defaults to: 0)

    the offset to start at

Returns:

  • (self)


27
28
29
30
31
# File 'opal/browser/dom/character_data.rb', line 27

def delete(count, offset = 0)
  `#@native.deleteData(offset, count)`

  self
end

#insert(string, offset = 0) ⇒ self

Insert data in the node.

Parameters:

  • string (String)

    the data to insert

  • offset (Integer) (defaults to: 0)

    the offset to start at

Returns:

  • (self)


39
40
41
42
43
# File 'opal/browser/dom/character_data.rb', line 39

def insert(string, offset = 0)
  `#@native.insertData(offset, string)`

  self
end

#replace(string, offset = 0, count = `#@native.length`) ⇒ self

Replace data in the node.

Parameters:

  • string (String)

    the data to replace with

  • offset (Integer) (defaults to: 0)

    the offset to start at

  • count (Integer) (defaults to: `#@native.length`)

    how much data to replace

Returns:

  • (self)


56
57
58
59
60
# File 'opal/browser/dom/character_data.rb', line 56

def replace(string, offset = 0, count = `#@native.length`)
  `#@native.replaceData(offset, count, string)`

  self
end

#substring(count, offset = 0) ⇒ String

Get a substring of the data.

Parameters:

  • count (Integer)

    how much data to lice

  • offset (Integer) (defaults to: 0)

    the offset to start at

Returns:



68
69
70
# File 'opal/browser/dom/character_data.rb', line 68

def substring(count, offset = 0)
  `#@native.substringData(offset, count)`
end