<commit_before>module Browser; module DOM

class NodeSet
  attr_reader :document

  def initialize(document, list = [])
    @document = document
    @literal  = []

    list.each {|el|
      if NodeSet === el
        @literal.concat(el.to_a)
      else
        @literal.push DOM(Native.convert(el))
      end
    }
  end

  def method_missing(name, *args, &block)
    unless @literal.respond_to? name
      each {|el|
        el.__send__(name, *args, &block)
      }

      return self
    end

    result = @literal.__send__ name, *args, &block

    if `result === #@literal`
      self
    elsif Array === result
      NodeSet.new(@document, result)
    else
      result
    end
  end

  def dup
    NodeSet.new(document, to_ary.dup)
  end

  def filter(expression)
    NodeSet.new(document, @internal.select { |node| node.matches?(expression) })
  end

  def after(node)
    last.after node
  end

  def at(path)
    raise NotImplementedError
  end

  def at_css(*rules)
    raise NotImplementedError
  end

  def at_xpath(*paths)
    raise NotImplementedError
  end

  def before
    first.before
  end

  def children
    result = NodeSet.new(document)

    each { |n| result.concat(n.children) }

    result
  end

  def css(*paths)
    raise NotImplementedError
  end

  def search(*what)
    map { |n| n.search(*what) }.flatten.uniq
  end

  def inspect
    "#<DOM::NodeSet: #{@internal.inspect[1 .. -2]}"
  end
end
<commit_msg>dom/node_set: forgot to rename some ivars<commit_after>module Browser; module DOM

class NodeSet
  attr_reader :document

  def initialize(document, list = [])
    @document = document
    @literal  = []

    list.each {|el|
      if NodeSet === el
        @literal.concat(el.to_a)
      else
        @literal.push DOM(Native.convert(el))
      end
    }
  end

  def method_missing(name, *args, &block)
    unless @literal.respond_to? name
      each {|el|
        el.__send__(name, *args, &block)
      }

      return self
    end

    result = @literal.__send__ name, *args, &block

    if `result === #@literal`
      self
    elsif Array === result
      NodeSet.new(@document, result)
    else
      result
    end
  end

  def dup
    NodeSet.new(document, to_ary.dup)
  end

  def filter(expression)
    NodeSet.new(document, @literal.select { |node| node.matches?(expression) })
  end

  def after(node)
    last.after node
  end

  def at(path)
    raise NotImplementedError
  end

  def at_css(*rules)
    raise NotImplementedError
  end

  def at_xpath(*paths)
    raise NotImplementedError
  end

  def before
    first.before
  end

  def children
    result = NodeSet.new(document)

    each { |n| result.concat(n.children) }

    result
  end

  def css(*paths)
    raise NotImplementedError
  end

  def search(*what)
    map { |n| n.search(*what) }.flatten.uniq
  end

  def inspect
    "#<DOM::NodeSet: #{@literal.inspect[1 .. -2]}"
  end
end

{'fraction_non_alphanumeric': 0.10896551724137932, 'fraction_numerical': 0.001379310344827586, 'mean_word_length': 2.4659498207885306, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2240330', 'n_tokens_mistral': 1005, 'n_tokens_neox': 967, 'n_words': 249}