Class: SemanticNavigation::Core::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/semantic_navigation/core/base.rb

Direct Known Subclasses

Leaf, Navigation, Node

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, level) ⇒ Base

Returns a new instance of Base.



18
19
20
21
22
23
24
# File 'lib/semantic_navigation/core/base.rb', line 18

def initialize(options, level)
  @level = level
  @html = {}
  options.keys.each do |option_name|
    instance_variable_set :"@#{option_name}", options[option_name]
  end
end

Instance Attribute Details

#activeObject

Returns the value of attribute active.



5
6
7
# File 'lib/semantic_navigation/core/base.rb', line 5

def active
  @active
end

#classesObject

Returns the value of attribute classes.



5
6
7
# File 'lib/semantic_navigation/core/base.rb', line 5

def classes
  @classes
end

#htmlObject

Returns the value of attribute html.



5
6
7
# File 'lib/semantic_navigation/core/base.rb', line 5

def html
  @html
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/semantic_navigation/core/base.rb', line 5

def id
  @id
end

#levelObject

Returns the value of attribute level.



5
6
7
# File 'lib/semantic_navigation/core/base.rb', line 5

def level
  @level
end

#render_ifObject



8
9
10
11
12
13
14
15
16
# File 'lib/semantic_navigation/core/base.rb', line 8

def render_if
  unless @render_if.nil?
    @render_if.map do |bl|
      view_object.instance_exec(self, &bl)
    end.all?
  else
    true
  end
end

Instance Method Details

#render(renderer) ⇒ Object



26
27
28
29
# File 'lib/semantic_navigation/core/base.rb', line 26

def render(renderer)
  class_name = self.class.name.split('::').last.downcase
  renderer.send :"render_#{class_name}", self
end