Class: Geospatial::Filter::Range

Inherits:
Object
  • Object
show all
Defined in:
lib/geospatial/filter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prefix, order) ⇒ Range

Returns a new instance of Range.



24
25
26
27
# File 'lib/geospatial/filter.rb', line 24

def initialize(prefix, order)
	@min = prefix
	update_max(prefix, order)
end

Instance Attribute Details

#maxObject (readonly)

Returns the value of attribute max.



30
31
32
# File 'lib/geospatial/filter.rb', line 30

def max
  @max
end

#minObject (readonly)

Returns the value of attribute min.



29
30
31
# File 'lib/geospatial/filter.rb', line 29

def min
  @min
end

Instance Method Details

#expand!(prefix, order) ⇒ Object

Returns the new max if expansion was possible, or nil otherwise.



37
38
39
40
41
# 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) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/geospatial/filter.rb', line 43

def include?(hash)
	hash >= min and hash <= max
end

#to_sObject



32
33
34
# File 'lib/geospatial/filter.rb', line 32

def to_s
	"#{min.to_s(2)}..#{max.to_s(2)}"
end