Class: Nendo::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/nendo/ruby/types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(typename, fields) ⇒ Record

Returns a new instance of Record.



343
344
345
346
347
348
349
# File 'lib/nendo/ruby/types.rb', line 343

def initialize( typename, fields )
  @slots = Hash.new
  @typename = typename
  fields.each { |key|
    @slots[key] = false
  }
end

Instance Attribute Details

#slotsObject (readonly)

Returns the value of attribute slots.



341
342
343
# File 'lib/nendo/ruby/types.rb', line 341

def slots
  @slots
end

#typenameObject (readonly)

Returns the value of attribute typename.



341
342
343
# File 'lib/nendo/ruby/types.rb', line 341

def typename
  @typename
end

Instance Method Details

#get(key) ⇒ Object



359
360
361
362
363
364
365
# File 'lib/nendo/ruby/types.rb', line 359

def get( key )
  if @slots.has_key?( key )
    @slots[key]
  else
    raise ArgumentError, sprintf( "Record <%s> doesn't have key[%s]", typename, key )
  end
end

#set!(key, value) ⇒ Object



351
352
353
354
355
356
357
# File 'lib/nendo/ruby/types.rb', line 351

def set!( key, value )
  if @slots.has_key?( key )
    @slots[key] = value
  else
    raise ArgumentError, sprintf( "Record <%s> doesn't have key[%s]", typename, key )
  end
end