Class: HTMLIndex

Inherits:
AbstractIndex show all
Defined in:
lib/langhelp/langhelp-base.rb

Overview

Information index class by HTML source

Direct Known Subclasses

PythonLib

Constant Summary

Constants inherited from AbstractIndex

AbstractIndex::SPACES

Constants included from LocalVariables

LocalVariables::ANCHOR_BEGIN, LocalVariables::ANCHOR_END

Constants included from KanjiConverter

KanjiConverter::KCONVERTERS

Instance Attribute Summary

Attributes inherited from AbstractIndex

#arg1, #conf, #title

Instance Method Summary collapse

Methods inherited from AbstractIndex

#initialize, #output_title

Methods included from LocalVariables

#insert_local_variables

Methods included from FilenameString

#abbreviate_filename, #abbreviate_filename!, #normalize_filename!

Methods included from KanjiConverter

#encoding, #kconv

Methods included from MkArray

#mkarray

Methods included from EmacsLispString

#lisp_dump_string

Constructor Details

This class inherits a constructor from AbstractIndex

Instance Method Details

#init(x = {}) ⇒ Object



382
383
384
385
# File 'lib/langhelp/langhelp-base.rb', line 382

def init(x={})
  @spaces = x[:spaces] || 20
  init_filename x
end

#init_filename(x) ⇒ Object



387
388
389
390
391
392
393
394
395
396
397
# File 'lib/langhelp/langhelp-base.rb', line 387

def init_filename(x)
  if arg1 =~ /\.html$/
    @index_page = arg1
    @dir = File.dirname(@index_page)
  else
    @dir = x[:dir]
    @index_page = x[:index_page]
  end

  normalize_filename! @dir, @index_page
end

#post_process(es_src) ⇒ Object

overridden by subclass



414
415
416
# File 'lib/langhelp/langhelp-base.rb', line 414

def post_process(es_src)
  es_src
end

#pre_process(html_src) ⇒ Object

overridden by subclass



409
410
411
# File 'lib/langhelp/langhelp-base.rb', line 409

def pre_process(html_src)
  html_src
end

#spaceObject

number of spaces between label and sexp



404
405
406
# File 'lib/langhelp/langhelp-base.rb', line 404

def space
  " "*@spaces
end

#to_e(out) ⇒ Object

Dump into e-script pre_process -> HTML2TXT -> post_process



420
421
422
423
424
425
426
427
# File 'lib/langhelp/langhelp-base.rb', line 420

def to_e(out)
  find_index unless @index_page
  f = Tempfile.new("lh")
  
  f.puts(pre_process(kconv{ File.read(@index_page) }))
  f.close
  out << post_process(kconv{ `#{conf[:HTML2TXT]} #{f.path}` })
end