Class: SiSU_SimpleXML_ModelSax::Convert

Inherits:
Object
  • Object
show all
Defined in:
lib/sisu/sst_to_s_xml_sax.rb

Defined Under Namespace

Classes: Output, Scroll, Songsheet, Tidy

Constant Summary collapse

@@fns =
nil

Instance Method Summary collapse

Constructor Details

#initialize(opt) ⇒ Convert

Returns a new instance of Convert.



74
75
76
77
# File 'lib/sisu/sst_to_s_xml_sax.rb', line 74

def initialize(opt)
  @opt=opt
  @particulars=SiSU_Particulars::CombinedSingleton.instance.get_env_md(opt)
end

Instance Method Details

#readObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/sisu/sst_to_s_xml_sax.rb', line 78

def read
  begin
    @md=@particulars.md #bug, relies on info persistence, assumes -m has previously been run
    @env=@particulars.env
    SiSU_Screen::Ansi.new(
      @opt.act[:color_state][:set],
      'invert',
      'XML SAX',
      "#{@md.fns} -> #{@md.fn[:sxs]}"
    ).colorize unless @opt.act[:quiet][:set]==:on
    if (@opt.act[:verbose_plus][:set]==:on \
    || @opt.act[:maintenance][:set]==:on)
      SiSU_Screen::Ansi.new(
        @opt.act[:color_state][:set],
        @opt.fns,
        "#{Dir.pwd}/#{@md.fn[:sxs]}"
      ).flow
    end
    unless @@fns==@opt.fns
      @@fns=@opt.fns
      @@fns_array=[]
    end
    @fns_array=if @@fns_array.empty?; read_fnm
    else @@fns_array.dup #check
    end
    SiSU_SimpleXML_ModelSax::Convert::Songsheet.new(@fns_array,@particulars).songsheet
  rescue
    SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do
      __LINE__.to_s + ':' + __FILE__
    end
  ensure #file closed in songsheet
  end
end

#read_fnmObject



111
112
113
114
115
116
117
# File 'lib/sisu/sst_to_s_xml_sax.rb', line 111

def read_fnm
  ao=[]
  if FileTest.file?("#{Dir.pwd}/#{@opt.fns}")
    ao=IO.readlines("#{Dir.pwd}/#{@opt.fns}","\n\n")
  else STDERR.puts 'Error'
  end
end