Module: OpenBEL::Storage::TripleStorage

Included in:
CacheProxy
Defined in:
lib/openbel/api/storage/triple_storage.rb

Instance Method Summary collapse

Instance Method Details

#all(statement) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/openbel/api/storage/triple_storage.rb', line 9

def all(statement)
  if statement.respond_to? :subject
    [
      statement.subject.to_s[1..-2],
      statement.predicate.to_s[1..-2],
      object(statement)
    ]
  else
    statement
  end
end

#object(statement) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/openbel/api/storage/triple_storage.rb', line 31

def object(statement)
  if statement.respond_to? :object
    object = statement.object
    (object.literal? && object.value.to_s) || object.to_s[1..-2]
  else
    statement[2]
  end
end

#predicate(statement) ⇒ Object



26
27
28
29
# File 'lib/openbel/api/storage/triple_storage.rb', line 26

def predicate(statement)
  return statement.predicate.to_s[1..-2] if statement.respond_to? :predicate
  statement[1]
end

#subject(statement) ⇒ Object



21
22
23
24
# File 'lib/openbel/api/storage/triple_storage.rb', line 21

def subject(statement)
  return statement.subject.to_s[1..-2] if statement.respond_to? :subject
  statement[0]
end

#triples(subject, predicate, object, options = {}) ⇒ Object



5
6
7
# File 'lib/openbel/api/storage/triple_storage.rb', line 5

def triples(subject, predicate, object, options={})
  fail NotImplementedError, "#{__method__} is not implemented"
end