class NWN::TwoDA::Row

A Row is simply an Array with some helpers. It wraps a data row in a TwoDA::Table.

You can access Table columns in a row by simply calling a method with the same name.

For example (spells.2da):

table.rows.select {|x| x.Wiz_Sorc == "9" }

selects all level 9 arcane spells.

Attributes

table[RW]

Public Instance Methods

ID() click to toggle source

Returns the id of this row.

# File lib/nwn/twoda.rb, line 37
def ID
  @table.rows.index(self)
end
method_missing(meth, *args) click to toggle source
Calls superclass method
# File lib/nwn/twoda.rb, line 41
def method_missing meth, *args
  col = meth.to_s
  assignment = if col =~ /(.+?)=$/
    col = $1
    true
  else
    false
  end

  if idx = @table.column_name_to_id(col)
    if assignment
      self[idx] = args.shift or raise ArgumentError,
        "Need a paramenter for assignments .."
    else
      self[idx]
    end
  else
    super
  end
end