Class: Navgate::Builder

Inherits:
Base
  • Object
show all
Defined in:
lib/navgate.rb

Instance Attribute Summary

Attributes inherited from Base

#by_id, #controller, #css_class, #default, #namespace, #prefix, #selection

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Base

Instance Method Details

#render_it_with(options) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/navgate.rb', line 5

def render_it_with(options)
  options_to_render = ""
  if options
    options.each do |key,value|
      options_to_render += ("#{key}=#{value}" + " ") unless ignoring key
      options_to_render += ("class='#{self.css_class}") if self.css_class
    end
  end
  style = styling(options)
  @text_to_render = ""
  if !self.by_id
    self.selection.each do |select|
      wrap_with options[:wrap] do
        @text_to_render += "<a href=\"#{path_for(select)}\" #{options_to_render}>#{select.gsub('_'," ")}</a>#{style}"
      end
    end
  else
    self.selection.each_with_index do |select,i|
      wrap_with options[:wrap] do
        @text_to_render += "<a href=\"#{path_for(self.by_id[i])}\" #{options_to_render}>#{select.gsub('_'," ")}</a>#{style}"
      end
    end
  end
  @text_to_render
end