Class: PostRunner::NavButtonRow
- Inherits:
-
Object
- Object
- PostRunner::NavButtonRow
- Defined in:
- lib/postrunner/NavButtonRow.rb
Overview
A NavButtonRow is a row of buttons used to navigate between HTML pages.
Defined Under Namespace
Classes: Button
Instance Method Summary collapse
-
#addButton(icon, url = nil) ⇒ Object
Add a new button to the NavButtonRow object.
-
#initialize(float = nil) ⇒ NavButtonRow
constructor
Create a new NavButtonRow object.
-
#to_html(doc) ⇒ Object
Add the object as HTML Elements to the document.
Constructor Details
#initialize(float = nil) ⇒ NavButtonRow
Create a new NavButtonRow object. be a floating object that floats left or right.
54 55 56 57 58 59 60 61 |
# File 'lib/postrunner/NavButtonRow.rb', line 54 def initialize(float = nil) unless float.nil? || %w( left right ).include?(float) raise ArgumentError "float argument must be nil, 'left' or 'right'" end @float = float @buttons = [] end |
Instance Method Details
#addButton(icon, url = nil) ⇒ Object
Add a new button to the NavButtonRow object.
66 67 68 |
# File 'lib/postrunner/NavButtonRow.rb', line 66 def addButton(icon, url = nil) @buttons << Button.new(icon, url) end |
#to_html(doc) ⇒ Object
Add the object as HTML Elements to the document.
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/postrunner/NavButtonRow.rb', line 72 def to_html(doc) doc.unique(:nav_button_row_style) { doc.head { doc.style(style) } } doc.div({ :class => 'nav_button_row', :style => "width: #{@buttons.length * (32 + 10)}px; " + "#{@float ? "float: #{@float};" : 'margin-left: auto; margin-right: auto'}"}) { @buttons.each { |btn| btn.to_html(doc) } } end |