Class: BEL::Namespace::NamespaceDefinition
- Inherits:
-
Object
- Object
- BEL::Namespace::NamespaceDefinition
- Includes:
- Enumerable
- Defined in:
- lib/bel/extensions/rdf/rdf.rb,
lib/bel/namespace.rb
Overview
OpenClass to contribute RDF functionality to BEL Model.
Instance Attribute Summary collapse
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#rdf_uri ⇒ Object
readonly
Returns the value of attribute rdf_uri.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #[](value) ⇒ Object
- #each(&block) ⇒ Object
- #hash ⇒ Object
-
#initialize(prefix, url, rdf_uri = DEFAULT_URI) ⇒ NamespaceDefinition
constructor
A new instance of NamespaceDefinition.
- #to_bel ⇒ Object
- #to_rdf_vocabulary ⇒ Object
- #to_s ⇒ Object
- #to_uri ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(prefix, url, rdf_uri = DEFAULT_URI) ⇒ NamespaceDefinition
Returns a new instance of NamespaceDefinition.
243 244 245 246 247 248 |
# File 'lib/bel/namespace.rb', line 243 def initialize(prefix, url, rdf_uri = DEFAULT_URI) @prefix = prefix @url = url @rdf_uri = rdf_uri @values = nil end |
Instance Attribute Details
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
239 240 241 |
# File 'lib/bel/namespace.rb', line 239 def prefix @prefix end |
#rdf_uri ⇒ Object (readonly)
Returns the value of attribute rdf_uri.
241 242 243 |
# File 'lib/bel/namespace.rb', line 241 def rdf_uri @rdf_uri end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
240 241 242 |
# File 'lib/bel/namespace.rb', line 240 def url @url end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
280 281 282 283 |
# File 'lib/bel/namespace.rb', line 280 def ==(other) return false if other == nil @prefix == other.prefix && @url == other.url end |
#[](value) ⇒ Object
257 258 259 260 261 262 263 |
# File 'lib/bel/namespace.rb', line 257 def [](value) return nil unless value reload(@url) if not @values sym = value.to_sym encoding = @values[sym] || :"" Model::Parameter.new(self, sym, encoding) end |
#each(&block) ⇒ Object
265 266 267 268 269 270 271 272 273 274 |
# File 'lib/bel/namespace.rb', line 265 def each &block reload(@url) if not @values @values.each do |val, enc| if block_given? block.call(Model::Parameter.new(self, val, enc)) else yield Model::Parameter.new(self, val, enc) end end end |
#hash ⇒ Object
276 277 278 |
# File 'lib/bel/namespace.rb', line 276 def hash [@prefix, @url].hash end |
#to_bel ⇒ Object
291 292 293 |
# File 'lib/bel/namespace.rb', line 291 def to_bel %Q{DEFINE NAMESPACE #{@prefix} AS URL "#{@url}"} end |
#to_rdf_vocabulary ⇒ Object
20 21 22 |
# File 'lib/bel/extensions/rdf/rdf.rb', line 20 def to_rdf_vocabulary RUBYRDF::Vocabulary.new("#{@rdf_uri}/") end |
#to_s ⇒ Object
287 288 289 |
# File 'lib/bel/namespace.rb', line 287 def to_s @prefix.to_s end |
#to_uri ⇒ Object
16 17 18 |
# File 'lib/bel/extensions/rdf/rdf.rb', line 16 def to_uri @rdf_uri end |
#values ⇒ Object
250 251 252 253 254 255 |
# File 'lib/bel/namespace.rb', line 250 def values unless @values reload(@url) end @values end |