Class: MapSource::Reader

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

Overview

Public: Parses GDB files and extracts waypoints, tracks and routes.

Examples:

reader = MapSource::Reader.new(open('around_the_world.gdb'))
reader.waypoints
# => [MapSource::Waypoint<...>, ...]

Constant Summary collapse

SUPPORTED_VERSIONS =

Public: Range of format versions supported.

(1..3)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gdb) ⇒ Reader

Public: Creates a Reader.

gdb - An IO object pointing to a GDB.



21
22
23
24
25
26
# File 'lib/mapsource/reader.rb', line 21

def initialize(gdb)
  @gdb = gdb
  @header = read_header

  @parsed = false
end

Instance Attribute Details

#headerObject (readonly)

Returns the value of attribute header.



16
17
18
# File 'lib/mapsource/reader.rb', line 16

def header
  @header
end

#waypointsObject (readonly)

Public: Read waypoints from file.

Returns an Array of waypoints.



31
32
33
# File 'lib/mapsource/reader.rb', line 31

def waypoints
  @waypoints
end

Instance Method Details

#tracksObject

Public: Reads tracks from file.

Returns an Array of tracks.



39
40
41
42
# File 'lib/mapsource/reader.rb', line 39

def tracks
  read_data
  @tracks
end