Class: BELParser::Expression::Model::Annotation
- Inherits:
-
Object
- Object
- BELParser::Expression::Model::Annotation
- Includes:
- Enumerable
- Defined in:
- lib/bel_parser/expression/model/annotation.rb
Overview
Annotation represents a catalog of biological annotation values.
Instance Attribute Summary collapse
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#keyword ⇒ Object
Returns the value of attribute keyword.
-
#type ⇒ Object
Returns the value of attribute type.
-
#uri_reader ⇒ Object
Returns the value of attribute uri_reader.
-
#url_reader ⇒ Object
Returns the value of attribute url_reader.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #[](value) ⇒ Object
- #domain_equal?(other) ⇒ Boolean
- #each ⇒ Object
- #hash ⇒ Object
-
#initialize(keyword, type, domain, options = {}) ⇒ Annotation
constructor
A new instance of Annotation.
- #initialize_copy(original) ⇒ Object
- #to_s ⇒ Object
- #uri? ⇒ Boolean
- #url? ⇒ Boolean
Constructor Details
#initialize(keyword, type, domain, options = {}) ⇒ Annotation
Returns a new instance of Annotation.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bel_parser/expression/model/annotation.rb', line 14 def initialize(keyword, type, domain, = {}) 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 uri_reader = .fetch(:uri_reader, nil) url_reader = .fetch(:url_reader, nil) end |
Instance Attribute Details
#domain ⇒ Object
Returns the value of attribute domain.
10 11 12 |
# File 'lib/bel_parser/expression/model/annotation.rb', line 10 def domain @domain end |
#keyword ⇒ Object
Returns the value of attribute keyword.
8 9 10 |
# File 'lib/bel_parser/expression/model/annotation.rb', line 8 def keyword @keyword end |
#type ⇒ Object
Returns the value of attribute type.
9 10 11 |
# File 'lib/bel_parser/expression/model/annotation.rb', line 9 def type @type end |
#uri_reader ⇒ Object
Returns the value of attribute uri_reader.
11 12 13 |
# File 'lib/bel_parser/expression/model/annotation.rb', line 11 def uri_reader @uri_reader end |
#url_reader ⇒ Object
Returns the value of attribute url_reader.
12 13 14 |
# File 'lib/bel_parser/expression/model/annotation.rb', line 12 def url_reader @url_reader end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
85 86 87 88 89 90 |
# File 'lib/bel_parser/expression/model/annotation.rb', line 85 def ==(other) return false if other.nil? @keyword == other.keyword && @type == other.type && @domain == other.domain end |
#[](value) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/bel_parser/expression/model/annotation.rb', line 53 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) ⇒ Boolean
93 94 95 96 |
# File 'lib/bel_parser/expression/model/annotation.rb', line 93 def domain_equal?(other) return false if other.nil? @type == other.type && @domain == other.domain end |
#each ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/bel_parser/expression/model/annotation.rb', line 63 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 ⇒ Object
81 82 83 |
# File 'lib/bel_parser/expression/model/annotation.rb', line 81 def hash [@keyword, @type, @domain].hash end |
#initialize_copy(original) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/bel_parser/expression/model/annotation.rb', line 27 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 ⇒ Object
98 99 100 |
# File 'lib/bel_parser/expression/model/annotation.rb', line 98 def to_s @keyword.to_s end |
#uri? ⇒ Boolean
45 46 47 |
# File 'lib/bel_parser/expression/model/annotation.rb', line 45 def uri? @type == :uri end |
#url? ⇒ Boolean
49 50 51 |
# File 'lib/bel_parser/expression/model/annotation.rb', line 49 def url? @type == :url end |