Class: Slaw::ZA::Act::Schedule

Inherits:
Treetop::Runtime::SyntaxNode
  • Object
show all
Defined in:
lib/slaw/za/act_nodes.rb

Instance Method Summary collapse

Instance Method Details

#aliasObject



414
415
416
417
418
419
420
# File 'lib/slaw/za/act_nodes.rb', line 414

def alias
  if num
    "Schedule #{num}"
  else
    "Schedule"
  end
end

#headingObject



422
423
424
425
426
427
428
# File 'lib/slaw/za/act_nodes.rb', line 422

def heading
  if schedule_heading.schedule_title.respond_to? :content
    schedule_heading.schedule_title.content.text_value
  else
    nil
  end
end

#numObject



409
410
411
412
# File 'lib/slaw/za/act_nodes.rb', line 409

def num
  n = schedule_heading.num.text_value
  return (n && !n.empty?) ? n : nil
end

#to_xml(b, idprefix = nil, i = 1) ⇒ Object



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
# File 'lib/slaw/za/act_nodes.rb', line 430

def to_xml(b, idprefix=nil, i=1)
  n = num.nil? ? i : num

  # component name
  comp = "schedule#{n}"
  id = "#{idprefix}schedule-#{n}"

  b.component(id: "component-#{id}") { |b|
    b.doc_(name: "schedule#{n}") { |b|
      b.meta { |b|
        b.identification(source: "#slaw") { |b|
          b.FRBRWork { |b|
            b.FRBRthis(value: "#{Act::WORK_URI}/#{comp}")
            b.FRBRuri(value: Act::WORK_URI)
            b.FRBRalias(value: self.alias)
            b.FRBRdate(date: '1980-01-01', name: 'Generation')
            b.FRBRauthor(href: '#council')
            b.FRBRcountry(value: 'za')
          }
          b.FRBRExpression { |b|
            b.FRBRthis(value: "#{Act::EXPRESSION_URI}/#{comp}")
            b.FRBRuri(value: Act::EXPRESSION_URI)
            b.FRBRdate(date: '1980-01-01', name: 'Generation')
            b.FRBRauthor(href: '#council')
            b.FRBRlanguage(language: 'eng')
          }
          b.FRBRManifestation { |b|
            b.FRBRthis(value: "#{Act::MANIFESTATION_URI}/#{comp}")
            b.FRBRuri(value: Act::MANIFESTATION_URI)
            b.FRBRdate(date: Time.now.strftime('%Y-%m-%d'), name: 'Generation')
            b.FRBRauthor(href: '#slaw')
          }
        }
      }

      b.mainBody { |b| 
        # there is no good AKN hierarchy container for schedules, so we
        # just use article because we don't use it anywhere else.
        b.article(id: id) { |b|
          b.heading(heading) if heading
          body.children.elements.each { |e| e.to_xml(b) }
        }
      }
    }
  }
end