Class: PostRunner::NavButtonRow::Button

Inherits:
Object
  • Object
show all
Defined in:
lib/postrunner/NavButtonRow.rb

Overview

A class to store the icon and URL of a button in the NavButtonRow objects.

Instance Method Summary collapse

Constructor Details

#initialize(icon, url = nil) ⇒ Button

Create a Button object.

Parameters:

  • icon (String)

    File name of the icon file

  • url (String) (defaults to: nil)

    URL of the page to change to



32
33
34
35
# File 'lib/postrunner/NavButtonRow.rb', line 32

def initialize(icon, url = nil)
  @icon = icon
  @url = url
end

Instance Method Details

#to_html(doc) ⇒ Object

Add the object as HTML Elements to the document.

Parameters:



39
40
41
42
43
44
45
46
47
# File 'lib/postrunner/NavButtonRow.rb', line 39

def to_html(doc)
  if @url
    doc.a({ :href => @url }) {
      doc.img({ :src => "icons/#{@icon}", :class => 'active_button' })
    }
  else
    doc.img({ :src => "icons/#{@icon}", :class => 'inactive_button' })
  end
end