class Tourguide::Renderers::Connections
Attributes
options[R]
Public Class Methods
new(context, options={})
click to toggle source
# File lib/tourguide/renderers/connections.rb, line 7 def initialize(context, options={}) @context = context @options = options.reverse_merge default_options @connections = [] end
Public Instance Methods
add(label, type)
click to toggle source
# File lib/tourguide/renderers/connections.rb, line 21 def add(label, type) @connections << Tourguide::Renderers::Link.new(@context, label, type) end
connections()
click to toggle source
# File lib/tourguide/renderers/connections.rb, line 25 def connections @connections.any? ? @connections : default_connections end
render()
click to toggle source
# File lib/tourguide/renderers/connections.rb, line 13 def render xhtml = Builder::XmlMarkup.new target: out=(''), indent: 2 xhtml.nav nav_options do |nav| nav << connections.map{ |x| x.render }.join("\n") end out.html_safe end
Private Instance Methods
css_classes()
click to toggle source
# File lib/tourguide/renderers/connections.rb, line 35 def css_classes out = [] out << ("connections-#{connections.count}") out << options[:class] out.compact.join(' ') end
default_connections()
click to toggle source
# File lib/tourguide/renderers/connections.rb, line 46 def default_connections @default_connections ||= [ Tourguide::Renderers::Link.new(@context, 'Previous', :prev), Tourguide::Renderers::Link.new(@context, 'Continue', :next) ] end
default_options()
click to toggle source
# File lib/tourguide/renderers/connections.rb, line 42 def default_options {} end