Class: Ocho::Converter

Inherits:
Object
  • Object
show all
Defined in:
lib/ocho/converter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Converter

Returns a new instance of Converter.



18
19
20
# File 'lib/ocho/converter.rb', line 18

def initialize(text)
  @text = text
end

Instance Attribute Details

#strategy=(value) ⇒ Object (writeonly)

Sets the attribute strategy

Parameters:

  • value

    the value to set the attribute strategy to.



16
17
18
# File 'lib/ocho/converter.rb', line 16

def strategy=(value)
  @strategy = value
end

#textObject (readonly)

Returns the value of attribute text.



15
16
17
# File 'lib/ocho/converter.rb', line 15

def text
  @text
end

Class Method Details

.strategyObject



10
11
12
# File 'lib/ocho/converter.rb', line 10

def strategy
  '//TRANSLIT//IGNORE'
end

Instance Method Details

#encodingObject



22
23
24
# File 'lib/ocho/converter.rb', line 22

def encoding
  CharDet.detect(text)['encoding']
end

#to_utf8Object



26
27
28
# File 'lib/ocho/converter.rb', line 26

def to_utf8
  Iconv.conv("#{encoding}#{strategy}", 'utf-8', text)
end