Sha256: 3616ff0ab4ce2fa8b7e5521954761b50e71341cd6145dd78b0c0dbdb67096fad
Contents?: true
Size: 724 Bytes
Versions: 2
Compression:
Stored size: 724 Bytes
Contents
module AprsParser # Checks all values coming in and makes sure # they are of an instance of the correct {#type_class}. module TypeSafety # Convert given value to native value, with type checking. # # @note Calls super-implementation if type is safe. # # @param value # @param ctx # @raise [TypeError] if value is not of the same kind as {#type_class}. def to_native(value, ctx) if value.is_a?(type_class) super else fail TypeError, "expected a kind of #{name}, was #{value.class}" end end # Retrieve the type that all objects going into to_native must be of. # # @return self by default def type_class self end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
aprs_parser-1.0.0 | lib/aprs_parser/type_safety.rb |
aprs_parser-1.0.0.pre | lib/aprs_parser/type_safety.rb |