Class: DOWL::Property

Inherits:
LabelledDocObject show all
Defined in:
lib/dowl/property.rb

Instance Attribute Summary

Attributes inherited from DocObject

#resource, #schema

Instance Method Summary collapse

Methods inherited from LabelledDocObject

#<=>, #comment, #label, #short_name, #status

Methods inherited from DocObject

#get_literal

Constructor Details

#initialize(resource, schema) ⇒ Property

Returns a new instance of Property.



7
8
9
# File 'lib/dowl/property.rb', line 7

def initialize(resource, schema)
  super(resource, schema)
end

Instance Method Details

#domainObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/dowl/property.rb', line 57

def domain()
  domains = []
  @schema.model.query(RDF::Query::Pattern.new( @resource, DOWL::Namespaces::RDFS.domain ) ) do |statement|
    domains << statement.object
  end  
  classes = []
  domains.each do |o|
    if o.resource?
      uri = o.to_s         
      if @schema.classes[uri]
        classes << @schema.classes[uri]
      else
        classes << uri
      end
    end
    #TODO union
  end
  return classes
end

#rangeObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/dowl/property.rb', line 38

def range()
  ranges = []
  @schema.model.query(RDF::Query::Pattern.new( @resource, DOWL::Namespaces::RDFS.range ) ) do |statement|
    ranges << statement.object
  end  
  classes = []
  ranges.each do |o|
    if o.resource?
      uri = o.to_s        
      if @schema.classes[uri]
        classes << @schema.classes[uri]
      else
        classes << uri
      end
    end
  end
  return classes
end

#see_alsosObject



15
16
17
18
19
20
21
22
# File 'lib/dowl/property.rb', line 15

def see_alsos()
   links = []
   @schema.model.query(
     RDF::Query::Pattern.new( @resource, DOWL::Namespaces::RDFS.seeAlso ) ) do |statement|
     links << statement.object.to_s
   end       
   return links
end

#sub_propertiesObject



77
78
79
80
81
82
83
# File 'lib/dowl/property.rb', line 77

def sub_properties()
  list = []
  @schema.model.query(RDF::Query::Pattern.new( nil, DOWL::Namespaces::RDFS.subPropertyOf, @resource ) ) do |statement|
    list << DOWL::Property.new( statement.subject, @schema )
  end
  return list
end

#sub_property_ofObject



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/dowl/property.rb', line 24

def sub_property_of()
  parent = @schema.model.first_value(
    RDF::Query::Pattern.new( @resource, DOWL::Namespaces::RDFS.subPropertyOf) )
  if parent
    uri = parent.to_s
    if @schema.properties[uri]
      return @schema.properties[uri]
    else
      return uri
    end
  end
  return nil
end

#uriObject



11
12
13
# File 'lib/dowl/property.rb', line 11

def uri
  return @resource.to_s
end