rhodes 0.3.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. data/Manifest.txt +0 -61
  2. data/Rakefile +11 -13
  3. data/lib/rhodes.rb +2 -2
  4. metadata +33 -77
  5. data/History.txt +0 -40
  6. data/README.rdoc +0 -2
  7. data/bin/rhogen +0 -8
  8. data/generators/rhogen.rb +0 -131
  9. data/generators/templates/application/application.rb +0 -4
  10. data/generators/templates/application/index.erb +0 -11
  11. data/generators/templates/application/layout.erb +0 -17
  12. data/generators/templates/model/config.rb +0 -3
  13. data/generators/templates/model/controller.rb +0 -49
  14. data/generators/templates/model/edit.erb +0 -21
  15. data/generators/templates/model/index.erb +0 -10
  16. data/generators/templates/model/new.erb +0 -16
  17. data/generators/templates/model/show.erb +0 -6
  18. data/generators/templates/source/source_adapter.rb +0 -56
  19. data/lib/ServeME.rb +0 -7
  20. data/lib/TestServe.rb +0 -9
  21. data/lib/bsearch.rb +0 -120
  22. data/lib/builtinME.rb +0 -588
  23. data/lib/date.rb +0 -1792
  24. data/lib/date/format.rb +0 -1339
  25. data/lib/dateME.rb +0 -24
  26. data/lib/erb.rb +0 -896
  27. data/lib/find.rb +0 -81
  28. data/lib/rational.rb +0 -19
  29. data/lib/rationalME.rb +0 -530
  30. data/lib/rho.rb +0 -1
  31. data/lib/rho/render.rb +0 -51
  32. data/lib/rho/rho.rb +0 -240
  33. data/lib/rho/rhoapplication.rb +0 -36
  34. data/lib/rho/rhocontact.rb +0 -110
  35. data/lib/rho/rhocontroller.rb +0 -35
  36. data/lib/rho/rhofsconnector.rb +0 -32
  37. data/lib/rho/rhosupport.rb +0 -139
  38. data/lib/rho/rhoviewhelpers.rb +0 -121
  39. data/lib/rhoframework.rb +0 -38
  40. data/lib/rhofsconnector.rb +0 -1
  41. data/lib/rhom.rb +0 -1
  42. data/lib/rhom/rhom.rb +0 -58
  43. data/lib/rhom/rhom_db_adapter.rb +0 -185
  44. data/lib/rhom/rhom_db_adapterME.rb +0 -93
  45. data/lib/rhom/rhom_object.rb +0 -65
  46. data/lib/rhom/rhom_object_factory.rb +0 -197
  47. data/lib/rhom/rhom_source.rb +0 -60
  48. data/lib/singleton.rb +0 -137
  49. data/lib/time.rb +0 -489
  50. data/spec/app_generator_spec.rb +0 -33
  51. data/spec/app_manifest.txt +0 -3
  52. data/spec/configs/account.rb +0 -3
  53. data/spec/configs/case.rb +0 -3
  54. data/spec/configs/employee.rb +0 -3
  55. data/spec/generator_spec_helper.rb +0 -12
  56. data/spec/model_generator_spec.rb +0 -36
  57. data/spec/rho_controller_spec.rb +0 -139
  58. data/spec/rho_spec.rb +0 -61
  59. data/spec/rhom_object_factory_spec.rb +0 -132
  60. data/spec/rhom_spec.rb +0 -45
  61. data/spec/source_generator_spec.rb +0 -27
  62. data/spec/spec_helper.rb +0 -48
  63. data/spec/stubs.rb +0 -31
  64. data/spec/syncdbtest.sqlite +0 -0
  65. data/tasks/rspec.rake +0 -34
