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



370
371
372
373
374
375
376
# File 'lib/slaw/za/act_nodes.rb', line 370

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

#headingObject



378
379
380
381
382
383
384
# File 'lib/slaw/za/act_nodes.rb', line 378

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

#numObject



365
366
367
368
# File 'lib/slaw/za/act_nodes.rb', line 365

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

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



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

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

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

  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', as: '#author')
          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', as: '#author')
          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', as: '#author')
        }
      }
    }

    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
        b.content { |b|
          statements.elements.each { |e| e.to_xml(b, id + '.') }
        }
      }
    }
  }
end