Class: SiSU_Param::Parameters::Md

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

Instance Method Summary collapse

Constructor Details

#initialize(str, opt, env) ⇒ Md

Returns a new instance of Md.



194
195
196
# File 'lib/sisu/dp.rb', line 194

def initialize(str,opt,env)
  @s,@opt,@env=str,opt,env
end

Instance Method Details

#abstractObject



851
852
853
854
855
# File 'lib/sisu/dp.rb', line 851

def abstract
  s=@h['abstract']
  l,n=Db[:col_info_note],'notes.abstract'
  validate_length(s,l,n)
end

#added_to_siteObject



743
744
745
746
747
# File 'lib/sisu/dp.rb', line 743

def added_to_site
  s=@h['added_to_site']
  l,n=Db[:col_date_text],'date.added_to_site'
  validate_length(s,l,n)
end

#allObject



621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
# File 'lib/sisu/dp.rb', line 621

def all
  s=if @h['all'] then @h['all']
  else
    s=''
    if defined? copyright.text \
    and copyright.text \
    and not copyright.text.empty?
      v=sep(copyright.text)
      s +='Copyright: ' + copyright.text + v
    end
    if defined? copyright.translation \
    and copyright.translation \
    and not copyright.translation.empty?
      v=sep(copyright.translation)
      s +='translation: ' + copyright.translation + v
    end
    if defined? copyright.illustrations \
    and copyright.illustrations \
    and not copyright.illustrations.empty?
      v=sep(copyright.illustrations)
      s +='illustrations: ' + copyright.illustrations + v
    end
    if defined? copyright.photographs \
    and copyright.photographs \
    and not copyright.photographs.empty?
      v=sep(copyright.photographs)
      s +='photographs: ' + copyright.photographs + v
    end
    if defined? copyright.digitization \
    and copyright.digitization \
    and not copyright.digitization.empty?
      v=sep(copyright.digitization)
      s +='digitization: ' + copyright.digitization + v
    end
    if defined? copyright.audio \
    and copyright.audio \
    and not copyright.audio.empty?
      v=sep(copyright.audio)
      s +='audio: ' + copyright.audio + v
    end
    if defined? copyright.license \
    and copyright.license \
    and not copyright.license.empty?
      s +='License: ' + copyright.license
    end
    if s.empty?
      SiSU_Screen::Ansi.new(
        @opt.act[:color_state][:set],
        'WARNING Document Rights information missing; provide @rights: :copyright:'
      ).warn if (@opt.act[:verbose][:set]==:on \
        || @opt.act[:verbose_plus][:set]==:on \
        || @opt.act[:maintenance][:set]==:on)
    else
      l,n=Db[:col_info_note],'rights.all'
      validate_length(s,l,n)
    end
    s=s.gsub(/ [\\]+\s+$/,'')
  end
  s
end

#audioObject



458
459
460
461
462
463
464
465
466
467
468
469
470
# File 'lib/sisu/dp.rb', line 458

def audio
  names=@h['audio'] \
  ? name_format(@h['audio'])
  : nil
  s=(names.is_a?(Hash)) \
  ? names[:name_str]
  : nil
  s=if s
    l,n=Db[:col_name],'creator.audio'
    validate_length(s,l,n)
  else nil
  end
end

#audio_detailObject



471
472
473
474
475
476
477
478
# File 'lib/sisu/dp.rb', line 471

def audio_detail
  names=@h['audio'] \
  ? name_format(@h['audio'])
  : nil
  (names.is_a?(Hash)) \
  ? names[:name_a_h]
  : nil
end

#authorObject



334
335
336
337
338
339
340
341
342
# File 'lib/sisu/dp.rb', line 334

def author
  @h['author']=(@h['author'] \
  ? @h['author']
  : @h['main'])
  names=name_format(@h['author'])
  s=names[:name_str]
  l,n=Db[:col_name],'creator.author'
  validate_length(s,l,n)
end

#author_detailObject



343
344
345
346
347
348
349
# File 'lib/sisu/dp.rb', line 343

def author_detail
  s=@h['author'] \
  ? @h['author']
  : @h['main']
  names=name_format(s)
  names[:name_a_h]
end

#availableObject



748
749
750
751
752
# File 'lib/sisu/dp.rb', line 748

def available
  s=@h['available']
  l,n=Db[:col_date_text],'date.available'
  validate_length(s,l,n)
end

#build_hash(arr) ⇒ Object



258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/sisu/dp.rb', line 258

def build_hash(arr)
  @h={}
  arr.each_with_index do |x,i|
    a,b=nil,nil
    if x =~/^%\s/ #ignore comment
    elsif x =~/:(\S+?):\s+(.+)/
      a,b=/:(\S+?):\s+(.+)\Z/m.match(x)[1,2]
      b=b.gsub(/\s*<br(?: \/)?>\s*/,' \\\\\\ ')
      b=if b =~/\n/m
        (b =~/;\n/m) \
        ? (b.split(/;\s*\n\s*/).join(';'))
        : (b.split(/\s*\n\s*/).join(' '))
      else
        b
      end
    elsif i == 0
      a='main'
      b=x
    else
    end
    @h[a]=b
  end
  @h
end

#classifyObject



703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
# File 'lib/sisu/dp.rb', line 703

