Class: SemanticNavigation::Core::Node

Inherits:
Base
  • Object
show all
Includes:
MixIn::ConditionMethods, MixIn::DslMethods, MixIn::NameMethods, MixIn::UrlMethods
Defined in:
lib/semantic_navigation/core/node.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#active, #classes, #html, #id, #level, #render_if

Instance Method Summary collapse

Methods included from MixIn::ConditionMethods

#skip?, #skip_for_renderer

Methods included from MixIn::DslMethods

#divider, #header, #item, #method_missing, #scope

Methods included from MixIn::NameMethods

#name

Methods included from MixIn::UrlMethods

#url

Methods inherited from Base

#render

Constructor Details

#initialize(options, level) ⇒ Node

Returns a new instance of Node.



12
13
14
15
16
17
18
19
# File 'lib/semantic_navigation/core/node.rb', line 12

def initialize(options, level)
  @url = []
  @link_html = {}
  @node_html = {}
  @scope_options = {}
  @sub_elements = []
  super options, level
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class SemanticNavigation::Core::MixIn::DslMethods

Instance Attribute Details

Returns the value of attribute link_classes.



9
10
11
# File 'lib/semantic_navigation/core/node.rb', line 9

def link_classes
  @link_classes
end

Returns the value of attribute link_html.



9
10
11
# File 'lib/semantic_navigation/core/node.rb', line 9

def link_html
  @link_html
end

#node_classesObject

Returns the value of attribute node_classes.



9
10
11
# File 'lib/semantic_navigation/core/node.rb', line 9

def node_classes
  @node_classes
end

#node_htmlObject

Returns the value of attribute node_html.



9
10
11
# File 'lib/semantic_navigation/core/node.rb', line 9

def node_html
  @node_html
end

#sub_elementsObject

Returns the value of attribute sub_elements.



9
10
11
# File 'lib/semantic_navigation/core/node.rb', line 9

def sub_elements
  @sub_elements
end

Instance Method Details

#mark_activeObject



21
22
23
24
25
# File 'lib/semantic_navigation/core/node.rb', line 21

def mark_active
  @sub_elements.each{|element| element.mark_active}
  @active = urls.map{|u| current_page?(u) rescue false}.reduce(:"|")
  @active |= !@sub_elements.find{|element| element.active}.nil?
end