@@ -1,4 +0,0 @@
1
- require 'rho/rhoapplication'
2
-
3
- class <%= class_name %>Application < Rho::RhoApplication
4
- end
@@ -1,11 +0,0 @@
1
- <div class="toolbar">
2
- <h1 id="pageTitle">
3
- <script language="JavaScript">
4
- document.write(document.title)
5
- </script>
6
- </h1>
7
- <a id="backButton" class="button" href="./"></a>
8
- </div>
9
- <ul id="home" selected="true" title="<%= class_name %>">
10
- <li>Something interesting here...</li>
11
- </ul>
@@ -1,17 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
- <html xmlns="http://www.w3.org/1999/xhtml">
4
- <head>
5
- <title><%= class_name %></title>
6
- <%% if System::get_property('platform') == 'APPLE' %>
7
- <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
8
- <style type="text/css" media="screen">@import "/shared/js/iui/iui.css"; @import "/shared/css/rho.css";</style>
9
- <script type="application/x-javascript" src="/shared/js/iui/iui.js"></script>
10
- <script src="/shared/js/jquery-1.2.6.min.js"></script>
11
- <script src="/shared/js/rho.js"></script>
12
- <%% end %>
13
- </head>
14
- <body>
15
- <%%= @content %>
16
- </body>
17
- </html>
@@ -1,3 +0,0 @@
1
- require 'rho'
2
-
3
- Rho::RhoConfig::add_source("<%= class_name %>", {"url"=>"<%= source_url %>", "source_id"=><%= source_id %>})
@@ -1,49 +0,0 @@
1
- require 'rho/rhocontroller'
2
-
3
- class <%= class_name %>Controller < Rho::RhoController
4
-
5
- #GET /<%= class_name %>
6
- def index
7
- @<%= name.pluralize %> = <%= class_name %>.find(:all)
8
- render
9
- end
10
-
11
- # GET /<%= class_name %>/1
12
- def show
13
- @<%= name %> = <%= class_name %>.find(@params['id'])
14
- render :action => :show
15
- end
16
-
17
- # GET /<%= class_name %>/new
18
- def new
19
- @<%= name %> = <%= class_name %>.new
20
- render :action => :new
21
- end
22
-
23
- # GET /<%= class_name %>/1/edit
24
- def edit
25
- @<%= name %> = <%= class_name %>.find(@params['id'])
26
- render :action => :edit
27
- end
28
-
29
- # POST /<%= class_name %>/create
30
- def create
31
- @<%= name %> = <%= class_name %>.new(@params['<%= name %>'])
32
- @<%= name %>.save
33
- redirect :action => :index
34
- end
35
-
36
- # POST /<%= class_name %>/1/update
37
- def update
38
- @<%= name %> = <%= class_name %>.find(@params['id'])
39
- @<%= name %>.update_attributes(@params['<%= name %>'])
40
- redirect :action => :index
41
- end
42
-
43
- # POST /<%= class_name %>/1/delete
44
- def delete
45
- @<%= name %> = <%= class_name %>.find(@params['id'])
46
- @<%= name %>.destroy
47
- redirect :action => :index
48
- end
49
- end
@@ -1,21 +0,0 @@
1
- <form title="Edit <%= class_name %>"
2
- class="panel"
3
- id="<%= name %>_edit_form"
4
- method="POST"
5
- action="<%%=url_for(:action => :update)%>">
6
- <fieldset>
7
- <input type="hidden" name="id" value="<%%=@<%= name %>.object%>"/>
8
- <% attributes.each do |attribute| %>
9
- <div class="row">
10
- <label><%=humanize(attribute)%>: </label>
11
- <input type="text" name="<%= name %>[<%= attribute %>]" value="<%%=@<%=name%>.<%=attribute%>%>"/>
12
- </div>
13
- <% end %>
14
- </fieldset>
15
- <input type="submit" value="Update"/>
16
- <p align="center">
17
- <a href="<%%=url_for(:action => :delete, :id => @<%= name %>.object)%>">
18
- <font color="#990000">Delete</font>
19
- </a>
20
- </p>
21
- </form>
@@ -1,10 +0,0 @@
1
- <ul id="<%= name.pluralize %>" title="<%= class_name.pluralize %>">
2
- <%%@<%=name.pluralize%>.each do |x|%>
3
- <%if self.attributes?%>
4
- <li><%%=link_to "#{x.<%=attributes[0]%>}", :action => :show, :id => x.object%></li>
5
- <%else%>
6
- <li>Some list entry...</li>
7
- <%end%>
8
- <%%end%>
9
- <li><font color="blue"><%%=link_to "New <%= class_name %>", :action => :new%></font></li>
10
- </ul>
@@ -1,16 +0,0 @@
1
- <form title="New <%= class_name %>"
2
- class="panel"
3
- id="<%= name %>_new_form"
4
- method="POST"
5
- action="<%%=url_for(:action => :create)%>">
6
- <fieldset>
7
- <input type="hidden" name="id" value="<%%=@<%= name %>.object%>"/>
8
- <% attributes.each do |attribute| %>
9
- <div class="row">
10
- <label><%=humanize(attribute)%>: </label>
11
- <input type="text" name="<%= name %>[<%= attribute %>]"/>
12
- </div>
13
- <% end %>
14
- </fieldset>
15
- <input type="submit" value="Create"/>
16
- </form>
@@ -1,6 +0,0 @@
1
- <ul id="<%= name %>" title="Show <%= class_name %>">
2
- <% attributes.each do |attribute| %>
3
- <li><%%=@<%=name%>.<%=attribute%>%></li>
4
- <% end %>
5
- <li><%%=link_to "Edit #{@<%=name%>.<%=attributes[0]%>}", :action => :edit, :id => @<%=name%>.object%></li>
6
- </ul>
@@ -1,56 +0,0 @@
1
- class <%=name%> < SourceAdapter
2
-
3
- def initialize(source)
4
- super(source)
5
- end
6
-
7
- def login
8
- #TODO: Write some code here
9
- # use the variable @source.login and @source.password
10
- raise "Please provide some code to perform an authenticated login to the backend application"
11
- end
12
-
13
- def query
14
- # TODO: write some code here
15
- raise "Please provide some code to read records from the backend application"
16
- end
17
-
18
- def sync
19
- # usually this generic code does the job
20
- @result.entry_list.each do |x|
21
- x.name_value_list.each do |y|
22
- o=ObjectValue.new
23
- o.source_id=@source.id
24
- o.object=x['id']
25
- o.attrib=y.name
26
- o.value=y.value
27
- o.user_id=user_id if user_id
28
- o.save
29
- end
30
- end
31
- end
32
-
33
- def create(name_value_list)
34
- #TODO: write some code here
35
- # the backend application will provide the object hash key and corresponding value
36
- raise "Please provide some code to create a single object in the backend application using the hash values in name_value_list"
37
- end
38
-
39
- def update(name_value_list)
40
- #TODO: write some code here
41
- # be sure to have a hash key and value for "object"
42
- raise "Please provide some code to update a single object in the backend application using the hash values in name_value_list"
43
- end
44
-
45
- def delete(name_value_list)
46
- #TODO: write some code here if applicable
47
- # be sure to have a hash key and value for "object"
48
- # for now, we'll say that its OK to not have a delete operation
49
- # raise "Please provide some code to delete a single object in the backend application using the hash values in name_value_list"
50
- end
51
-
52
- def logoff
53
- #TODO: write some code here if applicable
54
- # no need to do a raise here
55
- end
56
- end
@@ -1,7 +0,0 @@
1
- begin
2
- require 'rho'
3
- puts 'RHO loaded'
4
- Rho::RHO.new
5
- rescue Exception => e
6
- puts e.message
7
- end
@@ -1,9 +0,0 @@
1
- require 'rho'
2
- puts 'RHO loaded'
3
- r = Rho::RHO.new
4
- req = Hash.new
5
- req['application']="Rhosugar"
6
- req['model'] = 'Account'
7
- req['request-method']='GET'
8
- puts r.serve(req)
9
-
@@ -1,120 +0,0 @@
1
- #
2
- # Ruby/Bsearch - a binary search library for Ruby.
3
- #
4
- # Copyright (C) 2001 Satoru Takabayashi <satoru@namazu.org>
5
- # All rights reserved.
6
- # This is free software with ABSOLUTELY NO WARRANTY.
7
- #
8
- # You can redistribute it and/or modify it under the terms of
9
- # the Ruby's licence.
10
- #
11
- # Example:
12
- #
13
- # % irb -r ./bsearch.rb
14
- # >> %w(a b c c c d e f).bsearch_first {|x| x <=> "c"}
15
- # => 2
16
- # >> %w(a b c c c d e f).bsearch_last {|x| x <=> "c"}
17
- # => 4
18
- # >> %w(a b c e f).bsearch_first {|x| x <=> "c"}
19
- # => 2
20
- # >> %w(a b e f).bsearch_first {|x| x <=> "c"}
21
- # => nil
22
- # >> %w(a b e f).bsearch_last {|x| x <=> "c"}
23
- # => nil
24
- # >> %w(a b e f).bsearch_lower_boundary {|x| x <=> "c"}
25
- # => 2
26
- # >> %w(a b e f).bsearch_upper_boundary {|x| x <=> "c"}
27
- # => 2
28
- # >> %w(a b c c c d e f).bsearch_range {|x| x <=> "c"}
29
- # => 2...5
30
- # >> %w(a b c d e f).bsearch_range {|x| x <=> "c"}
31
- # => 2...3
32
- # >> %w(a b d e f).bsearch_range {|x| x <=> "c"}
33
- # => 2...2
34
-
35
- module Bsearch
36
- VERSION = '1.5'
37
- end
38
-
39
- class Array
40
- #
41
- # The binary search algorithm is extracted from Jon Bentley's
42
- # Programming Pearls 2nd ed. p.93
43
- #
44
-
45
- #
46
- # Return the lower boundary. (inside)
47
- #
48
- def bsearch_lower_boundary (range = 0 ... self.length, &block)
49
- lower = range.first() -1
50
- upper = if range.exclude_end? then range.last else range.last + 1 end
51
- while lower + 1 != upper
52
- mid = ((lower + upper) / 2).to_i # for working with mathn.rb (Rational)
53
- if yield(self[mid]) < 0
54
- lower = mid
55
- else
56
- upper = mid
57
- end
58
- end
59
- return upper
60
- end
61
-
62
- #
63
- # This method searches the FIRST occurrence which satisfies a
64
- # condition given by a block in binary fashion and return the
65
- # index of the first occurrence. Return nil if not found.
66
- #
67
- def bsearch_first (range = 0 ... self.length, &block)
68
- boundary = bsearch_lower_boundary(range, &block)
69
- if boundary >= self.length || yield(self[boundary]) != 0
70
- return nil
71
- else
72
- return boundary
73
- end
74
- end
75
-
76
- alias bsearch bsearch_first
77
-
78
- #
79
- # Return the upper boundary. (outside)
80
- #
81
- def bsearch_upper_boundary (range = 0 ... self.length, &block)
82
- lower = range.first() -1
83
- upper = if range.exclude_end? then range.last else range.last + 1 end
84
- while lower + 1 != upper
85
- mid = ((lower + upper) / 2).to_i # for working with mathn.rb (Rational)
86
- if yield(self[mid]) <= 0
87
- lower = mid
88
- else
89
- upper = mid
90
- end
91
- end
92
- return lower + 1 # outside of the matching range.
93
- end
94
-
95
- #
96
- # This method searches the LAST occurrence which satisfies a
97
- # condition given by a block in binary fashion and return the
98
- # index of the last occurrence. Return nil if not found.
99
- #
100
- def bsearch_last (range = 0 ... self.length, &block)
101
- # `- 1' for canceling `lower + 1' in bsearch_upper_boundary.
102
- boundary = bsearch_upper_boundary(range, &block) - 1
103
-
104
- if (boundary <= -1 || yield(self[boundary]) != 0)
105
- return nil
106
- else
107
- return boundary
108
- end
109
- end
110
-
111
- #
112
- # Return the search result as a Range object.
113
- #
114
- def bsearch_range (range = 0 ... self.length, &block)
115
- lower = bsearch_lower_boundary(range, &block)
116
- upper = bsearch_upper_boundary(range, &block)
117
- return lower ... upper
118
- end
119
- end
120
-
@@ -1,588 +0,0 @@
1
- $" = []
2
- $* = ARGV
3
- $SAFE = 0
4
-
5
- TRUE = true
6
- FALSE = false
7
- NIL = nil
8
-
9
- RUBY_VERSION = "1.8.5"
10
- VERSION = "1.8.5"
11
-
12
- TOPLEVEL_BINDING = self
13
-
14
- module Kernel
15
- def nil?
16
- false
17
- end
18
-
19
- def fork
20
- raise NotImplementedError, "the fork() function is unimplemented on this machine"
21
- end
22
-
23
- def =~ x
24
- false
25
- end
26
-
27
- def singleton_method_added symbol
28
- end
29
-
30
- def singleton_method_removed symbol
31
- end
32
-
33
- def singleton_method_undefined symbol
34
- end
35
-
36
- #private
37
- def require(file_name)
38
- return false if ($".include?(file_name) || $".include?(file_name + ".rb"))
39
-
40
- load(file_name);
41
- end
42
-
43
- #private
44
- def load(file_name)
45
- if __load_with_reflection__(file_name)
46
- return true
47
- end
48
-
49
- # $:.each do |path|
50
- # return true if load_rb_file(path, file_name)
51
- # end
52
-
53
- raise LoadError, "no such file to load -- " + file_name
54
- end
55
-
56
- private
57
- def method_added symbol
58
- end
59
- end
60
-
61
- class Object
62
- # def to_a
63
- # [self]
64
- # end
65
-
66
- alias type :class
67
-
68
- private
69
- def initialize
70
- end
71
- end
72
-
73
- module Enumerable
74
- def each_with_index
75
- i = 0;
76
- each {|x| yield x, i; i = i + 1}
77
- end
78
-
79
- def to_a
80
- arr = []
81
- each{|obj| arr <<obj}
82
- return arr
83
- end
84
-
85
- alias entries :to_a
86
-
87
- def inject(*args)
88
- if args.size == 0 then
89
- vals = to_a
90
- memo = vals[0]
91
- vals[1..vals.size-1].each {|obj| memo = yield(memo, obj)}
92
- return memo
93
- elsif args.size == 1 then
94
- memo = args[0]
95
- each {|obj| memo = yield(memo, obj)}
96
- return memo
97
- else
98
- nil
99
- end
100
- end
101
-
102
- def collect
103
- arr = []
104
- each{|obj| arr << yield(obj)}
105
- return arr
106
- end
107
-
108
- alias map :collect
109
-
110
- def max(&proc)
111
- proc = lambda { |a, b| a <=> b } unless block_given?
112
- max = nil
113
- each {|obj| max = obj if max.nil? || proc.call(max, obj) < 0}
114
- max
115
- end
116
-
117
- def min(&proc)
118
- proc = lambda { |a, b| a <=> b } unless block_given?
119
- min = nil
120
- each {|obj| min = obj if min.nil? || proc.call(min, obj) > 0}
121
- min
122
- end
123
-
124
- end
125
-
126
- class Array
127
- alias reject! delete_if
128
-
129
- def reject
130
- a = []
131
- each {|x|
132
- if !yield x
133
- a << x
134
- end
135
- }
136
- a
137
- end
138
-
139
- # def to_a
140
- # self
141
- # end
142
-
143
- def join(sepString="")
144
- return to_s if sepString.nil? || sepString == ""
145
-
146
- result = ""
147
- (length - 1).times do |index|
148
- result += (self[index].to_s) + sepString
149
- end
150
- result += self[length - 1].to_s if length != 0
151
- result
152
- end
153
-
154
- alias map! collect!
155
- alias size length
156
- alias to_ary to_a
157
-
158
- def inspect
159
- str = "["
160
- is_first = true
161
- self.each() { |x|
162
- if (!is_first)
163
- str << ", "
164
- end
165
- is_first = false
166
- str << x.inspect
167
- }
168
- str << "]"
169
- end
170
-
171
- alias to_s inspect
172
-
173
- end
174
-
175
- class File
176
- SEPARATOR = '/'
177
-
178
- def File.join *aString
179
- s = ""
180
- first = true
181
- aString.each {|x|
182
- if !first
183
- s += File::SEPARATOR
184
- end
185
- s+= x
186
- first = false
187
- }
188
- s
189
- end
190
- end
191
-
192
- class IO
193
- def each
194
- while !eof
195
- yield gets
196
- end
197
- close
198
- end
199
- end
200
-
201
- class Time
202
- include Comparable
203
- end
204
-
205
- class Hash
206
- def each
207
- ks = keys
208
- ks.each {|k| yield([k, self[k]])}
209
- end
210
-
211
- def each_key
212
- ks = keys
213
- ks.each {|k| yield(k)}
214
- end
215
-
216
- def each_value
217
- vs = values
218
- vs.each {|k| yield(k)}
219
- end
220
-
221
- def empty?
222
- length == 0
223
- end
224
-
225
- alias each_pair each
226
-
227
- def to_a
228
- res = []
229
- each_pair do |k, v|
230
- item = []
231
- item << k
232
- item << v
233
- res << item
234
- end
235
- res
236
- end
237
-
238
- def inspect
239
- r = '{'
240
- is_first = true
241
- each_pair do |k, v|
242
- if !is_first
243
- r << ", "
244
- end
245
- is_first = false
246
- r << k.inspect
247
- r << '=>'
248
- r << v.inspect
249
- end
250
- r << '}'
251
- end
252
-
253
- alias to_s inspect
254
-
255
- def invert
256
- h = {}
257
- each {|k, v| h[v] = k}
258
- h
259
- end
260
-
261
- def update other
262
- other.each {|k, v| self[k] = v}
263
- self
264
- end
265
-
266
- alias merge! update
267
-
268
- def merge other
269
- clone.merge!(other)
270
- end
271
-
272
- def index value
273
- each {|k, v| return k if value == v }
274
- return nil
275
- end
276
- end
277
-
278
- class Symbol
279
- alias to_s id2name
280
- end
281
-
282
- class << self
283
- def to_s
284
- return "main"
285
- end
286
-
287
- def public
288
- Object.public
289
- end
290
-
291
- def private
292
- Object.private
293
- end
294
-
295
- def protected
296
- Object.protected
297
- end
298
- end
299
-
300
- class Fixnum
301
- def is_alpha_numeric
302
- return (self>=?0 && self<=?9) || (self>=?a && self<=?z) || (self>=?A && self<=?Z)
303
- end
304
- end
305
-
306
- module Comparable
307
- def >=(value)
308
- compare = (self <=> value)
309
- return compare != -1 and compare != nil
310
- end
311
-
312
- def ==(value)
313
- compare = (self <=> value)
314
- return compare == 0
315
- end
316
-
317
- def <=(value)
318
- compare = (self <=> value)
319
- return compare != 1 and compare != nil
320
- end
321
-
322
- def >(value)
323
- compare = (self <=> value)
324
- return compare == 1
325
- end
326
-
327
- def <(value)
328
- compare = (self <=> value)
329
- return compare == -1
330
- end
331
-
332
- def between?(a, b)
333
- self >= a && self <= b
334
- end
335
- end
336
-
337
- class Numeric
338
- include Comparable
339
-
340
- def floor
341
- self.to_f.floor
342
- end
343
-
344
- def abs
345
- return -self if (self <=> 0) == -1
346
- self
347
- end
348
-
349
- def div value
350
- (self/value).floor
351
- end
352
-
353
- def divmod(value)
354
- [(self/value).floor, self % value]
355
- end
356
-
357
- def integer?
358
- false
359
- end
360
-
361
- alias eql? :==
362
-
363
- def modulo(value)
364
- self % value
365
- end
366
-
367
- def nonzero?
368
- return nil if self == 0
369
- self
370
- end
371
-
372
- def zero?
373
- return true if self == 0
374
- false
375
- end
376
-
377
- def remainder(value)
378
- self_sign = (self < 0)
379
- value_sign = (value < 0)
380
- return self % value if self_sign == value_sign
381
- self % (-value)
382
- end
383
-
384
- end
385
-
386
- class Integer < Numeric
387
-
388
- def to_i
389
- return self
390
- end
391
-
392
- alias to_int to_i
393
-
394
- #Returns the Integer equal to int + 1
395
- def next
396
- self + 1
397
- end
398
-
399
- #Synonym for Integer#next
400
- def succ
401
- self + 1
402
- end
403
-
404
- #Always returns true
405
- def integer?
406
- true
407
- end
408
-
409
- def upto(to)
410
- a = self
411
- while a <= to
412
- yield a
413
- a += 1
414
- end
415
- end
416
-
417
- def downto(to)
418
- a = self
419
- while a >= to
420
- yield a
421
- a -= 1
422
- end
423
- end
424
-
425
- def size
426
- 4
427
- end
428
-
429
- def integer?
430
- true
431
- end
432
- end
433
-
434
- class Fixnum < Integer
435
- def to_i
436
- self
437
- end
438
-
439
- alias inspect to_s
440
- end
441
-
442
- class NilClass
443
-
444
- #Returns false
445
- def &(anObject)
446
- false
447
- end
448
-
449
- #Returns false if anObject is nil or false, true otherwise
450
- def ^(anObject)
451
- anObject ? true : false
452
- end
453
-
454
- #Returns false if anObject is nil or false, true otherwise
455
- def |(anObject)
456
- anObject ? true : false
457
- end
458
-
459
- #Always returns true
460
- def nil?
461
- true
462
- end
463
-
464
- #Always returns an empty array
465
- def to_a
466
- []
467
- end
468
-
469
- #Always returns zero
470
- def to_i
471
- 0
472
- end
473
-
474
- def to_f
475
- 0.0
476
- end
477
-
478
- #Always returns the empty string
479
- def to_s
480
- ""
481
- end
482
-
483
- def inspect
484
- "nil"
485
- end
486
- alias to_str to_s
487
- end
488
-
489
- class TrueClass
490
- #Returns false if anObject is nil or false, true otherwise
491
- def &(anObject)
492
- anObject ? true : false
493
- end
494
-
495
- #Returns true if anObject is nil or false, false otherwise
496
- def ^(anObject)
497
- anObject ? false : true
498
- end
499
-
500
- #Returns true
501
- def |(anObject)
502
- true
503
- end
504
-
505
- def to_s
506
- "true"
507
- end
508
-
509
- def inspect
510
- "true"
511
- end
512
- end
513
-
514
- class FalseClass
515
-
516
- #Returns false
517
- def &(anObject)
518
- false
519
- end
520
-
521
- #If anObject is nil or false, returns false; otherwise, returns true
522
- def ^(anObject)
523
- anObject ? true : false
524
- end
525
-
526
- #Returns false if anObject is nil or false; true otherwise
527
- def |(anObject)
528
- anObject ? true : false
529
- end
530
-
531
- def to_s
532
- "false"
533
- end
534
-
535
- def inspect
536
- "false"
537
- end
538
- end
539
-
540
- class String
541
- include Comparable
542
-
543
- def to_s
544
- return self
545
- end
546
-
547
- def empty?
548
- length == 0
549
- end
550
-
551
- def inspect
552
- '"' + to_s + '"'
553
- end
554
-
555
- #from rubinius
556
- # justify left = -1, center = 0, right = 1
557
- def justify_string(width, str, justify)
558
- return self if width <= length
559
- pad = width - length
560
- out = str.to_str * (pad / str.length)
561
- out << str[0, pad - out.length] if out.length < pad
562
- # Left justification
563
- return self << out if justify == -1
564
- # Right justification
565
- return out << self if justify == 1
566
- # and finially center
567
- split = (width / 2) - (length / 2)
568
- return out.insert(split-((width-length)%2), self)
569
- end
570
-
571
- #from rubinius
572
- def rjust(width, str=" ")
573
- justify_string(width, str, 1)
574
- end
575
-
576
- #from rubinius
577
- def ljust(width, str=" ")
578
- justify_string(width, str, -1)
579
- end
580
-
581
- #from rubinius
582
- def center(width, str=" ")
583
- justify_string(width, str, 0)
584
- end
585
-
586
- alias to_str to_s
587
- alias size length
588
- end