def classify
  a=@s.split(/(\n%\s.+?$|[ ]*)(?:\n[ ]*(?=:)|\Z)/m)
  @h=build_hash(a)
  def topic_register
    s=@h['topic_register']
    l,n=Db[:col_info_note],'classify.topic_register'
    validate_length(s,l,n)
  end
  def subject
    s=@h['subject']
    l,n=Db[:col_txt_long],'classify.subject'
    validate_length(s,l,n)
  end
  def keywords
    s=@h['keywords']
    l,n=Db[:col_txt_long],'classify.keywords'
    validate_length(s,l,n)
  end
  def loc
    s=@h['loc']
    l,n=Db[:col_library],'classify.loc'
    validate_length(s,l,n)
  end
  def dewey
    s=@h['dewey']
    l,n=Db[:col_library],'classify.dewey'
    validate_length(s,l,n)
  end
  self
end

#commentObject



856
857
858
859
860
# File 'lib/sisu/dp.rb', line 856

def comment
  s=@h['comment']
  l,n=Db[:col_info_note],'notes.comment'
  validate_length(s,l,n)
end

#contributorObject



374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'lib/sisu/dp.rb', line 374

def contributor
  names=@h['contributor'] \
  ? name_format(@h['contributor'])
  : nil
  s=(names.is_a?(Hash)) \
  ? names[:name_str]
  : nil
  s=if s
    l,n=Db[:col_name],'creator.author'
    validate_length(s,l,n)
  else nil
  end
end

#contributor_detailObject



387
388
389
390
391
392
393
394
# File 'lib/sisu/dp.rb', line 387

def contributor_detail
  names=@h['contributor'] \
  ? name_format(@h['contributor'])
  : nil
  (names.is_a?(Hash)) \
  ? names[:name_a_h]
  : nil
end


527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
# File 'lib/sisu/dp.rb', line 527

def copyright
  def text #you may wish to expand to take from all
    s=if @h['copyright'] then @h['copyright']
    elsif @h['text']     then @h['text']
    elsif @h['main']     then @h['main']
    else
      SiSU_Screen::Ansi.new(
        @opt.act[:color_state][:set],
        'WARNING Document Copyright missing; provide @rights: :copyright:'
      ).warn if (@opt.act[:verbose][:set]==:on \
        || @opt.act[:verbose_plus][:set]==:on \
        || @opt.act[:maintenance][:set]==:on)
      ''
    end
    l,n=Db[:col_info_note],'rights.copyright.text'
    validate_length(s,l,n)
  end
  def translation
    s=@h['translation'] \
    ? @h['translation']
    : nil
    l,n=Db[:col_info_note],'rights.copyright.translation'
    validate_length(s,l,n)
  end
  def illustrations
    s=@h['illustrations'] \
    ? @h['illustrations']
    : nil
    l,n=Db[:col_info_note],'rights.copyright.illustrations'
    validate_length(s,l,n)
  end
  def photographs
    s=@h['photographs'] \
    ? @h['photographs']
    : nil
    l,n=Db[:col_info_note],'rights.copyright.photographs'
    validate_length(s,l,n)
  end
  def digitization
    s=@h['digitization'] \
    ? @h['digitization']
    : nil
    l,n=Db[:col_info_note],'rights.copyright.digitization'
    validate_length(s,l,n)
  end
  def audio
    s=@h['audio'] \
    ? @h['audio']
    : nil
    l,n=Db[:col_info_note],'rights.copyright.audio'
    validate_length(s,l,n)
  end
  self
end


591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
# File 'lib/sisu/dp.rb', line 591

def copyright_and_license
  s=if @h['copyright_and_license'] then @h['copyright_and_license']
  else
    s=''
    if defined? copyright.text \
    and copyright.text \
    and not copyright.text.empty?
      v=sep(copyright.text)
      s +=copyright.text + v
    end
    if defined? copyright.license \
    and copyright.license \
    and not copyright.license.empty?
      s +=copyright.license
    end
    if s.empty?
      SiSU_Screen::Ansi.new(
        @opt.act[:color_state][:set],
        'WARNING Document Rights information missing; provide @rights: :copyright:'
      ).warn if (@opt.act[:verbose][:set]==:on \
        || @opt.act[:verbose_plus][:set]==:on \
        || @opt.act[:maintenance][:set]==:on)
    else
      l,n=Db[:col_info_note],'rights.all'
      validate_length(s,l,n)
    end
    s=s.gsub(/ [\\]+\s+$/,'')
  end
  s
end

#coverageObject



861
862
863
864
865
# File 'lib/sisu/dp.rb', line 861

def coverage
  s=@h['coverage']
  l,n=Db[:col_info_note],'notes.coverage'
  validate_length(s,l,n)
end

#createdObject



753
754
755
756
757
# File 'lib/sisu/dp.rb', line 753

def created
  s=@h['created']
  l,n=Db[:col_date_text],'date.created'
  validate_length(s,l,n)
end

#creatorObject

there are sub categories that need to be catered for and sometimes more than one author etc.; implement array.to_s.length validation test later, current test on string approximate as string is not used



331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
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
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
# File 'lib/sisu/dp.rb', line 331

