Class: WrfForecast::Directions

Inherits:
Object
  • Object
show all
Defined in:
lib/wrf_forecast/data/directions.rb

Overview

Simple data class to map the geographical directions to a string representation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDirections

initialization



9
10
11
# File 'lib/wrf_forecast/data/directions.rb', line 9

def initialize
  initialize_directions
end

Instance Attribute Details

#directionsHash (readonly, private)

Returns the mapping of direction and direction name.

Returns:

  • (Hash)

    the mapping of direction and direction name



23
24
25
# File 'lib/wrf_forecast/data/directions.rb', line 23

def directions
  @directions
end

Instance Method Details

#get_direction_string(symbol) ⇒ String

encapsulating getter to retrieve the direction string to a given direction

Parameters:

  • symbol (Symbol)

    the symbol representing the direction

Returns:

  • (String)

    the string representation of the direction



16
17
18
# File 'lib/wrf_forecast/data/directions.rb', line 16

def get_direction_string(symbol)
  @directions[symbol]
end

#initialize_directionsObject (private)

method to initialize the mapping from direction to direction text



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/wrf_forecast/data/directions.rb', line 26

def initialize_directions
  @directions = Hash.new()
  @directions[:N]  = I18n.t("direction.north")
  @directions[:S]  = I18n.t("direction.south")
  @directions[:W]  = I18n.t("direction.west")
  @directions[:E]  = I18n.t("direction.east")
  @directions[:NW] = I18n.t("direction.northwest")
  @directions[:NE] = I18n.t("direction.northeast")
  @directions[:SW] = I18n.t("direction.southwest")
  @directions[:SE] = I18n.t("direction.southeast")
  nil
end