Sha256: d4d929416d4e09bd80739f4c7d029740f35d2161ad88f9bcbbc85057b13019ee

Contents?: true

Size: 401 Bytes

Versions: 9

Compression:

Stored size: 401 Bytes

Contents

module Bioshogi
  module Parser
    class TimeParser
      def initialize(time_str)
        @time_str = time_str
      end

      def to_time
        case_a || case_b
      end

      private

      def case_a
        Time.parse(@time_str) rescue nil
      end

      def case_b
        values = @time_str.scan(/\d+/).collect(&:to_i)
        Time.local(*values) rescue nil
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bioshogi-0.0.15 lib/bioshogi/parser/time_parser.rb
bioshogi-0.0.14 lib/bioshogi/parser/time_parser.rb
bioshogi-0.0.10 lib/bioshogi/parser/time_parser.rb
bioshogi-0.0.9 lib/bioshogi/parser/time_parser.rb
bioshogi-0.0.8 lib/bioshogi/parser/time_parser.rb
bioshogi-0.0.7 lib/bioshogi/parser/time_parser.rb
bioshogi-0.0.5 lib/bioshogi/parser/time_parser.rb
bioshogi-0.0.4 lib/bioshogi/parser/time_parser.rb
bioshogi-0.0.3 lib/bioshogi/parser/time_parser.rb