class Metrics
Constants
- METRICS
Public Class Methods
new(attributes)
click to toggle source
# File lib/skiplan_client/metrics.rb, line 12 def initialize(attributes) self.attributes = attributes.keep_if {|k, v| METRICS.include?(k)} unless attributes.nil? end
Public Instance Methods
alpine()
click to toggle source
# File lib/skiplan_client/metrics.rb, line 16 def alpine alpine_metrics = {} alpine_metrics[:total] = get_ratio(@SKI_ALPIN) alpine_metrics[:green] = get_ratio(@SKI_ALPIN_VERTES) alpine_metrics[:blue] = get_ratio(@SKI_ALPIN_BLEUES) alpine_metrics[:red] = get_ratio(@SKI_ALPIN_ROUGES) alpine_metrics[:black] = get_ratio(@SKI_ALPIN_NOIRES) alpine_metrics end
driving_conditions()
click to toggle source
# File lib/skiplan_client/metrics.rb, line 67 def driving_conditions @ETAT_ROUTE['lib'] end
night_ski()
click to toggle source
# File lib/skiplan_client/metrics.rb, line 59 def night_ski @SKI_NUIT && @SKI_NUIT['etat'] == '1' end
nordic()
click to toggle source
# File lib/skiplan_client/metrics.rb, line 27 def nordic nordic_metrics = {} nordic_metrics[:total] = get_ratio(@SKI_NORDIQUE) nordic_metrics[:green] = get_ratio(@SKI_NORDIQUE_VERTES) nordic_metrics[:blue] = get_ratio(@SKI_NORDIQUE_BLEUES) nordic_metrics[:red] = get_ratio(@SKI_NORDIQUE_ROUGES) nordic_metrics[:black] = get_ratio(@SKI_NORDIQUE_NOIRES) nordic_metrics[:km] = get_ratio_km(@SKI_NORDIQUE) nordic_metrics end
pedestrian()
click to toggle source
# File lib/skiplan_client/metrics.rb, line 39 def pedestrian {:total => get_ratio_km(@PIETONS)} end
roads()
click to toggle source
# File lib/skiplan_client/metrics.rb, line 71 def roads @ETAT_CHAUSSEE['lib'] unless (@ETAT_CHAUSSEE.nil? || @ETAT_CHAUSSEE['val'] == '8') end
skating()
click to toggle source
# File lib/skiplan_client/metrics.rb, line 63 def skating @KM_SKATING['ouvert'] unless @KM_SKATING.nil? end
skilifts()
click to toggle source
# File lib/skiplan_client/metrics.rb, line 55 def skilifts {:total => get_ratio(@REMONTEES)} end
sledge()
click to toggle source
# File lib/skiplan_client/metrics.rb, line 47 def sledge {:total => get_ratio(@LUGE)} end
snowpark()
click to toggle source
# File lib/skiplan_client/metrics.rb, line 51 def snowpark {:total => get_ratio(@SNOWPARK)} end
snowshoes()
click to toggle source
# File lib/skiplan_client/metrics.rb, line 43 def snowshoes {:total => get_ratio_km(@RAQUETTES)} end
Private Instance Methods
get_ratio(hash)
click to toggle source
# File lib/skiplan_client/metrics.rb, line 77 def get_ratio(hash) "#{hash['ouvertes_previsions']}/#{hash['total']}" unless hash.nil? end
get_ratio_km(hash)
click to toggle source
# File lib/skiplan_client/metrics.rb, line 81 def get_ratio_km(hash) "#{sprintf("%g", hash['lng_ouverts'].to_f)}/#{sprintf("%g", hash['lng_total'].to_f)}km" unless hash.nil? end