Class: InterfaceHelper Abstract
- Inherits:
-
Object
- Object
- InterfaceHelper
- Defined in:
- lib/svm_helper/interface_helper.rb
Overview
This class is abstract.
Subclass and define attributes
Direct Known Subclasses
Constant Summary collapse
- @@_attributes =
Hash.new { |hash, key| hash[key] = [] }
Class Method Summary collapse
-
.attribute(name) ⇒ Object
creates setter/getter similar to attr_accesor.
- .attributes ⇒ Object
Instance Method Summary collapse
-
#==(anOther) ⇒ Boolean
custom comperator.
-
#initialize(params = {}) ⇒ InterfaceHelper
constructor
A new instance of InterfaceHelper.
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
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 |
.attributes ⇒ Object
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
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 |