def dos2unix(string, strategy = :remove_all_cr)
    strategies = {
        remove_all_cr:     -> { string.gsub("\r", '') },
        remove_cr_in_crlf: -> { string.gsub("\r\n", "\n") }
    }

    unless strategies.keys.include?(strategy)
      message = "Unsupported strategy: #{strategy}. Must be one of [#{strategies.keys.sort.join(', ')}]."
      raise ArgumentError.new(message)
    end

    strategies[strategy].()
  end
def dos2unix(string, strategy = :remove_all_cr)
    strategies = {
        remove_all_cr:     -> { string.gsub("\r", '') },
        remove_cr_in_crlf: -> { string.gsub("\r\n", "\n") }
    }

    unless strategies.keys.include?(strategy)
      message = "Unsupported strategy: #{strategy}. Must be one of [#{strategies.keys.sort.join(', ')}]."
      raise ArgumentError.new(message)
    end

    strategies[strategy].()
  end
Like the Unix dos2unix command, but on strings rather than files,
 strips CR ("\r", 13, 0xD) characters.

 WARNING:

 Currently, two strategies are supported, but they do not account for
 character sets that might include characters that have "\r"'s numeric value,
 13, or 0xd, as part of their legitimate values, so we may need to
 add strategies to accommodate this.

 An example of a more complex implementation is at:
 http://dos2unix.sourcearchive.com/documentation/5.0-1/dos2unix_8c-source.html.

 Note: The 'os' gem can be used to determine os.

 @param string the string to convert
 @param strategy the strategy to use for the conversion (note: the default
        may change over time, so if you're sure you want to use the current
        default even if the default changes, don't rely on the default; specify it)