Class: Shapefile::Shape

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

Direct Known Subclasses

MultiPatch, MultiPoint, Null, Point, PolyLine, Polygon

Defined Under Namespace

Classes: MultiPatch, MultiPoint, MultiPointM, MultiPointZ, Null, Point, PointM, PointZ, PolyLine, PolyLineM, PolyLineZ, Polygon, PolygonM, PolygonZ

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, raw_record) ⇒ Shape

:nodoc:



5
6
7
8
# File 'lib/shapefile/shape.rb', line 5

def initialize(id, raw_record) # :nodoc:
  @id = id
  self.attributes = {}
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



3
4
5
# File 'lib/shapefile/shape.rb', line 3

def attributes
  @attributes
end

#idObject (readonly)

Returns the value of attribute id.



2
3
4
# File 'lib/shapefile/shape.rb', line 2

def id
  @id
end

Class Method Details

.class_for_code(code) ⇒ Object



22
23
24
# File 'lib/shapefile/shape.rb', line 22

def self.class_for_code(code)
  @codes_classes[code]
end

.codeObject



18
19
20
# File 'lib/shapefile/shape.rb', line 18

def self.code
  nil
end

.enumerate_subclass_codesObject

:nodoc:



10
11
12
13
14
15
16
# File 'lib/shapefile/shape.rb', line 10

def self.enumerate_subclass_codes # :nodoc:
  @codes_classes = {}
  constants.each do |const|
    subclass = eval("Shapefile::Shape::#{const}") rescue next
    @codes_classes[subclass.code] = subclass
  end
end

Instance Method Details

#[](key) ⇒ Object



26
27
28
# File 'lib/shapefile/shape.rb', line 26

def [](key)
  attributes[key]
end