Class: Ascii::Codepoint

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

Overview

The class responsible for translating a Unicode char to its ASCII representation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(char) ⇒ Codepoint

Returns a new instance of Codepoint.

Parameters:

  • char (String)

    the unicode char



12
13
14
# File 'lib/ascii/codepoint.rb', line 12

def initialize(char)
  @code = char.unpack("U").first
end

Instance Attribute Details

#codeInteger (readonly)

Returns the code of the unicode character.

Returns:

  • (Integer)

    the code of the unicode character



9
10
11
# File 'lib/ascii/codepoint.rb', line 9

def code
  @code
end

Instance Method Details

#decodeString

Returns an ASCII representation of input.

Returns:

  • (String)

    an ASCII representation of input



17
18
19
# File 'lib/ascii/codepoint.rb', line 17

def decode
  group.at(group_index)
end