Class: HTTParty::TextEncoder

Inherits:
Object
  • Object
show all
Defined in:
lib/httparty/text_encoder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, assume_utf16_is_big_endian: true, content_type: nil) ⇒ TextEncoder

Returns a new instance of TextEncoder.



7
8
9
10
11
# File 'lib/httparty/text_encoder.rb', line 7

def initialize(text, assume_utf16_is_big_endian: true, content_type: nil)
  @text = +text
  @content_type = content_type
  @assume_utf16_is_big_endian = assume_utf16_is_big_endian
end

Instance Attribute Details

#assume_utf16_is_big_endianObject (readonly)

Returns the value of attribute assume_utf16_is_big_endian.



5
6
7
# File 'lib/httparty/text_encoder.rb', line 5

def assume_utf16_is_big_endian
  @assume_utf16_is_big_endian
end

#content_typeObject (readonly)

Returns the value of attribute content_type.



5
6
7
# File 'lib/httparty/text_encoder.rb', line 5

def content_type
  @content_type
end

#textObject (readonly)

Returns the value of attribute text.



5
6
7
# File 'lib/httparty/text_encoder.rb', line 5

def text
  @text
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
# File 'lib/httparty/text_encoder.rb', line 13

def call
  if can_encode?
    encoded_text
  else
    text
  end
end