Class: VCDOM::Attr

Inherits:
Node
  • Object
show all
Includes:
Parent
Defined in:
lib/vcdom/attr.rb

Direct Known Subclasses

AttrNS

Instance Method Summary collapse

Constructor Details

#initialize(doc, name) ⇒ Attr

:nodoc:



11
12
13
14
15
16
# File 'lib/vcdom/attr.rb', line 11

def initialize( doc, name ) # :nodoc:
  initialize_parent()
  super( doc )
  @owner_element  = nil
  @local_name     = name
end

Instance Method Details

#_set_owner_element(elem) ⇒ Object

:nodoc:



25
26
27
# File 'lib/vcdom/attr.rb', line 25

def _set_owner_element( elem ) # :nodoc:
  @owner_element = elem
end

#append_child(new_child) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/vcdom/attr.rb', line 53

def append_child( new_child )
  # check the arg type
  if not new_child.is_a? Node then
    raise ArgumentError.new( "the argument [#{new_child.inspect}] is not an object of the expected class." )
  end
  # Text, EntityReference
  case new_child.node_type
    when TEXT_NODE, ENTITY_REFERENCE_NODE then
      # OK
    else
      # ERROR
      raise "ERROR"
  end
  _append_child( new_child )
end

#local_nameObject



34
35
36
# File 'lib/vcdom/attr.rb', line 34

def local_name
  nil
end

#nameObject Also known as: node_name



29
30
31
# File 'lib/vcdom/attr.rb', line 29

def name
  @local_name.to_s()
end

#node_typeObject



18
19
20
# File 'lib/vcdom/attr.rb', line 18

def node_type
  ATTRIBUTE_NODE
end

#owner_elementObject



22
23
24
# File 'lib/vcdom/attr.rb', line 22

def owner_element
  @owner_element
end

#valueObject



38
39
40
41
42
43
44
45
# File 'lib/vcdom/attr.rb', line 38

def value
  val = String.new()
  self.each_child_node do |n|
    # Text のみを考慮
    val << n.node_value
  end
  return val
end

#value=(val) ⇒ Object



46
47
48
49
50
51
# File 'lib/vcdom/attr.rb', line 46

def value=(val)
  while self.first_child do
    self.remove_child( self.first_child )
  end
  self.append_child( self.owner_document.create_text_node( val ) )
end