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.



1075
1076
1077
1078
1079
1080
1081
# File 'lib/wardite.rb', line 1075

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

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

Instance Attribute Details

#currentObject

: Integer



1065
1066
1067
# File 'lib/wardite.rb', line 1065

def current
  @current
end

#maxObject

: Integer|nil



1067
1068
1069
# File 'lib/wardite.rb', line 1067

def max
  @max
end

#refsObject

: Array



1069
1070
1071
# File 'lib/wardite.rb', line 1069

def refs
  @refs
end

#typeObject

: Symbol



1063
1064
1065
# File 'lib/wardite.rb', line 1063

def type
  @type
end

Instance Method Details

#set(idx, elem) ⇒ Object



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

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