Class: BEL::Language::E
- Inherits:
-
Object
- Object
- BEL::Language::E
- Defined in:
- lib/bel/language.rb
Instance Attribute Summary collapse
-
#encoding ⇒ Object
readonly
Returns the value of attribute encoding.
-
#var ⇒ Object
readonly
Returns the value of attribute var.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(encoding, var = false) ⇒ E
constructor
A new instance of E.
- #to_s ⇒ Object
Constructor Details
#initialize(encoding, var = false) ⇒ E
Returns a new instance of E.
212 213 214 215 |
# File 'lib/bel/language.rb', line 212 def initialize(encoding, var=false) @encoding = encoding @var = var end |
Instance Attribute Details
#encoding ⇒ Object (readonly)
Returns the value of attribute encoding.
211 212 213 |
# File 'lib/bel/language.rb', line 211 def encoding @encoding end |
#var ⇒ Object (readonly)
Returns the value of attribute var.
211 212 213 |
# File 'lib/bel/language.rb', line 211 def var @var end |
Instance Method Details
#<=>(other) ⇒ Object
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/bel/language.rb', line 217 def <=>(other) return 1 if @var ^ other.var # compare for equals and wildcard case cmp = @encoding <=> other.encoding return cmp if cmp.zero? or (@encoding == :* or other.encoding == :*) # compare encoding for assignability; based on array index @encoding.to_s.each_char do |enc_char| enc_sym = enc_char.to_sym tree = PARAMETER_ENCODING[enc_sym] next if not tree.include?(other.encoding) match = -(tree.index(enc_sym) <=> tree.index(other.encoding)) return match if match >= 0 end -1 end |
#to_s ⇒ Object
236 237 238 |
# File 'lib/bel/language.rb', line 236 def to_s "E:#{@encoding}" end |