class SiSU_Param::Parameters

Public Class Methods

new(opt) click to toggle source
# File lib/sisu/dp.rb, line 81
def initialize(opt)
  @opt=opt
  @cX||=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set])
  @fns=if @opt.act[:psql][:set] == [:on] #revisit CHECK
    opt.fns
  else opt.fns.gsub(/\.ssm$/,'.ssm.sst')
  end
  SiSU_Param::Instantiate.new.param_instantiate
  @env=SiSU_Env::InfoEnv.new(@fns)
  @pstorefile="#{@env.processing_path.ao}/#{@fns}.pstore"
end

Public Instance Methods

get() click to toggle source
# File lib/sisu/dp.rb, line 92
def get
  if @opt.f_pth \
  and @opt.f_pth[:pth] != Dir.pwd #BUG check
    # you may need to change Dir.pwd to @opt.f_pth[:pth] where the latter
    # has a path value that is different, however, f_pth is not always set!
    Dir.chdir(@opt.f_pth[:pth])
  end
  if @@fns !=@fns \
  or @@pth !=Dir.pwd               #@opt.f_pth[:pth]
    @@fns,@@pth=@fns,Dir.pwd       #@opt.f_pth[:pth]
    @@md=nil
  end
  if @@md.nil? \
  or @opt.act[:maintenance][:set]==:on #not particularly helpful, as current cycle is through output types, with files changing, only helpful if deal with a file all output types before going to next file
    if File.exist?(@pstorefile)
      param_msg='Parameters from pstore'
      store=PStore.new(@pstorefile)
      store.transaction do
        @md=store['md']
      end
      @md
    else
      param_msg='Parameters extracted'
      fns_array=@env.read_source_file(@opt.fns)
      @md=SiSU_Param::Parameters::Instructions.new(fns_array,@opt).extract
      @md
    end
    if defined? @md.title.main # on removal check problems with -U
      if (@opt.act[:verbose][:set]==:on \
      || @opt.act[:verbose_plus][:set]==:on \
      || @opt.act[:maintenance][:set]==:on)
        SiSU_Screen::Ansi.new(
          @opt.act[:color_state][:set],
          param_msg,
          @md.title.main
        ).txt_grey
      end
    end
    @@md=@md
  else @@md
  end
  begin
    @@md.opt=@opt
    @@md
  rescue
    SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
      mark('has an existing option been selected?')
    exit
  end
end