def initialize(name, args=[], extractor=nil, parent=nil, &block)
@name = name
@extractor = extractor
@parent = parent
@options = {}
@children = []
@filters = []
@constraints = []
@modifier_calls = []
examples = look_for_examples(args)
parse_options_hash(args[-1]) if args[-1].is_a? Hash
examples = check_if_shortcut_pattern() if examples == nil
check_if_detail_page(block)
@options[:output_type] = :page_list if name == 'page_list'
if examples == nil
@filters << Scrubyt::BaseFilter.create(self)
else
examples.each do |example|
@filters << Scrubyt::BaseFilter.create(self,example)
end
end
if @options[:generalize].nil?
@options[:generalize] = true if parent.nil?
@options[:generalize] = false if ((filters[0].example.is_a? String) && (filters[0].example =~ /.+\[[a-zA-Z].+\]$/))
end
parse_child_patterns(&block) if ( !block.nil? && type != :detail_page )
if type == :tree
@filters.each do |filter|
filter.generate_XPath_for_example(false) unless @name == 'next_page'
filter.generate_regexp_for_example
end
xpaths = @filters.collect { |filter| filter.xpath }
@children.each do |child|
child.generate_relative_XPaths xpaths
end
end
end