Sha256: dcf2870964dc4b19166b35a3449e7ce9711ac674e626839361ea7cd4d2657f84

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

require_relative 'google_api'

module Google
  class TrafficInfo
    attr_reader :infos
    attr_reader :origins, :dest, :mode
    attr_reader :anaDistance, :anaDuration, :fare


    def initialize(distance,search)

      parseSearch(search)
      @googleapi = ENV['GOOGLE_API']
      @infos = distance.map{ |item|
        infos = info(item)
      }
      @info = distance[0]
    end

    def trafficAnaly
      @anaDistance = @info['distance']['value']
      @anaDuration = @info['duration']
      if(@info['fare'])
        @fare = @info['fare']
      end

      @info

    end

    def self.find(origins:,destinations:,mode:)
      distance_data = GoogleApi.distanceInfo(origins,destinations,mode)
      @search_info = {googleapi:ENV['GOOGLE_API'],originsVal:origins,destVal:destinations,modeVal:mode}
    #  @info = distance_data[0]
    #  print @info.to_s

      new(distance_data,@search_info)
    end

    private
    def parseSearch(sear)
      @origins = sear[:originsVal]
      @dest = sear[:destVal]
      @mode = sear[:modeVal]
    end

    def info(item)
      info = item

    end

  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
VIAJERO-0.1.74 lib/VIAJERO/trafficinfo.rb
VIAJERO-0.1.73 lib/VIAJERO/trafficinfo.rb
Time_Traveler-0.1.72 lib/Time_Traveler/trafficinfo.rb
Time_Traveler-0.1.71 lib/Time_Traveler/trafficinfo.rb
Time_Traveler-0.1.70 lib/Time_Traveler/trafficinfo.rb