Class: Geospatial::Index
- Inherits:
-
Object
show all
- Defined in:
- lib/geospatial/index.rb
Overview
This class represents a n-dimentional index.
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(axes, bits) ⇒ Index
Returns a new instance of Index.
29
30
31
32
|
# File 'lib/geospatial/index.rb', line 29
def initialize(axes, bits)
@axes = axes
@bits = bits
end
|
Instance Attribute Details
#axes ⇒ Object
Returns the value of attribute axes.
38
39
40
|
# File 'lib/geospatial/index.rb', line 38
def axes
@axes
end
|
#bits ⇒ Object
Returns the value of attribute bits.
39
40
41
|
# File 'lib/geospatial/index.rb', line 39
def bits
@bits
end
|
Class Method Details
.from_integral(integral, width, bits) ⇒ Object
34
35
36
|
# File 'lib/geospatial/index.rb', line 34
def self.from_integral(integral, width, bits)
self.new(Interleave.unmap(integral, width), bits)
end
|
Instance Method Details
#&(mask) ⇒ Object
41
42
43
|
# File 'lib/geospatial/index.rb', line 41
def & mask
self.class.new(axes.collect{|axis| axis & mask}, @bits)
end
|
#bit_length ⇒ Object
57
58
59
|
# File 'lib/geospatial/index.rb', line 57
def bit_length
@axes.size * @bits
end
|
#eql?(other) ⇒ Boolean
49
50
51
|
# File 'lib/geospatial/index.rb', line 49
def eql?(other)
self.class.eql?(other.class) and @axes.eql?(other.axes) and @bits.eql?(other.bits)
end
|
#hash ⇒ Object
45
46
47
|
# File 'lib/geospatial/index.rb', line 45
def hash
@axes.hash
end
|
#inspect ⇒ Object
61
62
63
64
|
# File 'lib/geospatial/index.rb', line 61
def inspect
i = self.to_i
"\#<#{self.class}[#{@bits}] 0b#{i.to_s(2).rjust(bit_length, '0')} (#{i}) #{@axes.inspect}>"
end
|
#to_i ⇒ Object
53
54
55
|
# File 'lib/geospatial/index.rb', line 53
def to_i
Interleave.map(@axes, @bits)
end
|