Class: PerlFunc

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

Constant Summary collapse

FUNCLIST_BEGINS_FROM =
/Alphabetical Listing of Perl Functions/
REJECT_REGEXP =
/^\*$/

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

#extract_funcs(pod_source) ⇒ Object



69
70
71
72
73
74
75
76
# File 'lib/langhelp/lh_perl.rb', line 69

def extract_funcs(pod_source)
  _, text = pod_source.split(FUNCLIST_BEGINS_FROM, 2)
  @funcs = text.scan(/^=item (.+)$/).flatten.reject{|func| func =~ REJECT_REGEXP }.map {|usage|
    name = usage.split(/[\s\(]/)[0]
    name.sub!(/\/.+$/,'')
    [ name, usage ]
  }
end

#init(x = {}) ⇒ Object



62
63
64
65
# File 'lib/langhelp/lh_perl.rb', line 62

def init(x={})
  @perlfunc_pod = x[:perlfunc_pod]
  normalize_filename! @perlfunc_pod
end

#to_e(out) ⇒ Object



78
79
80
81
82
83
# File 'lib/langhelp/lh_perl.rb', line 78

def to_e(out)
  extract_funcs File.read(@perlfunc_pod)
  @funcs.each do |name, usage|
    out << format("# %-30s#{SPACES}(lh-perlfunc %s)\n", usage, lisp_dump_string(name))
  end  
end