Class: BEL::Annotation::AnnotationDefinition

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/bel/annotation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keyword, url, rdf_uri = DEFAULT_URI) ⇒ AnnotationDefinition

Returns a new instance of AnnotationDefinition.



54
55
56
57
58
59
# File 'lib/bel/annotation.rb', line 54

def initialize(keyword, url, rdf_uri = DEFAULT_URI)
  @keyword = keyword
  @url = url
  @rdf_uri = rdf_uri
  @values = nil
end

Instance Attribute Details

#keywordObject (readonly)

Returns the value of attribute keyword.



50
51
52
# File 'lib/bel/annotation.rb', line 50

def keyword
  @keyword
end

#rdf_uriObject (readonly)

Returns the value of attribute rdf_uri.



52
53
54
# File 'lib/bel/annotation.rb', line 52

def rdf_uri
  @rdf_uri
end

#urlObject (readonly)

Returns the value of attribute url.



51
52
53
# File 'lib/bel/annotation.rb', line 51

def url
  @url
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



91
92
93
94
# File 'lib/bel/annotation.rb', line 91

def ==(other)
  return false if other == nil
  @keyword == other.keyword && @url == other.url
end

#[](value) ⇒ Object



68
69
70
71
72
73
# File 'lib/bel/annotation.rb', line 68

def [](value)
  return nil unless value
  reload(@url) if not @values
  sym = value.to_sym
  Language::Annotation.new(keyword, sym)
end

#eachObject



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/bel/annotation.rb', line 75

def each
  reload(@url) if not @values
  if block_given?
    annotation_keyword = keyword
    @values.each do |val, _|
      yield Language::Annotation.new(annotation_keyword, val.to_sym)
    end
  else
    to_enum(:each)
  end
end

#hashObject



87
88
89
# File 'lib/bel/annotation.rb', line 87

def hash
  [@keyword, @url].hash
end

#to_belObject



102
103
104
# File 'lib/bel/annotation.rb', line 102

def to_bel
  %Q{DEFINE ANNOTATION #@keyword AS URL "#@url"}
end

#to_sObject



98
99
100
# File 'lib/bel/annotation.rb', line 98

def to_s
  @keyword.to_s
end

#valuesObject



61
62
63
64
65
66
# File 'lib/bel/annotation.rb', line 61

def values
  unless @values
    reload(@url)
  end
  @values
end