Class: ADT::Record

Inherits:
Object show all
Defined in:
lib/adt/record.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table) ⇒ Record

Initialize a new ADT::Record

Parameters:



11
12
13
14
15
16
# File 'lib/adt/record.rb', line 11

def initialize(table)
  @table, @data = table, table.data
  
  initialize_values
  define_accessors
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



4
5
6
# File 'lib/adt/record.rb', line 4

def attributes
  @attributes
end

Instance Method Details

#==(other) ⇒ Boolean

Equality

Parameters:

Returns:

  • (Boolean)


22
23
24
# File 'lib/adt/record.rb', line 22

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

#to_aArray

Maps a row to an array of values

Returns:

  • (Array)


29
30
31
# File 'lib/adt/record.rb', line 29

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