Module: Raudi::Source::Block
- Included in:
- Base
- Defined in:
- lib/raudi/source/block.rb
Instance Method Summary collapse
- #block_in ⇒ Object
- #block_out ⇒ Object
- #code_block(header) ⇒ Object
- #indent_count ⇒ Object
- #indent_count=(value) ⇒ Object
- #indent_line ⇒ Object
- #reset_indent_count ⇒ Object
Instance Method Details
#block_in ⇒ Object
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_out ⇒ Object
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_count ⇒ Object
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_line ⇒ Object
26 27 28 |
# File 'lib/raudi/source/block.rb', line 26 def indent_line " " * indent_count end |
#reset_indent_count ⇒ Object
22 23 24 |
# File 'lib/raudi/source/block.rb', line 22 def reset_indent_count @indent_count = 0 end |