class Datev::StringField
Public Instance Methods
limit()
click to toggle source
# File lib/datev/field/string_field.rb, line 3 def limit options[:limit] end
output(value, _context=nil)
click to toggle source
# File lib/datev/field/string_field.rb, line 21 def output(value, _context=nil) value = value.slice(0, limit || 255) if value quote(value) end
regex()
click to toggle source
# File lib/datev/field/string_field.rb, line 7 def regex options[:regex] end
validate!(value)
click to toggle source
Calls superclass method
Datev::Field#validate!
# File lib/datev/field/string_field.rb, line 11 def validate!(value) super if value raise ArgumentError.new("Value given for field '#{name}' is not a String") unless value.is_a?(String) raise ArgumentError.new("Value '#{value}' for field '#{name}' is too long") if limit && value.length > limit raise ArgumentError.new("Value '#{value}' for field '#{name}' does not match regex") if regex && value !~ regex end end
Private Instance Methods
quote(value)
click to toggle source
# File lib/datev/field/string_field.rb, line 29 def quote(value) # Existing quotes have to be doubled value = value.gsub('"','""') if value "\"#{value}\"" end