Module: Ritsu::BlockMixin
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#indent_length ⇒ Object
Returns the value of attribute indent_length.
-
#indent_level ⇒ Object
Returns the value of attribute indent_level.
-
#local_indentation ⇒ Object
Returns the value of attribute local_indentation.
Instance Method Summary collapse
- #add_line(line) ⇒ Object
- #add_new_line ⇒ Object
- #block_structure? ⇒ Boolean
- #clear_contents ⇒ Object
- #indent ⇒ Object
- #initialize_block_mixin(id = nil, options = {}) ⇒ Object
- #outdent ⇒ Object
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
10 11 12 |
# File 'lib/ritsu/block.rb', line 10 def contents @contents end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/ritsu/block.rb', line 9 def id @id end |
#indent_length ⇒ Object
Returns the value of attribute indent_length.
13 14 15 |
# File 'lib/ritsu/block.rb', line 13 def indent_length @indent_length end |
#indent_level ⇒ Object
Returns the value of attribute indent_level.
12 13 14 |
# File 'lib/ritsu/block.rb', line 12 def indent_level @indent_level end |
#local_indentation ⇒ Object
Returns the value of attribute local_indentation.
11 12 13 |
# File 'lib/ritsu/block.rb', line 11 def local_indentation @local_indentation end |
Instance Method Details
#add_line(line) ⇒ Object
29 30 31 |
# File 'lib/ritsu/block.rb', line 29 def add_line(line) contents << " " * (indent_level * indent_length) + line end |
#add_new_line ⇒ Object
33 34 35 |
# File 'lib/ritsu/block.rb', line 33 def add_new_line add_line("") end |
#block_structure? ⇒ Boolean
64 65 66 |
# File 'lib/ritsu/block.rb', line 64 def block_structure? true end |
#clear_contents ⇒ Object
52 53 54 |
# File 'lib/ritsu/block.rb', line 52 def clear_contents contents.clear end |
#indent ⇒ Object
56 57 58 |
# File 'lib/ritsu/block.rb', line 56 def indent @indent_level += 1 end |
#initialize_block_mixin(id = nil, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ritsu/block.rb', line 15 def initialize_block_mixin(id = nil, ={}) = { :contents => [], :local_indentation => "", :indent_length=>4 }.merge() @id = id @contents = [:contents] @local_indentation = [:local_indentation] @indent_length = [:indent_length] @indent_level = 0 end |
#outdent ⇒ Object
60 61 62 |
# File 'lib/ritsu/block.rb', line 60 def outdent @indent_level -= 1 end |