Sha256: 7bd5b9187a524bd79c16b3333154b8460113a5fa1804a5a4fa1eb5629fb3e67e

Contents?: true

Size: 579 Bytes

Versions: 3

Compression:

Stored size: 579 Bytes

Contents

module Sparrow
  module Strategies
    class ArrayJsonFormatStrategy < JsonFormatStrategy
      register_json_format

      ##
      # Matches if input is an Array
      # @param [Object] input the JSON object
      # @return true if the input is an Array
      def match?(input)
        input.is_a? Array
      end

      ##
      # Takes the first element from the Array and returns it
      # @param [Array] input the input Array
      # @return [String] the first element of the input as a String
      def convert(input)
        input.first.to_s
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cp-sparrow-0.0.16 lib/sparrow/strategies/json_format_strategies/array_json_format_strategy.rb
cp-sparrow-0.0.15 lib/sparrow/strategies/json_format_strategies/array_json_format_strategy.rb
cp-sparrow-0.0.14 lib/sparrow/strategies/json_format_strategies/array_json_format_strategy.rb