Skip to content

Instantly share code, notes, and snippets.

@seanhandley seanhandley/data.rb

Last active Mar 15, 2019
Embed
What would you like to do?
module H3
class Resolution
extend FFI::DataConverter
native_type FFI::Type::INT
RES_RANGE = 0..15
class << self
def to_native(value, _context)
failure unless value.is_a?(Integer) && RES_RANGE.cover?(value)
value
end
private
def failure
raise ArgumentError,
"resolution must be between #{RES_RANGE.first} and #{RES_RANGE.last}"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.