Class: ChatCorrect::Pluralization

Inherits:
Object
  • Object
show all
Defined in:
lib/chat_correct/pluralization.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token_a:, token_b:) ⇒ Pluralization

Returns a new instance of Pluralization.



4
5
6
7
# File 'lib/chat_correct/pluralization.rb', line 4

def initialize(token_a:, token_b:)
  @token_a = token_a
  @token_b = token_b
end

Instance Attribute Details

#token_aObject (readonly)

Returns the value of attribute token_a.



3
4
5
# File 'lib/chat_correct/pluralization.rb', line 3

def token_a
  @token_a
end

#token_bObject (readonly)

Returns the value of attribute token_b.



3
4
5
# File 'lib/chat_correct/pluralization.rb', line 3

def token_b
  @token_b
end

Instance Method Details

#pluralization_error?Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
# File 'lib/chat_correct/pluralization.rb', line 9

def pluralization_error?
  begin
    token_a_plural = token_a.en.plural
    token_b_plural = token_b.en.plural
  rescue
    return false
  end
  token_a_plural.eql?(token_b) || token_b_plural.eql?(token_a)
end