Module: Ritsu::BlockMixin

Included in:
Block, Template
Defined in:
lib/ritsu/block.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contentsObject

Returns the value of attribute contents.



10
11
12
# File 'lib/ritsu/block.rb', line 10

def contents
  @contents
end

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/ritsu/block.rb', line 9

def id
  @id
end

#indent_lengthObject

Returns the value of attribute indent_length.



13
14
15
# File 'lib/ritsu/block.rb', line 13

def indent_length
  @indent_length
end

#indent_levelObject

Returns the value of attribute indent_level.



12
13
14
# File 'lib/ritsu/block.rb', line 12

def indent_level
  @indent_level
end

#local_indentationObject

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_lineObject



33
34
35
# File 'lib/ritsu/block.rb', line 33

def add_new_line
  add_line("")
end

#block_structure?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/ritsu/block.rb', line 64

def block_structure?
  true
end

#clear_contentsObject



52
53
54
# File 'lib/ritsu/block.rb', line 52

def clear_contents
  contents.clear
end

#indentObject



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, options={})
  options = {
    :contents => [],
    :local_indentation => "", 
    :indent_length=>4
  }.merge(options)
  
  @id = id
  @contents = options[:contents]
  @local_indentation = options[:local_indentation]
  @indent_length = options[:indent_length]
  @indent_level = 0
end

#outdentObject



60
61
62
# File 'lib/ritsu/block.rb', line 60

def outdent
  @indent_level -= 1
end