Class: Saxerator::Latches::Within

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

Instance Method Summary collapse

Methods inherited from SaxHandler

#characters

Constructor Details

#initialize(name) ⇒ Within

Returns a new instance of Within.



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

def initialize(name)
  @name = name
  @depth_within_element = 0
end

Instance Method Details

#end_element(_) ⇒ Object



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

def end_element(_)
  @depth_within_element -= 1 if @depth_within_element > 0
end

#open?Boolean

Returns:

  • (Boolean)


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

def open?
  @depth_within_element > 1
end

#start_element(name, _) ⇒ Object



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

def start_element(name, _)
  @depth_within_element += 1 if name == @name || @depth_within_element > 0
end