class PostRunner::NavButtonRow

A NavButtonRow is a row of buttons used to navigate between HTML pages.

Public Class Methods

new(float = nil) click to toggle source

Create a new NavButtonRow object. @param float [String, Nil] specifies if the HTML representation should be a floating object that floats left or right.

# 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

Public Instance Methods

addButton(icon, url = nil) click to toggle source

Add a new button to the NavButtonRow object. @param icon [String] File name of the icon file @param url [String] URL of the page to change to

# File lib/postrunner/NavButtonRow.rb, line 66
def addButton(icon, url = nil)
  @buttons << Button.new(icon, url)
end
to_html(doc) click to toggle source

Add the object as HTML Elements to the document. @param doc [HTMLBuilder] XML Document

# 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

Private Instance Methods

style() click to toggle source
# File lib/postrunner/NavButtonRow.rb, line 86
    def style
      <<"EOT"
.nav_button_row {
  padding: 3px 30px;
}
.active_button {
  padding: 5px;
}
.inactive_button {
  padding: 5px;
  opacity: 0.4;
}
EOT
    end