Class: Collapser
- Inherits:
-
Object
- Object
- Collapser
- Defined in:
- lib/collapser.rb,
lib/collapser/version.rb
Constant Summary collapse
- DEFAULT_REPLACER =
'коллапс'- REPLACED_CHARS =
[ ('A'..'Z').to_a, ('А'..'Я').to_a, ('a'..'z').to_a, ('а'..'я').to_a ].flatten.freeze
- VERSION =
'0.2.2.3'
Instance Attribute Summary collapse
-
#replacer_arr ⇒ Object
readonly
Returns the value of attribute replacer_arr.
-
#text_arr ⇒ Object
readonly
Returns the value of attribute text_arr.
Instance Method Summary collapse
-
#initialize(text:, replacer: nil) ⇒ Collapser
constructor
A new instance of Collapser.
- #run ⇒ Object
Constructor Details
#initialize(text:, replacer: nil) ⇒ Collapser
Returns a new instance of Collapser.
19 20 21 22 23 |
# File 'lib/collapser.rb', line 19 def initialize(text:, replacer: nil) @text_arr = text.split('') @replacer_arr = (replacer || DEFAULT_REPLACER).split('') @replacer_arr_idx = 0 end |
Instance Attribute Details
#replacer_arr ⇒ Object (readonly)
Returns the value of attribute replacer_arr.
25 26 27 |
# File 'lib/collapser.rb', line 25 def replacer_arr @replacer_arr end |
#text_arr ⇒ Object (readonly)
Returns the value of attribute text_arr.
25 26 27 |
# File 'lib/collapser.rb', line 25 def text_arr @text_arr end |
Instance Method Details
#run ⇒ Object
27 28 29 |
# File 'lib/collapser.rb', line 27 def run text_arr.map { |char| convert_char(char: char) }.join end |