Class: Corrector::Parse

Inherits:
String
  • Object
show all
Defined in:
app/services/corrector/parse.rb

Overview

Converts a source to string using stored prefixes, words and phrases

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value = "", scope:) ⇒ Parse

Parses given string, caches and returns the result of parsing.

Params:

value

a string to be parsed

scope

a scope (dictionary) for translations

Returns a converted string with a source method containing the source string and scope containing the scope for translation.

Examples:

Parse.new "километра в час", scope: "UNITS" # => "КМ/Ч"


27
28
29
30
# File 'app/services/corrector/parse.rb', line 27

def initialize(value = "", scope:)
  @source, @scope = value.to_s, scope
  super phrase
end

Instance Attribute Details

#sourceObject (readonly)

Returns the source string having been parsed.

Examples:

str = Parse.new "километра в час", scope: "UNITS" # => "КМ/Ч"
str.source # => "километра в час"


14
15
16
# File 'app/services/corrector/parse.rb', line 14

def source
  @source
end