Class: Slaw::Grammars::Schedules::Schedule
- Inherits:
-
Treetop::Runtime::SyntaxNode
- Object
- Treetop::Runtime::SyntaxNode
- Slaw::Grammars::Schedules::Schedule
- Defined in:
- lib/slaw/grammars/schedules_nodes.rb
Instance Method Summary collapse
- #alias ⇒ Object
- #num ⇒ Object
- #subheading ⇒ Object
- #title ⇒ Object
- #to_xml(b, idprefix = nil, i = 1) ⇒ Object
Instance Method Details
#alias ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/slaw/grammars/schedules_nodes.rb', line 27 def alias if not schedule_title.title.text_value.blank? # plain-text elements only schedule_title.title.elements.select { |x| x.instance_of? ::Slaw::Grammars::Inlines::InlineItem }.map { |x| x.text_value }.join('').strip elsif num "Schedule #{num}" else "Schedule" end end |
#num ⇒ Object
22 23 24 25 |
# File 'lib/slaw/grammars/schedules_nodes.rb', line 22 def num n = schedule_title.num.text_value return (n && !n.empty?) ? n : nil end |
#subheading ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/slaw/grammars/schedules_nodes.rb', line 46 def subheading if not schedule_title.subheading.text_value.blank? schedule_title.subheading.inline_items else nil end end |
#title ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/slaw/grammars/schedules_nodes.rb', line 38 def title if not schedule_title.title.text_value.blank? schedule_title.title else nil end end |
#to_xml(b, idprefix = nil, i = 1) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/slaw/grammars/schedules_nodes.rb', line 54 def to_xml(b, idprefix=nil, i=1) if num n = num component = "schedule#{n}" else n = i # make a component name from the schedule title component = self.alias.downcase().strip().gsub(/[^a-z0-9]/i, '').gsub(/ +/, '') end id = "#{idprefix}#{component}" b.component(id: "component-#{id}") { |b| b.doc_(name: component) { |b| b. { |b| b.identification(source: "#slaw") { |b| b.FRBRWork { |b| b.FRBRthis(value: "#{WORK_URI}/#{component}") b.FRBRuri(value: 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: "#{EXPRESSION_URI}/#{component}") 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}/#{component}") b.FRBRuri(value: MANIFESTATION_URI) b.FRBRdate(date: Time.now.strftime('%Y-%m-%d'), name: 'Generation') b.FRBRauthor(href: '#slaw') } } } b.mainBody { |b| idprefix = "#{id}." # there is no good AKN hierarchy container for schedules, so we # use hcontainer instead b.hcontainer(id: id, name: "schedule") { |b| if title and title.elements b.heading { |b| title.to_xml(b, idprefix) } else b.heading(self.alias) end b.subheading { |b| subheading.to_xml(b, idprefix) } if subheading body.children.elements.each_with_index { |e| e.to_xml(b, idprefix, i) } if body.is_a? Body } } } } end |