Class: SiSU_AO::Output

Inherits:
Object
  • Object
show all
Defined in:
lib/sisu/ao.rb

Instance Method Summary collapse

Constructor Details

#initialize(fn, md, data) ⇒ Output

Returns a new instance of Output.



391
392
393
394
395
396
# File 'lib/sisu/ao.rb', line 391

def initialize(fn,md,data)
  @fn,@md,@data=fn,md,data
  @cf=SiSU_Env::CreateFile.new(@fn)
  @make=SiSU_Env::InfoFile.new(@fn)
  @dir=SiSU_Env::InfoEnv.new(@fn)
end

Instance Method Details

#hard_outputObject



431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
# File 'lib/sisu/ao.rb', line 431

def hard_output
  if @md.opt.act[:maintenance][:set]==:on
    filename_meta=@cf.metaverse.file_meta
    @data.each {|o| filename_meta.puts o.inspect.sub(/:0x[0-9a-f]{8}\s/,': ')} #to make diffing easier
    filename_txt=@cf.metaverse.file_txt
    @data.each do |o|
      if defined? o.ocn
        filename_txt.puts case o.is
        when :heading
          "[#{o.is.to_s} #{o.lv}~#{o.name} [#{o.ocn}]] #{o.obj}"
        else "[#{o.is.to_s} [#{o.ocn}]] #{o.obj}"
        end
      else
        filename_txt.puts case o.is
        when :meta
          "[m~#{o.tag}] #{o.obj}"
        else "[#{o.is.to_s}] #{o.obj}"
        end
      end
    end
    filename_debug=@cf.file_debug
    @data.each do |o|
      if defined? o.ocn
        case o.is
        when :heading
          filename_debug.puts
            "#{o.is.to_s} #{o.lv}~#{o.name} odv=#{o.odv} osp=#{o.osp} [#{o.ocn}] -->\n\t#{o.obj}"
        end
      end
    end
  else
    hard="#{@dir.processing_path.ao}/#{@md.fns}.meta"
    File.unlink(hard) if FileTest.file?(hard)
    hard="#{@dir.processing_path.ao}/#{@md.fns}.txt"
    File.unlink(hard) if FileTest.file?(hard)
    hard="#{@dir.processing_path.ao}/#{@md.fns}.debug.txt"
    File.unlink(hard) if FileTest.file?(hard)
  end
end

#idx_html_hard_outputObject



478
479
480
481
482
483
484
485
486
487
488
489
490
# File 'lib/sisu/ao.rb', line 478

def idx_html_hard_output
  if @md.book_idx \
  and @md.opt.act[:maintenance][:set]==:on
    filename_meta=@cf.file_meta_idx_html
    if @data.is_a?(Array)
      @data.each {|s| p s.inspect + "\n" unless s.is_a?(String)}
      @data.each {|s| filename_meta.puts s.strip + "\n" unless s.strip.empty?}
    end
  else
    hard_idx_html="#{@dir.processing_path.ao}/#{@md.fns}.idx.html"
    File.unlink(hard_idx_html) if FileTest.file?(hard_idx_html)
  end
end

#make_marshal_contentObject



470
471
472
473
# File 'lib/sisu/ao.rb', line 470

def make_marshal_content
  marshal_ao=@make.marshal.ao_content
  File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array)
end

#make_marshal_idx_htmlObject



501
502
503
504
505
# File 'lib/sisu/ao.rb', line 501

def make_marshal_idx_html
  marshal_ao=@make.marshal.ao_idx_html
  File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} \
    if @data.is_a?(Array)
end

#make_marshal_idx_sst_html_segObject



491
492
493
494
495
# File 'lib/sisu/ao.rb', line 491

def make_marshal_idx_sst_html_seg
  marshal_ao=@make.marshal.ao_idx_sst_rel_html_seg
  File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} \
    if @data.is_a?(Array)
end

#make_marshal_idx_sst_relObject



496
497
498
499
500
# File 'lib/sisu/ao.rb', line 496

def make_marshal_idx_sst_rel
  marshal_ao=@make.marshal.ao_idx_sst_rel
  File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} \
    if @data.is_a?(Array)
end

#make_marshal_idx_xhtmlObject



506
507
508
509
510
# File 'lib/sisu/ao.rb', line 506

def make_marshal_idx_xhtml
  marshal_ao=@make.marshal.ao_idx_xhtml
  File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} \
    if @data.is_a?(Array)
end

#make_marshal_map_name_ocn_htmlsegObject



516
517
518
519
520
# File 'lib/sisu/ao.rb', line 516

def make_marshal_map_name_ocn_htmlseg
  marshal_ao=@make.marshal.ao_map_ocn_htmlseg
  File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} \
    if @data.is_a?(Hash)
end

#make_marshal_map_nametagsObject



511
512
513
514
515
# File 'lib/sisu/ao.rb', line 511

def make_marshal_map_nametags
  marshal_ao=@make.marshal.ao_map_nametags
  File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} \
    if @data.is_a?(Hash)
end

#make_marshal_metadataObject



474
475
476
477
# File 'lib/sisu/ao.rb', line 474

def 
  marshal_ao=@make.marshal.
  File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array)
end

#screen_dump(o) ⇒ Object



397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
# File 'lib/sisu/ao.rb', line 397

def screen_dump(o)
  if defined? o.of
    print %{OF: #{o.of}; }
  end
  if defined? o.is
    print %{IS: #{o.is.to_s}; }
  end
  if defined? o.ocn
    print %{OCN: #{o.ocn}; }
  end
  if defined? o.node
    print %{NODE: #{o.node}; }
  end
  if defined? o.parent
    print %{Parent: #{o.parent}; }
  end
  if defined? o.obj and not o.obj.empty?
    puts %{\n#{o.obj}; }
  else "\n"
  end
end

#screen_output(data) ⇒ Object



423
424
425
426
427
428
429
430
# File 'lib/sisu/ao.rb', line 423

def screen_output(data)
  data.each do |o|
    print o.class
    screen_print(o.ocn)
    screen_print(o.obj)
    puts "\n"
  end
end

#screen_print(t_o) ⇒ Object



418
419
420
421
422
# File 'lib/sisu/ao.rb', line 418

def screen_print(t_o)
  if defined? t_o
    print ' ' + t_o.to_s
  end
end