Module: Deterministic::EnumBuilder::DataType::Binary
- Defined in:
- lib/deterministic/enum.rb
Overview
TODO: this should probably be named Multary
Instance Method Summary collapse
Instance Method Details
#initialize(*init) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/deterministic/enum.rb', line 50 def initialize(*init) raise ArgumentError, "Expected arguments for #{args}, got #{init}" unless (init.count == 1 && init[0].is_a?(Hash)) || init.count == args.count if init.count == 1 && init[0].is_a?(Hash) @value = Hash[args.zip(init[0].values)] else @value = Hash[args.zip(init)] end end |
#inspect ⇒ Object
59 60 61 62 |
# File 'lib/deterministic/enum.rb', line 59 def inspect params = value.map { |k, v| "#{k}: #{v.inspect}" } "#{name}(#{params.join(', ')})" end |