Class: BEL::Namespace::NamespaceDefinition
- Inherits:
-
Object
- Object
- BEL::Namespace::NamespaceDefinition
- Includes:
- Enumerable
- Defined in:
- lib/bel/translator/plugins/rdf/monkey_patch.rb,
lib/bel/namespace.rb
Overview
OpenClass to contribute RDF functionality to BEL Nanopub objects.
Instance Attribute Summary collapse
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#rdf_uri ⇒ Object
Returns the value of attribute rdf_uri.
-
#url ⇒ Object
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.
246 247 248 249 250 251 |
# File 'lib/bel/namespace.rb', line 246 def initialize(prefix, url, rdf_uri = DEFAULT_URI) @prefix = prefix @url = url @rdf_uri = rdf_uri @values = nil end |
Instance Attribute Details
#prefix ⇒ Object
Returns the value of attribute prefix.
242 243 244 |
# File 'lib/bel/namespace.rb', line 242 def prefix @prefix end |
#rdf_uri ⇒ Object
Returns the value of attribute rdf_uri.
244 245 246 |
# File 'lib/bel/namespace.rb', line 244 def rdf_uri @rdf_uri end |
#url ⇒ Object
Returns the value of attribute url.
243 244 245 |
# File 'lib/bel/namespace.rb', line 243 def url @url end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
287 288 289 290 |
# File 'lib/bel/namespace.rb', line 287 def ==(other) return false if other == nil @prefix == other.prefix && @url == other.url end |
#[](value) ⇒ Object
264 265 266 267 268 269 270 |
# File 'lib/bel/namespace.rb', line 264 def [](value) return nil unless value reload(@url) if not @values sym = value.to_sym encoding = @values[sym] || :'' Nanopub::Parameter.new(self, sym, encoding) end |
#each(&block) ⇒ Object
272 273 274 275 276 277 278 279 280 281 |
# File 'lib/bel/namespace.rb', line 272 def each &block reload(@url) if not @values @values.each do |val, enc| if block_given? block.call(Nanopub::Parameter.new(self, val, enc)) else yield Nanopub::Parameter.new(self, val, enc) end end end |
#hash ⇒ Object
283 284 285 |
# File 'lib/bel/namespace.rb', line 283 def hash [@prefix, @url].hash end |
#to_bel ⇒ Object
298 299 300 |
# File 'lib/bel/namespace.rb', line 298 def to_bel %Q{DEFINE NAMESPACE #{@prefix} AS URL "#{@url}"} end |
#to_rdf_vocabulary ⇒ Object
15 16 17 18 19 |
# File 'lib/bel/translator/plugins/rdf/monkey_patch.rb', line 15 def to_rdf_vocabulary uri = @rdf_uri uri << '/' if uri && !uri.end_with?('/') ::RDF::Vocabulary.new(uri) end |
#to_s ⇒ Object
294 295 296 |
# File 'lib/bel/namespace.rb', line 294 def to_s @prefix.to_s end |
#to_uri ⇒ Object
11 12 13 |
# File 'lib/bel/translator/plugins/rdf/monkey_patch.rb', line 11 def to_uri rdf_uri end |
#values ⇒ Object
257 258 259 260 261 262 |
# File 'lib/bel/namespace.rb', line 257 def values unless @values reload(@url) end @values end |