def creator #there are sub categories that need to be catered for and sometimes more than one author etc.; implement array.to_s.length validation test later, current test on string approximate as string is not used
  a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m)
  @h=build_hash(a)
  def author
    @h['author']=(@h['author'] \
    ? @h['author']
    : @h['main'])
    names=name_format(@h['author'])
    s=names[:name_str]
    l,n=Db[:col_name],'creator.author'
    validate_length(s,l,n)
  end
  def author_detail
    s=@h['author'] \
    ? @h['author']
    : @h['main']
    names=name_format(s)
    names[:name_a_h]
  end
  def email #revisit
    s=@h['email']
  end
  def editor
    names=@h['editor'] \
    ? name_format(@h['editor'])
    : nil
    s=(names.is_a?(Hash)) \
    ? names[:name_str]
    : nil
    s=if s
      l,n=Db[:col_name],'creator.editor'
      validate_length(s,l,n)
    else nil
    end
  end
  def editor_detail
    names=@h['editor'] \
    ? name_format(@h['editor'])
    : nil
    (names.is_a?(Hash)) \
    ? names[:name_a_h]
    : nil
  end
  def contributor
    names=@h['contributor'] \
    ? name_format(@h['contributor'])
    : nil
    s=(names.is_a?(Hash)) \
    ? names[:name_str]
    : nil
    s=if s
      l,n=Db[:col_name],'creator.author'
      validate_length(s,l,n)
    else nil
    end
  end
  def contributor_detail
    names=@h['contributor'] \
    ? name_format(@h['contributor'])
    : nil
    (names.is_a?(Hash)) \
    ? names[:name_a_h]
    : nil
  end
  def illustrator
    names=@h['illustrator'] \
    ? name_format(@h['illustrator'])
    : nil
    s=(names.is_a?(Hash)) \
    ? names[:name_str]
    : nil
    s=if s
      l,n=Db[:col_name],'creator.illustrator'
      validate_length(s,l,n)
    else nil
    end
  end
  def illustrator_detail
    names=@h['illustrator'] \
    ? name_format(@h['illustrator'])
    : nil
    (names.is_a?(Hash)) \
    ? names[:name_a_h]
    : nil
  end
  def photographer
    names=@h['photographer'] \
    ? name_format(@h['photographer'])
    : nil
    s=(names.is_a?(Hash)) \
    ? names[:name_str]
    : nil
    s=if s
      l,n=Db[:col_name],'creator.photographer'
      validate_length(s,l,n)
    else nil
    end
  end
  def photographer_detail
    names=@h['photographer'] \
    ? name_format(@h['photographer'])
    : nil
    (names.is_a?(Hash)) \
    ? names[:name_a_h]
    : nil
  end
  def translator
    names=@h['translator'] \
    ? name_format(@h['translator'])
    : nil
    s=(names.is_a?(Hash)) \
    ? names[:name_str]
    : nil
    s=if s
      l,n=Db[:col_name],'creator.translator'
      validate_length(s,l,n)
    else nil
    end
  end
  def translator_detail
    names=@h['translator'] \
    ? name_format(@h['translator'])
    : nil
    (names.is_a?(Hash)) \
    ? names[:name_a_h]
    : nil
  end
  def audio
    names=@h['audio'] \
    ? name_format(@h['audio'])
    : nil
    s=(names.is_a?(Hash)) \
    ? names[:name_str]
    : nil
    s=if s
      l,n=Db[:col_name],'creator.audio'
      validate_length(s,l,n)
    else nil
    end
  end
  def audio_detail
    names=@h['audio'] \
    ? name_format(@h['audio'])
    : nil
    (names.is_a?(Hash)) \
    ? names[:name_a_h]
    : nil
  end
  def digitized_by
    names=@h['digitized_by'] \
    ? name_format(@h['digitized_by'])
    : nil
    s=(names.is_a?(Hash)) \
    ? names[:name_str]
    : nil
    s=if s
      l,n=Db[:col_name],'creator.digitized_by'
      validate_length(s,l,n)
    else nil
    end
  end
  def digitized_by_detail
    names=@h['digitized_by'] \
    ? name_format(@h['digitized_by'])
    : nil
    (names.is_a?(Hash)) \
    ? names[:name_a_h]
    : nil
  end
  def prepared_by
    names=@h['prepared_by'] \
    ? name_format(@h['prepared_by'])
    : nil
    s=(names.is_a?(Hash)) \
    ? names[:name_str]
    : nil
    s=if s
      l,n=Db[:col_name],'creator.prepared_by'
      validate_length(s,l,n)
    else nil
    end
  end
  def prepared_by_detail
    names=@h['prepared_by'] \
    ? name_format(@h['prepared_by'])
    : nil
    names=name_format(@h['prepared_by'])
    (names.is_a?(Hash)) \
    ? names[:name_a_h]
    : nil
  end
  self
end

#current_publisherObject

def language # as things stand this should really be populated from title.language and original.language, resolve

a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m)
@h=build_hash(a)
def document
  s=@h['document']=(@h['document'] ? @h['document'] : @h['main'])
  l,n=Db[:col_language],'language.document'
  validate_length(s,l,n)
end
def document_char
  s=@h['document_char']=(@h['document_char'] ? @h['document_char'] : nil)
  l,n=Db[:col_language_char],'language.document_char'
  validate_length(s,l,n)
end
def original
  s=@h['original']
  l,n=Db[:col_language],'language.original'
  validate_length(s,l,n)
end
def original_char
  s=@h['original_char']
  l,n=Db[:col_language_char],'language.original_char'
  validate_length(s,l,n)
