Class: PostRunner::NavButtonRow

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(float = nil) ⇒ NavButtonRow

Create a new NavButtonRow object. be a floating object that floats left or right.

Parameters:

  • float (String, Nil) (defaults to: nil)

    specifies if the HTML representation should



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.

Parameters:

  • icon (String)

    File name of the icon file

  • url (String) (defaults to: nil)

    URL of the page to change to



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.

Parameters:



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