class Ldpath::Selector

Public Instance Methods

evaluate(program, uris, context) { |x| ... } click to toggle source
# File lib/ldpath/selectors.rb, line 3
def evaluate(program, uris, context)
  return to_enum(:evaluate, program, uris, context) unless block_given?
  enum_wrap(uris).map do |uri|
    loading program, uri, context
    enum_flatten_one(evaluate_one(uri, context)).each do |x|
      yield x unless x.nil?
    end
  end
end
loading(program, uri, context) click to toggle source
# File lib/ldpath/selectors.rb, line 13
def loading(program, uri, context)
  program.loading uri, context
end

Protected Instance Methods

enum_flatten_one(object) { |v| ... } click to toggle source
# File lib/ldpath/selectors.rb, line 33
def enum_flatten_one(object)
  return to_enum(:enum_flatten_one, object) unless block_given?

  enum_wrap(object).each do |e|
    enum_wrap(e).each do |v|
      yield v
    end
  end
end
enum_wrap(object) click to toggle source
# File lib/ldpath/selectors.rb, line 19
def enum_wrap(object)
  if object.nil?
    []
  elsif object.respond_to?(:to_ary)
    object.to_ary || [object]
  elsif object.is_a? Hash
    [object]
  elsif object.is_a? Enumerable
    object
  else
    [object]
  end
end