Last active
March 15, 2019 11:20
-
-
Save seanhandley/c692f3b924a3e2e4b52a030b94812612 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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