class TLAW::Param::EnumType
@private
Public Class Methods
new(enum)
click to toggle source
# File lib/tlaw/param/type.rb, line 84 def initialize(enum) @type = case enum when Hash enum when ->(e) { e.respond_to?(:map) } enum.map { |n| [n, n] }.to_h else fail ArgumentError, "Unparseable enum: #{enum.inspect}" end end
Public Instance Methods
_convert(value)
click to toggle source
# File lib/tlaw/param/type.rb, line 108 def _convert(value) type[value] end
validate(value)
click to toggle source
# File lib/tlaw/param/type.rb, line 100 def validate(value) type.key?(value) or nonconvertible!( value, "is not one of #{type.keys.map(&:inspect).join(', ')}" ) end
values()
click to toggle source
# File lib/tlaw/param/type.rb, line 96 def values type.keys end