Class: Hash

Inherits:
Object show all
Defined in:
lib/core_ext.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_properties(props, convert_symbols = false) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/core_ext.rb', line 12

def self.from_properties props,convert_symbols=false
  return unless props.is_a? java_import('java.util.Properties').first
  hash = new
  props.each do |k,v|
    k = k.to_sym if convert_symbols
    hash[k] = v
  end
  hash
end

Instance Method Details

#to_propertiesObject



3
4
5
6
7
8
9
10
# File 'lib/core_ext.rb', line 3

def to_properties
  # Java::JavaUtil::Properties
  props = java_import('java.util.Properties').first.new
  self.each do |k,v|
    props[k.to_s] = v.to_s
  end
  props
end