Class: BEL::Resource::Namespace

Inherits:
Object
  • Object
show all
Includes:
ConceptScheme
Defined in:
lib/bel/resource/namespace.rb

Overview

Namespace represents a NamespaceConceptScheme RDF Resource and associated properties.

Constant Summary collapse

DC =
RDF::Vocab::DC
SKOS =
RDF::Vocab::SKOS
BELV =
RDF::Vocabulary.new('http://www.openbel.org/vocabulary/')

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ConceptScheme

#domain, #pref_label, #prefix, #type

Constructor Details

#initialize(rdf_repository, uri) ⇒ Namespace

Returns a new instance of Namespace.



19
20
21
22
23
24
25
26
27
# File 'lib/bel/resource/namespace.rb', line 19

def initialize(rdf_repository, uri)
  @rdf_repository = rdf_repository
  @uri            = RDF::URI(uri.to_s)
  @uri_hash       = @uri.hash
  @concept_query  = [
    :predicate => SKOS.inScheme,
    :object    => @uri
  ]
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



13
14
15
# File 'lib/bel/resource/namespace.rb', line 13

def uri
  @uri
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



49
50
51
52
# File 'lib/bel/resource/namespace.rb', line 49

def ==(other)
  return false if other == nil
  @uri == other.uri
end

#eachObject



29
30
31
32
33
34
35
# File 'lib/bel/resource/namespace.rb', line 29

def each
  return to_enum(:each) unless block_given?
				@rdf_repository.
					query(@concept_query) { |solution|
yield NamespaceValue.new(@rdf_repository, solution.subject)
					}
end

#find(*values) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/bel/resource/namespace.rb', line 37

def find(*values)
     return to_enum(:find, *values) unless block_given?

     values.flatten.each do |v|
       yield find_value(v)
	end
end

#hashObject



45
46
47
# File 'lib/bel/resource/namespace.rb', line 45

def hash
  @uri_hash
end