lib/idnx/idn2.rb in idnx-0.0.1 vs lib/idnx/idn2.rb in idnx-0.1.0

- old
+ new

@@ -19,27 +19,25 @@ IDN2_NFC_INPUT = 1 IDN2_TRANSITIONAL = 4 IDN2_NONTRANSITIONAL = 8 FLAGS = if Gem::Version.new(VERSION) >= Gem::Version.new("0.14.0") - IDN2_NFC_INPUT | IDN2_NONTRANSITIONAL - else - IDN2_NFC_INPUT - end + IDN2_NFC_INPUT | IDN2_NONTRANSITIONAL + else + IDN2_NFC_INPUT + end - attach_function :idn2_lookup_ul, [:string, :pointer, :int], :int + attach_function :idn2_lookup_ul, %i[string pointer int], :int attach_function :idn2_strerror, [:int], :string attach_function :idn2_free, [:pointer], :void module_function def lookup(hostname) string_ptr = FFI::MemoryPointer.new(:pointer) result = idn2_lookup_ul(hostname, string_ptr, FLAGS) - if result != IDN2_OK - result = idn2_lookup_ul(hostname, string_ptr, IDN2_TRANSITIONAL) - end + result = idn2_lookup_ul(hostname, string_ptr, IDN2_TRANSITIONAL) if result != IDN2_OK if result != IDN2_OK string_ptr.free raise Error, "Failed to convert \"#{hostname}\" to ascii; (error: #{idn2_strerror(result)})" end