Class: Ratis::LandmarkCategory

Inherits:
Object
  • Object
show all
Defined in:
lib/ratis/landmark_category.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ti) ⇒ LandmarkCategory

Returns a new instance of LandmarkCategory.



7
8
9
10
11
12
# File 'lib/ratis/landmark_category.rb', line 7

def initialize(ti)
  @type              = ti[:type]
  @description       = ti[:description]
  @human_type        = type.gsub(/web/i, "")
  @human_description = description.gsub(/web\s*/i, "")
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/ratis/landmark_category.rb', line 5

def description
  @description
end

#human_descriptionObject

Returns the value of attribute human_description.



5
6
7
# File 'lib/ratis/landmark_category.rb', line 5

def human_description
  @human_description
end

#human_typeObject

Returns the value of attribute human_type.



5
6
7
# File 'lib/ratis/landmark_category.rb', line 5

def human_type
  @human_type
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/ratis/landmark_category.rb', line 5

def type
  @type
end

Class Method Details

.allObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/ratis/landmark_category.rb', line 14

def self.all
  response = Request.get 'Getcategories'

  return [] unless response.success?

  categories = response.to_array(:getcategories_response, :types, :typeinfo)
  categories.map do |category|
    Ratis::LandmarkCategory.new(category)
  end
end

.web_categoriesObject



25
26
27
28
29
# File 'lib/ratis/landmark_category.rb', line 25

def self.web_categories
  all.select{|cat| cat.type.include?('WEB') }.map do |cat|
    [ cat.human_description, cat.type ]
  end
end