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:



828
829
830
831
832
# File 'lib/rgeo/shapefile/reader.rb', line 828

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

Instance Attribute Details

#attributesObject (readonly)

The attributes as a hash.



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

def attributes
  @attributes
end

#geometryObject (readonly)

The geometry contained in this shapefile record



838
839
840
# File 'lib/rgeo/shapefile/reader.rb', line 838

def geometry
  @geometry
end

#indexObject (readonly)

The 0-based record number



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

def index
  @index
end

Instance Method Details

#[](key_) ⇒ Object

Returns the value for the given attribute key.



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

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

#keysObject

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



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

def keys
  @attributes.keys
end