Class: HStruct
- Inherits:
-
Struct
- Object
- Struct
- HStruct
- Defined in:
- lib/hstruct.rb
Instance Method Summary collapse
-
#initialize(args = nil) ⇒ HStruct
constructor
A new instance of HStruct.
- #to_hash ⇒ Object
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_hash ⇒ Object
6 7 8 |
# File 'lib/hstruct.rb', line 6 def to_hash Hash[each_pair.reject { |k, v| v.nil? }.to_a] end |