Class NWN::TwoDA::Row

  1. lib/nwn/twoda.rb
Parent: Array

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.

Methods

public instance

  1. ID
  2. method_missing

Attributes

table [RW]

Public instance methods

ID ()

Returns the id of this row.

[show source]
    # File lib/nwn/twoda.rb, line 39
39:       def ID
40:         @table.rows.index(self)
41:       end
method_missing (meth, *args)
[show source]
    # File lib/nwn/twoda.rb, line 43
43:       def method_missing meth, *args
44:         if idx = @table.columns.index(meth.to_s.downcase) || idx = @table.columns.index(meth.to_s)
45:           if meth.to_s =~ /=$/
46:             self[idx] = args.shift or raise ArgumentError,
47:               "Need a paramenter for assignments .."
48:           else
49:             self[idx]
50:           end
51:         else
52:           super
53:         end
54:       end