Class: Saxerator::Latches::Within

Inherits:
Nokogiri::XML::SAX::Document
  • Object
show all
Defined in:
lib/saxerator/latches/within.rb

Instance Method Summary collapse

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



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

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

#open?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/saxerator/latches/within.rb', line 21

def open?
  @depth_within_element > 1
end

#start_element(name, _) ⇒ Object



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

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