end
self

end



805
806
807
# File 'lib/sisu/dp.rb', line 805

def current_publisher
  @s
end

#dateObject



740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
# File 'lib/sisu/dp.rb', line 740

def date
  a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m)
  @h=build_hash(a)
  def added_to_site
    s=@h['added_to_site']
    l,n=Db[:col_date_text],'date.added_to_site'
    validate_length(s,l,n)
  end
  def available
    s=@h['available']
    l,n=Db[:col_date_text],'date.available'
    validate_length(s,l,n)
  end
  def created
    s=@h['created']
    l,n=Db[:col_date_text],'date.created'
    validate_length(s,l,n)
  end
  def issued
    s=@h['issued']
    l,n=Db[:col_date_text],'date.issued'
    validate_length(s,l,n)
  end
  def modified
    s=@h['modified']
    l,n=Db[:col_date_text],'date.modified'
    validate_length(s,l,n)
  end
  def published
    s=@h['published']=(@h['published'] ? @h['published'] : @h['main'])
    l,n=Db[:col_date_text],'date.published'
    validate_length(s,l,n)
  end
  def valid
    s=@h['valid']
    l,n=Db[:col_date_text],'date.valid'
    validate_length(s,l,n)
  end
  self
end

#descriptionObject



846
847
848
849
850
# File 'lib/sisu/dp.rb', line 846

def description
  s=@h['description']
  l,n=Db[:col_info_note],'notes.description'
  validate_length(s,l,n)
end

#deweyObject



726
727
728
729
730
# File 'lib/sisu/dp.rb', line 726

def dewey
  s=@h['dewey']
  l,n=Db[:col_library],'classify.dewey'
  validate_length(s,l,n)
end

#digitizationObject



565
566
567
568
569
570
571
# File 'lib/sisu/dp.rb', line 565

def digitization
  s=@h['digitization'] \
  ? @h['digitization']
  : nil
  l,n=Db[:col_info_note],'rights.copyright.digitization'
  validate_length(s,l,n)
end

#digitized_byObject



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

def digitized_by
  names=@h['digitized_by'] \
  ? name_format(@h['digitized_by'])
  : nil
  s=(names.is_a?(Hash)) \
  ? names[:name_str]
  : nil
  s=if s
    l,n=Db[:col_name],'creator.digitized_by'
    validate_length(s,l,n)
  else nil
  end
end

#digitized_by_detailObject



492
493
494
495
496
497
498
499
# File 'lib/sisu/dp.rb', line 492

def digitized_by_detail
  names=@h['digitized_by'] \
  ? name_format(@h['digitized_by'])
  : nil
  (names.is_a?(Hash)) \
  ? names[:name_a_h]
  : nil
end

#editionObject



295
296
297
298
299
# File 'lib/sisu/dp.rb', line 295

def edition
  s=@h['edition']
  l,n=Db[:col_title_edition],'title.edition'
  validate_length(s,l,n)
end

#editorObject



353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/sisu/dp.rb', line 353

def editor
  names=@h['editor'] \
  ? name_format(@h['editor'])
  : nil
  s=(names.is_a?(Hash)) \
  ? names[:name_str]
  : nil
  s=if s
    l,n=Db[:col_name],'creator.editor'
    validate_length(s,l,n)
  else nil
  end
end

#editor_detailObject



366
367
368
369
370
371
372
373
# File 'lib/sisu/dp.rb', line 366

def editor_detail
  names=@h['editor'] \
  ? name_format(@h['editor'])
  : nil
  (names.is_a?(Hash)) \
  ? names[:name_a_h]
  : nil
end

#emailObject

revisit



350
351
352
# File 'lib/sisu/dp.rb', line 350

def email #revisit
  s=@h['email']
end

#formatObject



886
887
888
889
890
# File 'lib/sisu/dp.rb', line 886

def format
  s=@h['format']
  l,n=Db[:col_txt_short],'notes.format'
  validate_length(s,l,n)
end

#fullObject



312
313
314
315
316
317
318
# File 'lib/sisu/dp.rb', line 312

def full
  s=@h['subtitle'] \
  ? (@h['main'] + ' - ' + @h['subtitle'])
  : @h['main']
  l,n=Db[:col_title],'title.full'
  validate_length(s,l,n)
end

#historyObject



876
877
878
879
880
# File 'lib/sisu/dp.rb', line 876

def history
  s=@h['history']
  l,n=Db[:col_txt_long],'notes.history'
  validate_length(s,l,n)
end

#identifierObject



683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
# File 'lib/sisu/dp.rb', line 683

def identifier
  a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m)
  @h=build_hash(a)
  def oclc
    s=@h['oclc']
    l,n=Db[:col_library],'identifier.oclc'
    validate_length(s,l,n)
  end
  def isbn
    s=@h['isbn']
    l,n=Db[:col_small],'identifier.isbn'
    validate_length(s,l,n)
  end
  def pg
    s=@h['pg']
    l,n=Db[:col_small],'identifier.pg'
    validate_length(s,l,n)
  end
  self
end

#illustrationsObject



551
552
553
554
555
556
557
# File 'lib/sisu/dp.rb', line 551

def illustrations
  s=@h['illustrations'] \
  ? @h['illustrations']
  : nil
  l,n=Db[:col_info_note],'rights.copyright.illustrations'
  validate_length(s,l,n)
