Class: SiteMap::Map

Inherits:
Object
  • Object
show all
Includes:
Helpers::Mapping
Defined in:
lib/site_map/map.rb

Constant Summary collapse

ATTRIBUTES =
[:view_nodes, :index_of_nodes]

Constants included from Helpers::Mapping

Helpers::Mapping::DEFAULT_ALIAS

Instance Method Summary collapse

Methods included from Helpers::Mapping

#alias, #collection, #collection_view, #group, #member, #member_view, #view

Constructor Details

#initializeMap

Returns a new instance of Map.



10
11
12
# File 'lib/site_map/map.rb', line 10

def initialize
  self.clear_nodes!
end

Instance Method Details

#add_to_children(view_node) ⇒ Object



18
19
20
# File 'lib/site_map/map.rb', line 18

def add_to_children(view_node)
  @view_nodes.push(view_node)
end

#add_to_index(index, view_node) ⇒ Object



21
22
23
# File 'lib/site_map/map.rb', line 21

def add_to_index(index, view_node)
  @index_of_nodes[index.to_sym] = view_node
end

#clear_nodes!Object



25
26
27
28
# File 'lib/site_map/map.rb', line 25

def clear_nodes!
  @view_nodes = []
  @index_of_nodes = {}
end

#find(view_node_index) ⇒ Object



14
15
16
# File 'lib/site_map/map.rb', line 14

def find(view_node_index)
  self.index_of_nodes[view_node_index.to_sym]
end

#inspectObject



35
36
37
# File 'lib/site_map/map.rb', line 35

def inspect
  "#<#{self.class}>"
end

#mapObject

convenience method



31
32
33
# File 'lib/site_map/map.rb', line 31

def map
  self
end

#visible_viewsObject



39
40
41
42
43
# File 'lib/site_map/map.rb', line 39

def visible_views
  @view_nodes.select do |view|
    view.visible?
  end
end