Class: Datagraph::Query

Inherits:
Resource show all
Defined in:
lib/datagraph/query.rb

Overview

Represents a Datagraph.org SPARQL query.

Constant Summary

SPEC =

/account/repository/query

%r(^([^/\.]+)/([^/\.]+)/([^/\.]+)$)

Constants inherited from Resource

HEADERS

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Resource

#<=>, #eql?, #exists?, #get, #head, #inspect, #inspect!, new, #to_rdf, #to_uri

Constructor Details

- (Query) initialize(repository_name, name)

A new instance of Query

Parameters:

  • (String, #to_s) repository_name
  • (String, #to_s) name


13
14
15
16
17
18
19
20
# File 'lib/datagraph/query.rb', line 13

def initialize(repository_name, name)
  @repository = case repository_name
    when Repository then repository_name
    else Repository.new(*repository_name.to_s.split('/'))
  end
  @name = name.to_s
  super(Datagraph::URL.join(path))
end

Instance Attribute Details

- (Object) name (readonly)

Returns the value of attribute name



8
9
10
# File 'lib/datagraph/query.rb', line 8

def name
  @name
end

- (Object) repository (readonly)

Returns the value of attribute repository



7
8
9
# File 'lib/datagraph/query.rb', line 7

def repository
  @repository
end

Instance Method Details

- (Object) path

Returns the path spec of this query.



24
25
26
# File 'lib/datagraph/query.rb', line 24

def path
  [repository.to_s, name].join('/')
end

- (Object) to_s

Returns a string representation of the query name.



30
31
32
# File 'lib/datagraph/query.rb', line 30

def to_s
  path
end