sdl4r 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +49 -2
- data/Rakefile +35 -5
- data/TODO +29 -3
- data/doc/classes/SDL4R.html +386 -674
- data/doc/classes/SDL4R/Parser.html +183 -307
- data/doc/classes/SDL4R/ParserTest.html +357 -0
- data/doc/classes/SDL4R/SDL4RTest.html +532 -0
- data/doc/classes/SDL4R/SDLTest.html +77 -0
- data/doc/classes/SDL4R/SdlBinary.html +180 -295
- data/doc/classes/SDL4R/SdlParseError.html +105 -180
- data/doc/classes/SDL4R/SdlTimeSpan.html +628 -939
- data/doc/classes/SDL4R/Tag.html +1236 -2036
- data/doc/classes/SDL4R/TagTest.html +292 -0
- data/doc/created.rid +1 -1
- data/doc/files/CHANGELOG.html +183 -184
- data/doc/files/LICENSE.html +496 -755
- data/doc/files/README.html +399 -623
- data/doc/files/lib/sdl4r/parser/reader_rb.html +53 -106
- data/doc/files/lib/sdl4r/parser/time_span_with_zone_rb.html +53 -106
- data/doc/files/lib/sdl4r/parser/token_rb.html +53 -106
- data/doc/files/lib/sdl4r/parser/tokenizer_rb.html +53 -106
- data/doc/files/lib/sdl4r/parser_rb.html +60 -112
- data/doc/files/lib/sdl4r/sdl4r_rb.html +62 -114
- data/doc/files/lib/sdl4r/sdl_binary_rb.html +53 -106
- data/doc/files/lib/sdl4r/sdl_parse_error_rb.html +53 -106
- data/doc/files/lib/sdl4r/sdl_time_span_rb.html +53 -106
- data/doc/files/lib/sdl4r/tag_rb.html +62 -114
- data/doc/files/lib/sdl4r_rb.html +53 -106
- data/doc/files/test/sdl4r/parser_test_rb.html +63 -0
- data/doc/files/test/sdl4r/sdl4r_test_rb.html +66 -0
- data/doc/files/test/sdl4r/sdl_test_rb.html +63 -0
- data/doc/files/test/sdl4r/tag_test_rb.html +63 -0
- data/doc/fr_class_index.html +19 -32
- data/doc/fr_file_index.html +37 -40
- data/doc/fr_method_index.html +4707 -114
- data/doc/index.html +14 -23
- data/doc/rdoc-style.css +323 -203
- data/lib/sdl4r/parser/reader.rb +26 -19
- data/lib/sdl4r/parser/token.rb +3 -3
- data/lib/sdl4r/parser/tokenizer.rb +93 -98
- data/lib/sdl4r/sdl_parse_error.rb +2 -2
- data/lib/sdl4r/tag.rb +127 -73
- data/test/sdl4r/parser_test.rb +109 -11
- data/test/sdl4r/tag_test.rb +73 -4
- metadata +15 -12
data/CHANGELOG
CHANGED
@@ -1,4 +1,51 @@
|
|
1
|
-
== v0.9.
|
1
|
+
== v0.9.8 (建設中)
|
2
|
+
|
3
|
+
== v0.9.7 (26-auf-2010)
|
4
|
+
|
5
|
+
=== Major changes:
|
6
|
+
|
7
|
+
* It could prove a hassle to use the block idiom of Tag.new or Tag.new_child when handling another
|
8
|
+
set of data. Therefore, if the given block takes a (not-optional) parameter, the context remains
|
9
|
+
the context of the calling code.
|
10
|
+
|
11
|
+
class Elephant
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@weight = 1000
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_sdl
|
18
|
+
SDL4R::Tag.new("elephant") do |tag|
|
19
|
+
tag.set_attribute("weight", @weight)
|
20
|
+
tag << "I love pink ones."
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
puts Elephant.new.to_sdl.to_s # ==> elephant "I love pink ones." weight=1000
|
27
|
+
|
28
|
+
* Tag.to_xml_string() has been refactor to take an option Hash (backward incompatible):
|
29
|
+
|
30
|
+
[:line_prefix] a text prefixing each line (default: "")
|
31
|
+
[:uri_by_namespace] a Hash giving the URIs for the namespaces
|
32
|
+
[:indent] text specifying one indentation (default: "\t")
|
33
|
+
[:eol] end of line expression (default: "\n")
|
34
|
+
[:omit_null_attributes]
|
35
|
+
if true, null/nil attributes are not exported (default: false). Otherwise, they are exported
|
36
|
+
as follows:
|
37
|
+
tag attr="null"
|
38
|
+
|
39
|
+
* Fixed the parsing of line continuations with anti-slashes.
|
40
|
+
* Fixed the parsing of double-quoted strings. It is better at detecting badly formed strings, now.
|
41
|
+
* Fixed the reporting of lines and columns in errors.
|
42
|
+
Although the column might be slightly off sometimes, the line should be correct.
|
43
|
+
|
44
|
+
|
45
|
+
=== Minor changes:
|
46
|
+
|
47
|
+
* The RDoc is now generated with the template Hanna[http://github.com/mislav/hanna/tree/master].
|
48
|
+
* Tag.<< now behaves with Enumerables (except Strings) as it does with Arrays.
|
2
49
|
|
3
50
|
== v0.9.6 (10-aug-2010)
|
4
51
|
|
@@ -30,7 +77,7 @@
|
|
30
77
|
|
31
78
|
require 'sdl4r'
|
32
79
|
|
33
|
-
* SDL4R#coerce_or_fail has been implemented, which means that random objects
|
80
|
+
* SDL4R#coerce_or_fail has been implemented, which means that random objects cannot be added to a
|
34
81
|
Tag as before. Rational instances are coerced using Rational#to_f.
|
35
82
|
* Added usual time methods to SdlTimeSpan: day(), hour(), min(), sec(), usec()
|
36
83
|
|
data/Rakefile
CHANGED
@@ -1,16 +1,23 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/clean'
|
3
|
-
require 'rake/testtask'
|
4
|
-
require 'rake/rdoctask'
|
3
|
+
require 'rake/testtask'
|
5
4
|
require 'rake/gempackagetask'
|
6
5
|
require 'rake/packagetask'
|
7
6
|
require 'rubygems'
|
8
7
|
|
8
|
+
if Gem.required_location("hanna", "hanna/rdoctask.rb")
|
9
|
+
puts "using Hanna RDoc template"
|
10
|
+
require 'hanna/rdoctask'
|
11
|
+
else
|
12
|
+
puts "using standard RDoc template"
|
13
|
+
require 'rake/rdoctask'
|
14
|
+
end
|
15
|
+
|
9
16
|
spec = Gem::Specification.new do |s|
|
10
17
|
s.platform = Gem::Platform::RUBY
|
11
18
|
s.summary = "Simple Declarative Language for Ruby library"
|
12
19
|
s.name = 'sdl4r'
|
13
|
-
s.version = '0.9.
|
20
|
+
s.version = '0.9.7'
|
14
21
|
s.requirements << 'none'
|
15
22
|
s.require_path = 'lib'
|
16
23
|
s.authors = ['Philippe Vosges', 'Daniel Leuck']
|
@@ -46,14 +53,37 @@ Rake::GemPackageTask.new(spec) do |pkg|
|
|
46
53
|
end
|
47
54
|
|
48
55
|
Rake::RDocTask.new do |rd|
|
49
|
-
files = ['README', 'LICENSE', 'CHANGELOG',
|
50
|
-
'lib/sdl4r.rb', 'lib/sdl4r/**/*.rb', 'doc/**/*.rdoc', 'test/*.rb']
|
56
|
+
files = ['README', 'LICENSE', 'CHANGELOG', 'lib/**/*.rb', 'doc/**/*.rdoc', 'test/**/*.rb']
|
51
57
|
rd.main = 'README'
|
52
58
|
rd.rdoc_files.include(files)
|
59
|
+
rd.rdoc_files.exclude("lib/scratchpad.rb")
|
53
60
|
rd.rdoc_dir = "doc"
|
54
61
|
rd.title = "RDoc: Simple Declarative Language for Ruby"
|
55
62
|
rd.options << '--charset' << 'utf-8'
|
63
|
+
rd.options << '--line-numbers'
|
64
|
+
rd.options << '--inline-source'
|
65
|
+
end
|
66
|
+
|
67
|
+
gen_rubyforge = task :gen_rubyforge => [:rdoc] do
|
68
|
+
# Modify the front page of the Rubyforge front page
|
69
|
+
File.open("doc/files/CHANGELOG.html", "r:UTF-8") do |f|
|
70
|
+
changelog = f.read
|
71
|
+
if changelog =~ /(<div id='content'>.*?)<div id='footer-push'>/im
|
72
|
+
changelog = $1
|
73
|
+
new_front_page = File.open("rubyforge/index.html", "r:UTF-8") do |f2|
|
74
|
+
f2.read.gsub(
|
75
|
+
/<!-- CHANGELOG_START -->.*?<!-- CHANGELOG_END -->/m,
|
76
|
+
"<!-- CHANGELOG_START -->\n" + changelog + "\n<!-- CHANGELOG_END -->")
|
77
|
+
end
|
78
|
+
File.open("rubyforge/index.html", "w:UTF-8") do |f2|
|
79
|
+
f2.write new_front_page
|
80
|
+
end
|
81
|
+
else
|
82
|
+
puts "couldn't extract info from changelog"
|
83
|
+
end
|
84
|
+
end
|
56
85
|
end
|
86
|
+
gen_rubyforge.comment = "Includes the CHANGELOG into the Rubyforge front page"
|
57
87
|
|
58
88
|
Rake::TestTask.new do |t|
|
59
89
|
t.libs << "lib"
|
data/TODO
CHANGED
@@ -74,13 +74,39 @@
|
|
74
74
|
Tag.add_value
|
75
75
|
==> Minor change: we return nil for the methods were nothing was really returned explicitely
|
76
76
|
(for the time being).
|
77
|
-
[x]
|
78
|
-
[ ] If there is any success, maybe create/recreate the Rubyforge site for the support.
|
77
|
+
[x] If there is any success, maybe create/recreate the Rubyforge site for the support.
|
79
78
|
[ ] Should we allow to create a Tag without a name (== "content") for anonymous Tags?
|
80
|
-
[
|
79
|
+
[x] It would be cool to be able to write this:
|
81
80
|
|
82
81
|
Tag.new "toto" do |tag|
|
83
82
|
tag << 123
|
84
83
|
end
|
85
84
|
|
85
|
+
==> We can detect whether there is an argument or not.
|
86
|
+
|
86
87
|
Note that instance_eval() doesn't allow to pass parameters right now.
|
88
|
+
[ ] Add latest doc access to RubyForge:
|
89
|
+
==> Rake task?
|
90
|
+
|
91
|
+
[x] Is it right to translate the SDL
|
92
|
+
attr1=null
|
93
|
+
into the XML
|
94
|
+
attr1="null"
|
95
|
+
?
|
96
|
+
Should we remove the attribute altogether? Check the Java version => same in Java
|
97
|
+
==> Maybe provide an options Hash in to_xml_string():
|
98
|
+
:uri_by_namespace => {...} (breaks the old interface)
|
99
|
+
:hide_null_attributes => true|false
|
100
|
+
[x] Where we accept Arrays (operator <<, for instance), let's accept Enumerable or something like
|
101
|
+
that.
|
102
|
+
[ ] Implement the [] operator in order to access attributes:
|
103
|
+
["attr"] <=> attribute("attr")
|
104
|
+
["ns:attr"] <=> attribute("ns", "attr") (should we allow this?)
|
105
|
+
["ns", "attr"] <=> attribute("ns", "attr")
|
106
|
+
Should we allow attribute("ns:attr")?
|
107
|
+
[ ] IDEA: marshaller? easy object <=> SDL read/write?
|
108
|
+
[ ] Check the coverage and make the tests better.
|
109
|
+
[ ] IDEA: add an option to the XML export allowing to write anonymous nodes as XML tag content?
|
110
|
+
[ ] IDEA: add an option to the XML export allowing to export without formatting?
|
111
|
+
[x] BUG: line continuation is not handled properly (skipping chars etc).
|
112
|
+
[ ] BUG: the rake task 'gen_rubyforge' doesn't work under 1.9 (only 1.8.7)
|
data/doc/classes/SDL4R.html
CHANGED
@@ -1,681 +1,393 @@
|
|
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
|
-
lib/sdl4r/parser/reader.rb
|
80
|
-
</a>
|
81
|
-
<br />
|
82
|
-
<a href="../files/lib/sdl4r/parser/tokenizer_rb.html">
|
83
|
-
lib/sdl4r/parser/tokenizer.rb
|
84
|
-
</a>
|
85
|
-
<br />
|
86
|
-
<a href="../files/lib/sdl4r/parser/token_rb.html">
|
87
|
-
lib/sdl4r/parser/token.rb
|
88
|
-
</a>
|
89
|
-
<br />
|
90
|
-
<a href="../files/lib/sdl4r/parser/time_span_with_zone_rb.html">
|
91
|
-
lib/sdl4r/parser/time_span_with_zone.rb
|
92
|
-
</a>
|
93
|
-
<br />
|
94
|
-
<a href="../files/lib/sdl4r/sdl4r_rb.html">
|
95
|
-
lib/sdl4r/sdl4r.rb
|
96
|
-
</a>
|
97
|
-
<br />
|
98
|
-
</td>
|
99
|
-
</tr>
|
100
|
-
|
101
|
-
</table>
|
102
|
-
</div>
|
103
|
-
<!-- banner header -->
|
104
|
-
|
105
|
-
<div id="bodyContent">
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
<div id="contextContent">
|
110
|
-
|
111
|
-
<div id="description">
|
112
|
-
<p>
|
113
|
-
Gathers utility methods.
|
114
|
-
</p>
|
115
|
-
|
116
|
-
</div>
|
117
|
-
|
118
|
-
|
119
|
-
</div>
|
120
|
-
|
121
|
-
<div id="method-list">
|
122
|
-
<h3 class="section-bar">Methods</h3>
|
123
|
-
|
124
|
-
<div class="name-list">
|
125
|
-
<a href="#M000001">SdlBinary</a>
|
126
|
-
<a href="#M000004">coerce_or_fail</a>
|
127
|
-
<a href="#M000002">format</a>
|
128
|
-
<a href="#M000003">new_date_time</a>
|
129
|
-
<a href="#M000006">read</a>
|
130
|
-
<a href="#M000009">to_attribute_map</a>
|
131
|
-
<a href="#M000007">to_value</a>
|
132
|
-
<a href="#M000008">to_value_array</a>
|
133
|
-
<a href="#M000005">validate_identifier</a>
|
134
|
-
</div>
|
135
|
-
</div>
|
136
|
-
|
137
|
-
</div>
|
138
|
-
|
139
|
-
|
140
|
-
<!-- if includes -->
|
141
|
-
|
142
|
-
<div id="section">
|
143
|
-
|
144
|
-
<div id="class-list">
|
145
|
-
<h3 class="section-bar">Classes and Modules</h3>
|
146
|
-
|
147
|
-
Class <a href="SDL4R/Parser.html" class="link">SDL4R::Parser</a><br />
|
148
|
-
Class <a href="SDL4R/SdlBinary.html" class="link">SDL4R::SdlBinary</a><br />
|
149
|
-
Class <a href="SDL4R/SdlParseError.html" class="link">SDL4R::SdlParseError</a><br />
|
150
|
-
Class <a href="SDL4R/SdlTimeSpan.html" class="link">SDL4R::SdlTimeSpan</a><br />
|
151
|
-
Class <a href="SDL4R/Tag.html" class="link">SDL4R::Tag</a><br />
|
152
|
-
|
153
|
-
</div>
|
154
|
-
|
155
|
-
<div id="constants-list">
|
156
|
-
<h3 class="section-bar">Constants</h3>
|
157
|
-
|
158
|
-
<div class="name-list">
|
159
|
-
<table summary="Constants">
|
160
|
-
<tr class="top-aligned-row context-row">
|
161
|
-
<td class="context-item-name">MAX_INTEGER_32</td>
|
162
|
-
<td>=</td>
|
163
|
-
<td class="context-item-value">2**31 - 1</td>
|
164
|
-
</tr>
|
165
|
-
<tr class="top-aligned-row context-row">
|
166
|
-
<td class="context-item-name">MIN_INTEGER_32</td>
|
167
|
-
<td>=</td>
|
168
|
-
<td class="context-item-value">-(2**31)</td>
|
169
|
-
</tr>
|
170
|
-
<tr class="top-aligned-row context-row">
|
171
|
-
<td class="context-item-name">MAX_INTEGER_64</td>
|
172
|
-
<td>=</td>
|
173
|
-
<td class="context-item-value">2**63 - 1</td>
|
174
|
-
</tr>
|
175
|
-
<tr class="top-aligned-row context-row">
|
176
|
-
<td class="context-item-name">MIN_INTEGER_64</td>
|
177
|
-
<td>=</td>
|
178
|
-
<td class="context-item-value">-(2**63)</td>
|
179
|
-
</tr>
|
180
|
-
<tr class="top-aligned-row context-row">
|
181
|
-
<td class="context-item-name">BASE64_WRAP_LINE_LENGTH</td>
|
182
|
-
<td>=</td>
|
183
|
-
<td class="context-item-value">72</td>
|
184
|
-
</tr>
|
185
|
-
<tr class="top-aligned-row context-row">
|
186
|
-
<td class="context-item-name">ESCAPED_QUOTES</td>
|
187
|
-
<td>=</td>
|
188
|
-
<td class="context-item-value">{ "\"" => "\\\"", "'" => "\\'", "`" => "\\`", }</td>
|
189
|
-
</tr>
|
190
|
-
<tr class="top-aligned-row context-row">
|
191
|
-
<td class="context-item-name">ESCAPED_CHARS</td>
|
192
|
-
<td>=</td>
|
193
|
-
<td class="context-item-value">{ "\\" => "\\\\", "\t" => "\\t", "\r" => "\\r", "\n" => "\\n", }</td>
|
194
|
-
</tr>
|
195
|
-
</table>
|
196
|
-
</div>
|
197
|
-
</div>
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
<!-- if method_list -->
|
205
|
-
<div id="methods">
|
206
|
-
<h3 class="section-bar">Public Class methods</h3>
|
207
|
-
|
208
|
-
<div id="method-M000001" class="method-detail">
|
209
|
-
<a name="M000001"></a>
|
210
|
-
|
211
|
-
<div class="method-heading">
|
212
|
-
<a href="#M000001" class="method-signature">
|
213
|
-
<span class="method-name">SdlBinary</span><span class="method-args">(o)</span>
|
214
|
-
</a>
|
215
|
-
</div>
|
216
|
-
|
217
|
-
<div class="method-description">
|
218
|
-
<p>
|
219
|
-
Try to coerce ‘o’ into a <a
|
220
|
-
href="SDL4R.html#M000001">SdlBinary</a>. Raise an ArgumentError if it
|
221
|
-
fails.
|
222
|
-
</p>
|
223
|
-
<p><a class="source-toggle" href="#"
|
224
|
-
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
225
|
-
<div class="method-source-code" id="M000001-source">
|
226
|
-
<pre>
|
227
|
-
<span class="ruby-comment cmt"># File lib/sdl4r/sdl_binary.rb, line 72</span>
|
228
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-constant">SdlBinary</span>(<span class="ruby-identifier">o</span>)
|
229
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">SdlBinary</span>
|
230
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>
|
231
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">String</span>
|
232
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">SdlBinary</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">o</span>)
|
233
|
-
<span class="ruby-keyword kw">else</span>
|
234
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"can't coerce argument"</span>
|
235
|
-
<span class="ruby-keyword kw">end</span>
|
236
|
-
<span class="ruby-keyword kw">end</span>
|
237
|
-
</pre>
|
238
|
-
</div>
|
239
|
-
</div>
|
240
|
-
</div>
|
241
|
-
|
242
|
-
<div id="method-M000004" class="method-detail">
|
243
|
-
<a name="M000004"></a>
|
244
|
-
|
245
|
-
<div class="method-heading">
|
246
|
-
<a href="#M000004" class="method-signature">
|
247
|
-
<span class="method-name">coerce_or_fail</span><span class="method-args">(o)</span>
|
248
|
-
</a>
|
249
|
-
</div>
|
250
|
-
|
251
|
-
<div class="method-description">
|
252
|
-
<p>
|
253
|
-
Coerce the type to a standard SDL type or raises an ArgumentError.
|
254
|
-
</p>
|
255
|
-
<p>
|
256
|
-
Returns <tt>o</tt> if of the following classes: NilClass, String, Numeric,
|
257
|
-
Float, TrueClass, FalseClass, Date, DateTime, Time, <a
|
258
|
-
href="SDL4R/SdlTimeSpan.html">SdlTimeSpan</a>, <a
|
259
|
-
href="SDL4R.html#M000001">SdlBinary</a>,
|
260
|
-
</p>
|
261
|
-
<p>
|
262
|
-
Rationals are turned into Floats using Rational#to_f.
|
263
|
-
</p>
|
264
|
-
<p><a class="source-toggle" href="#"
|
265
|
-
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
266
|
-
<div class="method-source-code" id="M000004-source">
|
267
|
-
<pre>
|
268
|
-
<span class="ruby-comment cmt"># File lib/sdl4r/sdl4r.rb, line 151</span>
|
269
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">coerce_or_fail</span>(<span class="ruby-identifier">o</span>)
|
270
|
-
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">o</span>
|
271
|
-
|
272
|
-
<span class="ruby-keyword kw">when</span> <span class="ruby-constant">Rational</span>
|
273
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_f</span>
|
274
|
-
|
275
|
-
<span class="ruby-keyword kw">when</span> <span class="ruby-constant">NilClass</span>,
|
276
|
-
<span class="ruby-constant">String</span>,
|
277
|
-
<span class="ruby-constant">Numeric</span>,
|
278
|
-
<span class="ruby-constant">Float</span>,
|
279
|
-
<span class="ruby-constant">TrueClass</span>,
|
280
|
-
<span class="ruby-constant">FalseClass</span>,
|
281
|
-
<span class="ruby-constant">Date</span>,
|
282
|
-
<span class="ruby-constant">DateTime</span>,
|
283
|
-
<span class="ruby-constant">Time</span>,
|
284
|
-
<span class="ruby-constant">SdlTimeSpan</span>,
|
285
|
-
<span class="ruby-constant">SdlBinary</span>
|
286
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>
|
287
|
-
|
288
|
-
<span class="ruby-keyword kw">end</span>
|
289
|
-
|
290
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"#{o.class.name} is not coercible to an SDL type"</span>
|
291
|
-
<span class="ruby-keyword kw">end</span>
|
292
|
-
</pre>
|
293
|
-
</div>
|
294
|
-
</div>
|
295
|
-
</div>
|
296
|
-
|
297
|
-
<div id="method-M000002" class="method-detail">
|
298
|
-
<a name="M000002"></a>
|
299
|
-
|
300
|
-
<div class="method-heading">
|
301
|
-
<a href="#M000002" class="method-signature">
|
302
|
-
<span class="method-name">format</span><span class="method-args">(o, add_quotes = true, line_prefix = "", indent = "\t")</span>
|
303
|
-
</a>
|
304
|
-
</div>
|
305
|
-
|
306
|
-
<div class="method-description">
|
307
|
-
<p>
|
308
|
-
Creates an SDL string representation for a given object and returns it.
|
309
|
-
</p>
|
310
|
-
<table>
|
311
|
-
<tr><td valign="top"><tt>o</tt>:</td><td>the object to <a href="SDL4R.html#M000002">format</a>
|
312
|
-
|
313
|
-
</td></tr>
|
314
|
-
<tr><td valign="top"><tt>add_quotes</tt>:</td><td>indicates whether quotes will be added to Strings and characters (true by
|
315
|
-
default)
|
316
|
-
|
317
|
-
</td></tr>
|
318
|
-
<tr><td valign="top"><tt>line_prefix</tt>:</td><td>the line prefix to use ("" by default)
|
319
|
-
|
320
|
-
</td></tr>
|
321
|
-
<tr><td valign="top"><tt>indent</tt>:</td><td>the indent string to use ("\t" by default)
|
322
|
-
|
323
|
-
</td></tr>
|
324
|
-
</table>
|
325
|
-
<p><a class="source-toggle" href="#"
|
326
|
-
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
327
|
-
<div class="method-source-code" id="M000002-source">
|
328
|
-
<pre>
|
329
|
-
<span class="ruby-comment cmt"># File lib/sdl4r/sdl4r.rb, line 44</span>
|
330
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">format</span>(<span class="ruby-identifier">o</span>, <span class="ruby-identifier">add_quotes</span> = <span class="ruby-keyword kw">true</span>, <span class="ruby-identifier">line_prefix</span> = <span class="ruby-value str">""</span>, <span class="ruby-identifier">indent</span> = <span class="ruby-value str">"\t"</span>)
|
331
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
|
332
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">add_quotes</span>
|
333
|
-
<span class="ruby-identifier">o_length</span> = <span class="ruby-value">0</span>
|
334
|
-
<span class="ruby-identifier">o</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/./</span><span class="ruby-identifier">m</span>) { <span class="ruby-identifier">o_length</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> } <span class="ruby-comment cmt"># counts the number of chars (as opposed of bytes)</span>
|
335
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">o_length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
|
336
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-value str">"'"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">escape</span>(<span class="ruby-identifier">o</span>, <span class="ruby-value str">"'"</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">"'"</span>
|
337
|
-
<span class="ruby-keyword kw">else</span>
|
338
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-value str">'"'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">escape</span>(<span class="ruby-identifier">o</span>, <span class="ruby-value str">'"'</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">'"'</span>
|
339
|
-
<span class="ruby-keyword kw">end</span>
|
340
|
-
<span class="ruby-keyword kw">else</span>
|
341
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">escape</span>(<span class="ruby-identifier">o</span>)
|
342
|
-
<span class="ruby-keyword kw">end</span>
|
343
|
-
|
344
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Bignum</span>)
|
345
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"BD"</span>
|
346
|
-
|
347
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Integer</span>)
|
348
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">MIN_INTEGER_32</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">o</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">o</span> <span class="ruby-operator"><=</span> <span class="ruby-constant">MAX_INTEGER_32</span>
|
349
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_s</span>
|
350
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">MIN_INTEGER_64</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">o</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">o</span> <span class="ruby-operator"><=</span> <span class="ruby-constant">MAX_INTEGER_64</span>
|
351
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"L"</span>
|
352
|
-
<span class="ruby-keyword kw">else</span>
|
353
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"BD"</span>
|
354
|
-
<span class="ruby-keyword kw">end</span>
|
355
|
-
|
356
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Float</span>)
|
357
|
-
<span class="ruby-keyword kw">return</span> (<span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"F"</span>)
|
358
|
-
|
359
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Rational</span>)
|
360
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_f</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"F"</span>
|
361
|
-
|
362
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">BigDecimal</span>)
|
363
|
-
<span class="ruby-identifier">s</span> = <span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_s</span>(<span class="ruby-value str">'F'</span>)
|
364
|
-
<span class="ruby-identifier">s</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-regexp re">/\.0$/</span>, <span class="ruby-value str">""</span>)
|
365
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-node">"#{s}BD"</span>
|
366
|
-
|
367
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">nil?</span>
|
368
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-value str">"null"</span>
|
369
|
-
|
370
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">SdlBinary</span>)
|
371
|
-
<span class="ruby-identifier">encoded_o</span> = <span class="ruby-constant">Base64</span>.<span class="ruby-identifier">encode64</span>(<span class="ruby-identifier">o</span>.<span class="ruby-identifier">bytes</span>)
|
372
|
-
<span class="ruby-identifier">encoded_o</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/[\r\n]/</span><span class="ruby-identifier">m</span>, <span class="ruby-value str">""</span>) <span class="ruby-comment cmt"># Remove the EOL inserted every 60 chars</span>
|
373
|
-
|
374
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">add_quotes</span>
|
375
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">encoded_o</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-constant">BASE64_WRAP_LINE_LENGTH</span>
|
376
|
-
<span class="ruby-comment cmt"># FIXME: we should a constant or some parameter instead of hardcoded spaces</span>
|
377
|
-
<span class="ruby-identifier">wrap_lines_in_ascii</span>(<span class="ruby-identifier">encoded_o</span>, <span class="ruby-constant">BASE64_WRAP_LINE_LENGTH</span>, <span class="ruby-node">"#{line_prefix}#{indent}"</span>)
|
378
|
-
<span class="ruby-identifier">encoded_o</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-node">"[#{$/}"</span>)
|
379
|
-
<span class="ruby-identifier">encoded_o</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{$/}#{line_prefix}]"</span>
|
380
|
-
<span class="ruby-keyword kw">else</span>
|
381
|
-
<span class="ruby-identifier">encoded_o</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-value str">"["</span>)
|
382
|
-
<span class="ruby-identifier">encoded_o</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"]"</span>
|
383
|
-
<span class="ruby-keyword kw">end</span>
|
384
|
-
<span class="ruby-keyword kw">end</span>
|
385
|
-
|
386
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">encoded_o</span>
|
387
|
-
|
388
|
-
<span class="ruby-comment cmt"># Below, we use "#{o.year}" instead of "%Y" because "%Y" always emit 4 chars at least even if</span>
|
389
|
-
<span class="ruby-comment cmt"># the date is before 1000.</span>
|
390
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">DateTime</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Time</span>)
|
391
|
-
<span class="ruby-identifier">milliseconds</span> = <span class="ruby-identifier">get_datetime_milliseconds</span>(<span class="ruby-identifier">o</span>)
|
392
|
-
|
393
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">milliseconds</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
|
394
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">zone</span>
|
395
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-node">"#{o.year}/%m/%d %H:%M:%S%Z"</span>)
|
396
|
-
<span class="ruby-keyword kw">else</span>
|
397
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-node">"#{o.year}/%m/%d %H:%M:%S"</span>)
|
398
|
-
<span class="ruby-keyword kw">end</span>
|
399
|
-
<span class="ruby-keyword kw">else</span>
|
400
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">zone</span>
|
401
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-node">"#{o.year}/%m/%d %H:%M:%S."</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">milliseconds</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">ljust</span>(<span class="ruby-value">3</span>, <span class="ruby-value str">'0'</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">"%Z"</span>)
|
402
|
-
<span class="ruby-keyword kw">else</span>
|
403
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-node">"#{o.year}/%m/%d %H:%M:%S."</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">milliseconds</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">ljust</span>(<span class="ruby-value">3</span>, <span class="ruby-value str">'0'</span>))
|
404
|
-
<span class="ruby-keyword kw">end</span>
|
405
|
-
<span class="ruby-keyword kw">end</span>
|
406
|
-
|
407
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Date</span>)
|
408
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-node">"#{o.year}/%m/%d"</span>)
|
409
|
-
|
410
|
-
<span class="ruby-keyword kw">else</span>
|
411
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_s</span>
|
412
|
-
<span class="ruby-keyword kw">end</span>
|
413
|
-
<span class="ruby-keyword kw">end</span>
|
414
|
-
</pre>
|
415
|
-
</div>
|
416
|
-
</div>
|
417
|
-
</div>
|
418
|
-
|
419
|
-
<div id="method-M000003" class="method-detail">
|
420
|
-
<a name="M000003"></a>
|
421
|
-
|
422
|
-
<div class="method-heading">
|
423
|
-
<a href="#M000003" class="method-signature">
|
424
|
-
<span class="method-name">new_date_time</span><span class="method-args">(year, month, day, hour, min, sec, time_zone_offset)</span>
|
425
|
-
</a>
|
426
|
-
</div>
|
427
|
-
|
428
|
-
<div class="method-description">
|
429
|
-
<p>
|
430
|
-
Creates and returns the object representing a datetime (DateTime in the
|
431
|
-
default implementation). This method is, by default, called by the <a
|
432
|
-
href="SDL4R/Parser.html">Parser</a> class. It could be overriden as follows
|
433
|
-
in order to get Time instances from all the <a href="SDL4R.html">SDL4R</a>
|
434
|
-
parsers.
|
435
|
-
</p>
|
436
|
-
<pre>
|
437
|
-
module SDL4R
|
438
|
-
def self.new_date_time(year, month, day, hour, min, sec, time_zone_offset)
|
439
|
-
Time.utc(year, month, day, hour, min, sec)
|
440
|
-
end
|
441
|
-
end
|
442
|
-
</pre>
|
443
|
-
<p><a class="source-toggle" href="#"
|
444
|
-
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
445
|
-
<div class="method-source-code" id="M000003-source">
|
446
|
-
<pre>
|
447
|
-
<span class="ruby-comment cmt"># File lib/sdl4r/sdl4r.rb, line 139</span>
|
448
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">new_date_time</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">sec</span>, <span class="ruby-identifier">time_zone_offset</span>)
|
449
|
-
<span class="ruby-constant">DateTime</span>.<span class="ruby-identifier">civil</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">sec</span>, <span class="ruby-identifier">time_zone_offset</span>)
|
450
|
-
<span class="ruby-keyword kw">end</span>
|
451
|
-
</pre>
|
452
|
-
</div>
|
453
|
-
</div>
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
+
<html lang='en'>
|
3
|
+
<head>
|
4
|
+
<title>: SDL4R [RDoc: Simple Declarative Language for Ruby]</title>
|
5
|
+
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
|
6
|
+
<link href='../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'>
|
7
|
+
<script type='text/javascript'>
|
8
|
+
//<![CDATA[
|
9
|
+
function popupCode(url) {
|
10
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
11
|
+
}
|
12
|
+
|
13
|
+
function toggleCode(id) {
|
14
|
+
var code = document.getElementById(id)
|
15
|
+
|
16
|
+
code.style.display = code.style.display != 'block' ? 'block' : 'none'
|
17
|
+
return true
|
18
|
+
}
|
19
|
+
|
20
|
+
// Make codeblocks hidden by default
|
21
|
+
document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
|
22
|
+
//]]>
|
23
|
+
</script>
|
24
|
+
</head>
|
25
|
+
<body class='page'>
|
26
|
+
<div class='class' id='wrapper'>
|
27
|
+
<div class='header'>
|
28
|
+
<h1 class='name'>
|
29
|
+
<span class='type'>Module</span>
|
30
|
+
SDL4R
|
31
|
+
</h1>
|
32
|
+
<ol class='paths'>
|
33
|
+
<li>
|
34
|
+
<a href="../files/lib/sdl4r/sdl_time_span_rb.html">lib/sdl4r/sdl_time_span.rb</a>
|
35
|
+
</li>
|
36
|
+
<li class='other'>
|
37
|
+
<a href="../files/lib/sdl4r/sdl_parse_error_rb.html">lib/sdl4r/sdl_parse_error.rb</a>
|
38
|
+
</li>
|
39
|
+
<li class='other'>
|
40
|
+
<a href="../files/lib/sdl4r/tag_rb.html">lib/sdl4r/tag.rb</a>
|
41
|
+
</li>
|
42
|
+
<li class='other'>
|
43
|
+
<a href="../files/lib/sdl4r/parser_rb.html">lib/sdl4r/parser.rb</a>
|
44
|
+
</li>
|
45
|
+
<li class='other'>
|
46
|
+
<a href="../files/lib/sdl4r/sdl_binary_rb.html">lib/sdl4r/sdl_binary.rb</a>
|
47
|
+
</li>
|
48
|
+
<li class='other'>
|
49
|
+
<a href="../files/lib/sdl4r/parser/reader_rb.html">lib/sdl4r/parser/reader.rb</a>
|
50
|
+
</li>
|
51
|
+
<li class='other'>
|
52
|
+
<a href="../files/lib/sdl4r/parser/tokenizer_rb.html">lib/sdl4r/parser/tokenizer.rb</a>
|
53
|
+
</li>
|
54
|
+
<li class='other'>
|
55
|
+
<a href="../files/lib/sdl4r/parser/token_rb.html">lib/sdl4r/parser/token.rb</a>
|
56
|
+
</li>
|
57
|
+
<li class='other'>
|
58
|
+
<a href="../files/lib/sdl4r/sdl4r_rb.html">lib/sdl4r/sdl4r.rb</a>
|
59
|
+
</li>
|
60
|
+
<li class='other'>
|
61
|
+
<a href="../files/lib/sdl4r/parser/time_span_with_zone_rb.html">lib/sdl4r/parser/time_span_with_zone.rb</a>
|
62
|
+
</li>
|
63
|
+
<li class='other'>
|
64
|
+
<a href="../files/test/sdl4r/parser_test_rb.html">test/sdl4r/parser_test.rb</a>
|
65
|
+
</li>
|
66
|
+
<li class='other'>
|
67
|
+
<a href="../files/test/sdl4r/tag_test_rb.html">test/sdl4r/tag_test.rb</a>
|
68
|
+
</li>
|
69
|
+
<li class='other'>
|
70
|
+
<a href="../files/test/sdl4r/sdl_test_rb.html">test/sdl4r/sdl_test.rb</a>
|
71
|
+
</li>
|
72
|
+
<li class='other'>
|
73
|
+
<a href="../files/test/sdl4r/sdl4r_test_rb.html">test/sdl4r/sdl4r_test.rb</a>
|
74
|
+
</li>
|
75
|
+
<li>
|
76
|
+
<a class='show' href='#' onclick='this.parentNode.parentNode.className += " expanded"; this.parentNode.removeChild(this); return false'>show all</a>
|
77
|
+
</li>
|
78
|
+
</ol>
|
454
79
|
</div>
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
</a>
|
463
|
-
</div>
|
464
|
-
|
465
|
-
<div class="method-description">
|
466
|
-
<p>
|
467
|
-
Creates and returns a tag named "root" and add all the tags
|
468
|
-
specified in the given <tt>input</tt>.
|
469
|
-
</p>
|
470
|
-
<table>
|
471
|
-
<tr><td valign="top"><tt>input</tt>:</td><td>String, IO, Pathname or URI.
|
472
|
-
|
473
|
-
</td></tr>
|
474
|
-
</table>
|
475
|
-
<pre>
|
476
|
-
root = SDL4R::read(<<EOF
|
477
|
-
planets {
|
478
|
-
earth area_km2=510900000
|
479
|
-
mars
|
480
|
-
}
|
481
|
-
EOF
|
482
|
-
)
|
483
|
-
|
484
|
-
root = SDL4R::read(Pathname.new("my_dir/my_file.sdl"))
|
485
|
-
|
486
|
-
IO.open("my_dir/my_file.sdl", "r") { |io|
|
487
|
-
root = SDL4R::read(io)
|
488
|
-
}
|
489
|
-
|
490
|
-
root = SDL4R::read(URI.new("http://my_site/my_file.sdl"))
|
491
|
-
</pre>
|
492
|
-
<p><a class="source-toggle" href="#"
|
493
|
-
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
494
|
-
<div class="method-source-code" id="M000006-source">
|
495
|
-
<pre>
|
496
|
-
<span class="ruby-comment cmt"># File lib/sdl4r/sdl4r.rb, line 232</span>
|
497
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">input</span>)
|
498
|
-
<span class="ruby-constant">Tag</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">"root"</span>).<span class="ruby-identifier">read</span>(<span class="ruby-identifier">input</span>)
|
499
|
-
<span class="ruby-keyword kw">end</span>
|
500
|
-
</pre>
|
80
|
+
<div id='content'>
|
81
|
+
<div id='text'>
|
82
|
+
<div id='description'>
|
83
|
+
<hr size="1"></hr><p>
|
84
|
+
Gathers utility methods.
|
85
|
+
</p>
|
86
|
+
<hr size="1"></hr>
|
501
87
|
</div>
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
Parse a string representing the attributes portion of an SDL tag and return
|
517
|
-
the results as a map.
|
518
|
-
</p>
|
519
|
-
<p>
|
520
|
-
Example
|
521
|
-
</p>
|
522
|
-
<pre>
|
523
|
-
hash = SDL4R.to_attribute_hash("value=1 debugging=on time=12:24:01");
|
524
|
-
|
525
|
-
# { "value" => 1, "debugging" => true, "time" => SdlTimeSpan.new(12, 24, 01) }
|
526
|
-
</pre>
|
527
|
-
<p><a class="source-toggle" href="#"
|
528
|
-
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
529
|
-
<div class="method-source-code" id="M000009-source">
|
530
|
-
<pre>
|
531
|
-
<span class="ruby-comment cmt"># File lib/sdl4r/sdl4r.rb, line 270</span>
|
532
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_attribute_map</span>(<span class="ruby-identifier">s</span>)
|
533
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"'s' cannot be null"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">nil?</span>
|
534
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">read</span>(<span class="ruby-value str">"atts "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">s</span>).<span class="ruby-identifier">child</span>.<span class="ruby-identifier">attributes</span>
|
535
|
-
<span class="ruby-keyword kw">end</span>
|
536
|
-
</pre>
|
88
|
+
<div id='method-list'>
|
89
|
+
<h2>Methods</h2>
|
90
|
+
<h3>public class</h3>
|
91
|
+
<ol>
|
92
|
+
<li><a href="#M000001">SdlBinary</a></li>
|
93
|
+
<li><a href="#M000004">coerce_or_fail</a></li>
|
94
|
+
<li><a href="#M000002">format</a></li>
|
95
|
+
<li><a href="#M000003">new_date_time</a></li>
|
96
|
+
<li><a href="#M000006">read</a></li>
|
97
|
+
<li><a href="#M000009">to_attribute_map</a></li>
|
98
|
+
<li><a href="#M000007">to_value</a></li>
|
99
|
+
<li><a href="#M000008">to_value_array</a></li>
|
100
|
+
<li><a href="#M000005">validate_identifier</a></li>
|
101
|
+
</ol>
|
537
102
|
</div>
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
<
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
</
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
<
|
563
|
-
<
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
</
|
103
|
+
<div id='section'>
|
104
|
+
<div id='class-list'>
|
105
|
+
<h2>Classes and Modules</h2>
|
106
|
+
Class <a href="SDL4R/Parser.html" class="link">SDL4R::Parser</a><br />
|
107
|
+
Class <a href="SDL4R/ParserTest.html" class="link">SDL4R::ParserTest</a><br />
|
108
|
+
Class <a href="SDL4R/SDL4RTest.html" class="link">SDL4R::SDL4RTest</a><br />
|
109
|
+
Class <a href="SDL4R/SDLTest.html" class="link">SDL4R::SDLTest</a><br />
|
110
|
+
Class <a href="SDL4R/SdlBinary.html" class="link">SDL4R::SdlBinary</a><br />
|
111
|
+
Class <a href="SDL4R/SdlParseError.html" class="link">SDL4R::SdlParseError</a><br />
|
112
|
+
Class <a href="SDL4R/SdlTimeSpan.html" class="link">SDL4R::SdlTimeSpan</a><br />
|
113
|
+
Class <a href="SDL4R/Tag.html" class="link">SDL4R::Tag</a><br />
|
114
|
+
Class <a href="SDL4R/TagTest.html" class="link">SDL4R::TagTest</a><br />
|
115
|
+
</div>
|
116
|
+
<div id='constants-list'>
|
117
|
+
<h2>Constants</h2>
|
118
|
+
<div class='name-list'>
|
119
|
+
<table summary='Constants'>
|
120
|
+
<tr class='top-aligned-row context-row'>
|
121
|
+
<td class='context-item-name'>MAX_INTEGER_32</td>
|
122
|
+
<td>=</td>
|
123
|
+
<td class='context-item-value'>2**31 - 1</td>
|
124
|
+
</tr>
|
125
|
+
<tr class='top-aligned-row context-row'>
|
126
|
+
<td class='context-item-name'>MIN_INTEGER_32</td>
|
127
|
+
<td>=</td>
|
128
|
+
<td class='context-item-value'>-(2**31)</td>
|
129
|
+
</tr>
|
130
|
+
<tr class='top-aligned-row context-row'>
|
131
|
+
<td class='context-item-name'>MAX_INTEGER_64</td>
|
132
|
+
<td>=</td>
|
133
|
+
<td class='context-item-value'>2**63 - 1</td>
|
134
|
+
</tr>
|
135
|
+
<tr class='top-aligned-row context-row'>
|
136
|
+
<td class='context-item-name'>MIN_INTEGER_64</td>
|
137
|
+
<td>=</td>
|
138
|
+
<td class='context-item-value'>-(2**63)</td>
|
139
|
+
</tr>
|
140
|
+
<tr class='top-aligned-row context-row'>
|
141
|
+
<td class='context-item-name'>BASE64_WRAP_LINE_LENGTH</td>
|
142
|
+
<td>=</td>
|
143
|
+
<td class='context-item-value'>72</td>
|
144
|
+
</tr>
|
145
|
+
<tr class='top-aligned-row context-row'>
|
146
|
+
<td class='context-item-name'>ESCAPED_QUOTES</td>
|
147
|
+
<td>=</td>
|
148
|
+
<td class='context-item-value'>{ "\"" => "\\\"", "'" => "\\'", "`" => "\\`", }</td>
|
149
|
+
</tr>
|
150
|
+
<tr class='top-aligned-row context-row'>
|
151
|
+
<td class='context-item-name'>ESCAPED_CHARS</td>
|
152
|
+
<td>=</td>
|
153
|
+
<td class='context-item-value'>{ "\\" => "\\\\", "\t" => "\\t", "\r" => "\\r", "\n" => "\\n", }</td>
|
154
|
+
</tr>
|
155
|
+
</table>
|
156
|
+
</div>
|
157
|
+
</div>
|
158
|
+
<div id='methods'>
|
159
|
+
<h2>Public class methods</h2>
|
160
|
+
<div class='method public-class' id='method-M000001'>
|
161
|
+
<a name='M000001'></a>
|
162
|
+
<div class='synopsis'>
|
163
|
+
<span class='name'>SdlBinary</span>
|
164
|
+
<span class='arguments'>(o)</span>
|
165
|
+
</div>
|
166
|
+
<div class='description'>
|
167
|
+
<p>
|
168
|
+
Try to coerce ‘o’ into a <a
|
169
|
+
href="SDL4R.html#M000001">SdlBinary</a>. Raise an ArgumentError if it
|
170
|
+
fails.
|
171
|
+
</p>
|
172
|
+
</div>
|
173
|
+
<div class='source'>
|
174
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000001-source'); return false">
|
175
|
+
[show source]
|
176
|
+
</a>
|
177
|
+
<pre id='M000001-source'> <span class="ruby-comment cmt"># File lib/sdl4r/sdl_binary.rb, line 72</span>
72: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-constant">SdlBinary</span>(<span class="ruby-identifier">o</span>)
73: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">SdlBinary</span>
74: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>
75: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">String</span>
76: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">SdlBinary</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">o</span>)
77: <span class="ruby-keyword kw">else</span>
78: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"can't coerce argument"</span>
79: <span class="ruby-keyword kw">end</span>
80: <span class="ruby-keyword kw">end</span></pre>
|
178
|
+
</div>
|
179
|
+
</div>
|
180
|
+
<div class='method public-class' id='method-M000004'>
|
181
|
+
<a name='M000004'></a>
|
182
|
+
<div class='synopsis'>
|
183
|
+
<span class='name'>coerce_or_fail</span>
|
184
|
+
<span class='arguments'>(o)</span>
|
185
|
+
</div>
|
186
|
+
<div class='description'>
|
187
|
+
<p>
|
188
|
+
Coerce the type to a standard SDL type or raises an ArgumentError.
|
189
|
+
</p>
|
190
|
+
<p>
|
191
|
+
Returns <tt>o</tt> if of the following classes: NilClass, String, Numeric,
|
192
|
+
Float, TrueClass, FalseClass, Date, DateTime, Time, <a
|
193
|
+
href="SDL4R/SdlTimeSpan.html">SdlTimeSpan</a>, <a
|
194
|
+
href="SDL4R.html#M000001">SdlBinary</a>,
|
195
|
+
</p>
|
196
|
+
<p>
|
197
|
+
Rationals are turned into Floats using Rational#to_f.
|
198
|
+
</p>
|
199
|
+
</div>
|
200
|
+
<div class='source'>
|
201
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000004-source'); return false">
|
202
|
+
[show source]
|
203
|
+
</a>
|
204
|
+
<pre id='M000004-source'> <span class="ruby-comment cmt"># File lib/sdl4r/sdl4r.rb, line 151</span>
151: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">coerce_or_fail</span>(<span class="ruby-identifier">o</span>)
152: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">o</span>
153: 
154: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Rational</span>
155: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_f</span>
156: 
157: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">NilClass</span>,
158: <span class="ruby-constant">String</span>,
159: <span class="ruby-constant">Numeric</span>,
160: <span class="ruby-constant">Float</span>,
161: <span class="ruby-constant">TrueClass</span>,
162: <span class="ruby-constant">FalseClass</span>,
163: <span class="ruby-constant">Date</span>,
164: <span class="ruby-constant">DateTime</span>,
165: <span class="ruby-constant">Time</span>,
166: <span class="ruby-constant">SdlTimeSpan</span>,
167: <span class="ruby-constant">SdlBinary</span>
168: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>
169: 
170: <span class="ruby-keyword kw">end</span>
171: 
172: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"#{o.class.name} is not coercible to an SDL type"</span>
173: <span class="ruby-keyword kw">end</span></pre>
|
205
|
+
</div>
|
206
|
+
</div>
|
207
|
+
<div class='method public-class' id='method-M000002'>
|
208
|
+
<a name='M000002'></a>
|
209
|
+
<div class='synopsis'>
|
210
|
+
<span class='name'>format</span>
|
211
|
+
<span class='arguments'>(o, add_quotes = true, line_prefix = "", indent = "\t")</span>
|
212
|
+
</div>
|
213
|
+
<div class='description'>
|
214
|
+
<p>
|
215
|
+
Creates an SDL string representation for a given object and returns it.
|
216
|
+
</p>
|
217
|
+
<table>
|
218
|
+
<tr><td valign="top"><tt>o</tt>:</td><td>the object to format
|
219
|
+
|
220
|
+
</td></tr>
|
221
|
+
<tr><td valign="top"><tt>add_quotes</tt>:</td><td>indicates whether quotes will be added to Strings and characters (true by
|
222
|
+
default)
|
223
|
+
|
224
|
+
</td></tr>
|
225
|
+
<tr><td valign="top"><tt>line_prefix</tt>:</td><td>the line prefix to use (“” by default)
|
226
|
+
|
227
|
+
</td></tr>
|
228
|
+
<tr><td valign="top"><tt>indent</tt>:</td><td>the indent string to use (“t“ by default)
|
229
|
+
|
230
|
+
</td></tr>
|
231
|
+
</table>
|
232
|
+
</div>
|
233
|
+
<div class='source'>
|
234
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000002-source'); return false">
|
235
|
+
[show source]
|
236
|
+
</a>
|
237
|
+
<pre id='M000002-source'> <span class="ruby-comment cmt"># File lib/sdl4r/sdl4r.rb, line 44</span>
 44: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">format</span>(<span class="ruby-identifier">o</span>, <span class="ruby-identifier">add_quotes</span> = <span class="ruby-keyword kw">true</span>, <span class="ruby-identifier">line_prefix</span> = <span class="ruby-value str">""</span>, <span class="ruby-identifier">indent</span> = <span class="ruby-value str">"\t"</span>)
 45: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
 46: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">add_quotes</span>
 47: <span class="ruby-identifier">o_length</span> = <span class="ruby-value">0</span>
 48: <span class="ruby-identifier">o</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/./</span><span class="ruby-identifier">m</span>) { <span class="ruby-identifier">o_length</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> } <span class="ruby-comment cmt"># counts the number of chars (as opposed of bytes)</span>
 49: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">o_length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
 50: <span class="ruby-keyword kw">return</span> <span class="ruby-value str">"'"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">escape</span>(<span class="ruby-identifier">o</span>, <span class="ruby-value str">"'"</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">"'"</span>
 51: <span class="ruby-keyword kw">else</span>
 52: <span class="ruby-keyword kw">return</span> <span class="ruby-value str">'"'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">escape</span>(<span class="ruby-identifier">o</span>, <span class="ruby-value str">'"'</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">'"'</span>
 53: <span class="ruby-keyword kw">end</span>
 54: <span class="ruby-keyword kw">else</span>
 55: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">escape</span>(<span class="ruby-identifier">o</span>)
 56: <span class="ruby-keyword kw">end</span>
 57: 
 58: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Bignum</span>)
 59: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"BD"</span>
 60: 
 61: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Integer</span>)
 62: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">MIN_INTEGER_32</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">o</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">o</span> <span class="ruby-operator"><=</span> <span class="ruby-constant">MAX_INTEGER_32</span>
 63: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_s</span>
 64: <span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">MIN_INTEGER_64</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">o</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">o</span> <span class="ruby-operator"><=</span> <span class="ruby-constant">MAX_INTEGER_64</span>
 65: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"L"</span>
 66: <span class="ruby-keyword kw">else</span>
 67: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"BD"</span>
 68: <span class="ruby-keyword kw">end</span>
 69: 
 70: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Float</span>)
 71: <span class="ruby-keyword kw">return</span> (<span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"F"</span>)
 72: 
 73: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Rational</span>)
 74: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_f</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"F"</span>
 75: 
 76: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">BigDecimal</span>)
 77: <span class="ruby-identifier">s</span> = <span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_s</span>(<span class="ruby-value str">'F'</span>)
 78: <span class="ruby-identifier">s</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-regexp re">/\.0$/</span>, <span class="ruby-value str">""</span>)
 79: <span class="ruby-keyword kw">return</span> <span class="ruby-node">"#{s}BD"</span>
 80: 
 81: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">nil?</span>
 82: <span class="ruby-keyword kw">return</span> <span class="ruby-value str">"null"</span>
 83: 
 84: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">SdlBinary</span>)
 85: <span class="ruby-identifier">encoded_o</span> = <span class="ruby-constant">Base64</span>.<span class="ruby-identifier">encode64</span>(<span class="ruby-identifier">o</span>.<span class="ruby-identifier">bytes</span>)
 86: <span class="ruby-identifier">encoded_o</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/[\r\n]/</span><span class="ruby-identifier">m</span>, <span class="ruby-value str">""</span>) <span class="ruby-comment cmt"># Remove the EOL inserted every 60 chars</span>
 87: 
 88: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">add_quotes</span>
 89: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">encoded_o</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-constant">BASE64_WRAP_LINE_LENGTH</span>
 90: <span class="ruby-comment cmt"># FIXME: we should a constant or some parameter instead of hardcoded spaces</span>
 91: <span class="ruby-identifier">wrap_lines_in_ascii</span>(<span class="ruby-identifier">encoded_o</span>, <span class="ruby-constant">BASE64_WRAP_LINE_LENGTH</span>, <span class="ruby-node">"#{line_prefix}#{indent}"</span>)
 92: <span class="ruby-identifier">encoded_o</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-node">"[#{$/}"</span>)
 93: <span class="ruby-identifier">encoded_o</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{$/}#{line_prefix}]"</span>
 94: <span class="ruby-keyword kw">else</span>
 95: <span class="ruby-identifier">encoded_o</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-value str">"["</span>)
 96: <span class="ruby-identifier">encoded_o</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"]"</span>
 97: <span class="ruby-keyword kw">end</span>
 98: <span class="ruby-keyword kw">end</span>
 99: 
100: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">encoded_o</span>
101: 
102: <span class="ruby-comment cmt"># Below, we use "#{o.year}" instead of "%Y" because "%Y" always emit 4 chars at least even if</span>
103: <span class="ruby-comment cmt"># the date is before 1000.</span>
104: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">DateTime</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Time</span>)
105: <span class="ruby-identifier">milliseconds</span> = <span class="ruby-identifier">get_datetime_milliseconds</span>(<span class="ruby-identifier">o</span>)
106: 
107: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">milliseconds</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
108: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">zone</span>
109: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-node">"#{o.year}/%m/%d %H:%M:%S%Z"</span>)
110: <span class="ruby-keyword kw">else</span>
111: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-node">"#{o.year}/%m/%d %H:%M:%S"</span>)
112: <span class="ruby-keyword kw">end</span>
113: <span class="ruby-keyword kw">else</span>
114: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">zone</span>
115: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-node">"#{o.year}/%m/%d %H:%M:%S."</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">milliseconds</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">ljust</span>(<span class="ruby-value">3</span>, <span class="ruby-value str">'0'</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">"%Z"</span>)
116: <span class="ruby-keyword kw">else</span>
117: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-node">"#{o.year}/%m/%d %H:%M:%S."</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">milliseconds</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">ljust</span>(<span class="ruby-value">3</span>, <span class="ruby-value str">'0'</span>))
118: <span class="ruby-keyword kw">end</span>
119: <span class="ruby-keyword kw">end</span>
120: 
121: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Date</span>)
122: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-node">"#{o.year}/%m/%d"</span>)
123: 
124: <span class="ruby-keyword kw">else</span>
125: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_s</span>
126: <span class="ruby-keyword kw">end</span>
127: <span class="ruby-keyword kw">end</span></pre>
|
238
|
+
</div>
|
239
|
+
</div>
|
240
|
+
<div class='method public-class' id='method-M000003'>
|
241
|
+
<a name='M000003'></a>
|
242
|
+
<div class='synopsis'>
|
243
|
+
<span class='name'>new_date_time</span>
|
244
|
+
<span class='arguments'>(year, month, day, hour, min, sec, time_zone_offset)</span>
|
245
|
+
</div>
|
246
|
+
<div class='description'>
|
247
|
+
<p>
|
248
|
+
Creates and returns the object representing a datetime (DateTime in the
|
249
|
+
default implementation). This method is, by default, called by the <a
|
250
|
+
href="SDL4R/Parser.html">Parser</a> class. It could be overriden as follows
|
251
|
+
in order to get Time instances from all the <a href="SDL4R.html">SDL4R</a>
|
252
|
+
parsers.
|
253
|
+
</p>
|
254
|
+
<pre>module SDL4R
 def self.new_date_time(year, month, day, hour, min, sec, time_zone_offset)
 Time.utc(year, month, day, hour, min, sec)
 end
end</pre>
|
255
|
+
</div>
|
256
|
+
<div class='source'>
|
257
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000003-source'); return false">
|
258
|
+
[show source]
|
259
|
+
</a>
|
260
|
+
<pre id='M000003-source'> <span class="ruby-comment cmt"># File lib/sdl4r/sdl4r.rb, line 139</span>
139: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">new_date_time</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">sec</span>, <span class="ruby-identifier">time_zone_offset</span>)
140: <span class="ruby-constant">DateTime</span>.<span class="ruby-identifier">civil</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">sec</span>, <span class="ruby-identifier">time_zone_offset</span>)
141: <span class="ruby-keyword kw">end</span></pre>
|
261
|
+
</div>
|
262
|
+
</div>
|
263
|
+
<div class='method public-class' id='method-M000006'>
|
264
|
+
<a name='M000006'></a>
|
265
|
+
<div class='synopsis'>
|
266
|
+
<span class='name'>read</span>
|
267
|
+
<span class='arguments'>(input)</span>
|
268
|
+
</div>
|
269
|
+
<div class='description'>
|
270
|
+
<p>
|
271
|
+
Creates and returns a tag named “root” and add all the tags
|
272
|
+
specified in the given <tt>input</tt>.
|
273
|
+
</p>
|
274
|
+
<table>
|
275
|
+
<tr><td valign="top"><tt>input</tt>:</td><td>String, IO, Pathname or URI.
|
276
|
+
|
277
|
+
</td></tr>
|
278
|
+
</table>
|
279
|
+
<pre>root = SDL4R::read(<<EOF
planets {
 earth area_km2=510900000
 mars
}
EOF
)

