Class: HTTP::Accept::Encodings::ContentCoding

Inherits:
Struct
  • Object
show all
Defined in:
lib/http/accept/encodings.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#encodingObject

Returns the value of attribute encoding

Returns:

  • (Object)

    the current value of encoding



40
41
42
# File 'lib/http/accept/encodings.rb', line 40

def encoding
  @encoding
end

#qObject

Returns the value of attribute q

Returns:

  • (Object)

    the current value of q



40
41
42
# File 'lib/http/accept/encodings.rb', line 40

def q
  @q
end

Class Method Details

.parse(scanner) ⇒ Object

Raises:



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/http/accept/encodings.rb', line 45

def self.parse(scanner)
	return to_enum(:parse, scanner) unless block_given?
	
	while scanner.scan(CODINGS)
		yield self.new(scanner[:encoding], scanner[:q])
		
		# Are there more?
		break unless scanner.scan(/\s*,\s*/)
	end
	
	raise ParseError.new('Could not parse entire string!') unless scanner.eos?
end

Instance Method Details

#quality_factorObject



41
42
43
# File 'lib/http/accept/encodings.rb', line 41

def quality_factor
	(q || 1.0).to_f
end