Class: Kin::Masthead::Builder

Inherits:
Object
  • Object
show all
Includes:
Merb::Helpers::Tag
Defined in:
lib/kin/masthead.rb

Overview

Most pages on Showcase have a masthead of some sort. The masthead fits beneath the main navigation and the page content. Typically it contains the page title and some other interesting information.

+--------+----------+---------+              +--------------------+
|  Sets  |  Search  |  Admin  |              |  Upload a new set  |
+--------+----------+---------+--------------+--------------------+
|  [Title]                                         [Right title]  |
|  [Subtitle]                                   [Right subtitle]  |
+-----------------------------------------------------------------+
|                                                                 |
|  Page contents                                                  |
|                                                                 |
+-----------------------------------------------------------------+

See the #masthead helper for more information on how to build a masthead.

Constant Summary collapse

CSS_CLASSES =
{
  :title          => ''.freeze,
  :subtitle       => 'subtitle'.freeze,
  :right_title    => 'main'.freeze,
  :right_subtitle => 'subtitle'.freeze
}.freeze

Instance Method Summary collapse

Constructor Details

#initializeBuilder

Creates a new masthead builder.



37
38
39
40
# File 'lib/kin/masthead.rb', line 37

def initialize
  @title = @right_title = @subtitle = @right_subtitle = nil
  @options = Hash.new { |hash, key| hash[key] = {} }
end

Instance Method Details

#build {|Kin::Nav::Builder| ... } ⇒ Kin::Nav::Builder

Builds a masthead.

Yields the builder instance providing a DSL for setting up the masthead as desired.

Yields:

Returns:



54
55
56
57
# File 'lib/kin/masthead.rb', line 54

def build
  yield self
  self
end

#right_subtitle(value = nil, options = nil) ⇒ String

Returns the current right subtitle title. If you supply a non-nil argument, the subtitle will be set to whatever is provided.

Parameters:

  • value (String) (defaults to: nil)

    The new right subtitle.

  • options (Hash) (defaults to: nil)

    A hash containing extraoptions.

Returns:

  • (String)

    The masthead right subtitle.



108
109
# File 'lib/kin/masthead.rb', line 108

def right_subtitle(value = nil, options = nil)
end

#right_title(value = nil, options = nil) ⇒ String

Returns the current right title. If you supply a non-nil argument, the right title will be set to whatever is provided.

Parameters:

  • value (String) (defaults to: nil)

    The new right title.

  • options (Hash) (defaults to: nil)

    A hash containing extraoptions.

Returns:

  • (String)

    The masthead right title.



82
83
# File 'lib/kin/masthead.rb', line 82

def right_title(value = nil, options = nil)
end

#subtitle(value = nil, options = nil) ⇒ String

Returns the current subtitle. If you supply a non-nil argument, the subtitle will be set to whatever is provided.

Parameters:

  • value (String) (defaults to: nil)

    The new subtitle.

  • options (Hash) (defaults to: nil)

    A hash containing extraoptions.

Returns:

  • (String)

    The masthead subtitle.



95
96
# File 'lib/kin/masthead.rb', line 95

def subtitle(value = nil, options = nil)
end

#title(value = nil, options = nil) ⇒ String

Returns the current title. If you supply a non-nil argument, the title will be set to whatever is provided.

Parameters:

  • value (String) (defaults to: nil)

    The new title.

  • options (Hash) (defaults to: nil)

    A hash containing extraoptions.

Returns:

  • (String)

    The masthead title.



69
70
# File 'lib/kin/masthead.rb', line 69

def title(value = nil, options = nil)
end

#to_htmlString

Returns the HTML representation of the masthead.

Returns:

  • (String)

    The masthead with all the various titles.



137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/kin/masthead.rb', line 137

def to_html
  "    <div id=\"masthead\">\n      <div class=\"details\">\n        \#{ formatted(:title, :h1) }\n        \#{ formatted(:subtitle) }\n      </div>\n\n      \#{ extras_as_html }\n    </div>\n  HTML\nend\n"