Class: Sapristi::AttributeNormalizer
- Inherits:
-
Object
- Object
- Sapristi::AttributeNormalizer
- Defined in:
- lib/sapristi/attribute_normalizer.rb
Instance Method Summary collapse
-
#initialize(key, raw, monitor) ⇒ AttributeNormalizer
constructor
A new instance of AttributeNormalizer.
- #normalize ⇒ Object
Constructor Details
#initialize(key, raw, monitor) ⇒ AttributeNormalizer
Returns a new instance of AttributeNormalizer.
5 6 7 8 9 |
# File 'lib/sapristi/attribute_normalizer.rb', line 5 def initialize(key, raw, monitor) @key = key @raw = raw @monitor = monitor end |
Instance Method Details
#normalize ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sapristi/attribute_normalizer.rb', line 11 def normalize if percentage? apply_percentage elsif not_a_percentage_but_includes_symbol? raise Error, "key=#{key}, invalid percentage=#{raw}" elsif numeric_field? raw&.to_i else raw end end |