Class: ADT::Record
Overview
An instance of ADT::Record represents a row in the ADT file
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Equality.
-
#initialize(table) ⇒ Record
constructor
Initialize a new ADT::Record.
-
#to_a ⇒ Array
Maps a row to an array of values.
Constructor Details
#initialize(table) ⇒ Record
Initialize a new ADT::Record
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
#attributes ⇒ Object (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
22 23 24 |
# File 'lib/adt/record.rb', line 22 def ==(other) other.respond_to?(:attributes) && other.attributes == attributes end |
#to_a ⇒ Array
Maps a row to an array of values
29 30 31 |
# File 'lib/adt/record.rb', line 29 def to_a columns.map { |column| @attributes[column.name.underscore] } end |