Class: Remocon::IntegerNormalizer

Inherits:
Normalizer show all
Defined in:
lib/remocon/normalizer/integer_normalizer.rb

Instance Attribute Summary

Attributes inherited from Normalizer

#content

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Normalizer

#initialize, #process

Constructor Details

This class inherits a constructor from Remocon::Normalizer

Class Method Details

.respond_symbolObject



5
6
7
# File 'lib/remocon/normalizer/integer_normalizer.rb', line 5

def self.respond_symbol
  Remocon::Type::INTEGER
end

Instance Method Details

#normalizeObject



19
20
21
# File 'lib/remocon/normalizer/integer_normalizer.rb', line 19

def normalize
  @int_val
end

#validateObject



9
10
11
12
13
14
15
16
17
# File 'lib/remocon/normalizer/integer_normalizer.rb', line 9

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