class Geospatial::Filter::Range
Attributes
max[R]
min[R]
Public Class Methods
new(prefix, order)
click to toggle source
# File lib/geospatial/filter.rb, line 24 def initialize(prefix, order) @min = prefix update_max(prefix, order) end
Public Instance Methods
expand!(prefix, order)
click to toggle source
Returns the new max if expansion was possible, or nil otherwise.
# File lib/geospatial/filter.rb, line 37 def expand!(prefix, order) if @max < prefix and prefix == @max+1 update_max(prefix, order) end end
include?(hash)
click to toggle source
# File lib/geospatial/filter.rb, line 43 def include?(hash) hash >= min and hash <= max end
to_s()
click to toggle source
# File lib/geospatial/filter.rb, line 32 def to_s "#{min.to_s(2)}..#{max.to_s(2)}" end
Private Instance Methods
update_max(prefix, order)
click to toggle source
# File lib/geospatial/filter.rb, line 49 def update_max(prefix, order) # We set the RHS of the prefix to 1s, which is the maximum: @max = prefix | ((1 << (order*2)) - 1) end