Class: BitBar::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/bitbar/base.rb

Direct Known Subclasses

Item, Menu

Instance Method Summary collapse

Constructor Details

#initialize(indent_level = -1,, &block) ⇒ Base

Returns a new instance of Base.



3
4
5
6
7
# File 'lib/bitbar/base.rb', line 3

def initialize(indent_level = -1, &block)
  @indent_level = indent_level
  @output = []
  instance_eval(&block) if block
end

Instance Method Details

#item(*args, &block) ⇒ Object



13
14
15
# File 'lib/bitbar/base.rb', line 13

def item(*args, &block)
  @output << Item.new(@indent_level + 1, *args, &block)
end

#separatorObject



9
10
11
# File 'lib/bitbar/base.rb', line 9

def separator
  @output << Separator.new(@indent_level + 1)
end

#to_sObject



17
18
19
# File 'lib/bitbar/base.rb', line 17

def to_s
  @output.map(&:to_s).join("\r\n")
end