Class: Ocho::Converter
- Inherits:
-
Object
- Object
- Ocho::Converter
- Defined in:
- lib/ocho/converter.rb
Instance Attribute Summary collapse
-
#strategy ⇒ Object
writeonly
Sets the attribute strategy.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #encoding ⇒ Object
-
#initialize(text) ⇒ Converter
constructor
A new instance of Converter.
- #to_utf8 ⇒ Object
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
16 17 18 |
# File 'lib/ocho/converter.rb', line 16 def strategy=(value) @strategy = value end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
15 16 17 |
# File 'lib/ocho/converter.rb', line 15 def text @text end |
Class Method Details
.strategy ⇒ Object
10 11 12 |
# File 'lib/ocho/converter.rb', line 10 def strategy '//TRANSLIT//IGNORE' end |
Instance Method Details
#encoding ⇒ Object
22 23 24 |
# File 'lib/ocho/converter.rb', line 22 def encoding CharDet.detect(text)['encoding'] end |
#to_utf8 ⇒ Object
26 27 28 |
# File 'lib/ocho/converter.rb', line 26 def to_utf8 Iconv.conv("#{encoding}#{strategy}", 'utf-8', text) end |