Sha256: fe907b950e0012f7e9675ef88953d462296a65eb7493c877df8c200a29da5a5f
Contents?: true
Size: 604 Bytes
Versions: 12
Compression:
Stored size: 604 Bytes
Contents
module Headmin module Filter class Number < Headmin::Filter::Base OPERATORS = %w[eq not_eq gt gteq lt lteq between not_between in not_in is_null is_not_null] def cast_value(value) is_i?(value) ? value.to_i : 0 end def to_s string end private def is_i?(value) # Regex: this selects signed digits (\d) only, it is then checked to the value, e.g.: # is_i?("3") = true # is_i?("-3") = true # is_i?("3a") = false # is_i?("3.2") = false /\A[-+]?\d+\z/.match(value) end end end end
Version data entries
12 entries across 12 versions & 1 rubygems