Class: YOWL::LabelledDocObject

Inherits:
DocObject show all
Defined in:
lib/yowl/util.rb

Instance Attribute Summary

Attributes inherited from DocObject

#resource, #schema

Instance Method Summary collapse

Methods inherited from DocObject

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

Constructor Details

#initialize(resource, schema) ⇒ LabelledDocObject

Returns a new instance of LabelledDocObject.



110
111
112
# File 'lib/yowl/util.rb', line 110

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

Instance Method Details

#<=>(other) ⇒ Object



178
179
180
# File 'lib/yowl/util.rb', line 178

def <=>(other)
  return label().downcase <=> other.label().downcase
end

#commentObject



125
126
127
# File 'lib/yowl/util.rb', line 125

def comment()
  return get_literal(YOWL::Namespaces::RDFS.comment)
end

#commentOrLabelObject



129
130
131
132
133
134
# File 'lib/yowl/util.rb', line 129

def commentOrLabel()
  if hasComment?
    return comment
  end
  return label
end

#definitionObject



141
142
143
# File 'lib/yowl/util.rb', line 141

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

#editorialNotesObject



150
151
152
153
154
155
156
157
158
# File 'lib/yowl/util.rb', line 150

def editorialNotes()
  notes = []
  @schema.model.query(
    RDF::Query::Pattern.new(@resource, YOWL::Namespaces::SKOS.editorialNote)
  ) do |statement|
    notes << statement.object.to_s
  end
  return notes
end

#hasComment?Boolean

Returns:

  • (Boolean)


136
137
138
139
# File 'lib/yowl/util.rb', line 136

def hasComment?
  comment = comment()
  return (comment and not comment.empty?)
end

#hasDefinition?Boolean

Returns:

  • (Boolean)


145
146
147
148
# File 'lib/yowl/util.rb', line 145

def hasDefinition?
  definition = definition()
  return (definition and not definition.empty?)
end

#hasDifferentLabel?Boolean

Returns:

  • (Boolean)


119
120
121
122
123
# File 'lib/yowl/util.rb', line 119

def hasDifferentLabel?
  #puts "****\n- #{short_name().sub(/.+:/, '')}\n- #{label}\n****"
  #return short_name().sub(/.+:/, '') != label()
  return short_name() != label()
end

#hasEditorialNotes?Boolean

Returns:

  • (Boolean)


160
161
162
# File 'lib/yowl/util.rb', line 160

def hasEditorialNotes?
  return editorialNotes.length > 0
end

#labelObject



114
115
116
117
# File 'lib/yowl/util.rb', line 114

def label()
  label = get_literal(YOWL::Namespaces::RDFS.label)
  return label.nil? ? short_name() : label
end

#see_alsosObject



164
165
166
167
168
169
170
171
172
# File 'lib/yowl/util.rb', line 164

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

#statusObject



174
175
176
# File 'lib/yowl/util.rb', line 174

def status()      
  return get_literal(YOWL::Namespaces::VS.status)
end