Sha256: fd8ca4defdb1b87e2ceac746957a756fcd05ab56874d5e53c0ccb0c309663a2d

Contents?: true

Size: 630 Bytes

Versions: 1

Compression:

Stored size: 630 Bytes

Contents

module Mandy
  class Task
    KEY_VALUE_SEPERATOR = "\t" unless defined?(KEY_VALUE_SEPERATOR)

    def initialize(input=STDIN, output=STDOUT)
      @input, @output = input, output
    end

    def emit(key, value=nil)
      key = 'nil' if key.nil?
      @output.puts(value.nil? ? key.to_s : "#{serialize(key)}\t#{serialize(value)}")
    end

    def get(store, key)
      Mandy.stores[store].get(key)
    end

    def put(store, key, values)
      Mandy.stores[store].put(key, values)
    end

    private


    def serialize(value)
      value = ArraySerializer.new(value) if value.is_a?(Array)
      value.to_s
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trafficbroker-mandy-0.2.6 lib/task.rb