Class: DeGiro::UrlsMap

Inherits:
Object
  • Object
show all
Defined in:
lib/degiro/urls_map.rb

Constant Summary collapse

URL_NAMES =
[
  'paUrl',
  'productSearchUrl',
  'productTypesUrl',
  'reportingUrl',
  'tradingUrl',
  'vwdQuotecastServiceUrl'
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ UrlsMap

Returns a new instance of UrlsMap.



14
15
16
17
18
19
# File 'lib/degiro/urls_map.rb', line 14

def initialize(data)
  @map = URL_NAMES.each_with_object({}) do |url_name, acc|
    raise MissingUrlError, "Could not find url '#{url_name}'" unless data.key?(url_name)
    acc[url_name.gsub(/(.)([A-Z])/, '\1_\2').downcase] = data[url_name]
  end
end

Instance Method Details

#[](url_name) ⇒ Object

Raises:



21
22
23
24
# File 'lib/degiro/urls_map.rb', line 21

def [](url_name)
  raise IncorrectUrlError, "Could not find url '#{url_name}'" unless @map.key?(url_name)
  @map[url_name]
end