class SiSU_ConvertFootnotes::Source
Public Class Methods
new(opt)
click to toggle source
# File lib/sisu/sst_do_inline_footnotes.rb, line 78 def initialize(opt) @opt=opt @@fns||@opt.fns @my_make=SiSU_Env::CreateFile.new(@opt.fns) @fnm=SiSU_Env::InfoFile.new(@opt.fns).marshal.ao_content end
Public Instance Methods
get()
click to toggle source
# File lib/sisu/sst_do_inline_footnotes.rb, line 97 def get #reads ao, unless does not exist then creates first begin ao=[] unless @@fns==@opt.fns @@fns=@opt.fns @@ao_array=[] end ao=(@@ao_array.empty?) \ ? read_fnm : @@ao_array.dup #check rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ end ensure Instantiate.new end end
read()
click to toggle source
# File lib/sisu/sst_do_inline_footnotes.rb, line 84 def read #creates ao begin @@ao_array=[] @@fns=@opt.fns create_ao rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ end ensure Instantiate.new end end
Protected Instance Methods
create_ao()
click to toggle source
# File lib/sisu/sst_do_inline_footnotes.rb, line 116 def create_ao ao_array=[] SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], 'convert footnotes' ).green_title_hi unless @opt.act[:quiet][:set]==:on file_array=IO.readlines(@opt.fns,'') file_array.each do |l| if l =~/\r\n/ then l.gsub!(/\r\n/,"\n") end end meta=file_array.dup meta=meta.join.split("\n\n") #check whether can be eliminated, some of these are large objects to have twice @md=SiSU_Param::Parameters::Instructions.new(meta,@opt).extract if @md.en[:mismatch]==0 \ or @md.opt.selections.str =~/=footnotes-force/ meta=nil ao=SiSU_ConvertFootnotes::Make.new(@md,file_array).song SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], @opt.fns, "#{@md.fns}.fn" ).output if @md.opt.act[:verbose][:set]==:on SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], "#{@md.fns}.fn -> #{@md.fns}.fn" ).txt_red unless @md.opt.act[:quiet][:set]==:on ao.each {|s| ao_array << "#{s.strip}\n\n" unless s.strip.empty?} ao_array else SiSU_Screen::Ansi.new( @md.opt.act[:color_state][:set], '*WARN* no footnote conversion done, problem with source file', 'to override use --convert=footnote-force (this is not advised)' ).warn unless @md.opt.act[:quiet][:set]==:on '' end end
read_fnm()
click to toggle source
# File lib/sisu/sst_do_inline_footnotes.rb, line 154 def read_fnm ao=[] ao=(FileTest.file?(@fnm)) \ ? (File.open(@fnm){ |f| ao=Marshal.load(f)}) : (SiSU_ConvertFootnotes::Source.new(@opt).create_ao) #watch end