class Audrey::Object::Scalar::String::Field
¶ ↑
Audrey::Object::Scalar::String::Field
Attributes
aclass[R]
collapse[RW]
downcase[RW]
hascontent[RW]
max_length[RW]
min_length[RW]
upcase[RW]
Public Class Methods
new(*opts)
click to toggle source
Calls superclass method
Audrey::Object::Custom::Field::new
# File lib/audrey.rb, line 2338 def initialize(*opts) super(*opts) @aclass = String # normalize @collapse = false @downcase = false @upcase = false # checks @min_length = nil @max_length = nil @hascontent = false end
Public Instance Methods
base_checks(xeme, fieldname, val)
click to toggle source
# File lib/audrey.rb, line 2403 def base_checks(xeme, fieldname, val) # $tm.hrm # min_length if @min_length if val.length < @min_length xeme.error('min-length') do |msg| msg['val'] = val msg['min-length'] = @min_length end end end # max_length if @max_length if val.length > @max_length xeme.error('max-length') do |msg| msg['val'] = val msg['max-length'] = @max_length end end end # hascontent if @hascontent if not val.match(/\S/mu) xeme.error('hascontent') do |msg| msg['val'] = val end end end end
has_checks?()
click to toggle source
# File lib/audrey.rb, line 2390 def has_checks? @min_length and return true @max_length and return true @hascontent and return true end
normalize(val)
click to toggle source
# File lib/audrey.rb, line 2360 def normalize(val) # early exit if not val.is_a?(String) return end # collapse if @collapse val.strip! val.gsub!(/[^[:graph:]]+/mu, ' ') end # downcase, upcase if @downcase val.downcase! elsif @upcase val.upcase! end # return return val end