Class: Cauldron::Caret

Inherits:
Object
  • Object
show all
Defined in:
lib/cauldron/caret.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCaret

Returns a new instance of Caret.



8
9
10
11
# File 'lib/cauldron/caret.rb', line 8

def initialize
  @total_lines, @current_depth = 0, 0 #,@line = 0, 0, 0
  @lines = { 0 => 0}
end

Instance Attribute Details

#current_depthObject (readonly)

attr_reader :line, :depth, :total_line



6
7
8
# File 'lib/cauldron/caret.rb', line 6

def current_depth
  @current_depth
end

#total_linesObject (readonly)

attr_reader :line, :depth, :total_line



6
7
8
# File 'lib/cauldron/caret.rb', line 6

def total_lines
  @total_lines
end

Instance Method Details

#add_line(depth) ⇒ Object

TODO This approach will need re-worked to support nesting - in and out



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cauldron/caret.rb', line 14

def add_line(depth)
  unless @lines.has_key?(depth)
    @lines[depth] = 0
  end

  @total_lines += 1
  if @current_depth != depth
    @current_depth = depth
  else
    @lines[depth] += 1
  end

end

#lineObject



32
33
34
# File 'lib/cauldron/caret.rb', line 32

def line
  @lines[@current_depth]
end

#pointObject



28
29
30
# File 'lib/cauldron/caret.rb', line 28

def point
  
end

#return_depth(depth) ⇒ Object



44
45
46
# File 'lib/cauldron/caret.rb', line 44

def return_depth(depth)
  @current_depth = depth
end

#step_inObject



36
37
38
39
40
41
42
# File 'lib/cauldron/caret.rb', line 36

def step_in
  @current_depth += 1
  unless @lines.has_key?(@current_depth)
    @lines[@current_depth] = 0
  end      
  #@line = 0
end