Commit cbdf6b7a authored by Konstantine's avatar Konstantine 💮

beginning support for AAT data parsing

parent bb5f0782
......@@ -2,7 +2,7 @@ require "csv"
require "./cycling/**"
module Cycling
VERSION = "0.2.1"
VERSION = "0.3.1"
# Initializing
Cycling::Options
......
require "xml"
class Cycling::AAT
def self.import(file)
f = File.read(file)
d = XML.parse(f).children
# Get Time
d.each do |q|
puts q.children[1].inner_text
end
# Get Entries
d.each{|q| q.children[3].children.each{|f| f.children.each do |g|
puts g # Get attributes for lat and lon
g.children.each{|h| puts h.children} # Printing for testing purposes
# TODO: Format the data to nested array or some other type to access
end}}
end
def self.error
puts "There was an error paring the file, please make sure your AAT gpx file is correct..."
exit
end
end
require "option_parser"
require "../cycling"
require "./options"
class Cycling::Options
# Option Flags to select different options for things
......@@ -9,17 +10,27 @@ class Cycling::Options
puts "Not Available"
exit
end
# Specifiy the file you wish to save data to as opposed to data.csv
p.on("-f PATH", "--file PATH", "Choose file to write to") do |new_path|
ENV["file"] = new_path.empty? ? "data.csv" : new_path
end
p.on("-a", "--aat", "Put path to AAT data file to input") do
puts "Not Available"
# For importing AAT GPX file
p.on("-a FILE", "--aat FILE", "Put path to AAT data file to input") do |aat_file|
# if aat_file.empty?
# raise "File Needs to be specified... Please try again..."
# end
File.exists?(aat_file) ? Cycling::AAT.import(aat_file) : Cycling::AAT.error
exit
end
# Get help for this program
p.on("-h", "--help", "Show this help") do
puts p
exit
end
# If flag unknown show help but show error
p.invalid_option do |flag|
STDERR.puts "ERROR: #{flag} is not a valid option."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment