Skip to content

Instantly share code, notes, and snippets.

@seanhandley
Last active March 15, 2019 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanhandley/c692f3b924a3e2e4b52a030b94812612 to your computer and use it in GitHub Desktop.
Save seanhandley/c692f3b924a3e2e4b52a030b94812612 to your computer and use it in GitHub Desktop.
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