Class: Hash::DeepHashConstructor

Inherits:
Object
  • Object
show all
Defined in:
lib/hash/deep_hash_constructor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(separator) ⇒ DeepHashConstructor

Returns a new instance of DeepHashConstructor.



4
5
6
# File 'lib/hash/deep_hash_constructor.rb', line 4

def initialize(separator)
  @separator = separator
end

Instance Attribute Details

#separatorObject

Returns the value of attribute separator.



2
3
4
# File 'lib/hash/deep_hash_constructor.rb', line 2

def separator
  @separator
end

Instance Method Details

#deep_hash(object) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/hash/deep_hash_constructor.rb', line 8

def deep_hash(object)
  if object.is_a? Array
    array_deep_hash(object)
  elsif object.is_a? Hash
    hash_deep_hash(object)
  else
    object
  end
end