Class: Gamefic::Query::Numerical

Inherits:
Integer
  • Object
show all
Defined in:
lib/gamefic/numerical.rb

Instance Method Summary collapse

Instance Method Details

#filter(_subject, token) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gamefic/numerical.rb', line 10

def filter(_subject, token)
  words = token.keywords
  numericals = []
  while (word = words.shift)
    compressed = NumbersInWords.in_numbers(word, only_compress: true)
    if compressed == []
      words.unshift(word)
      break
    end

    numericals.push word
  end
  return super if numericals.empty?

  Result.new(NumbersInWords.in_numbers(numericals.join(' ')), words.join(''))
end