root = SDL4R::read(Pathname.new("my_dir/my_file.sdl"))

IO.open("my_dir/my_file.sdl", "r") { |io|
 root = SDL4R::read(io)
}

root = SDL4R::read(URI.new("http://my_site/my_file.sdl"))</pre>
|
280
|
+
</div>
|
281
|
+
<div class='source'>
|
282
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000006-source'); return false">
|
283
|
+
[show source]
|
284
|
+
</a>
|
285
|
+
<pre id='M000006-source'> <span class="ruby-comment cmt"># File lib/sdl4r/sdl4r.rb, line 232</span>
232: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">input</span>)
233: <span class="ruby-constant">Tag</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">"root"</span>).<span class="ruby-identifier">read</span>(<span class="ruby-identifier">input</span>)
234: <span class="ruby-keyword kw">end</span></pre>
|
286
|
+
</div>
|
287
|
+
</div>
|
288
|
+
<div class='method public-class' id='method-M000009'>
|
289
|
+
<a name='M000009'></a>
|
290
|
+
<div class='synopsis'>
|
291
|
+
<span class='name'>to_attribute_map</span>
|
292
|
+
<span class='arguments'>(s)</span>
|
293
|
+
</div>
|
294
|
+
<div class='description'>
|
295
|
+
<p>
|
296
|
+
Parse a string representing the attributes portion of an SDL tag and return
|
297
|
+
the results as a map.
|
298
|
+
</p>
|
299
|
+
<p>
|
300
|
+
Example
|
301
|
+
</p>
|
302
|
+
<pre>hash = SDL4R.to_attribute_hash("value=1 debugging=on time=12:24:01");

