class BELParser::Expression::Model::Annotation
Annotation
represents a catalog of biological annotation values.
Attributes
domain[RW]
keyword[RW]
type[RW]
uri_reader[R]
url_reader[R]
Public Class Methods
new(keyword, type, domain, options = {})
click to toggle source
# File lib/bel_parser/expression/model/annotation.rb, line 14 def initialize(keyword, type, domain, options = {}) raise(ArgumentError, 'keyword is nil') unless keyword raise(ArgumentError, 'type is nil') unless type raise(ArgumentError, 'domain is nil') unless domain @keyword = keyword @type = type.to_sym @domain = domain # configure reader for URIs (RDF). @uri_reader = options.fetch(:uri_reader, BELParser::Resource.default_uri_reader) BELParser::Resource::Reader.assert_reader(@uri_reader, 'uri_reader') # configure reader for URLs (Resource files). @url_reader = options.fetch(:url_reader, BELParser::Resource.default_url_reader) BELParser::Resource::Reader.assert_reader(@url_reader, 'url_reader') end
Public Instance Methods
==(other)
click to toggle source
# File lib/bel_parser/expression/model/annotation.rb, line 90 def ==(other) return false if other.nil? @keyword == other.keyword && @type == other.type && @domain == other.domain end
[](value)
click to toggle source
# File lib/bel_parser/expression/model/annotation.rb, line 58 def [](value) if uri? @uri_reader.retrieve_value_from_resource(@domain, value) elsif url? @url_reader.retrieve_value_from_resource(@domain, value) else nil end end
domain_equal?(other)
click to toggle source
# File lib/bel_parser/expression/model/annotation.rb, line 98 def domain_equal?(other) return false if other.nil? @type == other.type && @domain == other.domain end
each() { |value| ... }
click to toggle source
# File lib/bel_parser/expression/model/annotation.rb, line 68 def each if block_given? values = if uri? @uri_reader.retrieve_values_from_resource(@domain) elsif url? @url_reader.retrieve_values_from_resource(@domain) else [] end values.each do |value| yield value end else to_enum(:each) end end
hash()
click to toggle source
# File lib/bel_parser/expression/model/annotation.rb, line 86 def hash [@keyword, @type, @domain].hash end
initialize_copy(original)
click to toggle source
# File lib/bel_parser/expression/model/annotation.rb, line 32 def initialize_copy(original) @keyword = original.keyword @type = original.type @domain = original.domain @uri_reader = original.uri_reader @url_reader = original.url_reader end
to_s()
click to toggle source
# File lib/bel_parser/expression/model/annotation.rb, line 103 def to_s @keyword.to_s end
uri?()
click to toggle source
# File lib/bel_parser/expression/model/annotation.rb, line 50 def uri? @type == :uri end
uri_reader=(uri_reader)
click to toggle source
# File lib/bel_parser/expression/model/annotation.rb, line 40 def uri_reader=(uri_reader) BELParser::Resource::Reader.assert_reader(@uri_reader, 'uri_reader') @uri_reader = uri_reader end
url?()
click to toggle source
# File lib/bel_parser/expression/model/annotation.rb, line 54 def url? @type == :url end
url_reader=(url_reader)
click to toggle source
# File lib/bel_parser/expression/model/annotation.rb, line 45 def url_reader=(url_reader) BELParser::Resource::Reader.assert_reader(@url_reader, 'url_reader') @url_reader = url_reader end