Class: Tourguide::Renderers::Connections

Inherits:
Object
  • Object
show all
Defined in:
lib/tourguide/renderers/connections.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, options = {}) ⇒ Connections

Returns a new instance of Connections.



7
8
9
10
11
# File 'lib/tourguide/renderers/connections.rb', line 7

def initialize(context, options={})
  @context = context
  @options = options.reverse_merge default_options
  @connections = []
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/tourguide/renderers/connections.rb', line 5

def options
  @options
end

Instance Method Details

#add(label, type) ⇒ Object



21
22
23
# File 'lib/tourguide/renderers/connections.rb', line 21

def add(label, type)
  @connections << Tourguide::Renderers::Link.new(@context, label, type)
end

#connectionsObject



25
26
27
# File 'lib/tourguide/renderers/connections.rb', line 25

def connections
  @connections.any? ? @connections : default_connections
end

#renderObject



13
14
15
16
17
18
19
# 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