Class: HStruct

Inherits:
Struct
  • Object
show all
Defined in:
lib/hstruct.rb

Instance Method Summary collapse

Constructor Details

#initialize(args = nil) ⇒ HStruct

Returns a new instance of HStruct.



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

def initialize(args = nil)
  super(*members.map { |m| args[m] }) if args
end

Instance Method Details

#to_hashObject



6
7
8
# File 'lib/hstruct.rb', line 6

def to_hash
  Hash[each_pair.reject { |k, v| v.nil? }.to_a]
end