Class: Cheri::Explorer::NameValue

Inherits:
Object
  • Object
show all
Defined in:
lib/cheri/explorer/explorer.rb

Overview

ValueType

Direct Known Subclasses

NameTypeValue

Instance Method Summary collapse

Constructor Details

#initialize(name, value) ⇒ NameValue

Returns a new instance of NameValue.



190
191
192
193
194
195
# File 'lib/cheri/explorer/explorer.rb', line 190

def initialize(name,value)
  raise Cheri.type_error(name,String) unless String === name
  @n = name
  @i = value.__id__ rescue '?'
  @v = String === value ? value[0,128] : (value.to_s[0,128] rescue '?')
end

Instance Method Details

#<=>(other) ⇒ Object



205
206
207
208
209
210
211
# File 'lib/cheri/explorer/explorer.rb', line 205

def <=>(other)
  if NameValue === other
    value <=> other.value
  else
    value <=> (other.to_s rescue '')
  end  
end

#idObject



202
203
204
# File 'lib/cheri/explorer/explorer.rb', line 202

def id
  @i  
end

#nameObject



196
197
198
# File 'lib/cheri/explorer/explorer.rb', line 196

def name
  @n  
end

#to_aObject Also known as: to_ary



212
213
214
# File 'lib/cheri/explorer/explorer.rb', line 212

def to_a
  [@n,@v,@i]
end

#valueObject



199
200
201
# File 'lib/cheri/explorer/explorer.rb', line 199

def value
  @v
end