Class: Prj::DirWithScore

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Comparable
Defined in:
lib/prj/dir_with_score.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dirObject

Returns the value of attribute dir.



9
10
11
# File 'lib/prj/dir_with_score.rb', line 9

def dir
  @dir
end

#scoreObject

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