Class: Slaw::Grammars::ZA::Act::Act

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

Constant Summary collapse

FRBR_URI =
'/za/act/1980/01'
WORK_URI =
FRBR_URI
EXPRESSION_URI =
"#{FRBR_URI}/eng@"
MANIFESTATION_URI =
EXPRESSION_URI

Instance Method Summary collapse

Instance Method Details

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



13
14
15
16
17
18
19
20
21
# File 'lib/slaw/grammars/za/act_nodes.rb', line 13

def to_xml(b, idprefix=nil, i=0)
  b.act(contains: "originalVersion") { |b|
    write_meta(b)
    write_preface(b)
    write_preamble(b)
    write_body(b)
  }
  write_schedules(b)
end

#write_body(b) ⇒ Object



69
70
71
# File 'lib/slaw/grammars/za/act_nodes.rb', line 69

def write_body(b)
  body.to_xml(b)
end

#write_identification(b) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/slaw/grammars/za/act_nodes.rb', line 34

def write_identification(b)
  b.identification(source: "#slaw") { |b|
    # use stub values so that we can generate a validating document
    b.FRBRWork { |b|
      b.FRBRthis(value: "#{WORK_URI}/main")
      b.FRBRuri(value: WORK_URI)
      b.FRBRalias(value: 'Short Title')
      b.FRBRdate(date: '1980-01-01', name: 'Generation')
      b.FRBRauthor(href: '#council')
      b.FRBRcountry(value: 'za')
    }
    b.FRBRExpression { |b|
      b.FRBRthis(value: "#{EXPRESSION_URI}/main")
      b.FRBRuri(value: EXPRESSION_URI)
      b.FRBRdate(date: '1980-01-01', name: 'Generation')
      b.FRBRauthor(href: '#council')
      b.FRBRlanguage(language: 'eng')
    }
    b.FRBRManifestation { |b|
      b.FRBRthis(value: "#{MANIFESTATION_URI}/main")
      b.FRBRuri(value: MANIFESTATION_URI)
      b.FRBRdate(date: Time.now.strftime('%Y-%m-%d'), name: 'Generation')
      b.FRBRauthor(href: '#slaw')
    }
  }
end

#write_meta(b) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/slaw/grammars/za/act_nodes.rb', line 23

def write_meta(b)
  b.meta { |b|
    write_identification(b)

    b.references(source: "#this") {
      b.TLCOrganization(id: 'slaw', href: 'https://github.com/longhotsummer/slaw', showAs: "Slaw")
      b.TLCOrganization(id: 'council', href: '/ontology/organization/za/council', showAs: "Council")
    }
  }
end

#write_preamble(b) ⇒ Object



65
66
67
# File 'lib/slaw/grammars/za/act_nodes.rb', line 65

def write_preamble(b)
  preamble.to_xml(b) if preamble.respond_to? :to_xml
end

#write_preface(b) ⇒ Object



61
62
63
# File 'lib/slaw/grammars/za/act_nodes.rb', line 61

def write_preface(b)
  preface.to_xml(b) if preface.respond_to? :to_xml
end

#write_schedules(b) ⇒ Object



73
74
75
76
77
# File 'lib/slaw/grammars/za/act_nodes.rb', line 73

def write_schedules(b)
  if schedules.text_value != ""
    schedules.to_xml(b)
  end
end