Class: RADT::Record

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/radt/record.rb

Overview

An instance of RADT::Record represents a row in the RADT file

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table) ⇒ Record

Initialize a new ADT::Record

Parameters:



13
14
15
16
17
18
# File 'lib/radt/record.rb', line 13

def initialize(table)
  @table, @data = table, table.data

  initialize_values
  define_accessors
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



6
7
8
# File 'lib/radt/record.rb', line 6

def attributes
  @attributes
end

Instance Method Details

#==(other) ⇒ Boolean

Equality

Parameters:

Returns:

  • (Boolean)


24
25
26
# File 'lib/radt/record.rb', line 24

def ==(other)
  other.respond_to?(:attributes) && other.attributes == attributes
end

#to_aArray

Maps a row to an array of values

Returns:

  • (Array)


31
32
33
# File 'lib/radt/record.rb', line 31

def to_a
  columns.map { |column| @attributes[column.name.underscore] }
end