module Trivet::Querier

This module provides the query_first() method for Trivet::Node and Trivet::Document.

Public Instance Methods

query_first(qobj, opts={}) { |node| ... } click to toggle source

Works like query(), but only returns/yields the first find.

# File lib/trivet.rb, line 46
def query_first(qobj, opts={})
        # run a query
        query(qobj, opts) do |node|
                # yield
                if block_given?
                        yield node
                end
                
                # return
                return node
        end
        
        # didn't find any such node
        return nil
end