Class: Protocol::HTTP::Header::AcceptCharset::Charset

Inherits:
Struct
  • Object
show all
Defined in:
lib/protocol/http/header/accept_charset.rb

Overview

A parsed character set entry with an optional quality factor.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



21
22
23
# File 'lib/protocol/http/header/accept_charset.rb', line 21

def name
  @name
end

#qObject

Returns the value of attribute q

Returns:

  • (Object)

    the current value of q



21
22
23
# File 'lib/protocol/http/header/accept_charset.rb', line 21

def q
  @q
end

Instance Method Details

#<=>(other) ⇒ Object

Compare character sets by descending quality factor.



33
34
35
# File 'lib/protocol/http/header/accept_charset.rb', line 33

def <=> other
	other.quality_factor <=> self.quality_factor
end

#quality_factorObject

The quality factor for this character set.



25
26
27
# File 'lib/protocol/http/header/accept_charset.rb', line 25

def quality_factor
	(q || 1.0).to_f
end