Sha256: f8b8debeac376341a00f5e3f2b9796bbd7c975361c884facff1771d5f4c23879

Contents?: true

Size: 792 Bytes

Versions: 2

Compression:

Stored size: 792 Bytes

Contents

module HoneyFormat
  # Utility class for sanitizing various simple data types.
  class Sanitize
    # Returns array of cleaned strings.
    # @return [Array] the cleaned array of strings.
    # @param [Array] row the array of strings to be cleaned.
    # @example Sanitize array
    #     Sanitize.array!(["  a "]) #=> ["a"]
    def self.array!(row)
      row.map! { |column| string!(column) }
      row
    end

    # Returns array of cleaned elements.
    # @return [String] the cleaned array.
    # @param [String] column the string to be cleaned.
    # @example Sanitize string
    #     Sanitize.string!("  a ") #=> "a"
    # @example Sanitize nil
    #     Sanitize.string!(nil) #=> nil
    def self.string!(column)
      column.strip! unless column.nil?
      column
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
honey_format-0.2.1 lib/honey_format/sanitize.rb
honey_format-0.2.0 lib/honey_format/sanitize.rb