Skip to content

Commit fdaa58e

Browse files
committed
cleanups
- move library_name out of the global namespace - fix rubocop stuff
1 parent aaa16d9 commit fdaa58e

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

lib/vips.rb

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
2323
# windows:
2424
# The ABI number must be included, but with a hyphen. ffi does not add a
2525
# "lib" prefix or a ".dll" suffix.
26-
def library_name(name, abi_number)
27-
if FFI::Platform.windows?
28-
"lib#{name}-#{abi_number}.dll"
29-
elsif FFI::Platform.mac?
30-
"#{name}.#{abi_number}"
31-
else
32-
"#{name}.so.#{abi_number}"
26+
module FFI
27+
def self.library_name(name, abi_number)
28+
if Platform.windows?
29+
"lib#{name}-#{abi_number}.dll"
30+
elsif Platform.mac?
31+
"#{name}.#{abi_number}"
32+
else
33+
"#{name}.so.#{abi_number}"
34+
end
3335
end
3436
end
3537

@@ -43,7 +45,7 @@ def library_name(name, abi_number)
4345
module Vips
4446
extend FFI::Library
4547

46-
ffi_lib library_name("vips", 42)
48+
ffi_lib FFI.library_name("vips", 42)
4749

4850
begin
4951
attach_function :g_malloc, [:size_t], :pointer
@@ -67,9 +69,9 @@ class << self
6769
extend FFI::Library
6870

6971
if Vips.unified?
70-
ffi_lib library_name("vips", 42)
72+
ffi_lib FFI.library_name("vips", 42)
7173
else
72-
ffi_lib library_name("glib-2.0", 0)
74+
ffi_lib FFI.library_name("glib-2.0", 0)
7375
end
7476

7577
attach_function :g_malloc, [:size_t], :pointer
@@ -163,9 +165,9 @@ module GObject
163165
extend FFI::Library
164166

165167
if Vips.unified?
166-
ffi_lib library_name("vips", 42)
168+
ffi_lib FFI.library_name("vips", 42)
167169
else
168-
ffi_lib library_name("gobject-2.0", 0)
170+
ffi_lib FFI.library_name("gobject-2.0", 0)
169171
end
170172

171173
# we can't just use ulong, windows has different int sizing rules

lib/vips/image.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,11 +1173,7 @@ def == other
11731173
# @return [Image] result of inequality
11741174
def != other
11751175
# for equality, we must allow tests against nil
1176-
if other.nil?
1177-
true
1178-
else
1179-
call_enum "relational", other, :noteq
1180-
end
1176+
other.nil? || call_enum("relational", other, :noteq)
11811177
end
11821178

11831179
# Fetch bands using a number or a range

0 commit comments

Comments
 (0)