Class: KML::Kml
- Inherits:
-
Object
- Object
- KML::Kml
- Defined in:
- lib/gpx_kml/kml.rb
Overview
Docu
Instance Attribute Summary collapse
-
#file_name ⇒ Object
readonly
access in read only of the number of points, routes and tracks in the kml.
-
#points ⇒ Object
readonly
access data of the kml in readonly.
-
#points_length ⇒ Object
readonly
access in read only of the number of points, routes and tracks in the kml.
-
#routes ⇒ Object
readonly
access data of the kml in readonly.
-
#routes_length ⇒ Object
readonly
access in read only of the number of points, routes and tracks in the kml.
-
#tracks ⇒ Object
readonly
access data of the kml in readonly.
-
#tracks_length ⇒ Object
readonly
access in read only of the number of points, routes and tracks in the kml.
Instance Method Summary collapse
-
#initialize(file_path) ⇒ Kml
constructor
A new instance of Kml.
- #kml? ⇒ Boolean
- #points? ⇒ Boolean
- #routes? ⇒ Boolean
- #tracks? ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(file_path) ⇒ Kml
Returns a new instance of Kml.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gpx_kml/kml.rb', line 11 def initialize(file_path) return unless correct_path?(file_path) && (File.size(file_path) < 10_000_000) @kml = Nokogiri::XML(File.open(file_path)) return unless valid? @file_name = File.basename(file_path) @tracks = _tracks @routes = _routes @points = _points @points_length = _points_length @routes_length = _routes_length @tracks_length = _tracks_length end |
Instance Attribute Details
#file_name ⇒ Object (readonly)
access in read only of the number of points, routes and tracks in the kml
27 28 29 |
# File 'lib/gpx_kml/kml.rb', line 27 def file_name @file_name end |
#points ⇒ Object (readonly)
access data of the kml in readonly
30 31 32 |
# File 'lib/gpx_kml/kml.rb', line 30 def points @points end |
#points_length ⇒ Object (readonly)
access in read only of the number of points, routes and tracks in the kml
27 28 29 |
# File 'lib/gpx_kml/kml.rb', line 27 def points_length @points_length end |
#routes ⇒ Object (readonly)
access data of the kml in readonly
30 31 32 |
# File 'lib/gpx_kml/kml.rb', line 30 def routes @routes end |
#routes_length ⇒ Object (readonly)
access in read only of the number of points, routes and tracks in the kml
27 28 29 |
# File 'lib/gpx_kml/kml.rb', line 27 def routes_length @routes_length end |
#tracks ⇒ Object (readonly)
access data of the kml in readonly
30 31 32 |
# File 'lib/gpx_kml/kml.rb', line 30 def tracks @tracks end |
#tracks_length ⇒ Object (readonly)
access in read only of the number of points, routes and tracks in the kml
27 28 29 |
# File 'lib/gpx_kml/kml.rb', line 27 def tracks_length @tracks_length end |
Instance Method Details
#kml? ⇒ Boolean
32 33 34 |
# File 'lib/gpx_kml/kml.rb', line 32 def kml? !@kml.nil? && !@kml.xpath('/xmlns:kml').empty? end |
#points? ⇒ Boolean
52 53 54 55 56 |
# File 'lib/gpx_kml/kml.rb', line 52 def points? return true unless @kml.xpath('//xmlns:Point').empty? false end |
#routes? ⇒ Boolean
40 41 42 43 44 |
# File 'lib/gpx_kml/kml.rb', line 40 def routes? return true unless @kml.xpath('//xmlns:LinearRing').empty? false end |
#tracks? ⇒ Boolean
46 47 48 49 50 |
# File 'lib/gpx_kml/kml.rb', line 46 def tracks? return true unless @kml.xpath('//xmlns:LineString').empty? false end |
#valid? ⇒ Boolean
36 37 38 |
# File 'lib/gpx_kml/kml.rb', line 36 def valid? kml? && (tracks? || routes? || points?) end |