lib/library_stdnums.rb
def reduce_to_basics rawnum, valid_sizes = nil
      return nil if rawnum.nil?

      num = extractNumber rawnum

      # Does it even look like a number?
      return nil unless num

      # Return what we've got if we don't care about the size
      return num unless valid_sizes

      # Check for valid size(s)
      [valid_sizes].flatten.each do |s|
        return num if num.size == s
      end

      # Didn't check out size-wise. Return nil
      return nil
    end
def reduce_to_basics rawnum, valid_sizes = nil
      return nil if rawnum.nil?

      num = extractNumber rawnum

      # Does it even look like a number?
      return nil unless num

      # Return what we've got if we don't care about the size
      return num unless valid_sizes

      # Check for valid size(s)
      [valid_sizes].flatten.each do |s|
        return num if num.size == s
      end

      # Didn't check out size-wise. Return nil
      return nil
    end
def reduce_to_basics rawnum , valid_sizes = nil return nil if rawnum . nil? num = extractNumber rawnum # Does it even look like a number? return nil unless num # Return what we've got if we don't care about the size return num unless valid_sizes # Check for valid size(s) [ valid_sizes ] . flatten . each do | s | return num if num . size == s end # Didn't check out size-wise. Return nil return nil end
Given any string, extract what looks like the most likely ISBN/ISSN
 of the given size(s), or nil if nothing matches at the correct size.
 @param [String] rawnum The raw string containing (hopefully) an ISSN/ISBN
 @param [Integer, Array<Integer>, nil] valid_sizes An integer or array of integers of valid sizes
 for this type (e.g., 10 or 13 for ISBN, 8 for ISSN)
 @return [String,nil] the reduced and verified number, or nil if there's no match at the right size
Given any string extract what looks like the most likely ISBN / ISSN of the given size ( s ) or nil if nothing matches at the correct size .