end

#illustratorObject



395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/sisu/dp.rb', line 395

def illustrator
  names=@h['illustrator'] \
  ? name_format(@h['illustrator'])
  : nil
  s=(names.is_a?(Hash)) \
  ? names[:name_str]
  : nil
  s=if s
    l,n=Db[:col_name],'creator.illustrator'
    validate_length(s,l,n)
  else nil
  end
end

#illustrator_detailObject



408
409
410
411
412
413
414
415
# File 'lib/sisu/dp.rb', line 408

def illustrator_detail
  names=@h['illustrator'] \
  ? name_format(@h['illustrator'])
  : nil
  (names.is_a?(Hash)) \
  ? names[:name_a_h]
  : nil
end

#institutionObject



831
832
833
834
835
# File 'lib/sisu/dp.rb', line 831

def institution
  s=@h['institution']
  l,n=Db[:col_name],'original.institution'
  validate_length(s,l,n)
end

#isbnObject



691
692
693
694
695
# File 'lib/sisu/dp.rb', line 691

def isbn
  s=@h['isbn']
  l,n=Db[:col_small],'identifier.isbn'
  validate_length(s,l,n)
end

#issuedObject



758
759
760
761
762
# File 'lib/sisu/dp.rb', line 758

def issued
  s=@h['issued']
  l,n=Db[:col_date_text],'date.issued'
  validate_length(s,l,n)
end

#keywordsObject



716
717
718
719
720
# File 'lib/sisu/dp.rb', line 716

def keywords
  s=@h['keywords']
  l,n=Db[:col_txt_long],'classify.keywords'
  validate_length(s,l,n)
end

#languageObject



319
320
321
322
323
# File 'lib/sisu/dp.rb', line 319

def language
  s=@h['language']
  l,n=Db[:col_language],'title.language'
  validate_length(s,l,n)
end

#language_charObject

look into, this must be set, from 1 directory stub (.fi), 2 filename (~fi), [3 (not used) document header (@title:n :language_char: fi)]



324
325
326
327
328
# File 'lib/sisu/dp.rb', line 324

def language_char # look into, this must be set, from 1 directory stub (.fi), 2 filename (~fi), [3 (not used) document header (@title:\n  :language_char: fi)]
  s=@h['language_char']
  l,n=Db[:col_language_char],'title.language_char'
  validate_length(s,l,n)
end

#licenseObject



581
582
583
584
585
586
587
# File 'lib/sisu/dp.rb', line 581

def license
  s=@h['license'] \
  ? @h['license']
  : nil
  l,n=Db[:col_info_note],'rights.license'
  validate_length(s,l,n)
end

#locObject



721
722
723
724
725
# File 'lib/sisu/dp.rb', line 721

def loc
  s=@h['loc']
  l,n=Db[:col_library],'classify.loc'
  validate_length(s,l,n)
end

#mainObject



285
286
287
288
289
# File 'lib/sisu/dp.rb', line 285

def main
  s=@h['main']
  l,n=Db[:col_title_part],'title.main'
  validate_length(s,l,n)
end

#modifiedObject



763
764
765
766
767
# File 'lib/sisu/dp.rb', line 763

def modified
  s=@h['modified']
  l,n=Db[:col_date_text],'date.modified'
  validate_length(s,l,n)
end

#name_format(name) ⇒ Object



216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/sisu/dp.rb', line 216

def name_format(name)
  if name
    name=name.strip
    @name_a_h=[]
    authors=name.scan(/[^;]+/)
    authors.each_with_index do |a,i|
      b=((a =~/\s*\|\s*/) ? (a.split(/\|/)) : [a])
      if b[0] =~/"(.+?)"/
        @name_a_h << { the: $1 }
      else
        x=b[0].scan(/[^,]+/)
        if x.length==1
          @name_a_h << { the: x[0].strip }
        elsif x.length==2
          @name_a_h << { the: x[0].strip, others: x[1].strip }
        else #p x.length
        end
      end
      b.delete_at(0)
      b.each do |d|
        k,c=nil
        k,c=/^(\S+)\s+(.*)/.match(d)[1,2] if d
        @name_a_h[i][:hon]=c.strip if k=='hon'
        @name_a_h[i][:affiliation]=c.strip if k=='affiliation'
        @name_a_h[i][:nationality]=c.strip if k=='nationality'
      end
    end
    l=@name_a_h.length
    name_str=''
    @name_a_h.each_with_index do |a,i|
      name_str += if a[:others]
        z=(((l - i) > 1) ? ', ' : '')
        "#{a[:others].strip} #{a[:the].strip}" + z
      else
        z=(((l - i) > 2) ? ', ' : '')
        "#{a[:the].strip}" + z
      end
    end
    { name_a_h: @name_a_h, name_str: name_str }
  else nil
  end
end

#nationalityObject



836
837
838
839
840
# File 'lib/sisu/dp.rb', line 836

def nationality
  s=@h['nationality']
  l,n=Db[:col_language],'original.nationality'
  validate_length(s,l,n)
end

#noteObject



300
301
302
303
304
# File 'lib/sisu/dp.rb', line 300

def note
  s=@h['note']
  l,n=Db[:col_info_note],'title.note'
  validate_length(s,l,n)
end

