Class: Cauldron::Caret
- Inherits:
-
Object
- Object
- Cauldron::Caret
- Defined in:
- lib/cauldron/caret.rb
Instance Attribute Summary collapse
-
#current_depth ⇒ Object
readonly
attr_reader :line, :depth, :total_line.
-
#total_lines ⇒ Object
readonly
attr_reader :line, :depth, :total_line.
Instance Method Summary collapse
-
#add_line(depth) ⇒ Object
TODO This approach will need re-worked to support nesting - in and out.
-
#initialize ⇒ Caret
constructor
A new instance of Caret.
- #line ⇒ Object
- #point ⇒ Object
- #return_depth(depth) ⇒ Object
- #step_in ⇒ Object
Constructor Details
#initialize ⇒ Caret
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_depth ⇒ Object (readonly)
attr_reader :line, :depth, :total_line
6 7 8 |
# File 'lib/cauldron/caret.rb', line 6 def current_depth @current_depth end |
#total_lines ⇒ Object (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 |
#line ⇒ Object
32 33 34 |
# File 'lib/cauldron/caret.rb', line 32 def line @lines[@current_depth] end |
#point ⇒ Object
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_in ⇒ Object
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 |