Class: Buhhub::Encoding::LegacyEncoder

Inherits:
Object
  • Object
show all
Defined in:
lib/bugno/encoding/legacy_encoder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ LegacyEncoder

Returns a new instance of LegacyEncoder.



10
11
12
# File 'lib/bugno/encoding/legacy_encoder.rb', line 10

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject

Returns the value of attribute object.



8
9
10
# File 'lib/bugno/encoding/legacy_encoder.rb', line 8

def object
  @object
end

Instance Method Details

#encodeObject



14
15
16
17
18
19
# File 'lib/bugno/encoding/legacy_encoder.rb', line 14

def encode
  value = object.to_s
  encoded_value = ::Iconv.conv('UTF-8//IGNORE', 'UTF-8', value)

  object.is_a?(Symbol) ? encoded_value.to_sym : encoded_value
end