#notesObject



843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
# File 'lib/sisu/dp.rb', line 843

def notes
  a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m)
  @h=build_hash(a)
  def description
    s=@h['description']
    l,n=Db[:col_info_note],'notes.description'
    validate_length(s,l,n)
  end
  def abstract
    s=@h['abstract']
    l,n=Db[:col_info_note],'notes.abstract'
    validate_length(s,l,n)
  end
  def comment
    s=@h['comment']
    l,n=Db[:col_info_note],'notes.comment'
    validate_length(s,l,n)
  end
  def coverage
    s=@h['coverage']
    l,n=Db[:col_info_note],'notes.coverage'
    validate_length(s,l,n)
  end
  def relation
    s=@h['relation']
    l,n=Db[:col_info_note],'notes.relation'
    validate_length(s,l,n)
  end
  def source
    s=@h['source']
    l,n=Db[:col_txt_long],'notes.source'
    validate_length(s,l,n)
  end
  def history
    s=@h['history']
    l,n=Db[:col_txt_long],'notes.history'
    validate_length(s,l,n)
  end
  def type
    s=@h['type']
    l,n=Db[:col_txt_long],'notes.relation'
    validate_length(s,l,n)
  end
  def format
    s=@h['format']
    l,n=Db[:col_txt_short],'notes.format'
    validate_length(s,l,n)
  end
  def prefix
    @h['prefix']
  end
  self
end

#oclcObject



686
687
688
689
690
# File 'lib/sisu/dp.rb', line 686

def oclc
  s=@h['oclc']
  l,n=Db[:col_library],'identifier.oclc'
  validate_length(s,l,n)
end

#originalObject



808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
# File 'lib/sisu/dp.rb', line 808

def original
  a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m)
  @h=build_hash(a)
  def publisher
    s=@h['publisher']
    l,n=Db[:col_name],'original.publisher'
    validate_length(s,l,n)
  end
  def language
    s=@h['language']
    l,n=Db[:col_language],'original.language'
    validate_length(s,l,n)
  end
  def language_char
    s=@h['language_char']
    l,n=Db[:col_language_char],'original.language_char'
    validate_length(s,l,n)
  end
  def source
    s=@h['source']
    l,n=Db[:col_name],'original.source'
    validate_length(s,l,n)
  end
  def institution
    s=@h['institution']
    l,n=Db[:col_name],'original.institution'
    validate_length(s,l,n)
  end
  def nationality
    s=@h['nationality']
    l,n=Db[:col_language],'original.nationality'
    validate_length(s,l,n)
  end
  self
end

#pgObject



696
697
698
699
700
# File 'lib/sisu/dp.rb', line 696

def pg
  s=@h['pg']
  l,n=Db[:col_small],'identifier.pg'
  validate_length(s,l,n)
end

#photographerObject



416
417
418
419
420
421
422
423
424
425
426
427
428
# File 'lib/sisu/dp.rb', line 416

def photographer
  names=@h['photographer'] \
  ? name_format(@h['photographer'])
  : nil
  s=(names.is_a?(Hash)) \
  ? names[:name_str]
  : nil
  s=if s
    l,n=Db[:col_name],'creator.photographer'
    validate_length(s,l,n)
  else nil
  end
end

#photographer_detailObject



429
430
431
432
433
434
435
436
# File 'lib/sisu/dp.rb', line 429

def photographer_detail
  names=@h['photographer'] \
  ? name_format(@h['photographer'])
  : nil
  (names.is_a?(Hash)) \
  ? names[:name_a_h]
  : nil
end

#photographsObject



558
559
560
561
562
563
564
# File 'lib/sisu/dp.rb', line 558

def photographs
  s=@h['photographs'] \
  ? @h['photographs']
  : nil
  l,n=Db[:col_info_note],'rights.copyright.photographs'
  validate_length(s,l,n)
end

#prefixObject



891
892
893
# File 'lib/sisu/dp.rb', line 891

def prefix
  @h['prefix']
end

#prepared_byObject



500
501
502
503
504
505
506
507
508
509
510
511
512
# File 'lib/sisu/dp.rb', line 500

def prepared_by
  names=@h['prepared_by'] \
  ? name_format(@h['prepared_by'])
  : nil
  s=(names.is_a?(Hash)) \
  ? names[:name_str]
  : nil
  s=if s
    l,n=Db[:col_name],'creator.prepared_by'
    validate_length(s,l,n)
  else nil
  end
end

#prepared_by_detailObject



513
514
515
516
517
518
519
520
521
# File 'lib/sisu/dp.rb', line 513

def prepared_by_detail
  names=@h['prepared_by'] \
  ? name_format(@h['prepared_by'])
  : nil
  names=name_format(@h['prepared_by'])
  (names.is_a?(Hash)) \
  ? names[:name_a_h]
  : nil
end

#publishedObject



768
769
770
771
772
# File 'lib/sisu/dp.rb', line 768

def published
  s=@h['published']=(@h['published'] ? @h['published'] : @h['main'])
  l,n=Db[:col_date_text],'date.published'
  validate_length(s,l,n)
end

#publisherObject



733
734
735
736
737
738
739
# File 'lib/sisu/dp.rb', line 733

def publisher
  a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m)
  @h=build_hash(a)
  s=@h['main']
  l,n=Db[:col_name],'publisher'
  validate_length(s,l,n)
