Class: Toolsmith::Views::PageHeader

Inherits:
Base
  • Object
show all
Defined in:
lib/toolsmith/views/page_header.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#context

Instance Method Summary collapse

Methods inherited from Base

#content_tag

Constructor Details

#initialize(context, title, *args) ⇒ PageHeader

Returns a new instance of PageHeader.



6
7
8
9
10
11
12
# File 'lib/toolsmith/views/page_header.rb', line 6

def initialize(context, title, *args)
  super(context)

  @options = args.extract_options!
  @title = title
  @subtitle = args.first
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/toolsmith/views/page_header.rb', line 4

def options
  @options
end

#subtitleObject

Returns the value of attribute subtitle.



4
5
6
# File 'lib/toolsmith/views/page_header.rb', line 4

def subtitle
  @subtitle
end

#titleObject

Returns the value of attribute title.



4
5
6
# File 'lib/toolsmith/views/page_header.rb', line 4

def title
  @title
end

Instance Method Details

#button(options) ⇒ Object



14
15
16
17
# File 'lib/toolsmith/views/page_header.rb', line 14

def button(options)
  [:title, :icon, :path].each { |param| missing_parameter(param, options) }
  buttons << options
end

#button_markup(options) ⇒ Object



19
20
21
22
23
24
# File 'lib/toolsmith/views/page_header.rb', line 19

def button_markup(options)
  anchor_options = options.fetch(:anchor, {})
  context.link_to options[:path], anchor_options.merge(class: "btn"), title: options[:title] do
     :i, "", class: "icon-#{options[:icon]}"
  end
end

#buttonsObject



26
27
28
# File 'lib/toolsmith/views/page_header.rb', line 26

def buttons
  @buttons ||= []
end

#full_titleObject



30
31
32
# File 'lib/toolsmith/views/page_header.rb', line 30

def full_title
  subtitle ? "#{ERB::Util.h(title)} #{(:small, self.subtitle)}".html_safe : ERB::Util.h(title)
end

#to_sObject



34
35
36
# File 'lib/toolsmith/views/page_header.rb', line 34

def to_s
   :div, h1_tag, class: "page-header"
end