Class: LexoRanker::Ranker::CharacterSpaceEncoder
- Inherits:
-
Object
- Object
- LexoRanker::Ranker::CharacterSpaceEncoder
- Defined in:
- lib/lexoranker/ranker.rb
Instance Attribute Summary collapse
-
#character_space ⇒ Object
readonly
Returns the value of attribute character_space.
Instance Method Summary collapse
- #encode(num) ⇒ Object
-
#initialize(character_space) ⇒ CharacterSpaceEncoder
constructor
A new instance of CharacterSpaceEncoder.
Constructor Details
#initialize(character_space) ⇒ CharacterSpaceEncoder
Returns a new instance of CharacterSpaceEncoder.
222 223 224 |
# File 'lib/lexoranker/ranker.rb', line 222 def initialize(character_space) @character_space = character_space end |
Instance Attribute Details
#character_space ⇒ Object (readonly)
Returns the value of attribute character_space.
220 221 222 |
# File 'lib/lexoranker/ranker.rb', line 220 def character_space @character_space end |
Instance Method Details
#encode(num) ⇒ Object
226 227 228 229 230 231 232 233 |
# File 'lib/lexoranker/ranker.rb', line 226 def encode(num) str = "" while num > 0 str = character_space.chr(num % character_space.size) + str num /= character_space.size end str end |