Class: BEL::Model::Parameter
- Inherits:
-
Object
- Object
- BEL::Model::Parameter
- Includes:
- ParameterValidation, Quoting, Comparable
- Defined in:
- lib/bel/evidence_model/bel_parameter.rb,
lib/bel/extensions/rdf/rdf.rb
Constant Summary
Constants included from Quoting
Quoting::KeywordMatcher, Quoting::NonWordMatcher
Instance Attribute Summary collapse
-
#enc ⇒ Object
Returns the value of attribute enc.
-
#ns ⇒ Object
Returns the value of attribute ns.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(ns, value, enc = nil) ⇒ Parameter
constructor
A new instance of Parameter.
- #to_bel ⇒ Object (also: #to_s)
- #to_rdf ⇒ Object
- #to_uri ⇒ Object
Methods included from ParameterValidation
Methods included from Quoting
#always_quote, #ensure_quotes, #quotes_required?, #remove_quotes
Constructor Details
#initialize(ns, value, enc = nil) ⇒ Parameter
Returns a new instance of Parameter.
19 20 21 22 23 |
# File 'lib/bel/evidence_model/bel_parameter.rb', line 19 def initialize(ns, value, enc=nil) @ns = ns @value = value @enc = enc || '' end |
Instance Attribute Details
#enc ⇒ Object
Returns the value of attribute enc.
17 18 19 |
# File 'lib/bel/evidence_model/bel_parameter.rb', line 17 def enc @enc end |
#ns ⇒ Object
Returns the value of attribute ns.
17 18 19 |
# File 'lib/bel/evidence_model/bel_parameter.rb', line 17 def ns @ns end |
#value ⇒ Object
Returns the value of attribute value.
17 18 19 |
# File 'lib/bel/evidence_model/bel_parameter.rb', line 17 def value @value end |
Instance Method Details
#<=>(other) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/bel/evidence_model/bel_parameter.rb', line 25 def <=>(other) ns_compare = @ns <=> other.ns if ns_compare == 0 @value <=> other.value else ns_compare end end |
#==(other) ⇒ Object Also known as: eql?
38 39 40 41 |
# File 'lib/bel/evidence_model/bel_parameter.rb', line 38 def ==(other) return false if other == nil @ns == other.ns && @value == other.value end |
#hash ⇒ Object
34 35 36 |
# File 'lib/bel/evidence_model/bel_parameter.rb', line 34 def hash [@ns, @value].hash end |
#to_bel ⇒ Object Also known as: to_s
44 45 46 47 48 49 50 51 52 |
# File 'lib/bel/evidence_model/bel_parameter.rb', line 44 def to_bel if @ns prefix = @ns.respond_to?(:prefix) ? @ns.prefix : @ns[:prefix] prefix = prefix ? (prefix.to_s + ':') : '' else prefix = '' end %Q{#{prefix}#{ensure_quotes(@value)}} end |
#to_rdf ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bel/extensions/rdf/rdf.rb', line 31 def to_rdf uri = to_uri encodings = ['A'].concat(@enc.to_s.each_char.to_a).uniq if block_given? encodings.map { |enc| concept_statement(enc, uri) }.each do |stmt| yield stmt end else encodings.map { |enc| concept_statement(enc, uri)} end end |
#to_uri ⇒ Object
27 28 29 |
# File 'lib/bel/extensions/rdf/rdf.rb', line 27 def to_uri @ns.to_rdf_vocabulary[URI::encode(@value)] end |