rubysl-xmlrpc 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +14 -6
- data/.travis.yml +5 -6
- data/lib/rubysl/xmlrpc.rb +1 -0
- data/lib/rubysl/xmlrpc/version.rb +1 -1
- data/lib/rubysl/xmlrpc/xmlrpc.rb +301 -0
- data/lib/xmlrpc.rb +1 -0
- data/lib/xmlrpc/.document +1 -0
- data/lib/xmlrpc/README.rdoc +300 -0
- data/lib/xmlrpc/base64.rb +27 -46
- data/lib/xmlrpc/client.rb +320 -343
- data/lib/xmlrpc/config.rb +18 -16
- data/lib/xmlrpc/create.rb +108 -112
- data/lib/xmlrpc/datetime.rb +59 -72
- data/lib/xmlrpc/httpserver.rb +38 -43
- data/lib/xmlrpc/marshal.rb +6 -16
- data/lib/xmlrpc/parser.rb +267 -242
- data/lib/xmlrpc/server.rb +297 -372
- data/lib/xmlrpc/utils.rb +40 -34
- data/rubysl-xmlrpc.gemspec +0 -1
- metadata +16 -24
data/lib/xmlrpc/config.rb
CHANGED
@@ -1,36 +1,38 @@
|
|
1
1
|
#
|
2
|
-
# $Id
|
2
|
+
# $Id$
|
3
3
|
# Configuration file for XML-RPC for Ruby
|
4
4
|
#
|
5
5
|
|
6
|
-
module XMLRPC
|
6
|
+
module XMLRPC # :nodoc:
|
7
7
|
|
8
8
|
module Config
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
10
|
+
# or XMLWriter::XMLParser
|
11
|
+
DEFAULT_WRITER = XMLWriter::Simple
|
12
|
+
|
13
|
+
# === Available parsers
|
14
|
+
#
|
15
|
+
# * XMLParser::NQXMLTreeParser
|
16
|
+
# * XMLParser::NQXMLStreamParser
|
17
|
+
# * XMLParser::XMLTreeParser
|
18
|
+
# * XMLParser::XMLStreamParser (fastest)
|
19
|
+
# * XMLParser::REXMLStreamParser
|
20
|
+
# * XMLParser::XMLScanStreamParser
|
19
21
|
DEFAULT_PARSER = XMLParser::REXMLStreamParser
|
20
22
|
|
21
|
-
# enable <nil
|
23
|
+
# enable <code><nil/></code> tag
|
22
24
|
ENABLE_NIL_CREATE = false
|
23
25
|
ENABLE_NIL_PARSER = false
|
24
|
-
|
25
|
-
# allows integers greater than 32-bit if true
|
26
|
+
|
27
|
+
# allows integers greater than 32-bit if +true+
|
26
28
|
ENABLE_BIGINT = false
|
27
29
|
|
28
30
|
# enable marshalling ruby objects which include XMLRPC::Marshallable
|
29
|
-
ENABLE_MARSHALLING = true
|
31
|
+
ENABLE_MARSHALLING = true
|
30
32
|
|
31
33
|
# enable multiCall extension by default
|
32
34
|
ENABLE_MULTICALL = false
|
33
|
-
|
35
|
+
|
34
36
|
# enable Introspection extension by default
|
35
37
|
ENABLE_INTROSPECTION = false
|
36
38
|
|
data/lib/xmlrpc/create.rb
CHANGED
@@ -1,25 +1,23 @@
|
|
1
1
|
#
|
2
|
-
# Creates XML-RPC call/response documents
|
3
|
-
#
|
4
2
|
# Copyright (C) 2001, 2002, 2003 by Michael Neumann (mneumann@ntecs.de)
|
5
3
|
#
|
6
|
-
# $Id
|
4
|
+
# $Id$
|
7
5
|
#
|
8
6
|
|
9
7
|
require "date"
|
10
8
|
require "xmlrpc/base64"
|
11
9
|
|
12
|
-
module XMLRPC
|
10
|
+
module XMLRPC # :nodoc:
|
13
11
|
|
14
12
|
module XMLWriter
|
15
13
|
|
16
14
|
class Abstract
|
17
15
|
def ele(name, *children)
|
18
|
-
|
16
|
+
element(name, nil, *children)
|
19
17
|
end
|
20
18
|
|
21
19
|
def tag(name, txt)
|
22
|
-
|
20
|
+
element(name, nil, text(txt))
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
@@ -27,21 +25,21 @@ module XMLRPC
|
|
27
25
|
class Simple < Abstract
|
28
26
|
|
29
27
|
def document_to_str(doc)
|
30
|
-
|
28
|
+
doc
|
31
29
|
end
|
32
30
|
|
33
31
|
def document(*params)
|
34
|
-
|
32
|
+
params.join("")
|
35
33
|
end
|
36
34
|
|
37
35
|
def pi(name, *params)
|
38
|
-
|
36
|
+
"<?#{name} " + params.join(" ") + " ?>"
|
39
37
|
end
|
40
38
|
|
41
39
|
def element(name, attrs, *children)
|
42
|
-
|
40
|
+
raise "attributes not yet implemented" unless attrs.nil?
|
43
41
|
if children.empty?
|
44
|
-
"<#{name}/>"
|
42
|
+
"<#{name}/>"
|
45
43
|
else
|
46
44
|
"<#{name}>" + children.join("") + "</#{name}>"
|
47
45
|
end
|
@@ -61,27 +59,27 @@ module XMLRPC
|
|
61
59
|
class XMLParser < Abstract
|
62
60
|
|
63
61
|
def initialize
|
64
|
-
|
62
|
+
require "xmltreebuilder"
|
65
63
|
end
|
66
64
|
|
67
65
|
def document_to_str(doc)
|
68
|
-
|
66
|
+
doc.to_s
|
69
67
|
end
|
70
68
|
|
71
69
|
def document(*params)
|
72
|
-
|
70
|
+
XML::SimpleTree::Document.new(*params)
|
73
71
|
end
|
74
72
|
|
75
73
|
def pi(name, *params)
|
76
|
-
|
74
|
+
XML::SimpleTree::ProcessingInstruction.new(name, *params)
|
77
75
|
end
|
78
76
|
|
79
77
|
def element(name, attrs, *children)
|
80
|
-
|
78
|
+
XML::SimpleTree::Element.new(name, attrs, *children)
|
81
79
|
end
|
82
80
|
|
83
81
|
def text(txt)
|
84
|
-
|
82
|
+
XML::SimpleTree::Text.new(txt)
|
85
83
|
end
|
86
84
|
|
87
85
|
end # class XMLParser
|
@@ -100,6 +98,8 @@ module XMLRPC
|
|
100
98
|
|
101
99
|
end # module XMLWriter
|
102
100
|
|
101
|
+
# Creates XML-RPC call/response documents
|
102
|
+
#
|
103
103
|
class Create
|
104
104
|
|
105
105
|
def initialize(xml_writer = nil)
|
@@ -111,20 +111,20 @@ module XMLRPC
|
|
111
111
|
name = name.to_s
|
112
112
|
|
113
113
|
if name !~ /[a-zA-Z0-9_.:\/]+/
|
114
|
-
|
114
|
+
raise ArgumentError, "Wrong XML-RPC method-name"
|
115
115
|
end
|
116
116
|
|
117
117
|
parameter = params.collect do |param|
|
118
|
-
|
118
|
+
@writer.ele("param", conv2value(param))
|
119
119
|
end
|
120
120
|
|
121
121
|
tree = @writer.document(
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
122
|
+
@writer.pi("xml", 'version="1.0"'),
|
123
|
+
@writer.ele("methodCall",
|
124
|
+
@writer.tag("methodName", name),
|
125
|
+
@writer.ele("params", *parameter)
|
126
|
+
)
|
127
|
+
)
|
128
128
|
|
129
129
|
@writer.document_to_str(tree) + "\n"
|
130
130
|
end
|
@@ -132,56 +132,51 @@ module XMLRPC
|
|
132
132
|
|
133
133
|
|
134
134
|
#
|
135
|
-
#
|
135
|
+
# Generates a XML-RPC methodResponse document
|
136
136
|
#
|
137
|
-
#
|
137
|
+
# When +is_ret+ is +false+ then the +params+ array must
|
138
138
|
# contain only one element, which is a structure
|
139
139
|
# of a fault return-value.
|
140
|
-
#
|
141
|
-
#
|
142
|
-
# return-value of all the given params is created.
|
140
|
+
#
|
141
|
+
# When +is_ret+ is +true+ then a normal
|
142
|
+
# return-value of all the given +params+ is created.
|
143
143
|
#
|
144
144
|
def methodResponse(is_ret, *params)
|
145
145
|
|
146
|
-
if is_ret
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
146
|
+
if is_ret
|
147
|
+
resp = params.collect do |param|
|
148
|
+
@writer.ele("param", conv2value(param))
|
149
|
+
end
|
150
|
+
|
151
|
+
resp = [@writer.ele("params", *resp)]
|
152
152
|
else
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
153
|
+
if params.size != 1 or params[0] === XMLRPC::FaultException
|
154
|
+
raise ArgumentError, "no valid fault-structure given"
|
155
|
+
end
|
156
|
+
resp = @writer.ele("fault", conv2value(params[0].to_h))
|
157
157
|
end
|
158
158
|
|
159
|
-
|
159
|
+
|
160
160
|
tree = @writer.document(
|
161
|
-
|
162
|
-
|
163
|
-
|
161
|
+
@writer.pi("xml", 'version="1.0"'),
|
162
|
+
@writer.ele("methodResponse", resp)
|
163
|
+
)
|
164
164
|
|
165
165
|
@writer.document_to_str(tree) + "\n"
|
166
166
|
end
|
167
167
|
|
168
168
|
|
169
169
|
|
170
|
-
#####################################
|
171
170
|
private
|
172
|
-
#####################################
|
173
171
|
|
174
172
|
#
|
175
|
-
#
|
176
|
-
# a XML-RPC <value> tag
|
173
|
+
# Converts a Ruby object into a XML-RPC <code><value></code> tag
|
177
174
|
#
|
178
|
-
def conv2value(param)
|
179
|
-
|
180
|
-
val = case param
|
181
|
-
when Fixnum
|
182
|
-
@writer.tag("i4", param.to_s)
|
175
|
+
def conv2value(param) # :doc:
|
183
176
|
|
184
|
-
|
177
|
+
val = case param
|
178
|
+
when Fixnum, Bignum
|
179
|
+
# XML-RPC's int is 32bit int, and Fixnum also may be beyond 32bit
|
185
180
|
if Config::ENABLE_BIGINT
|
186
181
|
@writer.tag("i4", param.to_s)
|
187
182
|
else
|
@@ -191,14 +186,14 @@ module XMLRPC
|
|
191
186
|
raise "Bignum is too big! Must be signed 32-bit integer!"
|
192
187
|
end
|
193
188
|
end
|
194
|
-
|
195
|
-
|
189
|
+
when TrueClass, FalseClass
|
190
|
+
@writer.tag("boolean", param ? "1" : "0")
|
196
191
|
|
197
|
-
|
198
|
-
|
192
|
+
when Symbol
|
193
|
+
@writer.tag("string", param.to_s)
|
199
194
|
|
200
|
-
|
201
|
-
|
195
|
+
when String
|
196
|
+
@writer.tag("string", param)
|
202
197
|
|
203
198
|
when NilClass
|
204
199
|
if Config::ENABLE_NIL_CREATE
|
@@ -207,55 +202,56 @@ module XMLRPC
|
|
207
202
|
raise "Wrong type NilClass. Not allowed!"
|
208
203
|
end
|
209
204
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
205
|
+
when Float
|
206
|
+
raise "Wrong value #{param}. Not allowed!" unless param.finite?
|
207
|
+
@writer.tag("double", param.to_s)
|
208
|
+
|
209
|
+
when Struct
|
210
|
+
h = param.members.collect do |key|
|
211
|
+
value = param[key]
|
212
|
+
@writer.ele("member",
|
213
|
+
@writer.tag("name", key.to_s),
|
214
|
+
conv2value(value)
|
215
|
+
)
|
216
|
+
end
|
217
|
+
|
218
|
+
@writer.ele("struct", *h)
|
219
|
+
|
220
|
+
when Hash
|
221
|
+
# TODO: can a Hash be empty?
|
222
|
+
|
223
|
+
h = param.collect do |key, value|
|
224
|
+
@writer.ele("member",
|
225
|
+
@writer.tag("name", key.to_s),
|
226
|
+
conv2value(value)
|
227
|
+
)
|
228
|
+
end
|
229
|
+
|
230
|
+
@writer.ele("struct", *h)
|
231
|
+
|
232
|
+
when Array
|
233
|
+
# TODO: can an Array be empty?
|
234
|
+
a = param.collect {|v| conv2value(v) }
|
235
|
+
|
236
|
+
@writer.ele("array",
|
237
|
+
@writer.ele("data", *a)
|
238
|
+
)
|
239
|
+
|
240
|
+
when Time, Date, ::DateTime
|
241
|
+
@writer.tag("dateTime.iso8601", param.strftime("%Y%m%dT%H:%M:%S"))
|
242
|
+
|
243
|
+
when XMLRPC::DateTime
|
244
|
+
@writer.tag("dateTime.iso8601",
|
245
|
+
format("%.4d%02d%02dT%02d:%02d:%02d", *param.to_a))
|
246
|
+
|
247
|
+
when XMLRPC::Base64
|
248
|
+
@writer.tag("base64", param.encoded)
|
249
|
+
|
250
|
+
else
|
255
251
|
if Config::ENABLE_MARSHALLING and param.class.included_modules.include? XMLRPC::Marshallable
|
256
252
|
# convert Ruby object into Hash
|
257
253
|
ret = {"___class___" => param.class.name}
|
258
|
-
param.instance_variables.each {|v|
|
254
|
+
param.instance_variables.each {|v|
|
259
255
|
name = v[1..-1]
|
260
256
|
val = param.instance_variable_get(v)
|
261
257
|
|
@@ -266,24 +262,24 @@ module XMLRPC
|
|
266
262
|
end
|
267
263
|
}
|
268
264
|
return conv2value(ret)
|
269
|
-
else
|
265
|
+
else
|
270
266
|
ok, pa = wrong_type(param)
|
271
267
|
if ok
|
272
268
|
return conv2value(pa)
|
273
|
-
else
|
269
|
+
else
|
274
270
|
raise "Wrong type!"
|
275
271
|
end
|
276
272
|
end
|
277
|
-
|
278
|
-
|
279
|
-
|
273
|
+
end
|
274
|
+
|
275
|
+
@writer.ele("value", val)
|
280
276
|
end
|
281
277
|
|
282
278
|
def wrong_type(value)
|
283
279
|
false
|
284
280
|
end
|
285
281
|
|
286
|
-
|
282
|
+
|
287
283
|
end # class Create
|
288
284
|
|
289
285
|
end # module XMLRPC
|
data/lib/xmlrpc/datetime.rb
CHANGED
@@ -1,115 +1,95 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Copyright (C) 2001, 2002, 2003 by Michael Neumann (mneumann@ntecs.de)
|
4
|
-
|
5
|
-
Released under the same term of license as Ruby.
|
6
|
-
|
7
|
-
= Classes
|
8
|
-
* ((<XMLRPC::DateTime>))
|
9
|
-
|
10
|
-
= XMLRPC::DateTime
|
11
|
-
== Description
|
12
|
-
This class is important to handle XMLRPC (('dateTime.iso8601')) values,
|
13
|
-
correcly, because normal UNIX-dates (class (({Date}))) only handle dates
|
14
|
-
from year 1970 on, and class (({Time})) handles dates without the time
|
15
|
-
component. (({XMLRPC::DateTime})) is able to store a XMLRPC
|
16
|
-
(('dateTime.iso8601')) value correctly.
|
17
|
-
|
18
|
-
== Class Methods
|
19
|
-
--- XMLRPC::DateTime.new( year, month, day, hour, min, sec )
|
20
|
-
Creates a new (({XMLRPC::DateTime})) instance with the
|
21
|
-
parameters ((|year|)), ((|month|)), ((|day|)) as date and
|
22
|
-
((|hour|)), ((|min|)), ((|sec|)) as time.
|
23
|
-
Raises (({ArgumentError})) if a parameter is out of range, or ((|year|)) is not
|
24
|
-
of type (({Integer})).
|
25
|
-
|
26
|
-
== Instance Methods
|
27
|
-
--- XMLRPC::DateTime#year
|
28
|
-
--- XMLRPC::DateTime#month
|
29
|
-
--- XMLRPC::DateTime#day
|
30
|
-
--- XMLRPC::DateTime#hour
|
31
|
-
--- XMLRPC::DateTime#min
|
32
|
-
--- XMLRPC::DateTime#sec
|
33
|
-
Return the value of the specified date/time component.
|
34
|
-
|
35
|
-
--- XMLRPC::DateTime#mon
|
36
|
-
Alias for ((<XMLRPC::DateTime#month>)).
|
37
|
-
|
38
|
-
--- XMLRPC::DateTime#year=( value )
|
39
|
-
--- XMLRPC::DateTime#month=( value )
|
40
|
-
--- XMLRPC::DateTime#day=( value )
|
41
|
-
--- XMLRPC::DateTime#hour=( value )
|
42
|
-
--- XMLRPC::DateTime#min=( value )
|
43
|
-
--- XMLRPC::DateTime#sec=( value )
|
44
|
-
Set ((|value|)) as the new date/time component.
|
45
|
-
Raises (({ArgumentError})) if ((|value|)) is out of range, or in the case
|
46
|
-
of (({XMLRPC::DateTime#year=})) if ((|value|)) is not of type (({Integer})).
|
47
|
-
|
48
|
-
--- XMLRPC::DateTime#mon=( value )
|
49
|
-
Alias for ((<XMLRPC::DateTime#month=>)).
|
50
|
-
|
51
|
-
--- XMLRPC::DateTime#to_time
|
52
|
-
Return a (({Time})) object of the date/time which (({self})) represents.
|
53
|
-
If the (('year')) is below 1970, this method returns (({nil})),
|
54
|
-
because (({Time})) cannot handle years below 1970.
|
55
|
-
The used timezone is GMT.
|
56
|
-
|
57
|
-
--- XMLRPC::DateTime#to_date
|
58
|
-
Return a (({Date})) object of the date which (({self})) represents.
|
59
|
-
The (({Date})) object do ((*not*)) contain the time component (only date).
|
60
|
-
|
61
|
-
--- XMLRPC::DateTime#to_a
|
62
|
-
Returns all date/time components in an array.
|
63
|
-
Returns (({[year, month, day, hour, min, sec]})).
|
64
|
-
=end
|
65
|
-
|
1
|
+
#
|
2
|
+
# xmlrpc/datetime.rb
|
3
|
+
# Copyright (C) 2001, 2002, 2003 by Michael Neumann (mneumann@ntecs.de)
|
4
|
+
#
|
5
|
+
# Released under the same term of license as Ruby.
|
6
|
+
#
|
66
7
|
require "date"
|
67
8
|
|
68
|
-
module XMLRPC
|
9
|
+
module XMLRPC # :nodoc:
|
69
10
|
|
11
|
+
# This class is important to handle XMLRPC +dateTime.iso8601+ values,
|
12
|
+
# correcly, because normal UNIX-dates, ie: Date, only handle dates
|
13
|
+
# from year 1970 on, and ruby's native Time class handles dates without the
|
14
|
+
# time component.
|
15
|
+
#
|
16
|
+
# XMLRPC::DateTime is able to store a XMLRPC +dateTime.iso8601+ value correctly.
|
70
17
|
class DateTime
|
71
|
-
|
18
|
+
|
19
|
+
# Return the value of the specified date/time component.
|
72
20
|
attr_reader :year, :month, :day, :hour, :min, :sec
|
73
21
|
|
22
|
+
# Set +value+ as the new date/time component.
|
23
|
+
#
|
24
|
+
# Raises ArgumentError if the given +value+ is out of range, or in the case
|
25
|
+
# of XMLRPC::DateTime#year= if +value+ is not of type Integer.
|
74
26
|
def year= (value)
|
75
27
|
raise ArgumentError, "date/time out of range" unless value.is_a? Integer
|
76
28
|
@year = value
|
77
29
|
end
|
78
30
|
|
31
|
+
# Set +value+ as the new date/time component.
|
32
|
+
#
|
33
|
+
# Raises an ArgumentError if the given +value+ isn't between 1 and 12.
|
79
34
|
def month= (value)
|
80
35
|
raise ArgumentError, "date/time out of range" unless (1..12).include? value
|
81
36
|
@month = value
|
82
37
|
end
|
83
38
|
|
39
|
+
# Set +value+ as the new date/time component.
|
40
|
+
#
|
41
|
+
# Raises an ArgumentError if the given +value+ isn't between 1 and 31.
|
84
42
|
def day= (value)
|
85
43
|
raise ArgumentError, "date/time out of range" unless (1..31).include? value
|
86
44
|
@day = value
|
87
45
|
end
|
88
46
|
|
47
|
+
# Set +value+ as the new date/time component.
|
48
|
+
#
|
49
|
+
# Raises an ArgumentError if the given +value+ isn't between 0 and 24.
|
89
50
|
def hour= (value)
|
90
51
|
raise ArgumentError, "date/time out of range" unless (0..24).include? value
|
91
52
|
@hour = value
|
92
53
|
end
|
93
54
|
|
55
|
+
# Set +value+ as the new date/time component.
|
56
|
+
#
|
57
|
+
# Raises an ArgumentError if the given +value+ isn't between 0 and 59.
|
94
58
|
def min= (value)
|
95
59
|
raise ArgumentError, "date/time out of range" unless (0..59).include? value
|
96
60
|
@min = value
|
97
61
|
end
|
98
62
|
|
63
|
+
# Set +value+ as the new date/time component.
|
64
|
+
#
|
65
|
+
# Raises an ArgumentError if the given +value+ isn't between 0 and 59.
|
99
66
|
def sec= (value)
|
100
67
|
raise ArgumentError, "date/time out of range" unless (0..59).include? value
|
101
68
|
@sec = value
|
102
69
|
end
|
103
70
|
|
71
|
+
# Alias for XMLRPC::DateTime#month.
|
104
72
|
alias mon month
|
105
|
-
|
106
|
-
|
73
|
+
# Alias for XMLRPC::DateTime#month=.
|
74
|
+
alias mon= month=
|
75
|
+
|
107
76
|
|
77
|
+
# Creates a new XMLRPC::DateTime instance with the
|
78
|
+
# parameters +year+, +month+, +day+ as date and
|
79
|
+
# +hour+, +min+, +sec+ as time.
|
80
|
+
#
|
81
|
+
# Raises an ArgumentError if a parameter is out of range,
|
82
|
+
# or if +year+ is not of the Integer type.
|
108
83
|
def initialize(year, month, day, hour, min, sec)
|
109
84
|
self.year, self.month, self.day = year, month, day
|
110
85
|
self.hour, self.min, self.sec = hour, min, sec
|
111
86
|
end
|
112
|
-
|
87
|
+
|
88
|
+
# Return a Time object of the date/time which represents +self+.
|
89
|
+
# If the <code>@year</code> is below 1970, this method returns +nil+,
|
90
|
+
# because Time cannot handle years below 1970.
|
91
|
+
#
|
92
|
+
# The timezone used is GMT.
|
113
93
|
def to_time
|
114
94
|
if @year >= 1970
|
115
95
|
Time.gm(*to_a)
|
@@ -118,16 +98,23 @@ class DateTime
|
|
118
98
|
end
|
119
99
|
end
|
120
100
|
|
101
|
+
# Return a Date object of the date which represents +self+.
|
102
|
+
#
|
103
|
+
# The Date object do _not_ contain the time component (only date).
|
121
104
|
def to_date
|
122
105
|
Date.new(*to_a[0,3])
|
123
106
|
end
|
124
107
|
|
108
|
+
# Returns all date/time components in an array.
|
109
|
+
#
|
110
|
+
# Returns +[year, month, day, hour, min, sec]+.
|
125
111
|
def to_a
|
126
112
|
[@year, @month, @day, @hour, @min, @sec]
|
127
113
|
end
|
128
114
|
|
115
|
+
# Returns whether or not all date/time components are an array.
|
129
116
|
def ==(o)
|
130
|
-
|
117
|
+
self.to_a == Array(o) rescue false
|
131
118
|
end
|
132
119
|
|
133
120
|
end
|
@@ -138,5 +125,5 @@ end # module XMLRPC
|
|
138
125
|
|
139
126
|
=begin
|
140
127
|
= History
|
141
|
-
$Id
|
128
|
+
$Id$
|
142
129
|
=end
|