Class: YOWL::Ontology

Inherits:
LabelledDocObject show all
Defined in:
lib/yowl/ontology.rb

Instance Attribute Summary

Attributes inherited from DocObject

#resource, #schema

Instance Method Summary collapse

Methods inherited from LabelledDocObject

#<=>, #commentOrLabel, #editorialNotes, #hasComment?, #hasDefinition?, #hasDifferentLabel?, #hasEditorialNotes?, #label, #status

Methods inherited from DocObject

#escaped_short_name, #escaped_uri, #get_literal, #hasOtherNamespace?, #hasUri?, #ontology, #repository, #to_s, #uri

Constructor Details

#initialize(resource, schema) ⇒ Ontology

Returns a new instance of Ontology.



5
6
7
# File 'lib/yowl/ontology.rb', line 5

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

Instance Method Details

#authorsObject



87
88
89
# File 'lib/yowl/ontology.rb', line 87

def authors
  @authors ||= init_authors
end

#classWithURI(uri_) ⇒ Object

See YOWL::Individual::classWithURI(uri)



181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/yowl/ontology.rb', line 181

def classWithURI(uri_)
  klass = @schema.classInSchemaWithURI(uri_)
  if klass
    return klass
  end
  imports.each do |import|
    klass = import.classWithURI(uri_)
    if klass
      return klass
    end
  end
  return nil
end

#commentObject



58
59
60
61
62
63
64
# File 'lib/yowl/ontology.rb', line 58

def comment()
  dctermsAbstract = get_literal(YOWL::Namespaces::DCTERMS.abstract)
  if dctermsAbstract
    return dctermsAbstract
  end
  return super
end

#createdObject



70
71
72
73
74
75
76
# File 'lib/yowl/ontology.rb', line 70

def created()
  dctermsCreated = get_literal(YOWL::Namespaces::DCTERMS.created)
  if dctermsCreated
    return dctermsCreated
  end
  return get_literal(YOWL::Namespaces::DC.date)
end

#definitionObject



66
67
68
# File 'lib/yowl/ontology.rb', line 66

def definition()
  return get_literal(YOWL::Namespaces::SKOS.definition)
end

#hasAuthors?Boolean

Returns:

  • (Boolean)


126
127
128
# File 'lib/yowl/ontology.rb', line 126

def hasAuthors?
  return ! authors.empty?
end

#importsObject



143
144
145
# File 'lib/yowl/ontology.rb', line 143

def imports
  @imports ||= init_imports
end

#init_nsObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/yowl/ontology.rb', line 30

def init_ns()
  _uri = @resource.to_s
  @schema.prefixes.each do |prefix, namespace|
    if _uri == namespace
      return namespace
    end
    _tmp = "#{_uri}/"
    if _tmp == namespace
      return _tmp
    end
    _tmp = "#{_uri}#"
    if "#{_uri}#" == namespace
      return _tmp
    end
  end
  if _uri[-1..1] == '/' or _uri[-1..1] == '#'
    return _uri
  end
  #
  # Basically make up a namespace... Don't know if this is such a good plan..
  #
  return "#{_uri}#"
end

#modifiedObject



78
79
80
# File 'lib/yowl/ontology.rb', line 78

def modified()
  return get_literal(YOWL::Namespaces::DCTERMS.modified)
end

#nsObject



25
26
27
28
# File 'lib/yowl/ontology.rb', line 25

def ns()
  @ns ||= init_ns()
  return @ns
end

#numberOfClassesObject



130
131
132
# File 'lib/yowl/ontology.rb', line 130

def numberOfClasses()
  return @schema.classes.size()
end

#numberOfIndividualsObject



138
139
140
# File 'lib/yowl/ontology.rb', line 138

def numberOfIndividuals()
  return @schema.individuals.size()
end

#numberOfPropertiesObject



134
135
136
# File 'lib/yowl/ontology.rb', line 134

def numberOfProperties()
  return @schema.properties.size()
end

#resourceNameHtmlObject



9
10
11
# File 'lib/yowl/ontology.rb', line 9

def resourceNameHtml
  return "#{@schema.name}.html"
end

#rightsObject



82
83
84
# File 'lib/yowl/ontology.rb', line 82

def rights()
  return get_literal(YOWL::Namespaces::DC.rights)
end

#see_alsosObject



162
163
164
# File 'lib/yowl/ontology.rb', line 162

def see_alsos
  @see_alsos ||= init_see_alsos
end

#short_nameObject



54
55
56
# File 'lib/yowl/ontology.rb', line 54

def short_name()
  return @schema.name
end

#titleObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/yowl/ontology.rb', line 13

def title()
  dctermsTitle = get_literal(YOWL::Namespaces::DCTERMS.title)
  if dctermsTitle
    return dctermsTitle
  end 
  dcTitle = get_literal(YOWL::Namespaces::DC.title)
  if dcTitle
    return dcTitle
  end
  return short_name() # We have to have a title
end