Class: RGeo::Shapefile::Reader::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/rgeo/shapefile/reader.rb

Overview

Shapefile records are provided to the caller as objects of this type. The record includes the record index (0-based), the geometry (which may be nil if the shape type is the null type), and a hash of attributes from the associated dbf file.

You should not need to create objects of this type yourself.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index_, geometry_, attributes_) ⇒ Record

:nodoc:


835
836
837
838
839
# File 'lib/rgeo/shapefile/reader.rb', line 835

def initialize(index_, geometry_, attributes_)  # :nodoc:
  @index = index_
  @geometry = geometry_
  @attributes = attributes_
end

Instance Attribute Details

#attributesObject (readonly)

The attributes as a hash.


848
849
850
# File 'lib/rgeo/shapefile/reader.rb', line 848

def attributes
  @attributes
end

#geometryObject (readonly)

The geometry contained in this shapefile record


845
846
847
# File 'lib/rgeo/shapefile/reader.rb', line 845

def geometry
  @geometry
end

#indexObject (readonly)

The 0-based record number


842
843
844
# File 'lib/rgeo/shapefile/reader.rb', line 842

def index
  @index
end

Instance Method Details

#[](key_) ⇒ Object

Returns the value for the given attribute key.


856
857
858
# File 'lib/rgeo/shapefile/reader.rb', line 856

def [](key_)
  @attributes[key_.to_s]
end

#keysObject

Returns an array of keys for all this record's attributes.


851
852
853
# File 'lib/rgeo/shapefile/reader.rb', line 851

def keys
  @attributes.keys
end