Class: Tabster::Tab

Inherits:
Object
  • Object
show all
Defined in:
lib/tabster/tab.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ Tab

Returns a new instance of Tab.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tabster/tab.rb', line 11

def initialize(options = {}, &block)
  puts " SEGMENTS IN TAB: #{options.inspect}"

  if block_given?
    @tabs = TabSet.new
    puts "BLOCK: #{block.inspect}"
    yield @tabs
  end

  @path      = options[:path_to] || '/'
  @highlight = options[:highlights_on] || ''
  @priority  = options[:priority] || 1
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/tabster/tab.rb', line 4

def name
  @name
end

#pathObject

Returns the value of attribute path.



3
4
5
# File 'lib/tabster/tab.rb', line 3

def path
  @path
end

#tabsObject

Returns the value of attribute tabs.



5
6
7
# File 'lib/tabster/tab.rb', line 5

def tabs
  @tabs
end

Instance Method Details

#add_tab(name, options, &block) ⇒ Object



25
26
27
# File 'lib/tabster/tab.rb', line 25

def add_tab(name, options, &block)
  Tabnav.new.add_tab(name, options, &block)
end

#extract_tabs(collection = []) ⇒ Object



29
30
31
32
# File 'lib/tabster/tab.rb', line 29

def extract_tabs(collection = [])
  return nil unless collection.is_a? Array
  collection.map { |item| self.new( { :title => item.title, :path => item.path }) }
end

#freezeObject



34
35
36
# File 'lib/tabster/tab.rb', line 34

def freeze
  self
end