Sha256: 6ad0ecdf4290685e8cba487041a4394a28822174d8ff4bff62ec609c4454bdf0

Contents?: true

Size: 425 Bytes

Versions: 12

Compression:

Stored size: 425 Bytes

Contents

# frozen_string_literal: true

module Remocon
  class IntegerNormalizer < Remocon::Normalizer
    def self.respond_symbol
      Remocon::Type::INTEGER
    end

    def validate
      return if @content.class == Integer.class

      begin
        @int_val = @content.to_s.to_integer
      rescue ArgumentError => e
        raise ValidationError, e.message
      end
    end

    def normalize
      @int_val
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
remocon-0.5.1 lib/remocon/normalizer/integer_normalizer.rb
remocon-0.5.0 lib/remocon/normalizer/integer_normalizer.rb
remocon-0.4.4 lib/remocon/normalizer/integer_normalizer.rb
remocon-0.4.3 lib/remocon/normalizer/integer_normalizer.rb
remocon-0.4.2 lib/remocon/normalizer/integer_normalizer.rb
remocon-0.4.1 lib/remocon/normalizer/integer_normalizer.rb
remocon-0.4.0 lib/remocon/normalizer/integer_normalizer.rb
remocon-0.4.0.pre.1 lib/remocon/normalizer/integer_normalizer.rb
remocon-0.3.1 lib/remocon/normalizer/integer_normalizer.rb
remocon-0.3.0 lib/remocon/normalizer/integer_normalizer.rb
remocon-0.2.0 lib/remocon/normalizer/integer_normalizer.rb
remocon-0.1.0 lib/remocon/normalizer/integer_normalizer.rb