Module: Java::JavaUtil::Collection

Includes:
Jinx::Collection
Defined in:
lib/jinx/import/java.rb,
lib/jinx/helpers/collections.rb

Overview

Aliases Java Collection methods with the standard Ruby Set counterpart, e.g. delete for remove.

Instance Method Summary collapse

Methods included from Jinx::Collection

#compact, #compact_map, #detect_value, #detect_with_value, #difference, #empty?, #filter, #first, #flatten, #hashify, #intersect, #join, #last, #partial_sort, #partial_sort!, #partial_sort_by, #size, #to_compact_hash, #to_compact_hash_with_index, #to_series, #transform, #union

Instance Method Details

#delete(item) ⇒ Object

Removes the given item from this collection.



35
36
37
38
# File 'lib/jinx/import/java.rb', line 35

def delete(item)
  # can't alias delete to remove, since a Java interface doesn't implement any methods
  remove(item)
end

#delete_ifObject

Removes the items from this collection for which the block given to this method returns a non-nil, non-false value.



41
42
43
44
# File 'lib/jinx/import/java.rb', line 41

def delete_if
  removeAll(select { |item| yield item })
  self
end

#to_aObject



30
31
32
# File 'lib/jinx/import/java.rb', line 30

def to_a
  inject(Array.new) { |array, item| array << item }
end