Class: Dydra::Query

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

Overview

Represents a Dydra.com SPARQL query.

See Also:

Constant Summary

SPEC =

/account/repository/query

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

Constants inherited from Resource

Resource::HEADERS

Instance Attribute Summary (collapse)

Attributes inherited from Resource

#url

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:

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


24
25
26
27
28
29
30
31
# File 'lib/dydra/query.rb', line 24

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(Dydra::URL.join(path))
end

Instance Attribute Details

- (String) name (readonly)

The machine-readable name of the query.

Returns:

  • (String)


19
20
21
# File 'lib/dydra/query.rb', line 19

def name
  @name
end

- (Repository) repository (readonly)

The repository this query belongs to.

Returns:



13
14
15
# File 'lib/dydra/query.rb', line 13

def repository
  @repository
end

Instance Method Details

- (String) path

Returns the path spec of this query.

Returns:

  • (String)


37
38
39
# File 'lib/dydra/query.rb', line 37

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

- (String) to_s

Returns a string representation of the query name.

Returns:

  • (String)


45
46
47
# File 'lib/dydra/query.rb', line 45

def to_s
  path
end