class FormatParser::FDXParser
Public Instance Methods
call(io)
click to toggle source
# File lib/parsers/fdx_parser.rb, line 8 def call(io) return unless xml_check(io) file_and_document_type = safe_read(io, 100) file_type, document_type = check_for_document_type(file_and_document_type) return if file_type != :fdx FormatParser::Document.new( format: file_type, document_type: document_type ) end
check_for_document_type(file_and_document_type)
click to toggle source
# File lib/parsers/fdx_parser.rb, line 24 def check_for_document_type(file_and_document_type) sanitized_data = file_and_document_type.downcase if sanitized_data.include?('finaldraft') && sanitized_data.include?('script') return :fdx, :script else return end end
likely_match?(filename)
click to toggle source
# File lib/parsers/fdx_parser.rb, line 4 def likely_match?(filename) filename =~ /\.fdx$/i end
xml_check(io)
click to toggle source
# File lib/parsers/fdx_parser.rb, line 19 def xml_check(io) xml_check = safe_read(io, 5) xml_check == '<?xml' end