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.



1123
1124
1125
1126
1127
1128
1129
# File 'lib/wardite.rb', line 1123

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

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

Instance Attribute Details

#currentObject

: Integer



1113
1114
1115
# File 'lib/wardite.rb', line 1113

def current
  @current
end

#maxObject

: Integer|nil



1115
1116
1117
# File 'lib/wardite.rb', line 1115

def max
  @max
end

#refsObject

: Array



1117
1118
1119
# File 'lib/wardite.rb', line 1117

def refs
  @refs
end

#typeObject

: Symbol



1111
1112
1113
# File 'lib/wardite.rb', line 1111

def type
  @type
end

Instance Method Details

#set(idx, elem) ⇒ Object



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

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