class Datev::IntegerField

Public Instance Methods

limit() click to toggle source
# File lib/datev/field/integer_field.rb, line 3
def limit
  options[:limit]
end
maximum() click to toggle source
# File lib/datev/field/integer_field.rb, line 7
def maximum
  options[:maximum]
end
minimum() click to toggle source
# File lib/datev/field/integer_field.rb, line 11
def minimum
  options[:minimum]
end
output(value, _context=nil) click to toggle source
# File lib/datev/field/integer_field.rb, line 26
def output(value, _context=nil)
  value.to_s if value
end
validate!(value) click to toggle source
Calls superclass method Datev::Field#validate!
# File lib/datev/field/integer_field.rb, line 15
def validate!(value)
  super

  if value
    raise ArgumentError.new("Value given for field '#{name}' is not an Integer") unless value.is_a?(Integer)
    raise ArgumentError.new("Value '#{value}' for field '#{name}' is too long") if limit && value.to_s.length > limit
    raise ArgumentError.new("Value '#{value}' for field '#{name}' is too large") if maximum && value > maximum
    raise ArgumentError.new("Value '#{value}' for field '#{name}' is too small") if minimum && value < minimum
  end
end