Class: CC::Formatters::SnapshotFormatter::Rating

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/cc/formatters/snapshot_formatter.rb

Overview

Simple Comparator for rating letters.

Instance Method Summary collapse

Constructor Details

#initialize(letter) ⇒ Rating

Returns a new instance of Rating.



7
8
9
# File 'lib/cc/formatters/snapshot_formatter.rb', line 7

def initialize(letter)
  @letter = letter
end

Instance Method Details

#<=>(other) ⇒ Object



11
12
13
# File 'lib/cc/formatters/snapshot_formatter.rb', line 11

def <=>(other)
  other.to_s <=> to_s
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/cc/formatters/snapshot_formatter.rb', line 19

def eql?(other)
  to_s == other.to_s
end

#hashObject



15
16
17
# File 'lib/cc/formatters/snapshot_formatter.rb', line 15

def hash
  @letter.hash
end

#inspectObject



23
24
25
# File 'lib/cc/formatters/snapshot_formatter.rb', line 23

def inspect
  "<Rating:#{self}>"
end

#to_sObject



27
28
29
# File 'lib/cc/formatters/snapshot_formatter.rb', line 27

def to_s
  @letter.to_s
end