Debian Codegraph @

ruby/lib/rdf/redland/schemas/rdfs.rb

raw symbols SCIP
1 require 'rdf/redland'
2 require 'rdf/redland/constants'
3
4 module Redland::RDFS
5 include Redland
6
7 RDFSNS = Namespace.new("http://www.w3.org/2000/01/rdf-schema#")
8 RDFS_CLASS = RDFSNS["Class"]
9 RDFS_RESOURCE = RDFSNS["Resource"]
10 RDFS_SUBCLASSOF = RDFSNS["subClassOf"]
11 RDFS_SUBPROPERTYOF = RDFSNS["subPropertyOf"]
12 RDFS_ISDEFINEDBY = RDFSNS["isDefinedBy"]
13 RDFS_LABEL = RDFSNS["label"]
14 RDFS_COMMENT = RDFSNS["comment"]
15 RDFS_RANGE = RDFSNS["range"]
16 RDFS_DOMAIN = RDFSNS["domain"]
17 RDFS_LITERAL = RDFSNS["Literal"]
18 RDFS_CONTAINER = RDFSNS["Container"]
19 RDFS_SEEALSO = RDFSNS["seeAlso"]
20
21 # A subclass of Resource that adds convenience methods for
22 # adding RDFS information
23 # class RDFSResource < Resource
24 # include Redland
25
26 # get the object with the following predicate:
27 # http://www.w3.org/2000/01/rdf-schema#comment'
28 def comment()
29 self.get_property(RDFS_COMMENT).to_s
30 end
31
32 # same as the following
33 # model.add(this,Resource.new('http://www.w3.org/2000/01/rdf-schema#comment','comment')
34 def comment=(a_comment)
35 if a_comment.class == String
36 self.delete_property(RDFS_COMMENT)
37 self.add_property(RDFS_COMMENT,a_comment)
38 end
39 return self
40 end
41
42 # add a 'http://www.w3.org/2000/01/rdf-schema#label' to this resource.
43 # a label is a literal that can have a language. If a label for
44 # a given language is already defined, it replaces the label.
45 # If a label is not defined for a language it adds the label
46 # res.add_label('my label') # label created
47 # res.add_label('change label') #label changed to 'change label'
48 # res.add_label('change again','en') # label added with language English
49 def add_label(a_label,lang=nil)
50 label = Literal.new(a_label,lang)
51 labels = self.get_properties(RDFS_LABEL) do |a_label|
52 if a_label.language == lang
53 self.model.delete(self,RDFS_LABEL,a_label)
54 end
55 end
56 self.add_property(RDFS_LABEL,label)
57 return self
58 end
59
60 # return the label for this resource
61 # if the lang is defined, return the label for this language
62 # if no label found return nil
63 def label(lang=nil)
64 self.get_properties(RDFS_LABEL) do |label|
65 if label.language == lang
66 return label
67 end
68 end
69 return nil
70 end
71
72
73
74
75
76
77
78
79 # end #end class
80 end