Class: Prj::DirWithScore
- Inherits:
-
Object
- Object
- Prj::DirWithScore
- Extended by:
- Forwardable
- Includes:
- Comparable
- Defined in:
- lib/prj/dir_with_score.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
Returns the value of attribute dir.
-
#score ⇒ Object
Returns the value of attribute score.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(dir, score) ⇒ DirWithScore
constructor
A new instance of DirWithScore.
Constructor Details
#initialize(dir, score) ⇒ DirWithScore
Returns a new instance of DirWithScore.
13 14 15 |
# File 'lib/prj/dir_with_score.rb', line 13 def initialize(dir, score) @dir, @score = dir, score end |
Instance Attribute Details
#dir ⇒ Object
Returns the value of attribute dir.
9 10 11 |
# File 'lib/prj/dir_with_score.rb', line 9 def dir @dir end |
#score ⇒ Object
Returns the value of attribute score.
9 10 11 |
# File 'lib/prj/dir_with_score.rb', line 9 def score @score end |
Instance Method Details
#<=>(other) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/prj/dir_with_score.rb', line 17 def <=>(other) if score < other.score -1 elsif score > other.score 1 else if length < other.length -1 elsif length > other.length 1 else 0 end end end |