Class: Bookbinder::Subnav::TemplateCreator::LinkHolder

Inherits:
Object
  • Object
show all
Defined in:
lib/bookbinder/subnav/template_creator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(links, template) ⇒ LinkHolder

Returns a new instance of LinkHolder.



42
43
44
45
# File 'lib/bookbinder/subnav/template_creator.rb', line 42

def initialize(links, template)
  @links = links
  @template = template
end

Instance Attribute Details

Returns the value of attribute links.



47
48
49
# File 'lib/bookbinder/subnav/template_creator.rb', line 47

def links
  @links
end

Instance Method Details

#escape_html(str) ⇒ Object



65
66
67
# File 'lib/bookbinder/subnav/template_creator.rb', line 65

def escape_html(str)
  Rack::Utils.escape_html(str)
end

#get_bindingObject



49
50
51
# File 'lib/bookbinder/subnav/template_creator.rb', line 49

def get_binding
  binding
end

#links?(links) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/bookbinder/subnav/template_creator.rb', line 61

def links?(links)
  (links || []).empty?
end


53
54
55
# File 'lib/bookbinder/subnav/template_creator.rb', line 53

def render_links(some_links)
  @template.result(LinkHolder.new(some_links, @template).get_binding)
end


57
58
59
# File 'lib/bookbinder/subnav/template_creator.rb', line 57

def submenu_class(link)
  'has_submenu' unless links?(link[:nested_links])
end