Class: Tourguide::Renderers::Connections
- Inherits:
-
Object
- Object
- Tourguide::Renderers::Connections
- Defined in:
- lib/tourguide/renderers/connections.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #add(label, type) ⇒ Object
- #connections ⇒ Object
-
#initialize(context, options = {}) ⇒ Connections
constructor
A new instance of Connections.
- #render ⇒ Object
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, ={}) @context = context @options = .reverse_merge @connections = [] end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/tourguide/renderers/connections.rb', line 5 def @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 |
#connections ⇒ Object
25 26 27 |
# File 'lib/tourguide/renderers/connections.rb', line 25 def connections @connections.any? ? @connections : default_connections end |
#render ⇒ Object
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 do |nav| nav << connections.map{ |x| x.render }.join("\n") end out.html_safe end |