Sha256: 9f4bf5d0ae798d69c3fc28ff5e12fab2254f193cd17507da9efcc17a219f55e4

Contents?: true

Size: 858 Bytes

Versions: 1

Compression:

Stored size: 858 Bytes

Contents

module EncoderTools
  class CLI
    module Subtitles
      class Base < CLI::Base
        def self.parser(parser=nil)
          case parser
          when nil
            @parser || EncoderTools::Subtitles::Parser
          when :default
            @parser = EncoderTools::Subtitles::Parser
          when :relaxed
            @parser = EncoderTools::Subtitles::RelaxedParser
          when Class
            @parser = parser
          else
            raise ArgumentError, "unexpected parser type: #{parser.inspect}"
          end
        end

        def parser
          self.class.parser
        end

        def parse(text)
          EncoderTools::Subtitles::List.load(text, parser)
        end

        def read
          parse(input.read)
        end

        def write(result)
          output << result.to_s
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
encoder-tools-1.0.0 lib/encoder-tools/cli/subtitles/base.rb