Module: Indentation

Included in:
Hue::Bridge, Hue::Bulb
Defined in:
lib/utilities/indentation.rb

Constant Summary collapse

DEFAULT_INDENTATION_SIZE =
2
@@indentation_size =
0
@@indentation_char =
' '
@@indentation_level =
0

Instance Method Summary collapse

Instance Method Details

#indent(size = DEFAULT_INDENTATION_SIZE, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/utilities/indentation.rb', line 7

def indent(size = DEFAULT_INDENTATION_SIZE, &block)
  original_size = @@indentation_size
  @@indentation_size = size
  @@indentation_level += 1
  yield
ensure
  @@indentation_size = original_size
  @@indentation_level -= 1
end

#puts(*message) ⇒ Object



17
18
19
20
21
22
# File 'lib/utilities/indentation.rb', line 17

def puts(*message)
  message.each do |line|
    print(@@indentation_char * @@indentation_size * @@indentation_level)
    super(line)
  end
end