Sha256: 466a1d24ce1e5ecc544225cb5ea95fa1743a54aedcd859a3bf7e14f78371e596

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

# encoding: utf-8
module Mail
  module CommonField # :nodoc:
    
    module ClassMethods # :nodoc:
      
    end
    
    module InstanceMethods # :doc:
      
      def name=(value)
        @name = value
      end
      
      def name
        @name
      end
      
      def value=(value)
        @length = nil
        @tree = nil
        @element = nil
        @value = value
      end
      
      def value
        @value
      end
      
      def to_s
        decoded
      end
      
      def default
        decoded
      end
      
      def field_length
        @length ||= name.length + value.length + ': '.length
      end
      
      def responsible_for?( val )
        name.to_s.downcase == val.to_s.downcase
      end

      private

      def strip_field(field_name, string)
        if string.is_a?(Array)
          string.join(', ')
        else
          string.to_s.gsub(/#{field_name}:\s+/i, '')
        end
      end

    end
    
    def self.included(receiver) # :nodoc:
      receiver.extend         ClassMethods
      receiver.send :include, InstanceMethods
    end
    
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
mail-2.1.5 lib/mail/fields/common/common_field.rb
mail-2.1.3 lib/mail/fields/common/common_field.rb
kbaum-mail-2.1.2.1 lib/mail/fields/common/common_field.rb
mail-2.1.2 lib/mail/fields/common/common_field.rb
mail-2.1.1 lib/mail/fields/common/common_field.rb
mail-2.1.0 lib/mail/fields/common/common_field.rb