@@ -30,13 +30,13 @@ def self.new_from_bin(bin)
3030 # @param filename [String] the fat file to load from
3131 # @raise [ArgumentError] if the given file does not exist
3232 def initialize ( filename )
33- raise ArgumentError . new ( "#{ filename } : no such file" ) unless File . file? ( filename )
33+ raise ArgumentError , "#{ filename } : no such file" unless File . file? ( filename )
3434
3535 @filename = filename
36- @raw_data = File . open ( @filename , "rb" ) { | f | f . read }
37- @header = get_fat_header
38- @fat_archs = get_fat_archs
39- @machos = get_machos
36+ @raw_data = File . open ( @filename , "rb" , & : read)
37+ @header = populate_fat_header
38+ @fat_archs = populate_fat_archs
39+ @machos = populate_machos
4040 end
4141
4242 # Initializes a new FatFile instance from a binary string.
@@ -45,9 +45,9 @@ def initialize(filename)
4545 def initialize_from_bin ( bin )
4646 @filename = nil
4747 @raw_data = bin
48- @header = get_fat_header
49- @fat_archs = get_fat_archs
50- @machos = get_machos
48+ @header = populate_fat_header
49+ @fat_archs = populate_fat_archs
50+ @machos = populate_machos
5151 end
5252
5353 # The file's raw fat data.
@@ -142,13 +142,8 @@ def dylib_id
142142 # @raise [ArgumentError] if `new_id` is not a String
143143 # @see MachO::MachOFile#linked_dylibs
144144 def change_dylib_id ( new_id , options = { } )
145- if !new_id . is_a? ( String )
146- raise ArgumentError . new ( "argument must be a String" )
147- end
148-
149- if !machos . all? ( &:dylib? )
150- return nil
151- end
145+ raise ArgumentError , "argument must be a String" unless new_id . is_a? ( String )
146+ return unless machos . all? ( &:dylib? )
152147
153148 each_macho ( options ) do |macho |
154149 macho . change_dylib_id ( new_id , options )
@@ -157,7 +152,7 @@ def change_dylib_id(new_id, options = {})
157152 synchronize_raw_data
158153 end
159154
160- alias : dylib_id= : change_dylib_id
155+ alias dylib_id = change_dylib_id
161156
162157 # All shared libraries linked to the file's Mach-Os.
163158 # @return [Array<String>] an array of all shared libraries
@@ -188,7 +183,7 @@ def change_install_name(old_name, new_name, options = {})
188183 synchronize_raw_data
189184 end
190185
191- alias : change_dylib : change_install_name
186+ alias change_dylib change_install_name
192187
193188 # All runtime paths associated with the file's Mach-Os.
194189 # @return [Array<String>] an array of all runtime paths
@@ -265,7 +260,7 @@ def write(filename)
265260 # @note Overwrites all data in the file!
266261 def write!
267262 if filename . nil?
268- raise MachOError . new ( "cannot write to a default file when initialized from a binary string" )
263+ raise MachOError , "cannot write to a default file when initialized from a binary string"
269264 else
270265 File . open ( @filename , "wb" ) { |f | f . write ( @raw_data ) }
271266 end
@@ -280,14 +275,14 @@ def write!
280275 # @raise [MachO::MachOBinaryError] if the magic is for a non-fat Mach-O file
281276 # @raise [MachO::JavaClassFileError] if the file is a Java classfile
282277 # @api private
283- def get_fat_header
278+ def populate_fat_header
284279 # the smallest fat Mach-O header is 8 bytes
285- raise TruncatedFileError . new if @raw_data . size < 8
280+ raise TruncatedFileError if @raw_data . size < 8
286281
287282 fh = FatHeader . new_from_bin ( :big , @raw_data [ 0 , FatHeader . bytesize ] )
288283
289- raise MagicError . new ( fh . magic ) unless Utils . magic? ( fh . magic )
290- raise MachOBinaryError . new unless Utils . fat_magic? ( fh . magic )
284+ raise MagicError , fh . magic unless Utils . magic? ( fh . magic )
285+ raise MachOBinaryError unless Utils . fat_magic? ( fh . magic )
291286
292287 # Rationale: Java classfiles have the same magic as big-endian fat
293288 # Mach-Os. Classfiles encode their version at the same offset as
@@ -296,15 +291,15 @@ def get_fat_header
296291 # technically possible for a fat Mach-O to have over 30 architectures,
297292 # but this is extremely unlikely and in practice distinguishes the two
298293 # formats.
299- raise JavaClassFileError . new if fh . nfat_arch > 30
294+ raise JavaClassFileError if fh . nfat_arch > 30
300295
301296 fh
302297 end
303298
304299 # Obtain an array of fat architectures from raw file data.
305300 # @return [Array<MachO::FatArch>] an array of fat architectures
306301 # @api private
307- def get_fat_archs
302+ def populate_fat_archs
308303 archs = [ ]
309304
310305 fa_off = FatHeader . bytesize
@@ -319,7 +314,7 @@ def get_fat_archs
319314 # Obtain an array of Mach-O blobs from raw file data.
320315 # @return [Array<MachO::MachOFile>] an array of Mach-Os
321316 # @api private
322- def get_machos
317+ def populate_machos
323318 machos = [ ]
324319
325320 fat_archs . each do |arch |
0 commit comments