Class: Ascii::Unidecoder

Inherits:
Object
  • Object
show all
Defined in:
lib/ascii/unidecoder.rb

Overview

The class resposible for generating ASCII representation of the given string

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ Unidecoder

Returns a new instance of Unidecoder.

Parameters:

  • input (String)

    string to process



11
12
13
# File 'lib/ascii/unidecoder.rb', line 11

def initialize(input)
  @input = input.to_s
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



8
9
10
# File 'lib/ascii/unidecoder.rb', line 8

def input
  @input
end

Instance Method Details

#to_asciiString

Processes input string and returns ASCII

Returns:

  • (String)

    An ASCII approximation of input string



18
19
20
# File 'lib/ascii/unidecoder.rb', line 18

def to_ascii
  input.gsub(/[^\x00-\x7f]/u, &method(:decode)).strip
end