end

#relationObject



866
867
868
869
870
# File 'lib/sisu/dp.rb', line 866

def relation
  s=@h['relation']
  l,n=Db[:col_info_note],'notes.relation'
  validate_length(s,l,n)
end

#rightsObject



524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
# File 'lib/sisu/dp.rb', line 524

def rights
  a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m)
  @h=build_hash(a)
  def copyright
    def text #you may wish to expand to take from all
      s=if @h['copyright'] then @h['copyright']
      elsif @h['text']     then @h['text']
      elsif @h['main']     then @h['main']
      else
        SiSU_Screen::Ansi.new(
          @opt.act[:color_state][:set],
          'WARNING Document Copyright missing; provide @rights: :copyright:'
        ).warn if (@opt.act[:verbose][:set]==:on \
          || @opt.act[:verbose_plus][:set]==:on \
          || @opt.act[:maintenance][:set]==:on)
        ''
      end
      l,n=Db[:col_info_note],'rights.copyright.text'
      validate_length(s,l,n)
    end
    def translation
      s=@h['translation'] \
      ? @h['translation']
      : nil
      l,n=Db[:col_info_note],'rights.copyright.translation'
      validate_length(s,l,n)
    end
    def illustrations
      s=@h['illustrations'] \
      ? @h['illustrations']
      : nil
      l,n=Db[:col_info_note],'rights.copyright.illustrations'
      validate_length(s,l,n)
    end
    def photographs
      s=@h['photographs'] \
      ? @h['photographs']
      : nil
      l,n=Db[:col_info_note],'rights.copyright.photographs'
      validate_length(s,l,n)
    end
    def digitization
      s=@h['digitization'] \
      ? @h['digitization']
      : nil
      l,n=Db[:col_info_note],'rights.copyright.digitization'
      validate_length(s,l,n)
    end
    def audio
      s=@h['audio'] \
      ? @h['audio']
      : nil
      l,n=Db[:col_info_note],'rights.copyright.audio'
      validate_length(s,l,n)
    end
    self
  end
  def license
    s=@h['license'] \
    ? @h['license']
    : nil
    l,n=Db[:col_info_note],'rights.license'
    validate_length(s,l,n)
  end
  def sep(str)
    ' \\\\ '
  end
  def copyright_and_license
    s=if @h['copyright_and_license'] then @h['copyright_and_license']
    else
      s=''
      if defined? copyright.text \
      and copyright.text \
      and not copyright.text.empty?
        v=sep(copyright.text)
        s +=copyright.text + v
      end
      if defined? copyright.license \
      and copyright.license \
      and not copyright.license.empty?
        s +=copyright.license
      end
      if s.empty?
        SiSU_Screen::Ansi.new(
          @opt.act[:color_state][:set],
          'WARNING Document Rights information missing; provide @rights: :copyright:'
        ).warn if (@opt.act[:verbose][:set]==:on \
          || @opt.act[:verbose_plus][:set]==:on \
          || @opt.act[:maintenance][:set]==:on)
      else
        l,n=Db[:col_info_note],'rights.all'
        validate_length(s,l,n)
      end
      s=s.gsub(/ [\\]+\s+$/,'')
    end
    s
  end
  def all
    s=if @h['all'] then @h['all']
    else
      s=''
      if defined? copyright.text \
      and copyright.text \
      and not copyright.text.empty?
        v=sep(copyright.text)
        s +='Copyright: ' + copyright.text + v
      end
      if defined? copyright.translation \
      and copyright.translation \
      and not copyright.translation.empty?
        v=sep(copyright.translation)
        s +='translation: ' + copyright.translation + v
      end
      if defined? copyright.illustrations \
      and copyright.illustrations \
      and not copyright.illustrations.empty?
        v=sep(copyright.illustrations)
        s +='illustrations: ' + copyright.illustrations + v
      end
      if defined? copyright.photographs \
      and copyright.photographs \
      and not copyright.photographs.empty?
        v=sep(copyright.photographs)
        s +='photographs: ' + copyright.photographs + v
      end
      if defined? copyright.digitization \
      and copyright.digitization \
      and not copyright.digitization.empty?
        v=sep(copyright.digitization)
        s +='digitization: ' + copyright.digitization + v
      end
      if defined? copyright.audio \
      and copyright.audio \
      and not copyright.audio.empty?
        v=sep(copyright.audio)
        s +='audio: ' + copyright.audio + v
      end
      if defined? copyright.license \
      and copyright.license \
      and not copyright.license.empty?
        s +='License: ' + copyright.license
      end
      if s.empty?
        SiSU_Screen::Ansi.new(
          @opt.act[:color_state][:set],
          'WARNING Document Rights information missing; provide @rights: :copyright:'
        ).warn if (@opt.act[:verbose][:set]==:on \
          || @opt.act[:verbose_plus][:set]==:on \
          || @opt.act[:maintenance][:set]==:on)
      else
        l,n=Db[:col_info_note],'rights.all'
        validate_length(s,l,n)
      end
      s=s.gsub(/ [\\]+\s+$/,'')
    end
    s
  end
  self
end

#sep(str) ⇒ Object



588
589
590
# File 'lib/sisu/dp.rb', line 588

def sep(str)
  ' \\\\ '
end

#shortObject



