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.



1143
1144
1145
1146
1147
1148
1149
# File 'lib/wardite.rb', line 1143

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

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

Instance Attribute Details

#currentObject

: Integer



1133
1134
1135
# File 'lib/wardite.rb', line 1133

def current
  @current
end

#maxObject

: Integer|nil



1135
1136
1137
# File 'lib/wardite.rb', line 1135

def max
  @max
end

#refsObject

: Array



1137
1138
1139
# File 'lib/wardite.rb', line 1137

def refs
  @refs
end

#typeObject

: Symbol



1131
1132
1133
# File 'lib/wardite.rb', line 1131

def type
  @type
end

Instance Method Details

#set(idx, elem) ⇒ Object



1154
1155
1156
1157
1158
1159
# File 'lib/wardite.rb', line 1154

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