File: processinginstruction.rb

package info (click to toggle)
ruby-xmlparser 0.7.3-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 980 kB
  • sloc: ruby: 9,342; ansic: 2,017; makefile: 11
file content (155 lines) | stat: -rw-r--r-- 2,675 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
## -*- Ruby -*-
## XML::DOM
## 1998-2001 by yoshidam
##

require 'xml/dom2/node'

module XML
  module DOM

=begin
== Class XML::DOM::ProcessingInstruction

=== superclass
Node

=end
    class ProcessingInstruction<Node

=begin
=== Class Methods

    --- ProcessingInstruction.new(target = nil, data = nil)

creates a new ProcessingInstruction.
=end
      ## new(target, data)
      ##     target: String
      ##     data: String
      def initialize(target = nil, data = nil)
        super()
        raise "parameter error" if !data
        @target = target.freeze
        @data = data.freeze
        @value = target.dup
        @value << " #{data}" if data != ""
        @value.freeze
      end

=begin
=== Methods

    --- ProcessingInstruction#nodeType

[DOM]
returns the nodeType.
=end
      ## [DOM]
      def nodeType
        PROCESSING_INSTRUCTION_NODE
      end

=begin
    --- ProcessingInstruction#nodeName

[DOM]
returns the nodeName.
=end
      ## [DOM]
      def nodeName
        "#proccessing-instruction"
      end

=begin
    --- ProcessingInstruction#target

[DOM]
returns the target of the ProcessingInstruction.
=end
      ## [DOM]
      def target
        @target
      end

      def target=(p)
        @target = p.freeze
        @value = @target.dup
        @value << " #{@data}" if @data != ""
        @value.freeze
      end

=begin
    --- ProcessingInstruction#data

[DOM]
return the content of the ProcessingInstruction.
=end
      ## [DOM]
      def data
        @data
      end

=begin
    --- ProcessingInstruction#data=(p)

[DOM]
sets p to the content of the ProcessingInstruction.
=end
      ## [DOM]
      def data=(p)
        @data = p.freeze
        @value = @target.dup
        @value << " #{@data}" if @data != ""
        @value.freeze
      end

=begin
    --- ProcessingInstruction#nodeValue

[DOM]
return nodevalue.

=end
      ## [DOM]
      def nodeValue
        @value
      end

      ## inhibit changing value without target= or data=
      undef nodeValue=

=begin
    --- ProcessingInstruction#to_s

returns the string representation of the ProcessingInstruction.
=end
      def to_s
        ret = "<?#{@value}?>"
        ret << "\n" if parentNode.nodeType == DOCUMENT_NODE
        ret
      end

=begin
    --- ProcessingInstruction#dump(depth = 0)

dumps the ProcessingInstruction.
=end
      def dump(depth = 0)
        print ' ' * depth * 2
        print "<?#{@value.inspect}?>\n"
      end

=begin
    --- ProcessingInstruction#cloneNode(deep = true)

[DOM]
returns the copy of the ProcessingInstruction.
=end
      ## [DOM]
      def cloneNode(deep = true)
        super(deep, @target, @data)
      end
    end
  end
end