Class: OWL::Thing

Inherits:
RDFS::Resource show all
Defined in:
lib/objectmanager/owl/thing.rb

Overview

Resembles the ontology root.

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RDFS::Resource

#ancestors, #geopoint, #geopoints, #gmarker, #is_class?, #is_image?, #is_mappable?, #is_property?, #latitude, #localname, #longitude, #parents, #properties, #range, #resources_for_property, #stripped_uri, #types

Constructor Details

#initialize(resource, options = {}) ⇒ Thing

Creates a new OWL::Thing.

parameters:

1  resource ( RDFS::Resource or URI String )


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/objectmanager/owl/thing.rb', line 21

def initialize( resource, options={} )
  @@log.deep "Formulating new Owl::Thing #{resource} from #{resource.class}"
  @uri = case resource
  when OWL::Thing
    @@log.warn "Redundant new OWL::Thing, resource already was one."
    resource.uri
  when RDFS::Resource
    resource.uri
  when String
    resource
  else
    raise ActiveRdfError, "Resource #{resource} (#{resource.class}) is improperly formulated"
    return nil
  end

#       @data_stores = options[ :from ] || RUBIC_DATASTORES
#       @predicates = Hash.new
end

Class Attribute Details

.class_uriObject

Returns the value of attribute class_uri.



11
12
13
# File 'lib/objectmanager/owl/thing.rb', line 11

def class_uri
  @class_uri
end

Instance Attribute Details

#uriObject (readonly)

uri of the resource (for instances of this class: rdf resources)



15
16
17
# File 'lib/objectmanager/owl/thing.rb', line 15

def uri
  @uri
end

Class Method Details

.==(other) ⇒ Object



46
47
48
# File 'lib/objectmanager/owl/thing.rb', line 46

def self.==(other)
  other.respond_to?(:uri) ? other.uri == self.uri : false
end

.uriObject



45
# File 'lib/objectmanager/owl/thing.rb', line 45

def self.uri; class_uri.uri; end

Instance Method Details

#labelObject Also known as: labelize

return the localname as label



55
56
57
58
# File 'lib/objectmanager/owl/thing.rb', line 55

def label
  @label = Namespace.localname( self.uri ).capitalize
  return @label
end

#rootsObject

the roots of the ontology (only available from Jena)



62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/objectmanager/owl/thing.rb', line 62

def roots
  begin
    if @roots.nil? then
      @roots = Array.new
      ActiveRubic::Base.find( :roots, :ontology => self.uri ).each do |root|
        @roots << OwlClass.new( root )
      end
    end
    return @roots
  
  rescue
    return Array.new
  end
end