Module: Taka::DOM::CharacterData

Defined in:
lib/taka/dom/character_data.rb

Instance Method Summary collapse

Instance Method Details

#appendData(data) ⇒ Object



23
24
25
# File 'lib/taka/dom/character_data.rb', line 23

def appendData data
  self.content = "#{content}#{data}"
end

#dataObject



4
5
6
# File 'lib/taka/dom/character_data.rb', line 4

def data
  content
end

#data=(_) ⇒ Object

Raises:

  • (NotImplementedError)


8
9
10
# File 'lib/taka/dom/character_data.rb', line 8

def data=(_)
  raise(NotImplementedError.new)
end

#deleteData(offset, count) ⇒ Object



36
37
38
39
40
41
# File 'lib/taka/dom/character_data.rb', line 36

def deleteData offset, count
  if offset < 0 || count < 0 || offset > length
    raise DOMException.new(DOMException::INDEX_SIZE_ERR)
  end
  replaceData(offset, count, '')
end

#insertData(offset, arg) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/taka/dom/character_data.rb', line 27

def insertData offset, arg
  if offset < 0 || offset > length
    raise DOMException.new(DOMException::INDEX_SIZE_ERR)
  end
  copy = content
  copy.insert(offset, arg)
  self.content = copy
end

#lengthObject



12
13
14
# File 'lib/taka/dom/character_data.rb', line 12

def length
  content.length
end

#nodeNameObject



52
53
54
# File 'lib/taka/dom/character_data.rb', line 52

def nodeName
  '#cdata-section'
end

#replaceData(offset, count, arg) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/taka/dom/character_data.rb', line 43

def replaceData offset, count, arg
  if offset < 0 || count < 0 || offset > length
    raise DOMException.new(DOMException::INDEX_SIZE_ERR)
  end
  copy = content
  copy[offset, count] = arg
  self.content = copy
end

#substringData(offset, count) ⇒ Object



16
17
18
19
20
21
# File 'lib/taka/dom/character_data.rb', line 16

def substringData offset, count
  if offset > length || offset < 0 || count < 0
    raise DOMException.new(DOMException::INDEX_SIZE_ERR)
  end
  content[offset, count]
end