class AttrSearchableGrammar::Attributes::Datetime
Public Instance Methods
between(range)
click to toggle source
# File lib/attr_searchable_grammar/attributes.rb, line 189 def between(range) gteq(range.first).and(lteq(range.last)) end
eq(value)
click to toggle source
# File lib/attr_searchable_grammar/attributes.rb, line 177 def eq(value) between parse(value) end
gt(value)
click to toggle source
Calls superclass method
# File lib/attr_searchable_grammar/attributes.rb, line 185 def gt(value) super parse(value).last end
map(value)
click to toggle source
# File lib/attr_searchable_grammar/attributes.rb, line 173 def map(value) parse(value).first end
not_eq(value)
click to toggle source
# File lib/attr_searchable_grammar/attributes.rb, line 181 def not_eq(value) between(parse(value)).not end
parse(value)
click to toggle source
# File lib/attr_searchable_grammar/attributes.rb, line 153 def parse(value) return value .. value unless value.is_a?(::String) if value =~ /^[0-9]{4,}$/ ::Time.new(value).beginning_of_year .. ::Time.new(value).end_of_year elsif value =~ /^([0-9]{4,})(\.|-|\/)([0-9]{1,2})$/ ::Time.new($1, $3, 15).beginning_of_month .. ::Time.new($1, $3, 15).end_of_month elsif value =~ /^([0-9]{1,2})(\.|-|\/)([0-9]{4,})$/ ::Time.new($3, $1, 15).beginning_of_month .. ::Time.new($3, $1, 15).end_of_month elsif value !~ /:/ time = ::Time.parse(value) time.beginning_of_day .. time.end_of_day else time = ::Time.parse(value) time .. time end rescue ArgumentError raise AttrSearchable::IncompatibleDatatype, "Incompatible datatype for #{value}" end