# File lib/scrubyt/core/scraping/pattern.rb, line 68
    def initialize(name, args=[], extractor=nil, parent=nil, &block)
      #init attributes
      @name = name
      @extractor = extractor
      @parent = parent
      @options = {}
      @children = []
      @filters = []
      @constraints = []
      @modifier_calls = []

      #grab any examples that are defined
      examples = look_for_examples(args)

      #parse the options hash if provided
      parse_options_hash(args[-1]) if args[-1].is_a? Hash

      #perform checks for special cases
      examples = check_if_shortcut_pattern() if examples == nil
      check_if_detail_page(block)
      @options[:output_type] = :page_list if name == 'page_list'

      #create filters
      if examples == nil
        @filters << Scrubyt::BaseFilter.create(self) #create a default filter
      else
        examples.each do |example|
          @filters << Scrubyt::BaseFilter.create(self,example) #create a filter
        end
      end

      #by default, generalize the root pattern, but only in the case if
      #@generalize was not set up explicitly
      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 if available
      parse_child_patterns(&block) if ( !block.nil? && type != :detail_page )

      #tree pattern only (TODO: subclass?)
      if type == :tree
        #generate xpaths and regexps
        @filters.each do |filter|
          filter.generate_XPath_for_example(false) unless @name == 'next_page'
          filter.generate_regexp_for_example
        end
        #when the xpaths of this pattern have been created, its children can make their xpaths relative
        xpaths = @filters.collect { |filter| filter.xpath }
        @children.each do |child|
          child.generate_relative_XPaths xpaths
        end
      end
    end