Method: Mail::Encodings::TransferEncoding.lowest_cost
- Defined in:
- lib/mail/encodings/transfer_encoding.rb
.lowest_cost(str, encodings) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/mail/encodings/transfer_encoding.rb', line 56 def self.lowest_cost(str, encodings) best = nil best_cost = nil encodings.each do |enc| # If the current choice cannot be transported safely, give priority # to other choices but allow it to be used as a fallback. this_cost = enc.cost(str) if enc.compatible_input?(str) if !best_cost || (this_cost && this_cost < best_cost) best_cost = this_cost best = enc elsif this_cost == best_cost best = enc if enc::PRIORITY < best::PRIORITY end end best end |