Sha256: 59db787b299dbacf30c64a3815d965a5c3a27c63a4d079e654ddf2afcf76276a

Contents?: true

Size: 873 Bytes

Versions: 16

Compression:

Stored size: 873 Bytes

Contents

module Mail::Parsers
  class DateTimeParser
    include Mail::Utilities

    def parse(s)
      date_time = DateTimeStruct.new([])

      actions, error = Ragel.parse(:date_time, s)
      if error
        raise Mail::Field::ParseError.new(Mail::DateTimeElement, s, error)
      end

      date_s = time_s = nil
      actions.each_slice(2) do |action_id, p|
        action = Mail::Parsers::Ragel::ACTIONS[action_id]
        case action

        # Date
        when :date_s then date_s = p
        when :date_e
          date_time.date_string = s[date_s..(p-1)]

        # Time
        when :time_s then time_s = p
        when :time_e
          date_time.time_string = s[time_s..(p-1)]

        else
          raise Mail::Field::ParseError.new(Mail::DateTimeElement, s, "Failed to process unknown action: #{action}")
        end
      end

      date_time
    end
  end
end

Version data entries

16 entries across 15 versions & 7 rubygems

Version Path
mail-2.6.4.rc2 lib/mail/parsers/date_time_parser.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/mail-2.6.3/lib/mail/parsers/date_time_parser.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/mail-2.6.3/lib/mail/parsers/date_time_parser.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/mail-2.6.3/lib/mail/parsers/date_time_parser.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/gems/mail-2.6.3/lib/mail/parsers/date_time_parser.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/mail-2.6.3/lib/mail/parsers/date_time_parser.rb
mail-2.6.4.rc1 lib/mail/parsers/date_time_parser.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/mail-2.6.3/lib/mail/parsers/date_time_parser.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/mail-2.6.3/lib/mail/parsers/date_time_parser.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/mail-2.6.3/lib/mail/parsers/date_time_parser.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/mail-2.6.3/lib/mail/parsers/date_time_parser.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/mail-2.6.3/lib/mail/parsers/date_time_parser.rb
mail-2.6.3 lib/mail/parsers/date_time_parser.rb
mail-portertech-2.6.2.edge lib/mail/parsers/date_time_parser.rb
mail-2.6.1 lib/mail/parsers/date_time_parser.rb
mail-2.6.0 lib/mail/parsers/date_time_parser.rb