Sha256: 6a711f2e8bbd433c48b482664e957e79fac5493b71c9690dab1fc599478a8921
Contents?: true
Size: 1.7 KB
Versions: 1
Compression:
Stored size: 1.7 KB
Contents
module LIVR module Rules module Modifiers class Default < Rule def initialize(default_value) @default_value = default_value end def call(value, user_data, field_results) if is_no_value(value) field_results << @default_value end return end end class Trim < Rule def call(value, user_data, field_results) return if is_no_value(value) || value.is_a?(Hash) field_results << value.to_s.strip return end end class ToLc < Rule def call(value, user_data, field_results) return if is_no_value(value) || value.is_a?(Hash) field_results << value.to_s.downcase return end end class ToUc < Rule def call(value, user_data, field_results) return if is_no_value(value) || value.is_a?(Hash) field_results << value.to_s.upcase return end end class Remove < Rule def initialize(chars) @chars = chars @re = Regexp.compile("[#{Regexp.quote(@chars)}]") end def call(value, user_data, field_results) return if is_no_value(value) || value.is_a?(Hash) field_results << value.to_s.gsub(@re, '') return end end class LeaveOnly < Rule def initialize(chars) @chars = chars @re = Regexp.compile("[^#{Regexp.quote(@chars)}]") end def call(value, user_data, field_results) return if is_no_value(value) || value.is_a?(Hash) field_results << value.to_s.gsub(@re, '') return end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
livr2-2.0.0 | lib/livr/rules/modifiers.rb |