Class: Saxerator::Latches::AtDepth

Inherits:
SaxHandler show all
Defined in:
lib/saxerator/latches/at_depth.rb

Instance Method Summary collapse

Methods inherited from SaxHandler

#characters

Constructor Details

#initialize(depth) ⇒ AtDepth

Returns a new instance of AtDepth.



4
5
6
7
# File 'lib/saxerator/latches/at_depth.rb', line 4

def initialize(depth)
  @target_depth = depth
  @current_depth = -1
end

Instance Method Details

#end_element(_) ⇒ Object



13
14
15
# File 'lib/saxerator/latches/at_depth.rb', line 13

def end_element(_)
  @current_depth -= 1
end

#open?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/saxerator/latches/at_depth.rb', line 17

def open?
  @current_depth == @target_depth
end

#start_element(_, __) ⇒ Object



9
10
11
# File 'lib/saxerator/latches/at_depth.rb', line 9

def start_element(_, __)
  @current_depth += 1
end