Class: RoadForest::SourceRigor::ResourceQuery

Inherits:
RDF::Query
  • Object
show all
Defined in:
lib/roadforest/source-rigor/resource-query.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(patterns = [], options = {}, &block) ⇒ ResourceQuery

Returns a new instance of ResourceQuery.



6
7
8
9
10
11
12
13
14
15
# File 'lib/roadforest/source-rigor/resource-query.rb', line 6

def initialize(patterns = [], options = {}, &block)
  @subject_context = options[:subject_context]
  @source_rigor = options[:source_rigor]
  super
  patterns = @patterns.dup
  @patterns.clear
  patterns.each do |pattern|
    pattern(pattern)
  end
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



18
19
20
# File 'lib/roadforest/source-rigor/resource-query.rb', line 18

def options
  @options
end

#patternsObject

Returns the value of attribute patterns.



18
19
20
# File 'lib/roadforest/source-rigor/resource-query.rb', line 18

def patterns
  @patterns
end

#solutionsObject

Returns the value of attribute solutions.



18
19
20
# File 'lib/roadforest/source-rigor/resource-query.rb', line 18

def solutions
  @solutions
end

#source_rigorObject

Returns the value of attribute source_rigor.



17
18
19
# File 'lib/roadforest/source-rigor/resource-query.rb', line 17

def source_rigor
  @source_rigor
end

#subject_contextObject

Returns the value of attribute subject_context.



17
18
19
# File 'lib/roadforest/source-rigor/resource-query.rb', line 17

def subject_context
  @subject_context
end

#variablesObject

Returns the value of attribute variables.



18
19
20
# File 'lib/roadforest/source-rigor/resource-query.rb', line 18

def variables
  @variables
end

Class Method Details

.from(other, subject_context = nil, source_rigor = nil) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/roadforest/source-rigor/resource-query.rb', line 34

def self.from(other, subject_context = nil, source_rigor = nil)
  query = self.new

  if subject_context.nil? and other.respond_to?(:subject_context)
    query.subject_context = other.subject_context
  else
    query.subject_context = subject_context
  end

  if source_rigor.nil? and other.respond_to?(:source_rigor)
    query.source_rigor = other.source_rigor
  else
    query.source_rigor = source_rigor
  end

  other.patterns.each do |pattern|
    query.pattern(pattern)
  end
  query.variables = other.variables
  query.solutions = other.solutions
  query.options = other.options
  return query
end

Instance Method Details

#<<(pattern) ⇒ Object



20
21
22
# File 'lib/roadforest/source-rigor/resource-query.rb', line 20

def <<(pattern)
  pattern(pattern)
end

#pattern(pattern, options = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/roadforest/source-rigor/resource-query.rb', line 24

def pattern(pattern, options = nil)
  options = {
    :context_roles => {:subject => subject_context},
    :source_rigor => source_rigor
  }.merge(options || {})

  @patterns << ResourcePattern.from(pattern, options)
  self
end