# { "value" => 1, "debugging" => true, "time" => SdlTimeSpan.new(12, 24, 01) }</pre>
|
303
|
+
</div>
|
304
|
+
<div class='source'>
|
305
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000009-source'); return false">
|
306
|
+
[show source]
|
307
|
+
</a>
|
308
|
+
<pre id='M000009-source'> <span class="ruby-comment cmt"># File lib/sdl4r/sdl4r.rb, line 270</span>
270: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_attribute_map</span>(<span class="ruby-identifier">s</span>)
271: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"'s' cannot be null"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">nil?</span>
272: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">read</span>(<span class="ruby-value str">"atts "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">s</span>).<span class="ruby-identifier">child</span>.<span class="ruby-identifier">attributes</span>
273: <span class="ruby-keyword kw">end</span></pre>
|
309
|
+
</div>
|
310
|
+
</div>
|
311
|
+
<div class='method public-class' id='method-M000007'>
|
312
|
+
<a name='M000007'></a>
|
313
|
+
<div class='synopsis'>
|
314
|
+
<span class='name'>to_value</span>
|
315
|
+
<span class='arguments'>(s)</span>
|
316
|
+
</div>
|
317
|
+
<div class='description'>
|
318
|
+
<p>
|
319
|
+
Parses and returns the value corresponding with the specified SDL literal.
|
320
|
+
</p>
|
321
|
+
<pre>SDL4R.to_value("\"abcd\"") # => "abcd"
SDL4R.to_value("1") # => 1
SDL4R.to_value("null") # => nil</pre>
|
322
|
+
</div>
|
323
|
+
<div class='source'>
|
324
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000007-source'); return false">
|
325
|
+
[show source]
|
326
|
+
</a>
|
327
|
+
<pre id='M000007-source'> <span class="ruby-comment cmt"># File lib/sdl4r/sdl4r.rb, line 242</span>
242: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_value</span>(<span class="ruby-identifier">s</span>)
243: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"'s' cannot be null"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">nil?</span>
244: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">read</span>(<span class="ruby-identifier">s</span>).<span class="ruby-identifier">child</span>.<span class="ruby-identifier">value</span>
245: <span class="ruby-keyword kw">end</span></pre>
|
328
|
+
</div>
|
329
|
+
</div>
|
330
|
+
<div class='method public-class' id='method-M000008'>
|
331
|
+
<a name='M000008'></a>
|
332
|
+
<div class='synopsis'>
|
333
|
+
<span class='name'>to_value_array</span>
|
334
|
+
<span class='arguments'>(s)</span>
|
335
|
+
</div>
|
336
|
+
<div class='description'>
|
337
|
+
<p>
|
338
|
+
Parse the string of values and return a list. The string is handled as if
|
339
|
+
it is the values portion of an SDL tag.
|
340
|
+
</p>
|
341
|
+
<p>
|
342
|
+
Example
|
343
|
+
</p>
|
344
|
+
<pre>array = SDL4R.to_value_array("1 true 12:24:01")</pre>
|
345
|
+
<p>
|
346
|
+
Will return an int, a boolean, and a time span.
|
347
|
+
</p>
|
348
|
+
</div>
|
349
|
+
<div class='source'>
|
350
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000008-source'); return false">
|
351
|
+
[show source]
|
352
|
+
</a>
|
353
|
+
<pre id='M000008-source'> <span class="ruby-comment cmt"># File lib/sdl4r/sdl4r.rb, line 256</span>
256: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_value_array</span>(<span class="ruby-identifier">s</span>)
257: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"'s' cannot be null"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">nil?</span>
258: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">read</span>(<span class="ruby-identifier">s</span>).<span class="ruby-identifier">child</span>.<span class="ruby-identifier">values</span>
259: <span class="ruby-keyword kw">end</span></pre>
|
354
|
+
</div>
|
355
|
+
</div>
|
356
|
+
<div class='method public-class' id='method-M000005'>
|
357
|
+
<a name='M000005'></a>
|
358
|
+
<div class='synopsis'>
|
359
|
+
<span class='name'>validate_identifier</span>
|
360
|
+
<span class='arguments'>(identifier)</span>
|
361
|
+
</div>
|
362
|
+
<div class='description'>
|
363
|
+
<p>
|
364
|
+
Validates an SDL identifier String. SDL Identifiers must start with a
|
365
|
+
Unicode letter or underscore (_) and contain only unicode letters, digits,
|
366
|
+
underscores (_), dashes(-) and periods (.).
|
367
|
+
</p>
|
368
|
+
<h2>Raises</h2>
|
369
|
+
<p>
|
370
|
+
ArgumentError if the identifier is not legal
|
371
|
+
</p>
|
372
|
+
<p>
|
373
|
+
TODO: support UTF-8 identifiers
|
374
|
+
</p>
|
375
|
+
</div>
|
376
|
+
<div class='source'>
|
377
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000005-source'); return false">
|
378
|
+
[show source]
|
379
|
+
</a>
|
380
|
+
<pre id='M000005-source'> <span class="ruby-comment cmt"># File lib/sdl4r/sdl4r.rb, line 184</span>
184: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">validate_identifier</span>(<span class="ruby-identifier">identifier</span>)
185: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">identifier</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">identifier</span>.<span class="ruby-identifier">empty?</span>
186: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"SDL identifiers cannot be null or empty."</span>
187: <span class="ruby-keyword kw">end</span>
188: 
189: <span class="ruby-comment cmt"># in Java, was if(!Character.isJavaIdentifierStart(identifier.charAt(0)))</span>
190: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">identifier</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^[a-zA-Z_]/</span>
191: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>,
192: <span class="ruby-value str">"'"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">identifier</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">0</span>] <span class="ruby-operator">+</span>
193: <span class="ruby-value str">"' is not a legal first character for an SDL identifier. "</span> <span class="ruby-operator">+</span>
194: <span class="ruby-value str">"SDL Identifiers must start with a unicode letter or "</span> <span class="ruby-operator">+</span>
195: <span class="ruby-value str">"an underscore (_)."</span>
196: <span class="ruby-keyword kw">end</span>
197: 
198: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">identifier</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">identifier</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^[a-zA-Z_][a-zA-Z_0-9\-\.]*$/</span>
199: <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword kw">in</span> <span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">identifier</span>.<span class="ruby-identifier">length</span>
200: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">identifier</span>[<span class="ruby-identifier">i</span><span class="ruby-operator">..</span><span class="ruby-identifier">i</span>] <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^[a-zA-Z_0-9\-]$/</span>
201: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>,
202: <span class="ruby-value str">"'"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">identifier</span>[<span class="ruby-identifier">i</span><span class="ruby-operator">..</span><span class="ruby-identifier">i</span>] <span class="ruby-operator">+</span> 
203: <span class="ruby-value str">"' is not a legal character for an SDL identifier. "</span> <span class="ruby-operator">+</span>
204: <span class="ruby-value str">"SDL Identifiers must start with a unicode letter or "</span> <span class="ruby-operator">+</span>
205: <span class="ruby-value str">"underscore (_) followed by 0 or more unicode "</span> <span class="ruby-operator">+</span>
206: <span class="ruby-value str">"letters, digits, underscores (_), or dashes (-)"</span>
207: <span class="ruby-keyword kw">end</span>
208: <span class="ruby-keyword kw">end</span>
209: <span class="ruby-keyword kw">end</span>
210: <span class="ruby-keyword kw">end</span></pre>
|
381
|
+
</div>
|
382
|
+
</div>
|
383
|
+
</div>
|
569
384
|
</div>
|
570
385
|
</div>
|
571
386
|
</div>
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
<div class="method-heading">
|
577
|
-
<a href="#M000008" class="method-signature">
|
578
|
-
<span class="method-name">to_value_array</span><span class="method-args">(s)</span>
|
579
|
-
</a>
|
580
|
-
</div>
|
581
|
-
|
582
|
-
<div class="method-description">
|
583
|
-
<p>
|
584
|
-
Parse the string of values and return a list. The string is handled as if
|
585
|
-
it is the values portion of an SDL tag.
|
586
|
-
</p>
|
587
|
-
<p>
|
588
|
-
Example
|
589
|
-
</p>
|
590
|
-
<pre>
|
591
|
-
array = SDL4R.to_value_array("1 true 12:24:01")
|
592
|
-
</pre>
|
593
|
-
<p>
|
594
|
-
Will return an int, a boolean, and a time span.
|
595
|
-
</p>
|
596
|
-
<p><a class="source-toggle" href="#"
|
597
|
-
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
598
|
-
<div class="method-source-code" id="M000008-source">
|
599
|
-
<pre>
|
600
|
-
<span class="ruby-comment cmt"># File lib/sdl4r/sdl4r.rb, line 256</span>
|
601
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_value_array</span>(<span class="ruby-identifier">s</span>)
|
602
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"'s' cannot be null"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">nil?</span>
|
603
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">read</span>(<span class="ruby-identifier">s</span>).<span class="ruby-identifier">child</span>.<span class="ruby-identifier">values</span>
|
604
|
-
<span class="ruby-keyword kw">end</span>
|
605
|
-
</pre>
|
606
|
-
</div>
|
607
|
-
</div>
|
608
|
-
</div>
|
609
|
-
|
610
|
-
<div id="method-M000005" class="method-detail">
|
611
|
-
<a name="M000005"></a>
|
612
|
-
|
613
|
-
<div class="method-heading">
|
614
|
-
<a href="#M000005" class="method-signature">
|
615
|
-
<span class="method-name">validate_identifier</span><span class="method-args">(identifier)</span>
|
616
|
-
</a>
|
617
|
-
</div>
|
618
|
-
|
619
|
-
<div class="method-description">
|
620
|
-
<p>
|
621
|
-
Validates an SDL identifier String. SDL Identifiers must start with a
|
622
|
-
Unicode letter or underscore (_) and contain only unicode letters, digits,
|
623
|
-
underscores (_), dashes(-) and periods (.).
|
624
|
-
</p>
|
625
|
-
<h2>Raises</h2>
|
626
|
-
<p>
|
627
|
-
ArgumentError if the identifier is not legal
|
628
|
-
</p>
|
629
|
-
<p>
|
630
|
-
TODO: support UTF-8 identifiers
|
631
|
-
</p>
|
632
|
-
<p><a class="source-toggle" href="#"
|
633
|
-
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
634
|
-
<div class="method-source-code" id="M000005-source">
|
635
|
-
<pre>
|
636
|
-
<span class="ruby-comment cmt"># File lib/sdl4r/sdl4r.rb, line 184</span>
|
637
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">validate_identifier</span>(<span class="ruby-identifier">identifier</span>)
|
638
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">identifier</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">identifier</span>.<span class="ruby-identifier">empty?</span>
|
639
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"SDL identifiers cannot be null or empty."</span>
|
640
|
-
<span class="ruby-keyword kw">end</span>
|
641
|
-
|
642
|
-
<span class="ruby-comment cmt"># in Java, was if(!Character.isJavaIdentifierStart(identifier.charAt(0)))</span>
|
643
|
-
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">identifier</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^[a-zA-Z_]/</span>
|
644
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>,
|
645
|
-
<span class="ruby-value str">"'"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">identifier</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">0</span>] <span class="ruby-operator">+</span>
|
646
|
-
<span class="ruby-value str">"' is not a legal first character for an SDL identifier. "</span> <span class="ruby-operator">+</span>
|
647
|
-
<span class="ruby-value str">"SDL Identifiers must start with a unicode letter or "</span> <span class="ruby-operator">+</span>
|
648
|
-
<span class="ruby-value str">"an underscore (_)."</span>
|
649
|
-
<span class="ruby-keyword kw">end</span>
|
650
|
-
|
651
|
-
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">identifier</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">identifier</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^[a-zA-Z_][a-zA-Z_0-9\-\.]*$/</span>
|
652
|
-
<span class="ruby-keyword kw">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword kw">in</span> <span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">identifier</span>.<span class="ruby-identifier">length</span>
|
653
|
-
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">identifier</span>[<span class="ruby-identifier">i</span><span class="ruby-operator">..</span><span class="ruby-identifier">i</span>] <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^[a-zA-Z_0-9\-]$/</span>
|
654
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>,
|
655
|
-
<span class="ruby-value str">"'"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">identifier</span>[<span class="ruby-identifier">i</span><span class="ruby-operator">..</span><span class="ruby-identifier">i</span>] <span class="ruby-operator">+</span>
|
656
|
-
<span class="ruby-value str">"' is not a legal character for an SDL identifier. "</span> <span class="ruby-operator">+</span>
|
657
|
-
<span class="ruby-value str">"SDL Identifiers must start with a unicode letter or "</span> <span class="ruby-operator">+</span>
|
658
|
-
<span class="ruby-value str">"underscore (_) followed by 0 or more unicode "</span> <span class="ruby-operator">+</span>
|
659
|
-
<span class="ruby-value str">"letters, digits, underscores (_), or dashes (-)"</span>
|
660
|
-
<span class="ruby-keyword kw">end</span>
|
661
|
-
<span class="ruby-keyword kw">end</span>
|
662
|
-
<span class="ruby-keyword kw">end</span>
|
663
|
-
<span class="ruby-keyword kw">end</span>
|
664
|
-
</pre>
|
665
|
-
</div>
|
666
|
-
</div>
|
667
|
-
</div>
|
668
|
-
|
669
|
-
|
387
|
+
<div id='footer-push'></div>
|
388
|
+
</div>
|
389
|
+
<div id='footer'>
|
390
|
+
<a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
|
670
391
|
</div>
|
671
|
-
|
672
|
-
|
673
|
-
</div>
|
674
|
-
|
675
|
-
|
676
|
-
<div id="validator-badges">
|
677
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
678
|
-
</div>
|
679
|
-
|
680
|
-
</body>
|
681
|
-
</html>
|
392
|
+
</body>
|
393
|
+
</html>
|