Class: Basset::Feature
- Inherits:
-
Object
- Object
- Basset::Feature
- Defined in:
- lib/basset/feature.rb
Overview
A class to hold a feature which consists of a name and a value. In the basic sense of document classification the name would be the word and the value would be the number of times that word appeared in the document.
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
-
#initialize(name, value = 0) ⇒ Feature
constructor
A new instance of Feature.
Constructor Details
#initialize(name, value = 0) ⇒ Feature
Returns a new instance of Feature.
9 10 11 12 |
# File 'lib/basset/feature.rb', line 9 def initialize(name, value = 0) @name = name @value = value end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/basset/feature.rb', line 7 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
7 8 9 |
# File 'lib/basset/feature.rb', line 7 def value @value end |
Instance Method Details
#<=>(other) ⇒ Object
14 15 16 17 18 |
# File 'lib/basset/feature.rb', line 14 def <=>(other) ret = self.name <=> other.name ret = self.value <=> other.value if ret.zero? ret end |
#==(other) ⇒ Object
20 21 22 23 24 |
# File 'lib/basset/feature.rb', line 20 def ==(other) ret = self.name == other.name ret = self.value == other.value if ret ret end |