Class: TXTextControl::ReportingCloud::IncorrectWord

Inherits:
Object
  • Object
show all
Defined in:
lib/txtextcontrol/reportingcloud/incorrect_word.rb

Overview

Represents an incorrect word in spell checked text.

Author:

  • Thorsten Kummerow (@thomerow)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(length, start, text, is_duplicate, language) ⇒ IncorrectWord

Returns a new instance of IncorrectWord

Parameters:

  • length (Integer)

    The starting position of a spelled word.

  • start (Integer)

    The starting position of a spelled word.

  • text (String)

    The text of the spelled word.

  • is_duplicate (Boolean)

    Indicating whether the spelled word is declared as incorrect, because the previous word has the same text.

  • language (String)

    Indicating the language the incorrect word was spelled.



42
43
44
45
46
47
48
# File 'lib/txtextcontrol/reportingcloud/incorrect_word.rb', line 42

def initialize(length, start, text, is_duplicate, language)
  @length = Integer(length)
  @start = Integer(start)
  @text = text
  @is_duplicate = !!is_duplicate
  @language = language
end

Instance Attribute Details

#is_duplicateBoolean (readonly) Also known as: is_duplicate?

Indicating whether the spelled word is declared as incorrect, because the previous word has the same text.

Returns:

  • (Boolean)

    the current value of is_duplicate



26
27
28
# File 'lib/txtextcontrol/reportingcloud/incorrect_word.rb', line 26

def is_duplicate
  @is_duplicate
end

#languageString (readonly)

Indicating the language the incorrect word was spelled.

Returns:

  • (String)

    the current value of language



26
27
28
# File 'lib/txtextcontrol/reportingcloud/incorrect_word.rb', line 26

def language
  @language
end

#lengthInteger (readonly)

The length of the spelled word.

Returns:

  • (Integer)

    the current value of length



26
27
28
# File 'lib/txtextcontrol/reportingcloud/incorrect_word.rb', line 26

def length
  @length
end

#startInteger (readonly)

The starting position of a spelled word.

Returns:

  • (Integer)

    the current value of start



26
27
28
# File 'lib/txtextcontrol/reportingcloud/incorrect_word.rb', line 26

def start
  @start
end

#textString (readonly)

The text of the spelled word.

Returns:

  • (String)

    the current value of text



26
27
28
# File 'lib/txtextcontrol/reportingcloud/incorrect_word.rb', line 26

def text
  @text
end

Class Method Details

.from_camelized_hash(hash) ⇒ IncorrectWord

Creates an IncorrectWord instance from a hash.

Parameters:

  • hash (Hash)

    The hash to try and create an IncorrectWord instance from.

Returns:



53
54
55
56
57
58
59
60
# File 'lib/txtextcontrol/reportingcloud/incorrect_word.rb', line 53

def self.from_camelized_hash(hash)
  l = hash["length"]
  s = hash["start"]
  txt = hash["text"]
  id = hash["isDuplicate"]
  lan = hash["language"]
  return IncorrectWord.new(l, s, txt, id, lan)
end