Class: Collapser

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_arrObject (readonly)

Returns the value of attribute replacer_arr.



25
26
27
# File 'lib/collapser.rb', line 25

def replacer_arr
  @replacer_arr
end

#text_arrObject (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

#runObject



27
28
29
# File 'lib/collapser.rb', line 27

def run
  text_arr.map { |char| convert_char(char: char) }.join
end