305
306
307
308
309
310
311
# File 'lib/sisu/dp.rb', line 305

def short
  s=@h['short'] \
  ? @h['short']
  : @h['main']
  l,n=Db[:col_title_part],'title.short'
  validate_length(s,l,n)
end

#sourceObject



826
827
828
829
830
# File 'lib/sisu/dp.rb', line 826

def source
  s=@h['source']
  l,n=Db[:col_name],'original.source'
  validate_length(s,l,n)
end

#subObject



290
291
292
293
294
# File 'lib/sisu/dp.rb', line 290

def sub
  s=@h['subtitle']
  l,n=Db[:col_title_part],'title.subtitle'
  validate_length(s,l,n)
end

#subjectObject



711
712
713
714
715
# File 'lib/sisu/dp.rb', line 711

def subject
  s=@h['subject']
  l,n=Db[:col_txt_long],'classify.subject'
  validate_length(s,l,n)
end

#textObject

you may wish to expand to take from all



528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
# File 'lib/sisu/dp.rb', line 528

def text #you may wish to expand to take from all
  s=if @h['copyright'] then @h['copyright']
  elsif @h['text']     then @h['text']
  elsif @h['main']     then @h['main']
  else
    SiSU_Screen::Ansi.new(
      @opt.act[:color_state][:set],
      'WARNING Document Copyright missing; provide @rights: :copyright:'
    ).warn if (@opt.act[:verbose][:set]==:on \
      || @opt.act[:verbose_plus][:set]==:on \
      || @opt.act[:maintenance][:set]==:on)
    ''
  end
  l,n=Db[:col_info_note],'rights.copyright.text'
  validate_length(s,l,n)
end

#titleObject



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/sisu/dp.rb', line 282

def title
  a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m)
  @h=build_hash(a)
  def main
    s=@h['main']
    l,n=Db[:col_title_part],'title.main'
    validate_length(s,l,n)
  end
  def sub
    s=@h['subtitle']
    l,n=Db[:col_title_part],'title.subtitle'
    validate_length(s,l,n)
  end
  def edition
    s=@h['edition']
    l,n=Db[:col_title_edition],'title.edition'
    validate_length(s,l,n)
  end
  def note
    s=@h['note']
    l,n=Db[:col_info_note],'title.note'
    validate_length(s,l,n)
  end
  def short
    s=@h['short'] \
    ? @h['short']
    : @h['main']
    l,n=Db[:col_title_part],'title.short'
    validate_length(s,l,n)
  end
  def full
    s=@h['subtitle'] \
    ? (@h['main'] + ' - ' + @h['subtitle'])
    : @h['main']
    l,n=Db[:col_title],'title.full'
    validate_length(s,l,n)
  end
  def language
    s=@h['language']
    l,n=Db[:col_language],'title.language'
    validate_length(s,l,n)
  end
  def language_char # look into, this must be set, from 1 directory stub (.fi), 2 filename (~fi), [3 (not used) document header (@title:\n  :language_char: fi)]
    s=@h['language_char']
    l,n=Db[:col_language_char],'title.language_char'
    validate_length(s,l,n)
  end
  self
end

#topic_registerObject



706
707
708
709
710
# File 'lib/sisu/dp.rb', line 706

def topic_register
  s=@h['topic_register']
  l,n=Db[:col_info_note],'classify.topic_register'
  validate_length(s,l,n)
end

#translationObject



544
545
546
547
548
549
550
# File 'lib/sisu/dp.rb', line 544

def translation
  s=@h['translation'] \
  ? @h['translation']
  : nil
  l,n=Db[:col_info_note],'rights.copyright.translation'
  validate_length(s,l,n)
end

#translatorObject



437
438
439
440
441
442
443
444
445
446
447
448
449
# File 'lib/sisu/dp.rb', line 437

def translator
  names=@h['translator'] \
  ? name_format(@h['translator'])
  : nil
  s=(names.is_a?(Hash)) \
  ? names[:name_str]
  : nil
  s=if s
    l,n=Db[:col_name],'creator.translator'
    validate_length(s,l,n)
  else nil
  end
end

#translator_detailObject



450
451
452
453
454
455
456
457
# File 'lib/sisu/dp.rb', line 450

def translator_detail
  names=@h['translator'] \
  ? name_format(@h['translator'])
  : nil
  (names.is_a?(Hash)) \
  ? names[:name_a_h]
  : nil
end

#typeObject



881
882
883
884
885
# File 'lib/sisu/dp.rb', line 881

def type
  s=@h['type']
  l,n=Db[:col_txt_long],'notes.relation'
  validate_length(s,l,n)
end

#validObject



773
774
775
776
777
# File 'lib/sisu/dp.rb', line 773

def valid
  s=@h['valid']
  l,n=Db[:col_date_text],'date.valid'
  validate_length(s,l,n)
end

#validate_length(s, l, n) ⇒ Object



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/sisu/dp.rb', line 197

def validate_length(s,l,n)
  #s=(s.length <= l) ? s : nil
  s=if s.is_a?(String) \
  and s.length <= l
    s
  elsif s.is_a?(NilClass)
    nil
  elsif s.class !=String
    STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}"
    s
  else
    SiSU_Screen::Ansi.new(
      'v',
      "*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped",
      @opt.fns
    ).warn unless @opt.act[:quiet][:set]==:on
    nil
  end
end