Skip to content

Commit

Permalink
dom/character_data: cleanup and add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
meh committed Jan 20, 2014
1 parent 311687f commit e7a9f0c
Showing 1 changed file with 43 additions and 7 deletions.
50 changes: 43 additions & 7 deletions opal/browser/dom/character_data.rb
@@ -1,34 +1,70 @@
module Browser; module DOM

class CharacterData < Node
# Append data to the node.
#
# @param string [String] the data to add
#
# @return [self]
def append(string)
`#@native.appendData(string)`

self
end

# @!attribute [r] data
# @return [String] the data of the node
def data
`#@native.data`
end

def append(string)
`#@native.appendData(string)`
# Delete data from the node.
#
# @param count [Integer] how much data to delete
# @param offset [Integer] the offset to start at
#
# @return [self]
def delete(count, offset = 0)
`#@native.deleteData(offset, count)`

self
end

# Insert data in the node.
#
# @param string [String] the data to insert
# @param offset [Integer] the offset to start at
#
# @return [self]
def insert(string, offset = 0)
`#@native.insertData(offset, string)`

self
end

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

self
end
# @!attribute [r] length
# @return [Integer] the length of the node
alias_native :length

# Replace data in the node.
#
# @param string [String] the data to replace with
# @param offset [Integer] the offset to start at
# @param count [Integer] how much data to replace
#
# @return [self]
def replace(string, offset = 0, count = `#@native.length`)
`#@native.replaceData(offset, count, string)`

self
end

# Get a substring of the data.
#
# @param count [Integer] how much data to lice
# @param offset [Integer] the offset to start at
#
# @return [String] the substring
def substring(count, offset = 0)
`#@native.substringData(offset, count)`
end
Expand Down

0 comments on commit e7a9f0c

Please sign in to comment.