module Saxerator::DSL
Public Instance Methods
at_depth(depth)
click to toggle source
# File lib/saxerator/dsl.rb, line 12 def at_depth(depth) specify Latches::AtDepth.new(depth.to_i) end
child_of(tag)
click to toggle source
# File lib/saxerator/dsl.rb, line 20 def child_of(tag) specify Latches::ChildOf.new(tag.to_s) end
for_tag(*tags)
click to toggle source
# File lib/saxerator/dsl.rb, line 3 def for_tag(*tags) for_tags(tags) end
with_attribute(name, value = nil)
click to toggle source
# File lib/saxerator/dsl.rb, line 24 def with_attribute(name, value = nil) specify Latches::WithAttributes.new(name.to_s => !value.nil? ? value.to_s : nil) end
with_attributes(attrs)
click to toggle source
# File lib/saxerator/dsl.rb, line 28 def with_attributes(attrs) if attrs.is_a? Array attrs = Hash[attrs.map { |k| [k, nil] }] elsif attrs.is_a? Hash attrs = Hash[attrs.map { |k, v| [k.to_s, v ? v.to_s : v] }] else raise ArgumentError, 'attributes should be a Hash or Array' end specify Latches::WithAttributes.new(attrs) end
within(tag)
click to toggle source
# File lib/saxerator/dsl.rb, line 16 def within(tag) specify Latches::Within.new(tag.to_s) end
Private Instance Methods
specify(predicate)
click to toggle source
# File lib/saxerator/dsl.rb, line 41 def specify(predicate) DocumentFragment.new(@source, @config, @latches + [predicate]) end