Class: SiSU_Po4aUtils::HeaderScan

Inherits:
Object
  • Object
show all
Defined in:
lib/sisu/src_po4a_shelf_set.rb,
lib/sisu/src_po4a_sst_ao_sst_set.rb

Instance Method Summary collapse

Constructor Details

#initialize(md, para) ⇒ HeaderScan

Returns a new instance of HeaderScan.



174
175
176
# File 'lib/sisu/src_po4a_shelf_set.rb', line 174

def initialize(md,para)
  @md,@p=md,para
end

Instance Method Details

#attribObject



204
205
206
# File 'lib/sisu/src_po4a_shelf_set.rb', line 204

def attrib
  @attrib
end

#attributeObject



198
199
200
# File 'lib/sisu/src_po4a_shelf_set.rb', line 198

def attribute
  @attrib
end

#dublinObject



263
264
265
266
267
# File 'lib/sisu/src_po4a_shelf_set.rb', line 263

def dublin
  (@p =~/^#{Mx[:meta_o]}\S+?#{Mx[:meta_c]}/) \
  ? start_is_match
  : nil
end

#elObject



207
208
209
# File 'lib/sisu/src_po4a_shelf_set.rb', line 207

def el
  @tag
end

#elementObject



201
202
203
# File 'lib/sisu/src_po4a_shelf_set.rb', line 201

def element
  @tag
end

#extract(tag, tag_content, type, attrib) ⇒ Object



177
178
179
180
181
182
183
# File 'lib/sisu/src_po4a_shelf_set.rb', line 177

def extract(tag,tag_content,type,attrib)
  if dc_tag \
  and dc_content
    [dc_tag,dc_content,{dc_tag=>dc_content}]
  else nil
  end
end

#header(tag, tag_content, type = '', attrib = '') ⇒ Object

this will break stuff and must be tested thoroughly 20060825



184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/sisu/src_po4a_shelf_set.rb', line 184

def header(tag,tag_content,type='',attrib='') #this will break stuff and must be tested thoroughly 20060825
  @tag,@tag_content,@type,@attrib=tag,tag_content,type,attrib
  def label #element
    @tag
  end
  def type
    @type
  end
  def text
    @tag_content
  end
  def info  #element text
    @tag_content
  end
  def attribute
    @attrib
  end
  def element
    @tag
  end
  def attrib
    @attrib
  end
  def el
    @tag
  end
  self
end

#infoObject

element text



195
196
197
# File 'lib/sisu/src_po4a_shelf_set.rb', line 195

def info  #element text
  @tag_content
end

#labelObject

element



186
187
188
# File 'lib/sisu/src_po4a_shelf_set.rb', line 186

def label #element
  @tag
end

#metaObject



268
269
270
271
272
# File 'lib/sisu/src_po4a_shelf_set.rb', line 268

def meta
  (@p =~/^#{Mx[:meta_o]}\S+?#{Mx[:meta_c]}/) \
  ? start_is_match
  : nil
end

#start_is_matchObject



212
213
214
215
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
258
259
260
261
262
# File 'lib/sisu/src_po4a_shelf_set.rb', line 212

def start_is_match
  case @p
  when /^#{Mx[:meta_o]}(title)#{Mx[:meta_c]}\s*(.+?)$/                      then header($1,@md.title.full,'meta','dc') #dc 1
  when /^#{Mx[:meta_o]}(creator|author)#{Mx[:meta_c]}\s*(.+?)$/             then header('creator',$2,'meta','dc')    #dc 2
  when /^#{Mx[:meta_o]}(subject)#{Mx[:meta_c]}\s*(.+?)$/                    then header($1,$2,'meta','dc')           #dc 3
  when /^#{Mx[:meta_o]}(description)#{Mx[:meta_c]}\s*(.+?)$/                then header($1,$2,'meta','dc')           #dc 4
  when /^#{Mx[:meta_o]}(publisher)#{Mx[:meta_c]}\s*(.+?)$/                  then header($1,$2,'meta','dc')           #dc 5
  when /^#{Mx[:meta_o]}(contributor)#{Mx[:meta_c]}\s*(.+?)$/                then header($1,$2,'meta','dc')           #dc 6
  when /^#{Mx[:meta_o]}(date)#{Mx[:meta_c]}\s*(.+?)$/                       then header($1,$2,'meta','dc')           #dc 7
  when /^#{Mx[:meta_o]}(date\.created)#{Mx[:meta_c]}\s*(.+?)$/              then header($1,$2,'meta','extra')
  when /^#{Mx[:meta_o]}(date\.issued)#{Mx[:meta_c]}\s*(.+?)$/               then header($1,$2,'meta','extra')
  when /^#{Mx[:meta_o]}(date\.available)#{Mx[:meta_c]}\s*(.+?)$/            then header($1,$2,'meta','extra')
  when /^#{Mx[:meta_o]}(date\.valid)#{Mx[:meta_c]}\s*(.+?)$/                then header($1,$2,'meta','extra')
  when /^#{Mx[:meta_o]}(date\.modified)#{Mx[:meta_c]}\s*(.+?)$/             then header($1,$2,'meta','extra')
  when /^#{Mx[:meta_o]}(type)#{Mx[:meta_c]}\s*(.+?)$/                       then header($1,$2,'meta','dc')           #dc 8
  when /^#{Mx[:meta_o]}(format)#{Mx[:meta_c]}\s*(.+?)$/                     then header($1,$2,'meta','dc')           #dc 9
  when /^#{Mx[:meta_o]}(identifier)#{Mx[:meta_c]}\s*(.+?)$/                 then header($1,$2,'meta','dc')           #dc 10
  when /^#{Mx[:meta_o]}(source)#{Mx[:meta_c]}\s*(.+?)$/                     then header($1,$2,'meta','dc')           #dc 11
  when /^#{Mx[:meta_o]}(language)#{Mx[:meta_c]}\s*(.+?)$/                   then header($1,$2,'meta','dc')           #dc 12
  when /^#{Mx[:meta_o]}(relation)#{Mx[:meta_c]}\s*(.+?)$/                   then header($1,$2,'meta','dc')           #dc 13
  when /^#{Mx[:meta_o]}(coverage)#{Mx[:meta_c]}\s*(.+?)$/                   then header($1,$2,'meta','dc')           #dc 14
  when /^#{Mx[:meta_o]}(rights)#{Mx[:meta_c]}\s*(.+?)$/                     then header($1,$2,'meta','dc')           #dc 15
  when /^#{Mx[:meta_o]}(keywords)#{Mx[:meta_c]}\s*(.+?)$/                   then header($1,$2,'meta','extra')
  when /^#{Mx[:meta_o]}(copyright)#{Mx[:meta_c]}\s*(.+?)$/                  then header($1,$2,'meta','extra')
  when /^#{Mx[:meta_o]}(translator|translated_by)#{Mx[:meta_c]}\s*(.+?)$/   then header('translator',$2)
  when /^#{Mx[:meta_o]}(illustrator|illustrated_by)#{Mx[:meta_c]}\s*(.+?)$/ then header('illustrator',$2)
  when /^#{Mx[:meta_o]}(prepared_by)#{Mx[:meta_c]}\s*(.+?)$/                then header($1,$2,'meta','extra')
  when /^#{Mx[:meta_o]}(digitized_by)#{Mx[:meta_c]}\s*(.+?)$/               then header($1,$2,'meta','extra')
  when /^#{Mx[:meta_o]}(comments?)#{Mx[:meta_c]}\s*(.+?)$/                  then header($1,$2,'meta','extra')
  when /^#{Mx[:meta_o]}(abstract)#{Mx[:meta_c]}\s*(.+?)$/                   then header($1,$2,'meta','extra')
  when /^#{Mx[:meta_o]}(tags?)#{Mx[:meta_c]}\s*(.+?)$/                      then header($1,$2,'meta','extra')
  when /^#{Mx[:meta_o]}(catalogue)#{Mx[:meta_c]}\s*(.+?)$/                  then header($1,$2,'meta','extra')
  when /^#{Mx[:meta_o]}(class(?:ify)?_loc)#{Mx[:meta_c]}\s*(.+?)$/          then header('classify_loc',$2,'meta','extra')
  when /^#{Mx[:meta_o]}(class(?:ify)?_dewey)#{Mx[:meta_c]}\s*(.+?)$/        then header('classify_dewey',$2,'meta','extra')
  when /^#{Mx[:meta_o]}(class(?:ify)?_pg)#{Mx[:meta_c]}\s*(.+?)$/           then header('classify_pg',$2,'meta','extra')
  when /^#{Mx[:meta_o]}(class(?:ify)?_isbn)#{Mx[:meta_c]}\s*(.+?)$/         then header('classify_isbn',$2,'meta','extra')
  when /^#{Mx[:meta_o]}(toc|structure)#{Mx[:meta_c]}\s*(.+?)$/              then header('structure',$2,'process','instruct')
  when /^#{Mx[:meta_o]}(level|page|markup)#{Mx[:meta_c]}\s*(.+?)$/          then header('markup',$2,'process','instruct')
  when /^#{Mx[:meta_o]}(bold)#{Mx[:meta_c]}\s*(.+?)$/                       then header($1,$2,'process','instruct')
  when /^#{Mx[:meta_o]}(italics|itali[sz]e)#{Mx[:meta_c]}\s*(.+?)$/         then header('italicize',$2,'process','instruct')
  when /^#{Mx[:meta_o]}(vocabulary|wordlist)#{Mx[:meta_c]}\s*(.+?)$/        then header('vocabulary',$2,'process','instruct')
  when /^#{Mx[:meta_o]}(css|stylesheet)#{Mx[:meta_c]}\s*(.+?)$/             then header('css',$2,'process','instruct')
  when /^#{Mx[:meta_o]}(links)#{Mx[:meta_c]}\s*(.+?)$/                      then header($1,$2,'process','instruct')
  when /^#{Mx[:meta_o]}(prefix)#{Mx[:meta_c]}\s*(.+?)$/                     then header($1,$2,'process','instruct') #add a & b
  when /^#{Mx[:meta_o]}(suffix)#{Mx[:meta_c]}\s*(.+?)$/                     then header($1,$2,'process','instruct')
  when /^#{Mx[:meta_o]}(information)#{Mx[:meta_c]}\s*(.+?)$/                then header($1,$2,'process','instruct')
  when /^#{Mx[:meta_o]}(contact)#{Mx[:meta_c]}\s*(.+?)$/                    then header($1,$2,'process','instruct')
  when /^#{Mx[:meta_o]}(rcs|cvs)#{Mx[:meta_c]}\s*(.+?)$/                    then header('version',$2,'process','instruct')
  else nil
  end
end

#textObject



192
193
194
# File 'lib/sisu/src_po4a_shelf_set.rb', line 192

def text
  @tag_content
end

#typeObject



189
190
191
# File 'lib/sisu/src_po4a_shelf_set.rb', line 189

def type
  @type
end