Sha256: 6b1840e28c9f3926696511030e03a6b0dced1d3f5c0f948f6884cc62d8c1dbbf

Contents?: true

Size: 460 Bytes

Versions: 122

Compression:

Stored size: 460 Bytes

Contents

class Eco::API::Common::People::DefaultParsers::NumericParser < Eco::API::Common::Loaders::Parser
  attribute :number

  def parser(value, deps)
    value.is_a?(Array) ? value.map { |v| parse_number(v) } :  parse_number(value)
  end

  def serializer(value, deps)
    value.is_a?(Array) ? value.map { |v| v.to_s } : value.to_s
  end

  private

  def parse_number(value)
    value.to_s.strip.empty? ? nil : (value.to_f rescue nil)
  end

end

Version data entries

122 entries across 122 versions & 1 rubygems

Version Path
eco-helpers-2.6.4 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-2.6.3 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-2.6.2 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-2.6.1 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-2.6.0 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-2.5.10 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-2.5.9 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-2.5.8 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-2.5.7 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-2.5.6 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-2.5.5 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-2.5.4 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-2.5.3 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-2.5.2 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-2.5.1 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-2.4.9 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-2.4.8 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-2.4.7 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-2.4.6 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-2.4.5 lib/eco/api/common/people/default_parsers/numeric_parser.rb