Module: Philiprehberger::HeaderKit::AcceptBuilder
- Defined in:
- lib/philiprehberger/header_kit/accept_builder.rb
Overview
Builds Accept header strings from structured type entries.
Class Method Summary collapse
-
.build(types) ⇒ String
Build an Accept header string from an array of type hashes.
Class Method Details
.build(types) ⇒ String
Build an Accept header string from an array of type hashes.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/philiprehberger/header_kit/accept_builder.rb', line 11 def self.build(types) return '' if types.nil? || types.empty? parts = types.map do |entry| type = entry[:type] quality = entry[:quality] if quality && quality < 1.0 "#{type};q=#{format_quality(quality)}" else type end end parts.join(', ') end |