Class: Mail::Encodings::TransferEncoding
- Defined in:
- lib/mail/encodings/transfer_encoding.rb
Direct Known Subclasses
Constant Summary collapse
- NAME =
''
- PRIORITY =
-1
Class Method Summary collapse
- .can_encode?(enc) ⇒ Boolean
- .can_transport?(enc) ⇒ Boolean
- .cost(str) ⇒ Object
- .get_best_compatible(source_encoding, str) ⇒ Object
- .to_s ⇒ Object
Instance Method Summary collapse
Class Method Details
.can_encode?(enc) ⇒ Boolean
18 19 20 |
# File 'lib/mail/encodings/transfer_encoding.rb', line 18 def self.can_encode?(enc) can_transport? enc end |
.can_transport?(enc) ⇒ Boolean
9 10 11 12 13 14 15 16 |
# File 'lib/mail/encodings/transfer_encoding.rb', line 9 def self.can_transport?(enc) enc = Encodings.get_name(enc) if Encodings.defined? enc Encodings.get_encoding(enc).new.is_a? self else false end end |
.cost(str) ⇒ Object
22 23 24 |
# File 'lib/mail/encodings/transfer_encoding.rb', line 22 def self.cost(str) raise "Unimplemented" end |
.get_best_compatible(source_encoding, str) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/mail/encodings/transfer_encoding.rb', line 30 def self.get_best_compatible(source_encoding, str) if self.can_transport? source_encoding then source_encoding else choices = [] Encodings.get_all.each do |enc| choices << enc if self.can_transport? enc and enc.can_encode? source_encoding end best = nil best_cost = 100 choices.each do |enc| this_cost = enc.cost str if this_cost < best_cost then best_cost = this_cost best = enc elsif this_cost == best_cost then best = enc if enc::PRIORITY < best::PRIORITY end end best end end |
.to_s ⇒ Object
26 27 28 |
# File 'lib/mail/encodings/transfer_encoding.rb', line 26 def self.to_s self::NAME end |
Instance Method Details
#to_s ⇒ Object
53 54 55 |
# File 'lib/mail/encodings/transfer_encoding.rb', line 53 def to_s self.class.to_s end |