@@ -439,25 +439,34 @@ def self.left_pad(spaces, text = '')
439439 end
440440
441441 # Utility Method!
442- # Given a class, output that same class, except preserve some backward compatible
443- # or equivalent class names.
442+ # Harmonize equivalent class names for comparison purposes.
444443 # @param class_name [String] Class name as input
445444 # @return [String] Class name as output
446445 def self . class_name_for_diffy ( class_name )
447- return 'Fixnum ' if class_name == 'Integer '
446+ return 'Integer ' if class_name == 'Fixnum '
448447 class_name
449448 end
450449
450+ # Utility Method!
451+ # `is_a?(class)` only allows one method, but this uses an array
452+ # @param object [?] Object to consider
453+ # @param classes [Array] Classes to determine if object is a member of
454+ # @return [Boolean] True if object is_a any of the classes, false otherwise
455+ def self . object_is_any_of? ( object , classes )
456+ classes . each { |clazz | return true if object . is_a? clazz }
457+ false
458+ end
459+
451460 # Utility Method!
452461 # Given an arbitrary object, convert it into a string for use by 'diffy'.
453462 # This basically exists so we can do something prettier than just calling .inspect or .to_s
454463 # on object types we anticipate seeing, while not failing entirely on other object types.
455464 # @param obj [?] Object to be stringified
456465 # @return [String] String representation of object for diffy
457466 def self . stringify_for_diffy ( obj )
458- return JSON . pretty_generate ( obj ) if [ Hash , Array ] . include? ( obj . class )
467+ return JSON . pretty_generate ( obj ) if object_is_any_of? ( obj , [ Hash , Array ] )
459468 return '""' if obj . is_a? ( String ) && obj == ''
460- return obj if [ String , Fixnum , Integer , Float ] . include? ( obj . class )
469+ return obj if object_is_any_of? ( obj , [ String , Fixnum , Integer , Float ] )
461470 "#{ class_name_for_diffy ( obj . class ) } : #{ obj . inspect } "
462471 end
463472
0 commit comments