Class: Highscore::Keyword

Inherits:
Object
  • Object
show all
Defined in:
lib/highscore/keyword.rb

Overview

keywords read from the content

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, weight) ⇒ Keyword

init a keyword

Parameters:

  • text

    String

  • weight

    Float



12
13
14
15
# File 'lib/highscore/keyword.rb', line 12

def initialize(text, weight)
  @text = text
  @weight = weight.to_f
end

Instance Attribute Details

#textObject

Returns the value of attribute text.



6
7
8
# File 'lib/highscore/keyword.rb', line 6

def text
  @text
end

#weightObject

Returns the value of attribute weight.



6
7
8
# File 'lib/highscore/keyword.rb', line 6

def weight
  @weight
end

Instance Method Details

#<=>(other) ⇒ Object

sort keywords

Parameters:

  • other

    Highscore::Keyword



20
21
22
# File 'lib/highscore/keyword.rb', line 20

def <=>(other)
  other.weight <=> @weight
end

#to_sObject

get the string

Returns:

  • String



27
28
29
# File 'lib/highscore/keyword.rb', line 27

def to_s
  @text
end