class Saxerator::Latches::ChildOf
Public Class Methods
new(name)
click to toggle source
# File lib/saxerator/latches/child_of.rb, line 4 def initialize(name) @name = name @depths = [] end
Public Instance Methods
depth_within_element()
click to toggle source
# File lib/saxerator/latches/child_of.rb, line 28 def depth_within_element !@depths.empty? ? @depths[-1] : 0 end
end_element(_)
click to toggle source
# File lib/saxerator/latches/child_of.rb, line 14 def end_element(_) return unless depth_within_element > 0 increment_depth(-1) @depths.pop if @depths[-1].zero? end
increment_depth(amount)
click to toggle source
# File lib/saxerator/latches/child_of.rb, line 24 def increment_depth(amount) @depths.map! { |depth| depth + amount } end
open?()
click to toggle source
# File lib/saxerator/latches/child_of.rb, line 20 def open? depth_within_element == 2 end
start_element(name, _)
click to toggle source
# File lib/saxerator/latches/child_of.rb, line 9 def start_element(name, _) increment_depth(1) if depth_within_element > 0 @depths.push 1 if @name == name end