Sha256: 96daa3d4971b7434b6257653b556daf850c0c634b409b29edafb7155babd29d4

Contents?: true

Size: 563 Bytes

Versions: 2

Compression:

Stored size: 563 Bytes

Contents

require_relative 'formats/base'
require_relative 'formats/human'
require_relative 'formats/json'

module Mulder
  class Formatter

    VALID_FORMATS = {
      'human' => Formats::Human,
      'json'  => Formats::JSON
    }

    def initialize(instances, format)
      unless VALID_FORMATS.keys.include?(format)
        raise NotImplementedError.new("Formatting as #{format} has not been implemented!")
      end

      @instances = instances
      @format    = VALID_FORMATS[format]
    end

    def output
      @format.new(@instances).output
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mulder-0.4.0 lib/mulder/formatter.rb
mulder-0.3.2 lib/mulder/formatter.rb