Class: OWL::ObjectProperty

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

Overview

Resembles a property in OWL context.

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, #resources_for_property, #stripped_uri, #types

Constructor Details

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

Creates a new OWL::Class.

parameters:

1  resource ( RDFS::Resource or URI )
2  options ( Hash; )


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

def initialize( resource, options={} )
  @@log.deep "Formulating new OWL::ObjectProperty #{resource} from #{resource.class}"
  @uri = case resource
  when OWL::ObjectProperty
    @@log.warn "Redundant new OWL::ObjectProperty, 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.



8
9
10
# File 'lib/objectmanager/owl/object_property.rb', line 8

def class_uri
  @class_uri
end

Instance Attribute Details

#uriObject (readonly)

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



12
13
14
# File 'lib/objectmanager/owl/object_property.rb', line 12

def uri
  @uri
end

Class Method Details

.==(other) ⇒ Object



44
45
46
# File 'lib/objectmanager/owl/object_property.rb', line 44

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

.uriObject



43
# File 'lib/objectmanager/owl/object_property.rb', line 43

def self.uri; class_uri.uri; end

Instance Method Details

#domainObject

returns the resources that are a domain for the given ObjectProperty



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

def domain
  begin
    if @domain.nil?
      @domain = ActiveRubic::Base.query(
        Query.new.distinct( :domain ).where( :domain, self, :any ) )
    end
    return @domain
  rescue
    @@log.error $!
  end
end

#inverseObject Also known as: inverse_of

returns the inverse of the given bidirectional ObjectProperty



53
54
55
56
57
58
59
60
# File 'lib/objectmanager/owl/object_property.rb', line 53

def inverse
  if @inverse.nil?
    # ActiveRubic always returns values in an Array, but a property
    # can have only one inverse values.
    @inverse = ActiveRubic::Base.find( :inverse, :property => self ).first
  end
  return @inverse
end

#rangeObject

returns the resources that are in the range of the given ObjectProperty



77
78
79
80
81
82
83
84
85
86
# File 'lib/objectmanager/owl/object_property.rb', line 77

def range
  begin
    if @range.nil?
      @range = ActiveRubic::Base.find( :within_range, :property => self )
    end
    return @range
  rescue
    @@log.error $!
  end
end