Class: RbbtRESTHelpers::Tabs

Inherits:
Object
  • Object
show all
Defined in:
lib/rbbt/rest/common/tabs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page) ⇒ Tabs

Returns a new instance of Tabs.



5
6
7
# File 'lib/rbbt/rest/common/tabs.rb', line 5

def initialize(page)
  @page = page
end

Instance Attribute Details

#classesObject

Returns the value of attribute classes.



4
5
6
# File 'lib/rbbt/rest/common/tabs.rb', line 4

def classes
  @classes
end

#codesObject

Returns the value of attribute codes.



4
5
6
# File 'lib/rbbt/rest/common/tabs.rb', line 4

def codes
  @codes
end

#contentObject

Returns the value of attribute content.



4
5
6
# File 'lib/rbbt/rest/common/tabs.rb', line 4

def content
  @content
end

#headersObject

Returns the value of attribute headers.



4
5
6
# File 'lib/rbbt/rest/common/tabs.rb', line 4

def headers
  @headers
end

#tab_classesObject

Returns the value of attribute tab_classes.



4
5
6
# File 'lib/rbbt/rest/common/tabs.rb', line 4

def tab_classes
  @tab_classes
end

Instance Method Details

#active(header = nil) ⇒ Object



26
27
28
# File 'lib/rbbt/rest/common/tabs.rb', line 26

def active(header=nil)
  @active ||= header.nil? ? false : header 
end

#add(header = nil, code = nil, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rbbt/rest/common/tabs.rb', line 9

def add(header = nil, code = nil, &block)
  
  @headers ||= []
  @codes ||= {}
  @content ||= {}

  if block_given? 
    html = @page.capture_haml &block
  else
    html = nil
  end

  @headers << header
  @codes[header] = code.to_s if code
  @content[header] = html
end