Class: BEL::Namespace::NamespaceDefinition
- Inherits:
-
Object
- Object
- BEL::Namespace::NamespaceDefinition
- Includes:
- Enumerable
- Defined in:
- lib/bel/namespace.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #[](value) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(prefix, url) ⇒ NamespaceDefinition
constructor
A new instance of NamespaceDefinition.
Constructor Details
#initialize(prefix, url) ⇒ NamespaceDefinition
Returns a new instance of NamespaceDefinition.
56 57 58 59 60 |
# File 'lib/bel/namespace.rb', line 56 def initialize(prefix, url) @prefix = prefix @url = url @values = nil end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
53 54 55 |
# File 'lib/bel/namespace.rb', line 53 def url @url end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
54 55 56 |
# File 'lib/bel/namespace.rb', line 54 def values @values end |
Instance Method Details
#[](value) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/bel/namespace.rb', line 62 def [](value) return nil unless value reload(@url) if not @values sym = value.to_sym Language::Parameter.new(@prefix, sym, @values[sym]) if @values.key?(sym) end |
#each(&block) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/bel/namespace.rb', line 71 def each &block reload(@url) if not @values ns = @prefix.to_sym @values.each do |val, enc| if block_given? block.call(Language::Parameter.new(ns, val, enc)) else yield Language::Parameter.new(ns, val, enc) end end end |