Class: HTTPX::Plugins::XML::Transcoder::Encoder

Inherits:
Object
  • Object
show all
Defined in:
lib/httpx/plugins/xml.rb,
sig/plugins/xml.rbs

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Encoder

Returns a new instance of Encoder.

Parameters:

  • xml (Nokogiri::XML::Node, String)


16
17
18
# File 'lib/httpx/plugins/xml.rb', line 16

def initialize(xml)
  @raw = xml
end

Instance Method Details

#bytesizeInteger, Float

Returns:

  • (Integer, Float)


25
26
27
# File 'lib/httpx/plugins/xml.rb', line 25

def bytesize
  @raw.to_s.bytesize
end

#content_typeString

Returns:

  • (String)


20
21
22
23
# File 'lib/httpx/plugins/xml.rb', line 20

def content_type
  charset = @raw.respond_to?(:encoding) && @raw.encoding ? @raw.encoding.to_s.downcase : "utf-8"
  "application/xml; charset=#{charset}"
end

#to_sString

Returns:

  • (String)


29
30
31
# File 'lib/httpx/plugins/xml.rb', line 29

def to_s
  @raw.to_s
end