Class: Radiant::AdminUI::TabSet

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/radiant/admin_ui.rb

Instance Method Summary collapse

Constructor Details

#initializeTabSet

Returns a new instance of TabSet.



27
28
29
# File 'lib/radiant/admin_ui.rb', line 27

def initialize
  @tabs = []
end

Instance Method Details

#[](index) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/radiant/admin_ui.rb', line 57

def [](index)
  if index.kind_of? Integer
    @tabs[index]
  else
    @tabs.find { |tab| tab.name == index }
  end
end

#add(name, url, options = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/radiant/admin_ui.rb', line 31

def add(name, url, options = {})
  options.symbolize_keys!
  before = options.delete(:before)
  after = options.delete(:after)
  tab_name = before || after
  if self[name]
    raise DuplicateTabNameError.new("duplicate tab name `#{name}'")
  else
    if tab_name
      index = @tabs.index(self[tab_name])
      index += 1 if before.nil?
      @tabs.insert(index, Tab.new(name, url, options))
    else
      @tabs << Tab.new(name, url, options)
    end
  end
end

#clearObject



69
70
71
# File 'lib/radiant/admin_ui.rb', line 69

def clear
  @tabs.clear
end

#eachObject



65
66
67
# File 'lib/radiant/admin_ui.rb', line 65

def each
  @tabs.each { |t| yield t }
end

#remove(name) ⇒ Object



49
50
51
# File 'lib/radiant/admin_ui.rb', line 49

def remove(name)
  @tabs.delete(self[name])
end

#sizeObject



53
54
55
# File 'lib/radiant/admin_ui.rb', line 53

def size
  @tabs.size
end