Class: Wardite::Table

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, init, max) ⇒ Table

Returns a new instance of Table.



1093
1094
1095
1096
1097
1098
1099
# File 'lib/wardite.rb', line 1093

def initialize(type, init, max)
  @type = type
  @current = init
  @max = max

  @refs = Array.new(3, nil)
end

Instance Attribute Details

#currentObject

: Integer



1083
1084
1085
# File 'lib/wardite.rb', line 1083

def current
  @current
end

#maxObject

: Integer|nil



1085
1086
1087
# File 'lib/wardite.rb', line 1085

def max
  @max
end

#refsObject

: Array



1087
1088
1089
# File 'lib/wardite.rb', line 1087

def refs
  @refs
end

#typeObject

: Symbol



1081
1082
1083
# File 'lib/wardite.rb', line 1081

def type
  @type
end

Instance Method Details

#set(idx, elem) ⇒ Object



1104
1105
1106
1107
1108
1109
# File 'lib/wardite.rb', line 1104

def set(idx, elem)
  if idx >= @current
    raise GenericError, "idx too large for table"
  end
  @refs[idx] = elem
end