Class: Document

Inherits:
Token show all
Defined in:
lib/magic_parser.rb

Constant Summary collapse

@@parser =
nil

Instance Attribute Summary

Attributes inherited from Token

#name, #text

Instance Method Summary collapse

Methods inherited from Token

#print, #print_verbose, #to_s, #update, #write

Methods inherited from Array

#assert_all_types, #contains?, #find, #prep_insert, #to_s

Constructor Details

#initialize(text: '', file: nil) ⇒ Document


209
210
211
212
213
214
215
216
217
# File 'lib/magic_parser.rb', line 209

def initialize text: '', file: nil
  check_args [text, file], [String, [String, NilClass]]

  assert @@parser, 'Parser must be assigned'

  result = @@parser.parse( text: text, file: file )
  concat result
  super result.name, result.text
end