Class: InterfaceHelper Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/svm_helper/interface_helper.rb

Overview

This class is abstract.

Subclass and define attributes

Author:

  • Andreas Eger

Direct Known Subclasses

FeatureVector, PreprocessedData

Constant Summary collapse

@@_attributes =
Hash.new { |hash, key| hash[key] = [] }

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ InterfaceHelper

Returns a new instance of InterfaceHelper.



28
29
30
31
32
33
# File 'lib/svm_helper/interface_helper.rb', line 28

def initialize(params={})
  @_attributes = {}
  params.each do |key, value|
    send("#{key}=", value)
  end
end

Class Method Details

.attribute(name) ⇒ Object

creates setter/getter similar to attr_accesor

Parameters:

  • name (Symbol)


16
17
18
19
20
21
22
23
24
# File 'lib/svm_helper/interface_helper.rb', line 16

def self.attribute name
  define_method(name) do
    @_attributes[name]
  end
  define_method(:"#{name}=") do |v|
    @_attributes[name] = v
  end
  attributes << name unless attributes.include? name
end

.attributesObject



25
26
27
# File 'lib/svm_helper/interface_helper.rb', line 25

def self.attributes
  @@_attributes[self]
end

Instance Method Details

#==(anOther) ⇒ Boolean

custom comperator

Parameters:

Returns:

  • (Boolean)

    result after comparing each attribute



40
41
42
# File 'lib/svm_helper/interface_helper.rb', line 40

def == anOther
  @_attributes.keys.map{ |sym| self.send(sym) == anOther.send(sym)}.reduce(true){|a,e| a && e }
end