Class: Idhja22::Dataset::Example

Inherits:
Datum
  • Object
show all
Defined in:
lib/idhja22/dataset/datum.rb

Instance Attribute Summary collapse

Attributes inherited from Datum

#attribute_labels, #attributes, #category_label

Instance Method Summary collapse

Methods inherited from Datum

#[]

Constructor Details

#initialize(row, attr_labels, category_label) ⇒ Example

Returns a new instance of Example.



29
30
31
32
33
# File 'lib/idhja22/dataset/datum.rb', line 29

def initialize(row, attr_labels, category_label)
  super
  self.category = self.attributes.pop
  raise UnknownCategoryValue, "Unrecognised category: #{@category} - should be Y or N" unless ['Y', 'N'].include?(@category)
end

Instance Attribute Details

#categoryObject

Returns the value of attribute category.



27
28
29
# File 'lib/idhja22/dataset/datum.rb', line 27

def category
  @category
end

Instance Method Details

#to_aObject



35
36
37
# File 'lib/idhja22/dataset/datum.rb', line 35

def to_a
  super+[category]
end