Module: Raudi::Source::Block

Included in:
Base
Defined in:
lib/raudi/source/block.rb

Instance Method Summary collapse

Instance Method Details

#block_inObject



30
31
32
33
# File 'lib/raudi/source/block.rb', line 30

def block_in
  code_line '{', skip_semicolon: true 
  self.indent_count += 1
end

#block_outObject



35
36
37
38
# File 'lib/raudi/source/block.rb', line 35

def block_out
  self.indent_count -= 1
  code_line '}', skip_semicolon: true
end

#code_block(header) ⇒ Object



7
8
9
10
11
12
# File 'lib/raudi/source/block.rb', line 7

def code_block(header)
  code_line header, skip_semicolon: true
  block_in
  yield if block_given?
  block_out 
end

#indent_countObject



14
15
16
# File 'lib/raudi/source/block.rb', line 14

def indent_count
  @indent_count || reset_indent_count
end

#indent_count=(value) ⇒ Object



18
19
20
# File 'lib/raudi/source/block.rb', line 18

def indent_count=(value)
  @indent_count = value unless value < 0
end

#indent_lineObject



26
27
28
# File 'lib/raudi/source/block.rb', line 26

def indent_line
  "  " * indent_count 
end

#reset_indent_countObject



22
23
24
# File 'lib/raudi/source/block.rb', line 22

def reset_indent_count
  @indent_count = 0
end