Module: GW2::Map

Extended by:
GW2
Defined in:
lib/gw2/map.rb,
lib/gw2/map/maps.rb,
lib/gw2/map/map_floor.rb,
lib/gw2/map/continents.rb

Constant Summary

Constants included from GW2

BASE_URL

Class Method Summary collapse

Methods included from GW2

request

Class Method Details

.allObject



3
4
5
# File 'lib/gw2/map/maps.rb', line 3

def self.all
  self.where
end

.continentsObject



3
4
5
6
7
8
9
10
11
# File 'lib/gw2/map/continents.rb', line 3

def self.continents
  response = request(
    action: "Get",
    ssl: true,
    url: "#{BASE_URL}/continents.json"
  )

  return JSON.parse(response.body)
end

.map_floor(continent_id, floor) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/gw2/map/map_floor.rb', line 3

def self.map_floor(continent_id, floor)
  response = request(
    action: "Get",
    ssl: true,
    url: "#{BASE_URL}/map_floor.json?continent_id=#{continent_id}&floor=#{floor}"
  )

  return JSON.parse(response.body)
end

.where(map_id = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/gw2/map/maps.rb', line 7

def self.where(map_id = {})
  url = "#{BASE_URL}/maps.json"
  query_string = map_id.collect { |k,v| "#{v}" }.join
  url += "?map_id=#{query_string}" unless query_string.empty?

  response = request(
    action: "Get",
    ssl: true,
    url: url
  )

  return JSON.parse(response.body)
end