Class: Sparrow::Strategies::ArrayJsonFormatStrategy

Inherits:
JsonFormatStrategy show all
Defined in:
lib/sparrow/strategies/json_format_strategies/array_json_format_strategy.rb

Instance Method Summary collapse

Methods inherited from JsonFormatStrategy

convert, #initialize, register_json_format

Constructor Details

This class inherits a constructor from Sparrow::Strategies::JsonFormatStrategy

Instance Method Details

#convert(input) ⇒ String

Takes the first element from the Array and returns it

Parameters:

  • input (Array)

    the input Array

Returns:

  • (String)

    the first element of the input as a String



18
19
20
# File 'lib/sparrow/strategies/json_format_strategies/array_json_format_strategy.rb', line 18

def convert(input)
  input.first.to_s
end

#match?(input) ⇒ Boolean

Matches if input is an Array

Parameters:

  • input (Object)

    the JSON object

Returns:

  • (Boolean)

    true if the input is an Array



10
11
12
# File 'lib/sparrow/strategies/json_format_strategies/array_json_format_strategy.rb', line 10

def match?(input)
  input.is_a? Array
end