Class: BEL::Language::Parameter

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/bel/language.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ns_def, value, enc) ⇒ Parameter

Returns a new instance of Parameter.



119
120
121
122
123
124
# File 'lib/bel/language.rb', line 119

def initialize(ns_def, value, enc)
  @ns_def = ns_def
  @value = value
  @enc = enc || ''
  @signature = E.new(@enc)
end

Instance Attribute Details

#encObject (readonly)

Returns the value of attribute enc.



117
118
119
# File 'lib/bel/language.rb', line 117

def enc
  @enc
end

#ns_defObject (readonly)

Returns the value of attribute ns_def.



117
118
119
# File 'lib/bel/language.rb', line 117

def ns_def
  @ns_def
end

#signatureObject (readonly)

Returns the value of attribute signature.



117
118
119
# File 'lib/bel/language.rb', line 117

def signature
  @signature
end

#valueObject (readonly)

Returns the value of attribute value.



117
118
119
# File 'lib/bel/language.rb', line 117

def value
  @value
end

Instance Method Details

#<=>(other) ⇒ Object



126
127
128
129
130
131
132
133
# File 'lib/bel/language.rb', line 126

def <=>(other)
  ns_compare = ns_def <=> other.ns_def
  if ns_compare == 0
    value <=> other.value
  else
    ns_compare
  end
end

#to_sObject



135
136
137
138
139
140
141
# File 'lib/bel/language.rb', line 135

def to_s
  value = @value
  if value =~ %r{\W}
    value = %Q{"#{value}"}
  end
  "#{@ns_def}:#{value}"
end