jruby-scala-collections 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/jruby/scala_support.rb +16 -5
- metadata +1 -1
data/lib/jruby/scala_support.rb
CHANGED
@@ -46,7 +46,7 @@ module JRuby::ScalaSupport
|
|
46
46
|
@raw
|
47
47
|
end
|
48
48
|
|
49
|
-
def
|
49
|
+
def empty?
|
50
50
|
@raw.isEmpty
|
51
51
|
end
|
52
52
|
|
@@ -68,6 +68,10 @@ module JRuby::ScalaSupport
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
def keys
|
72
|
+
@raw.keys.toSeq.from_scala
|
73
|
+
end
|
74
|
+
|
71
75
|
def has_key?(key)
|
72
76
|
@raw.contains(key)
|
73
77
|
end
|
@@ -264,7 +268,7 @@ module JRuby::ScalaSupport
|
|
264
268
|
@size
|
265
269
|
end
|
266
270
|
|
267
|
-
def
|
271
|
+
def empty?
|
268
272
|
false
|
269
273
|
end
|
270
274
|
|
@@ -291,11 +295,11 @@ module JRuby::ScalaSupport
|
|
291
295
|
|
292
296
|
def [](index)
|
293
297
|
if index < 0
|
294
|
-
@raw.send("_#{size + index + 1}")
|
298
|
+
@raw.send("_#{size + index + 1}").from_scala
|
295
299
|
elsif index >= size
|
296
300
|
nil
|
297
301
|
else
|
298
|
-
@raw.send("_#{index + 1}")
|
302
|
+
@raw.send("_#{index + 1}").from_scala
|
299
303
|
end
|
300
304
|
end
|
301
305
|
|
@@ -341,7 +345,14 @@ class Object
|
|
341
345
|
when Java::scala.collection.Seq, Java::scala.collection.immutable.Seq
|
342
346
|
JRuby::ScalaSupport::Seq::Immutable.new(self)
|
343
347
|
when Java::scala.Product
|
344
|
-
|
348
|
+
# Sometimes tuples have some wraping classes, like "#<Class:...>" on top
|
349
|
+
# of them. Some magic is needed to find actual tuple name.
|
350
|
+
match = nil
|
351
|
+
self.class.ancestors.find do |klass|
|
352
|
+
match = klass.to_s.match(/^Java::Scala::Tuple(\d+)$/)
|
353
|
+
! match.nil?
|
354
|
+
end
|
355
|
+
|
345
356
|
if match
|
346
357
|
size = match[1].to_i
|
347
358
|
JRuby::ScalaSupport::Tuple.new(self, size)
|