From 6b2c44794b8aeeca96a9b3114b87b3c1df69fd9d Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 Oct 2012 15:43:19 -0400 Subject: v3: cosmetic code, .is_a?(X) replaces .class==X (& some defined? & nil? tests) --- lib/sisu/v3/cgi_pgsql.rb | 2 +- lib/sisu/v3/cgi_sql_common.rb | 5 +- lib/sisu/v3/dal.rb | 20 +++---- lib/sisu/v3/dal_character_check.rb | 2 +- lib/sisu/v3/dal_doc_str.rb | 11 ++-- lib/sisu/v3/dal_hash_digest.rb | 4 +- lib/sisu/v3/dal_idx.rb | 22 ++++--- lib/sisu/v3/dal_numbering.rb | 10 ++-- lib/sisu/v3/dal_syntax.rb | 2 +- lib/sisu/v3/db_columns.rb | 24 ++++---- lib/sisu/v3/db_select.rb | 2 +- lib/sisu/v3/db_sqltxt.rb | 2 +- lib/sisu/v3/dbi_discreet.rb | 2 +- lib/sisu/v3/epub_format.rb | 2 +- lib/sisu/v3/epub_segments.rb | 4 +- lib/sisu/v3/epub_tune.rb | 2 +- lib/sisu/v3/harvest_authors.rb | 16 +++--- lib/sisu/v3/harvest_topics.rb | 114 ++++++++++++++++++------------------- lib/sisu/v3/html_format.rb | 2 +- lib/sisu/v3/html_promo.rb | 4 +- lib/sisu/v3/html_segments.rb | 4 +- lib/sisu/v3/html_tune.rb | 2 +- lib/sisu/v3/hub.rb | 2 +- lib/sisu/v3/manifest.rb | 2 +- lib/sisu/v3/manpage.rb | 2 +- lib/sisu/v3/odf.rb | 4 +- lib/sisu/v3/odf_format.rb | 2 +- lib/sisu/v3/param.rb | 46 +++++++-------- lib/sisu/v3/plaintext.rb | 4 +- lib/sisu/v3/plaintext_format.rb | 2 +- lib/sisu/v3/po4a.rb | 12 ++-- lib/sisu/v3/po4a_set.rb | 2 +- lib/sisu/v3/qrcode.rb | 2 +- lib/sisu/v3/shared_markup_alt.rb | 4 +- lib/sisu/v3/shared_metadata.rb | 18 +++--- lib/sisu/v3/shared_txt.rb | 2 +- lib/sisu/v3/shared_xml.rb | 4 +- lib/sisu/v3/sst_to_s_xml_sax.rb | 2 +- lib/sisu/v3/sysenv.rb | 80 +++++++++++--------------- lib/sisu/v3/texinfo_format.rb | 4 +- lib/sisu/v3/texpdf.rb | 24 ++++---- lib/sisu/v3/texpdf_format.rb | 2 +- lib/sisu/v3/xhtml_table.rb | 2 +- lib/sisu/v3/xml_format.rb | 2 +- 44 files changed, 235 insertions(+), 247 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/cgi_pgsql.rb b/lib/sisu/v3/cgi_pgsql.rb index d2c13132..83a1cecf 100644 --- a/lib/sisu/v3/cgi_pgsql.rb +++ b/lib/sisu/v3/cgi_pgsql.rb @@ -75,7 +75,7 @@ module SiSU_CGI_PgSQL available_db_table=`psql --list` # system call requires psql available_db=available_db_table.scan(/(#{Db[:name_prefix]}\S+)/) if not available_db_table.nil? if available_db \ - and available_db.class==Array + and available_db.is_a?(Array) available_db.flatten.each do |x| serve << x.gsub(/#{Db[:name_prefix]}(\S+)/,'\1') end diff --git a/lib/sisu/v3/cgi_sql_common.rb b/lib/sisu/v3/cgi_sql_common.rb index 5a044d5f..94026ce7 100644 --- a/lib/sisu/v3/cgi_sql_common.rb +++ b/lib/sisu/v3/cgi_sql_common.rb @@ -1024,8 +1024,9 @@ module SiSU_CGI_SQL if cgi['view']=~/text/ \ or (cgi['view']!~/index/ and cgi['search'] !~/search db/) #% txt endnotes @counter_endn_ocn+=1 - matched_endnote=(@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/) \ - ? matched=e['body'].gsub(/(<\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{\\1}) + matched_endnote=(@search_regx.to_s.is_a?(String) \ + && @search_regx.to_s=~/\S\S+/) \ + ? (matched=e['body'].gsub(/(<\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{\\1})) : e['body'] output=%{#{title}
note #{e['nr']} referred to from ocn #{e['ocn']}: #{matched_endnote}} else #elsif cgi['view']=~/index/ #doc #FIX #% idx endnotes diff --git a/lib/sisu/v3/dal.rb b/lib/sisu/v3/dal.rb index 79e12e2d..a03ed55c 100644 --- a/lib/sisu/v3/dal.rb +++ b/lib/sisu/v3/dal.rb @@ -445,18 +445,18 @@ module SiSU_DAL end def make_marshal_content marshal_dal=@make.marshal.dal_content - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.class==Array + File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) end def make_marshal_metadata marshal_dal=@make.marshal.dal_metadata - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.class==Array + File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) end def idx_html_hard_output if @md.book_idx \ and @md.opt.cmd =~/M/ filename_meta=@cf.file_meta_idx_html - unless @data.nil? #REMOVE earliest possible - @data.each {|s| p s.inspect + "\n" unless s.class==String} + if @data.is_a?(Array) + @data.each {|s| p s.inspect + "\n" unless s.is_a?(String)} @data.each {|s| filename_meta.puts s.strip + "\n" unless s.strip.empty?} end else @@ -466,27 +466,27 @@ module SiSU_DAL end def make_marshal_idx_sst_html_seg marshal_dal=@make.marshal.dal_idx_sst_rel_html_seg - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.class==Array + File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) end def make_marshal_idx_sst_rel marshal_dal=@make.marshal.dal_idx_sst_rel - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.class==Array + File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) end def make_marshal_idx_html marshal_dal=@make.marshal.dal_idx_html - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.class==Array + File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) end def make_marshal_idx_xhtml marshal_dal=@make.marshal.dal_idx_xhtml - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.class==Array + File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) end def make_marshal_map_nametags marshal_dal=@make.marshal.dal_map_nametags - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.class==Hash + File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Hash) end def make_marshal_map_name_ocn_htmlseg marshal_dal=@make.marshal.dal_map_ocn_htmlseg - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.class==Hash + File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Hash) end end class Make diff --git a/lib/sisu/v3/dal_character_check.rb b/lib/sisu/v3/dal_character_check.rb index df14e1aa..f20d4106 100644 --- a/lib/sisu/v3/dal_character_check.rb +++ b/lib/sisu/v3/dal_character_check.rb @@ -93,7 +93,7 @@ module SiSU_DAL_CharacterCheck end end end - @tuned_file << dob unless dob.nil? + @tuned_file << dob if dob.is_a?(Object) end @tuned_file=@tuned_file.flatten.compact [@tuned_file,@endnote_array] diff --git a/lib/sisu/v3/dal_doc_str.rb b/lib/sisu/v3/dal_doc_str.rb index 0abaf4d0..6bde88e2 100644 --- a/lib/sisu/v3/dal_doc_str.rb +++ b/lib/sisu/v3/dal_doc_str.rb @@ -363,8 +363,8 @@ module SiSU_DAL_DocumentStructureExtract t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) t_o else - if t_o !~/^table\{/ \ - and not t_o.nil? + if t_o.is_a?(String) \ + and t_o !~/^table\{/ t_o=t_o.gsub(/^\n+/m,''). #check added for ruby 1.9.2 not needed in 1.8 series (tested in v2) gsub(/\n+/m,"#{Mx[:tc_p]}") @rows += t_o + Mx[:tc_c] @@ -385,8 +385,7 @@ module SiSU_DAL_DocumentStructureExtract t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) end if @@flag['code'] \ - and t_o.class==String \ - and not t_o.nil? #you may need to introduce t_o.class==String test more widely + and t_o.is_a?(String) sub_array=t_o.dup + "#{Mx[:br_nl]}" @line_mode=sub_array.scan(/.+/) @line_mode=[] @@ -461,7 +460,7 @@ module SiSU_DAL_DocumentStructureExtract if @@flag['poem'] \ or @@flag['group'] \ or @@flag['alt'] - if t_o.class==String + if t_o.is_a?(String) t_o=t_o.gsub(/\n/m,"#{Mx[:br_nl]}"). gsub(/[ ][ ]/m,"#{Mx[:nbsp]*2}"). gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") @@ -527,7 +526,7 @@ module SiSU_DAL_DocumentStructureExtract lines.each do |line| line=if line =~/\S/ \ and line !~/^code\{|^\}code/ \ - and line.class != Hash + and not line.is_a?(Hash) @@counter+=1 if @@flag['code'] line=line.gsub(/\s\s/,"#{Mx[:nbsp]*2}"). gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") diff --git a/lib/sisu/v3/dal_hash_digest.rb b/lib/sisu/v3/dal_hash_digest.rb index c30048db..8718c461 100644 --- a/lib/sisu/v3/dal_hash_digest.rb +++ b/lib/sisu/v3/dal_hash_digest.rb @@ -72,13 +72,13 @@ module SiSU_DAL_Hash sha_ =(@env.digest.type=='sha256' ? true : false) sha_ ? (require 'digest/sha2') : (require 'digest/md5') data.each do |t_o| - unless t_o.obj.class==Array + unless t_o.obj.is_a?(Array) t_o.obj=t_o.obj.strip end if (t_o.of !=:structure \ && t_o.of !=:comment \ && t_o.of !=:layout) \ - && t_o.ocn.class==Fixnum + && t_o.ocn.is_a?(Fixnum) if sha_ for hash_class in [ Digest::SHA256 ] @tuned_file << stamped(t_o,hash_class) diff --git a/lib/sisu/v3/dal_idx.rb b/lib/sisu/v3/dal_idx.rb index 63735bde..a90217c4 100644 --- a/lib/sisu/v3/dal_idx.rb +++ b/lib/sisu/v3/dal_idx.rb @@ -79,7 +79,11 @@ module SiSU_DAL_BookIndex && dob.ln==4 @seg=dob.name end - idx_array << "#{dob.idx}~#{dob.ocn}~#{@seg}" if defined? dob.idx and not (dob.idx.nil? or dob.idx.empty?) + if defined? dob.idx \ + and dob.idx.is_a?(String) \ + and not dob.idx.empty? + idx_array << "#{dob.idx}~#{dob.ocn}~#{@seg}" + end tuned_file << dob if dob end idx_array=construct_idx_array(idx_array) if idx_array.length > 0 @@ -193,7 +197,7 @@ module SiSU_DAL_BookIndex idx[:xhtml] << %{\n

0 - 9

} the_idx.each do |i| i.each do |x| - if x.class==String + if x.is_a?(String) f=/^(\S)/.match(x)[1] if letter < f while letter < f @@ -216,11 +220,11 @@ module SiSU_DAL_BookIndex @q=idx[:html].index(idx[:html].last) @r=idx[:xhtml].index(idx[:xhtml].last) print "\n" + x + ', ' if @md.opt.cmd =~/V/ - elsif x.class==Array + elsif x.is_a?(Array) p 'array error? -->' print x - elsif x.class==Hash - if x['term_node_lev1'].class==Array + elsif x.is_a?(Hash) + if x['term_node_lev1'].is_a?(Array) x['term_node_lev1'].each do |a| if a[:range] idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}/#{a[:seg]}.html##{a[:ocn]}#{Mx[:rel_c]}, } @@ -283,13 +287,13 @@ module SiSU_DAL_BookIndex def screen_print(the_idx) the_idx.each do |i| i.each do |x| - if x.class==String + if x.is_a?(String) print "\n" + x + ', ' - elsif x.class==Array + elsif x.is_a?(Array) p 'array error? -->' print x - elsif x.class==Hash - if x['term_node_lev1'].class==Array + elsif x.is_a?(Hash) + if x['term_node_lev1'].is_a?(Array) x['term_node_lev1'].each do |a| if a[:range] print a[:range] + ', ' diff --git a/lib/sisu/v3/dal_numbering.rb b/lib/sisu/v3/dal_numbering.rb index 4c7ad642..f81563f3 100644 --- a/lib/sisu/v3/dal_numbering.rb +++ b/lib/sisu/v3/dal_numbering.rb @@ -82,7 +82,7 @@ module SiSU_DAL_Numbering && dob.ocn_ #and dob.obj !~ /#{Mx[:gr_o]}Th|#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}/ #FIX dob.obj=dob.obj.gsub(/(.+)\n/,'\1 ') #messy, but idea is that tables should retain breaks end - unless dob.obj.class==Array + unless dob.obj.is_a?(Array) dob.obj=dob.obj.gsub(/^\s+/,''). gsub(/\s$/,"\n") end @@ -160,7 +160,7 @@ module SiSU_DAL_Numbering if dob.ln==no1 t_no1+=1; t_no2=0; t_no3=0 title_no="#{t_no1}" - if not @md.seg_names.nil? \ + if @md.seg_names.is_a?(Array) \ and not @md.seg_names.include?(title_no) if dob.ln==no1 dob.name="#{title_no}" if not dob.name @@ -303,7 +303,7 @@ module SiSU_DAL_Numbering possible_seg_name=$1 possible_seg_name=possible_seg_name.gsub(/(?:[:,-]|\W)/,'.'). gsub(/\.$/,'') - if not @md.seg_names.nil? \ + if @md.seg_names.is_a?(Array) \ and not @md.seg_names.include?(possible_seg_name) dob.name=possible_seg_name dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ @@ -313,7 +313,7 @@ module SiSU_DAL_Numbering end if dob.ln==4 \ and dob.name #extract segment name from embedded document structure info - if not @md.seg_names.nil? \ + if @md.seg_names.is_a?(Array) \ and not @md.seg_names.include?(dob.name) dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ @md.seg_names << dob.name @@ -323,7 +323,7 @@ module SiSU_DAL_Numbering and not dob.name #if still no segment name, provide a numerical one pf='_' #pg='' #may use e.g. '' or '~' or '_' segn_auto="#{pf}#{art_filename_auto.to_s}" - if not @md.seg_names.nil? \ + if @md.seg_names.is_a?(Array) \ and not @md.seg_names.include?(segn_auto) dob.name=segn_auto dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ #check whether will work across file types with stop signs diff --git a/lib/sisu/v3/dal_syntax.rb b/lib/sisu/v3/dal_syntax.rb index 839fb399..b21f94a5 100644 --- a/lib/sisu/v3/dal_syntax.rb +++ b/lib/sisu/v3/dal_syntax.rb @@ -238,7 +238,7 @@ module SiSU_DAL_Syntax def substitutions(dob) dob=dob.dup dob=if defined? @md.make.substitute[:match_and_replace] \ - and @md.make.substitute[:match_and_replace].class == Array + and @md.make.substitute[:match_and_replace].is_a?(Array) dob=if dob.is !=:meta \ && dob.is !=:heading_insert \ && dob.is !=:code \ diff --git a/lib/sisu/v3/db_columns.rb b/lib/sisu/v3/db_columns.rb index 5ae17707..7c4fa9eb 100644 --- a/lib/sisu/v3/db_columns.rb +++ b/lib/sisu/v3/db_columns.rb @@ -295,7 +295,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.author_detail \ - and @md.creator.author_detail.class==Array \ + and @md.creator.author_detail.is_a?(Array) \ and @md.creator.author_detail.length > 0 txt='' @md.creator.author_detail.each do |h| @@ -366,7 +366,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.editor_detail \ - and @md.creator.editor_detail.class==Array \ + and @md.creator.editor_detail.is_a?(Array) \ and @md.creator.editor_detail.length > 0 txt=@md.creator.editor_detail #dc txt='' @@ -394,7 +394,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.contributor_detail \ - and @md.creator.contributor_detail.class==Array \ + and @md.creator.contributor_detail.is_a?(Array) \ and @md.creator.contributor_detail.length > 0 txt=@md.creator.contributor_detail #dc txt='' @@ -422,7 +422,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.illustrator_detail \ - and @md.creator.illustrator_detail.class==Array \ + and @md.creator.illustrator_detail.is_a?(Array) \ and @md.creator.illustrator_detail.length > 0 txt=@md.creator.illustrator_detail txt='' @@ -450,7 +450,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.photographer_detail \ - and @md.creator.photographer_detail.class==Array \ + and @md.creator.photographer_detail.is_a?(Array) \ and @md.creator.photographer_detail.length > 0 txt=@md.creator.photographer_detail txt='' @@ -478,7 +478,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.translator_detail \ - and @md.creator.translator_detail.class==Array \ + and @md.creator.translator_detail.is_a?(Array) \ and @md.creator.translator_detail.length > 0 txt='' @md.creator.translator_detail.each do |h| @@ -505,7 +505,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.prepared_by_detail \ - and @md.creator.prepared_by_detail.class==Array \ + and @md.creator.prepared_by_detail.is_a?(Array) \ and @md.creator.prepared_by_detail.length > 0 txt=@md.creator.prepared_by_detail txt='' @@ -533,7 +533,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.digitized_by_detail \ - and @md.creator.digitized_by_detail.class==Array \ + and @md.creator.digitized_by_detail.is_a?(Array) \ and @md.creator.digitized_by_detail.length > 0 txt=@md.creator.digitized_by_detail txt='' @@ -561,7 +561,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.audio_detail \ - and @md.creator.audio_detail.class==Array \ + and @md.creator.audio_detail.is_a?(Array) \ and @md.creator.audio_detail.length > 0 txt=@md.creator.audio_detail txt='' @@ -589,7 +589,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.video_detail \ - and @md.creator.video_detail.class==Array \ + and @md.creator.video_detail.is_a?(Array) \ and @md.creator.video_detail.length > 0 txt='' @md.creator.video_detail.each do |h| @@ -1891,7 +1891,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.dgst \ - and @md.dgst.class==Array \ + and @md.dgst.is_a?(Array) \ and @md.dgst[1]=~/\S+/ txt=@md.dgst[1] ["#{name}, ","'#{txt}', "] @@ -2025,7 +2025,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.dgst_skin \ - and @md.dgst_skin.class==Array \ + and @md.dgst_skin.is_a?(Array) \ and @md.dgst_skin[1]=~/\S+/ txt=@md.dgst_skin[1] txt=special_character_escape(txt) diff --git a/lib/sisu/v3/db_select.rb b/lib/sisu/v3/db_select.rb index b2773b97..a013c00b 100644 --- a/lib/sisu/v3/db_select.rb +++ b/lib/sisu/v3/db_select.rb @@ -78,7 +78,7 @@ module SiSU_DbSelect puts %{no connection with #{@sql_type} database established, createdb "#{@db.sqlite.db}"?} exit end - if @conn.class==NilClass + if @conn.is_a?(NilClass) db=@sql_type=='sqlite' \ ? @db.sqlite.db : @db.psql.db diff --git a/lib/sisu/v3/db_sqltxt.rb b/lib/sisu/v3/db_sqltxt.rb index f6651724..53c15ed3 100644 --- a/lib/sisu/v3/db_sqltxt.rb +++ b/lib/sisu/v3/db_sqltxt.rb @@ -68,7 +68,7 @@ module SiSU_DbText end def clean_searchable_text(arr) #produce clean, searchable, plaintext from document source txt_arr,en=[],[] - arr=arr.class==String ? arr.split(/\n+/m) : arr + arr=(arr.is_a?(String)) ? arr.split(/\n+/m) : arr arr.each do |s| s=s.gsub(/([*\/_-])\{(.+?)\}\1/m,'\2'). gsub(/^(?:block|group|poem|code)\{/m,'').gsub(/^\}(?:block|group|poem|code)/m,''). diff --git a/lib/sisu/v3/dbi_discreet.rb b/lib/sisu/v3/dbi_discreet.rb index fc10fd71..07814a1a 100644 --- a/lib/sisu/v3/dbi_discreet.rb +++ b/lib/sisu/v3/dbi_discreet.rb @@ -106,7 +106,7 @@ module SiSU_DBI_Discreet #% database building puts msg exit end - if conn.class==NilClass + if conn.is_a?(NilClass) puts msg exit end diff --git a/lib/sisu/v3/epub_format.rb b/lib/sisu/v3/epub_format.rb index 06a6d623..cc98219c 100644 --- a/lib/sisu/v3/epub_format.rb +++ b/lib/sisu/v3/epub_format.rb @@ -1838,7 +1838,7 @@ WOK attr_accessor :md,:t_o,:txt,:ocn,:format,:table,:link,:linkname,:paranum,:p_num,:headname,:banner,:url def initialize(md,t_o) @md,@t_o=md,t_o - if t_o.class==Hash + if t_o.is_a?(Hash) @txt =t_o[:txt] || nil @ocn =t_o[:ocn] || nil @ocn_display =t_o[:ocn_display] || nil diff --git a/lib/sisu/v3/epub_segments.rb b/lib/sisu/v3/epub_segments.rb index 896ed152..5a3f3092 100644 --- a/lib/sisu/v3/epub_segments.rb +++ b/lib/sisu/v3/epub_segments.rb @@ -271,9 +271,9 @@ WOK @@get_hash_to=dob.name @@get_hash_fn=dob.name end - if dob.obj.class==String + if dob.obj.is_a?(String) markup(dob) - elsif dob.obj.class==Array + elsif dob.obj.is_a?(Array) dob.obj.each do |pg| markup(pg) end diff --git a/lib/sisu/v3/epub_tune.rb b/lib/sisu/v3/epub_tune.rb index a9bf31b0..1362815e 100644 --- a/lib/sisu/v3/epub_tune.rb +++ b/lib/sisu/v3/epub_tune.rb @@ -96,7 +96,7 @@ module SiSU_EPUB_Tune end def clean html=@html - str=if html.class==String + str=if html.is_a?(String) html else html.obj end diff --git a/lib/sisu/v3/harvest_authors.rb b/lib/sisu/v3/harvest_authors.rb index 6036816d..7c044425 100644 --- a/lib/sisu/v3/harvest_authors.rb +++ b/lib/sisu/v3/harvest_authors.rb @@ -157,7 +157,7 @@ module SiSU_HarvestAuthors idx_array.each do |idx| idx[:author][:last_first_format_a].each do |author| author=author.strip - if @@the_idx_authors[lang][author].class==NilClass + if @@the_idx_authors[lang][author].is_a?(NilClass) @@the_idx_authors[lang][author]={ md: [] } end @@the_idx_authors[lang][author][:md] << { filename: idx[:filename], file: idx[:file], author: idx[:author], title: idx[:title], date: idx[:date], page: idx[:page], lang: idx[:lang] } @@ -201,7 +201,7 @@ module SiSU_HarvestAuthors def html_file_close @the_idx.keys.each do |lng| @output[lng][:html].close - @output[lng][:html_mnt].close if @output[lng][:html_mnt].class==File + @output[lng][:html_mnt].close if @output[lng][:html_mnt].is_a?(File) end end def html_print @@ -305,12 +305,12 @@ WOK WOK @the_idx.keys.each do |lng| - @output[lng][:html_mnt] << a if @output[lng][:html_mnt].class==File + @output[lng][:html_mnt] << a if @output[lng][:html_mnt].is_a?(File) @output[lng][:html] << a end end def do_html(lng,html) - @output[lng][:html_mnt] << html if @output[lng][:html_mnt].class==File + @output[lng][:html_mnt] << html if @output[lng][:html_mnt].is_a?(File) @output[lng][:html] << html end def do_string_name(lng,attrib,string) @@ -324,7 +324,7 @@ WOK while @letter < f if @alph.length > 0 @letter=@alph.shift - if @output[lng][:html_mnt].class==File + if @output[lng][:html_mnt].is_a?(File) @output[lng][:html_mnt] << %{\n

#{@letter}

} end @output[lng][:html] << %{\n

#{@letter}

} @@ -340,7 +340,7 @@ WOK do_string_name(lng,'',a) name=a[0].sub(/(.+?)(?:,.+|$)/,'\1').gsub(/\s+/,'_') x = %{

#{a[0]}

} - if @output[lng][:html_mnt].class==File + if @output[lng][:html_mnt].is_a?(File) @output[lng][:html_mnt] << x end @output[lng][:html] << x @@ -356,13 +356,13 @@ WOK "../#{x[:file]}/#{x[:page]}" end work=[ "#{x[:date]} #{x[:title]}", %{

#{x[:date]} #{x[:title]}, #{x[:author][:authors_s]}

} ] - works<<=(@output[lng][:html_mnt].class==File) \ + works<<=(@output[lng][:html_mnt].is_a?(File)) \ ? (work.concat([%{

[src]  #{x[:date]} #{x[:title]}, #{x[:author][:authors_s]} -- [#{x[:file]}.sst]

}])) : work end works.sort_by {|x| x[0]}.each do |x| @output[lng][:html] << x[1] - @output[lng][:html_mnt] << x[2] if @output[lng][:html_mnt].class==File + @output[lng][:html_mnt] << x[2] if @output[lng][:html_mnt].is_a?(File) end end end diff --git a/lib/sisu/v3/harvest_topics.rb b/lib/sisu/v3/harvest_topics.rb index 3487ab6b..952f1411 100644 --- a/lib/sisu/v3/harvest_topics.rb +++ b/lib/sisu/v3/harvest_topics.rb @@ -233,8 +233,8 @@ module SiSU_HarvestTopics end @idx_a.each do |c| if c.length > 1 \ - and c.class == Array - if c[2].class == Hash + and c.is_a?(Array) + if c[2].is_a?(Hash) c[1].each do |alt| v=key_create(c,alt) @the_a << [v, c[2]] if v @@ -242,8 +242,8 @@ module SiSU_HarvestTopics end end if c.length > 2 \ - and c.class == Array - if c[3].class == Hash + and c.is_a?(Array) + if c[3].is_a?(Hash) c[2].each do |alt| v=key_create(c,alt) @the_a << [v, c[3]] if v @@ -251,8 +251,8 @@ module SiSU_HarvestTopics end end if c.length > 3 \ - and c.class == Array - if c[4].class == Hash + and c.is_a?(Array) + if c[4].is_a?(Hash) c[3].each do |alt| v=key_create(c,alt) @the_a << [v, c[4]] if v @@ -260,8 +260,8 @@ module SiSU_HarvestTopics end end if c.length > 4 \ - and c.class == Array - if c[5].class == Hash + and c.is_a?(Array) + if c[5].is_a?(Hash) c[4].each do |alt| v=key_create(c,alt) @the_a << [v, c[5]] if v @@ -269,8 +269,8 @@ module SiSU_HarvestTopics end end if c.length > 5 \ - and c.class == Array - if c[6].class == Hash + and c.is_a?(Array) + if c[6].is_a?(Hash) c[5].each do |alt| v=key_create(c,alt) @the_a << [v, c[6]] if v @@ -278,8 +278,7 @@ module SiSU_HarvestTopics end end end - y=@the_a.sort_by { |x| x[0] } - #y.each {|z| puts z} + y=@the_a.sort_by { |x| x[0] } #; y.each {|z| puts z} end def construct_book_topic_hash(y) @the_h={} @@ -369,22 +368,22 @@ module SiSU_HarvestTopics end def traverse_base @the_h.each_pair do |x0,y| - puts ' '*0 + x0 if x0.class == String - if y.class == Hash + puts ' '*0 + x0 if x0.is_a?(String) + if y.is_a?(Hash) y.each_pair do |x1,y| - puts ' '*1 + x1 if x1.class == String - if y.class == Hash + puts ' '*1 + x1 if x1.is_a?(String) + if y.is_a?(Hash) y.each_pair do |x2,y| - puts ' '*2 + x2 if x2.class == String - if y.class == Hash + puts ' '*2 + x2 if x2.is_a?(String) + if y.is_a?(Hash) y.each_pair do |x3,y| - puts ' '*3 + x3 if x3.class == String - if y.class == Hash + puts ' '*3 + x3 if x3.is_a?(String) + if y.is_a?(Hash) y.each_pair do |x4,y| - puts ' '*4 + x4 if x4.class == String - if y.class == Hash + puts ' '*4 + x4 if x4.is_a?(String) + if y.is_a?(Hash) y.each_pair do |x5,y| - puts ' '*5 + x5 if x5.class == String + puts ' '*5 + x5 if x5.is_a?(String) end end end @@ -399,37 +398,37 @@ module SiSU_HarvestTopics end def traverse @the_h.each_pair do |x0,y| - puts ' '*0 + x0 if x0.class == String - if y.class == Hash + puts ' '*0 + x0 if x0.is_a?(String) + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each { |x| puts ' '*5 + x[:title] } end y.each_pair do |x1,y| - puts ' '*1 + x1 if x1.class == String - if y.class == Hash + puts ' '*1 + x1 if x1.is_a?(String) + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each { |x| puts ' '*5 + x[:title] } end y.each_pair do |x2,y| - puts ' '*2 + x2 if x2.class == String - if y.class == Hash + puts ' '*2 + x2 if x2.is_a?(String) + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each { |x| puts ' '*5 + x[:title] } end y.each_pair do |x3,y| - puts ' '*3 + x3 if x3.class == String - if y.class == Hash + puts ' '*3 + x3 if x3.is_a?(String) + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each { |x| puts ' '*5 + x[:title] } end y.each_pair do |x4,y| - puts ' '*4 + x4 if x4.class == String - if y.class == Hash + puts ' '*4 + x4 if x4.is_a?(String) + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each { |x| puts ' '*5 + x[:title] } end y.each_pair do |x5,y| - puts ' '*5 + x4 if x4.class == String + puts ' '*5 + x4 if x4.is_a?(String) end end end @@ -480,7 +479,7 @@ module SiSU_HarvestTopics def html_file_close @the_idx.keys.each do |lng| @output[lng][:html].close - @output[lng][:html_mnt].close if @output[lng][:html_mnt].class==File + @output[lng][:html_mnt].close if @output[lng][:html_mnt].is_a?(File) end end def html_print @@ -496,11 +495,11 @@ module SiSU_HarvestTopics def html_body_traverse @the_idx.each_pair do |x0,y| lng=x0 - if x0.class == String + if x0.is_a?(String) #do_string_name(lng,'lev0',x0) #puts ' '*0 + x0 end - if y.class == Hash + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each do |x| #do_hash(lng,attrib,x) #lv==0 ? @@ -508,11 +507,11 @@ module SiSU_HarvestTopics end end y.each_pair do |x1,y| - if x1.class == String + if x1.is_a?(String) do_string_name(lng,'lev0',x1) #puts ' '*1 + x1 end - if y.class == Hash + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each do |x| do_hash(lng,0,x) @@ -520,11 +519,11 @@ module SiSU_HarvestTopics end end y.each_pair do |x2,y| - if x2.class == String + if x2.is_a?(String) do_string(lng,'lev1',x2) #puts ' '*2 + x2 end - if y.class == Hash + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each do |x| do_hash(lng,1,x) @@ -532,11 +531,11 @@ module SiSU_HarvestTopics end end y.each_pair do |x3,y| - if x3.class == String + if x3.is_a?(String) do_string(lng,'lev2',x3) #puts ' '*3 + x3 end - if y.class == Hash + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each do |x| do_hash(lng,2,x) @@ -544,11 +543,11 @@ module SiSU_HarvestTopics end end y.each_pair do |x4,y| - if x4.class == String + if x4.is_a?(String) do_string(lng,'lev3',x4) #puts ' '*4 + x4 end - if y.class == Hash + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each do |x| do_hash(lng,3,x) @@ -556,7 +555,7 @@ module SiSU_HarvestTopics end end y.each_pair do |x5,y| - if x5.class == String + if x5.is_a?(String) do_string(lng,'lev4',x5) #puts ' '*5 + x5 end @@ -667,7 +666,7 @@ WOK WOK @the_idx.keys.each do |lng| - @output[lng][:html_mnt] << a if @output[lng][:html_mnt].class==File + @output[lng][:html_mnt] << a if @output[lng][:html_mnt].is_a?(File) @output[lng][:html] << a end end @@ -675,12 +674,12 @@ WOK @output[lng][:html] << html end def do_html_maintenance(lng,html) - @output[lng][:html_mnt] << html if @output[lng][:html_mnt].class==File + @output[lng][:html_mnt] << html if @output[lng][:html_mnt].is_a?(File) end def do_string(lng,attrib,string) html=%{

#{string}

} do_html(lng,html) - do_html_maintenance(lng,html) if @output[lng][:html_mnt].class==File + do_html_maintenance(lng,html) if @output[lng][:html_mnt].is_a?(File) end def do_string_default(lng,attrib,string) html=%{

#{string}

} @@ -688,7 +687,7 @@ WOK end def do_string_maintenance(lng,attrib,string) html=%{

#{string}

} - do_html_maintenance(lng,html) if @output[lng][:html_mnt].class==File + do_html_maintenance(lng,html) if @output[lng][:html_mnt].is_a?(File) end def do_string_name(lng,attrib,string) f=/^(\S)/.match(string)[1] @@ -701,7 +700,7 @@ WOK while @letter < f if @alph.length > 0 @letter=@alph.shift - if @output[lng][:html_mnt].class==File + if @output[lng][:html_mnt].is_a?(File) @output[lng][:html_mnt] << %{\n

#{@letter}

} end @output[lng][:html] << %{\n

#{@letter}

} @@ -712,7 +711,7 @@ WOK name=string.strip.gsub(/\s+/,'_') html=%{

#{string}

} do_html(lng,html) - do_html_maintenance(lng,html) if @output[lng][:html_mnt].class==File + do_html_maintenance(lng,html) if @output[lng][:html_mnt].is_a?(File) end def do_array(lng,lv,array) lv+=1 @@ -733,7 +732,7 @@ WOK do_string_default(lng,attrib,html) end def do_hash_md_maintenance(lng,attrib,hash) - if @output[lng][:html_mnt].class==File #should not be run for presentation output + if @output[lng][:html_mnt].is_a?(File) #should not be run for presentation output html=%{[src]  #{hash[:title]} - #{hash[:author]}} do_string_maintenance(lng,attrib,html) end @@ -765,16 +764,15 @@ WOK end end def do_case(lng,lv,a) - y = a.class - case - when y==String + case a + when String attrib="lev#{lv}" if a=~/S/ lv==0 ? do_string_name(lng,attrib,a) : do_string(lng,attrib,a) end - when y==Array + when Array do_array(lng,lv,a) - when y==Hash + when Hash do_hash(lng,lv,a) end end diff --git a/lib/sisu/v3/html_format.rb b/lib/sisu/v3/html_format.rb index 1b950358..e16cbc5d 100644 --- a/lib/sisu/v3/html_format.rb +++ b/lib/sisu/v3/html_format.rb @@ -903,7 +903,7 @@ WOK attr_accessor :md,:t_o,:txt,:ocn,:format,:table,:link,:linkname,:paranum,:p_num,:headname,:banner,:url def initialize(md,t_o) @md,@t_o=md,t_o - if t_o.class==Hash + if t_o.is_a?(Hash) @txt =t_o[:txt] || nil @ocn =t_o[:ocn] || nil @ocn_display =t_o[:ocn_display] || nil diff --git a/lib/sisu/v3/html_promo.rb b/lib/sisu/v3/html_promo.rb index a2edea47..387da244 100644 --- a/lib/sisu/v3/html_promo.rb +++ b/lib/sisu/v3/html_promo.rb @@ -98,7 +98,7 @@ module SiSU_HTML_Promo elsif @flag[:sk] #promo set in associated skin promo_array=@vz.widget_promo elsif @flag[:rc] #promo set in rc file - promo_array=if @rc['html']['promo'].class==String + promo_array=if @rc['html']['promo'].is_a?(String) @rc['html']['promo'].split(/[,;]\s*/) else @rc['html']['promo'] end @@ -406,7 +406,7 @@ WOK adverts << output_form_select(type,id) else if defined? @ad[:promo][category][type][id] \ - and @ad[:promo][category][type][id].class==Array \ + and @ad[:promo][category][type][id].is_a?(Array) \ and @ad[:promo][category][type][id].length > 0 adverts << @ad[:promo][category][type][id].join("\n") end diff --git a/lib/sisu/v3/html_segments.rb b/lib/sisu/v3/html_segments.rb index bb77cb36..14c13d36 100644 --- a/lib/sisu/v3/html_segments.rb +++ b/lib/sisu/v3/html_segments.rb @@ -312,9 +312,9 @@ module SiSU_HTML_Seg @@get_hash_to=dob.name @@get_hash_fn=dob.name end - if dob.obj.class==String + if dob.obj.is_a?(String) markup(dob) - elsif dob.obj.class==Array + elsif dob.obj.is_a?(Array) dob.obj.each do |pg| markup(pg) end diff --git a/lib/sisu/v3/html_tune.rb b/lib/sisu/v3/html_tune.rb index f7b60cff..05126ede 100644 --- a/lib/sisu/v3/html_tune.rb +++ b/lib/sisu/v3/html_tune.rb @@ -101,7 +101,7 @@ module SiSU_HTML_Tune end def clean html=@html - str=if html.class==String + str=if html.is_a?(String) html else html.obj end diff --git a/lib/sisu/v3/hub.rb b/lib/sisu/v3/hub.rb index 2ab95052..8a67ce10 100644 --- a/lib/sisu/v3/hub.rb +++ b/lib/sisu/v3/hub.rb @@ -141,7 +141,7 @@ module SiSU number_of_files={} @opt.files.each_with_index do |fns,i| fn=fns.gsub(/(?:~(?:#{@r}))?\.ss[tm]$/,'') - if number_of_files[fn].class == Array + if number_of_files[fn].is_a?(Array) number_of_files[fn] << i else number_of_files.store(fn,[i]) diff --git a/lib/sisu/v3/manifest.rb b/lib/sisu/v3/manifest.rb index 743bc090..fdacf164 100644 --- a/lib/sisu/v3/manifest.rb +++ b/lib/sisu/v3/manifest.rb @@ -697,7 +697,7 @@ WOK @manifest[:html] << %{

#{@translate.topic_register}:

\n} @md.topic_register_array.each do |t| t.each_with_index do |st,i| - if st.class==Array + if st.is_a?(Array) st.each do |v| @manifest[:html] << %{

#{v}

\n} end diff --git a/lib/sisu/v3/manpage.rb b/lib/sisu/v3/manpage.rb index 31a64a57..81f2ed2c 100644 --- a/lib/sisu/v3/manpage.rb +++ b/lib/sisu/v3/manpage.rb @@ -415,7 +415,7 @@ WOK filename_manpage=SiSU_Env::FileOp.new(@md).write_file.manpage @sisu=[] @content.each do |para| # this is a hack - if para.class==Array \ + if para.is_a?(Array) \ and para.length > 0 para.each do |line| line=line.gsub(/\s+$/m,'') diff --git a/lib/sisu/v3/odf.rb b/lib/sisu/v3/odf.rb index d4d16b1d..807d2832 100644 --- a/lib/sisu/v3/odf.rb +++ b/lib/sisu/v3/odf.rb @@ -386,7 +386,7 @@ module SiSU_ODF end def footnote(t_o) str=if defined? t_o.obj then t_o.obj - elsif t_o.class==String then t_o + elsif t_o.is_a?(String) then t_o end if str @astx||=10000 @@ -421,7 +421,7 @@ module SiSU_ODF end end if defined? t_o.obj then t_o.obj=str - elsif t_o.class==String then t_o=str + elsif t_o.is_a?(String) then t_o=str end t_o end diff --git a/lib/sisu/v3/odf_format.rb b/lib/sisu/v3/odf_format.rb index 62eae47a..adfcf684 100644 --- a/lib/sisu/v3/odf_format.rb +++ b/lib/sisu/v3/odf_format.rb @@ -127,7 +127,7 @@ module SiSU_ODF_Format class FormatTextObject def initialize(md,t_o) @md,@t_o=md,t_o - if t_o.class==Hash + if t_o.is_a?(Hash) @txt =t_o[:txt] || nil else p t_o.class diff --git a/lib/sisu/v3/param.rb b/lib/sisu/v3/param.rb index 7a416bd9..64baf271 100644 --- a/lib/sisu/v3/param.rb +++ b/lib/sisu/v3/param.rb @@ -165,10 +165,10 @@ module SiSU_Param end def validate_length(s,l,n) #s=(s.length <= l) ? s : nil - s=if s.class==String \ + s=if s.is_a?(String) \ and s.length <= l s - elsif s.class==NilClass + elsif s.is_a?(NilClass) nil elsif s.class !=String STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}" @@ -308,7 +308,7 @@ module SiSU_Param names=@h['editor'] \ ? name_format(@h['editor']) : nil - s=(names.class==Hash) \ + s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s @@ -321,7 +321,7 @@ module SiSU_Param names=@h['editor'] \ ? name_format(@h['editor']) : nil - (names.class==Hash) \ + (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end @@ -329,7 +329,7 @@ module SiSU_Param names=@h['contributor'] \ ? name_format(@h['contributor']) : nil - s=(names.class==Hash) \ + s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s @@ -342,7 +342,7 @@ module SiSU_Param names=@h['contributor'] \ ? name_format(@h['contributor']) : nil - (names.class==Hash) \ + (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end @@ -350,7 +350,7 @@ module SiSU_Param names=@h['illustrator'] \ ? name_format(@h['illustrator']) : nil - s=(names.class==Hash) \ + s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s @@ -363,7 +363,7 @@ module SiSU_Param names=@h['illustrator'] \ ? name_format(@h['illustrator']) : nil - (names.class==Hash) \ + (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end @@ -371,7 +371,7 @@ module SiSU_Param names=@h['photographer'] \ ? name_format(@h['photographer']) : nil - s=(names.class==Hash) \ + s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s @@ -384,7 +384,7 @@ module SiSU_Param names=@h['photographer'] \ ? name_format(@h['photographer']) : nil - (names.class==Hash) \ + (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end @@ -392,7 +392,7 @@ module SiSU_Param names=@h['translator'] \ ? name_format(@h['translator']) : nil - s=(names.class==Hash) \ + s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s @@ -405,7 +405,7 @@ module SiSU_Param names=@h['translator'] \ ? name_format(@h['translator']) : nil - (names.class==Hash) \ + (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end @@ -413,7 +413,7 @@ module SiSU_Param names=@h['audio'] \ ? name_format(@h['audio']) : nil - s=(names.class==Hash) \ + s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s @@ -426,7 +426,7 @@ module SiSU_Param names=@h['audio'] \ ? name_format(@h['audio']) : nil - (names.class==Hash) \ + (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end @@ -434,7 +434,7 @@ module SiSU_Param names=@h['digitized_by'] \ ? name_format(@h['digitized_by']) : nil - s=(names.class==Hash) \ + s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s @@ -447,7 +447,7 @@ module SiSU_Param names=@h['digitized_by'] \ ? name_format(@h['digitized_by']) : nil - (names.class==Hash) \ + (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end @@ -455,7 +455,7 @@ module SiSU_Param names=@h['prepared_by'] \ ? name_format(@h['prepared_by']) : nil - s=(names.class==Hash) \ + s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s @@ -469,7 +469,7 @@ module SiSU_Param ? name_format(@h['prepared_by']) : nil names=name_format(@h['prepared_by']) - (names.class==Hash) \ + (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end @@ -1186,7 +1186,7 @@ module SiSU_Param SiSU_Screen::Ansi.new(@opt.cmd,'No SiSU markup version provided').warn if @opt.cmd =~/[VM]/ end else - mv=if defined? @markup_version.determined and not @markup_version.determined.nil? + mv=if @markup_version.determined.is_a?(Float) x=@markup_version.determined "markup version determined #{x}" else '' @@ -1406,17 +1406,17 @@ module SiSU_Param @ec[:multimedia]=@ec[:multimedia].uniq.flatten.sort unless @rights if defined? @creator.author \ - and @creator.author \ + and @creator.author.is_a?(String) \ and defined? @date.published \ - and @date.published + and @date.published.is_a?(String) @rights=SiSU_Param::Parameters::MdDefault.new.rights(@creator.author,@date.published) elsif defined? @creator.author \ - and @creator.author + and @creator.author.is_a?(String) @rights=SiSU_Param::Parameters::MdDefault.new.rights("[#{@creator.author}]",'') end end if defined? @classify.topic_register \ - and not @classify.topic_register.nil? \ + and @classify.topic_register.is_a?(String) \ and @classify.topic_register.length >3 topic_register=@classify.topic_register u=topic_register.scan(/[^;]+/) diff --git a/lib/sisu/v3/plaintext.rb b/lib/sisu/v3/plaintext.rb index 2fa98883..c86fddb9 100644 --- a/lib/sisu/v3/plaintext.rb +++ b/lib/sisu/v3/plaintext.rb @@ -350,7 +350,7 @@ WOK p_num='' if @env.plaintext_ocn? if defined? dob.ocn \ - and not dob.ocn.nil? + and dob.ocn.is_a?(Fixnum) p_num=SiSU_PlaintextFormat::ParagraphNumber.new(dob.ocn).display end end @@ -409,7 +409,7 @@ WOK @sisu=[] emptyline=0 @content.each do |para| # this is a hack - if para.class==Array \ + if para.is_a?(Array) \ and para.length > 0 para.each do |line| if line diff --git a/lib/sisu/v3/plaintext_format.rb b/lib/sisu/v3/plaintext_format.rb index 445d8c66..fe24112d 100644 --- a/lib/sisu/v3/plaintext_format.rb +++ b/lib/sisu/v3/plaintext_format.rb @@ -76,7 +76,7 @@ module SiSU_PlaintextFormat class FormatTextObject def initialize(md,t_o) @md,@t_o=md,t_o - if t_o.class==Hash + if t_o.is_a?(Hash) @txt =t_o[:txt] || nil @lnk_url =t_o[:lnk_url] || nil @lnk_txt =t_o[:lnk_txt] || nil diff --git a/lib/sisu/v3/po4a.rb b/lib/sisu/v3/po4a.rb index 7ce825ee..53bab960 100644 --- a/lib/sisu/v3/po4a.rb +++ b/lib/sisu/v3/po4a.rb @@ -214,7 +214,7 @@ module SiSU_Po4a end desc="#{d}#{s_mark}#{instruct}" orig=(orig_notes[i].to_s =~/^\^~[\d*+]+/) ? (orig_notes[i].to_s.gsub(/^\^~[\d*+]+/,'^~')) : orig_notes[i].to_s - trans=if trn_notes.class==Array \ + trans=if trn_notes.is_a?(Array) \ and trn_notes.length==orig_notes.length (trn_notes[i].to_s =~/^\^~[\d*+]+/) ? (trn_notes[i].to_s.gsub(/^\^~[\d*+]+/,'^~')) : trn_notes[i].to_s else '' @@ -749,12 +749,12 @@ GSUB #next if data_trn[t].is == :comment end end - if (defined? data_src[s].ocn and data_src[s].ocn.class == Fixnum) \ - and (defined? data_trn[t].ocn and data_trn[t].ocn.class == Fixnum) \ + if (defined? data_src[s].ocn and data_src[s].ocn.is_a?(Fixnum)) \ + and (defined? data_trn[t].ocn and data_trn[t].ocn.is_a?(Fixnum)) \ and (data_src[s].ocn == data_trn[t].ocn) @m_s,@m_t=s,t - elsif (defined? data_src[s].ocn and data_src[s].ocn.class == Fixnum) \ - and (defined? data_trn[t].ocn and data_trn[t].ocn.class == Fixnum) \ + elsif (defined? data_src[s].ocn and data_src[s].ocn.is_a?(Fixnum)) \ + and (defined? data_trn[t].ocn and data_trn[t].ocn.is_a?(Fixnum)) \ and (data_src[s].ocn != data_trn[t].ocn) p '--- OCN ---' p 'mis-match' @@ -934,7 +934,7 @@ GSUB @sisu=[] emptyline=0 @content.each do |para| # this is a hack - if para.class==Array \ + if para.is_a?(Array) \ and para.length > 0 para.each do |line| if line diff --git a/lib/sisu/v3/po4a_set.rb b/lib/sisu/v3/po4a_set.rb index af6fba88..0dcc25a9 100644 --- a/lib/sisu/v3/po4a_set.rb +++ b/lib/sisu/v3/po4a_set.rb @@ -162,7 +162,7 @@ WOK line_wrap end def array_wrap - if @orig.class==Array + if @orig.is_a?(Array) @arr=[] @orig.each do |line| @arr << SiSU_TextUtils::Wrap.new(line,@n_char_max,@n_indent,@n_hang).line_wrap diff --git a/lib/sisu/v3/qrcode.rb b/lib/sisu/v3/qrcode.rb index dfd253d8..3908a1d4 100644 --- a/lib/sisu/v3/qrcode.rb +++ b/lib/sisu/v3/qrcode.rb @@ -668,7 +668,7 @@ WOK @sp=' ' @md.topic_register_array.each do |t| t.each_with_index do |st,i| - if st.class==Array + if st.is_a?(Array) st.each do |v| @manifest[:txt] << %{#{@sp*i}#{v}\n} end diff --git a/lib/sisu/v3/shared_markup_alt.rb b/lib/sisu/v3/shared_markup_alt.rb index 98c55e66..4efedff1 100644 --- a/lib/sisu/v3/shared_markup_alt.rb +++ b/lib/sisu/v3/shared_markup_alt.rb @@ -58,7 +58,7 @@ module SiSU_TextRepresentation class Alter def initialize(x) - if x.class==String + if x.is_a?(String) @t_o,@s=nil,x else @t_o,@s=x,x.obj.dup @@ -196,7 +196,7 @@ module SiSU_TextRepresentation class ModifiedTextPlusHashDigest def initialize(md,x) @md=md - if x.class==String + if x.is_a?(String) @t_o,@s=nil,x else @t_o,@s=x,x.obj.dup diff --git a/lib/sisu/v3/shared_metadata.rb b/lib/sisu/v3/shared_metadata.rb index a8698fd7..cd1e97db 100644 --- a/lib/sisu/v3/shared_metadata.rb +++ b/lib/sisu/v3/shared_metadata.rb @@ -259,12 +259,12 @@ module SiSU_Metadata meta << self.meta_para end if defined? @md.dgst \ - and @md.dgst.class==Array + and @md.dgst.is_a?(Array) @tag,@inf,@class='Source Digest',"#{@md.dgst[0]} #{@md.dgst[1]}",'src' meta << self.meta_para end if defined? @md.dgst_skin \ - and @md.dgst_skin.class==Array + and @md.dgst_skin.is_a?(Array) @tag,@inf,@class='Skin Digest',"#{@md.dgst_skin[0]} #{@md.dgst_skin[1]}",'src' meta << self.meta_para end @@ -288,7 +288,7 @@ module SiSU_Metadata meta << self.meta_para end if defined? @md.generated \ - and @md.generated.class==Time + and @md.generated.is_a?(Time) @tag,@inf,@class=tr.last_generated,@md.generated,'date' meta << self.meta_para end @@ -734,7 +734,7 @@ module SiSU_Metadata @s=str def utf8 if @s \ - and @s.class==String + and @s.is_a?(String) @s=@s.gsub(//u,Mx[:br_paragraph]). gsub(//,'>'). gsub(/<br(?: \/)?>/,'
') if @inf =~/&/ @@ -979,7 +979,7 @@ WOK @br="\\\\\n" end def meta_para(tag,inf,sc=true) - inf=((inf.class==String && sc) ? spec_char(inf) : inf) + inf=((inf.is_a?(String) && sc) ? spec_char(inf) : inf) %{\\begin\{bfseries\}#{tag}:\\end\{bfseries\} #{inf} } end @@ -1193,7 +1193,7 @@ WOK meta << meta_para(tag,inf) end if defined? @md.dgst \ - and @md.dgst.class==Array + and @md.dgst.is_a?(Array) hash_of=spec_char(@md.dgst[0]) hash_of=word_break_points(hash_of) dgst=number_break_points(@md.dgst[1]) @@ -1201,7 +1201,7 @@ WOK meta << meta_para(tag,inf,false) end if defined? @md.dgst_skin \ - and @md.dgst_skin.class==Array + and @md.dgst_skin.is_a?(Array) hash_of=spec_char(@md.dgst_skin[0]) hash_of=word_break_points(hash_of) dgst=number_break_points(@md.dgst_skin[1]) @@ -1210,7 +1210,7 @@ WOK end meta << %{#{@br}\\begin\{bfseries\}Generated \\end\{bfseries\}} if defined? @md.generated \ - and @md.generated.class==Time + and @md.generated.is_a?(Time) tag,inf=tr.last_generated,@md.generated meta << meta_para(tag,inf) end diff --git a/lib/sisu/v3/shared_txt.rb b/lib/sisu/v3/shared_txt.rb index 39363fcf..228109c1 100644 --- a/lib/sisu/v3/shared_txt.rb +++ b/lib/sisu/v3/shared_txt.rb @@ -114,7 +114,7 @@ module SiSU_TextUtils line_wrap end def array_wrap - if @para.class==Array + if @para.is_a?(Array) @arr=[] @para.each do |line| @arr << SiSU_TextUtils::Wrap.new(line,@n_char_max,@n_indent,@n_hang).line_wrap diff --git a/lib/sisu/v3/shared_xml.rb b/lib/sisu/v3/shared_xml.rb index 959170b6..6860d80c 100644 --- a/lib/sisu/v3/shared_xml.rb +++ b/lib/sisu/v3/shared_xml.rb @@ -110,7 +110,7 @@ module SiSU_XML_Munge def utf8(dob='') if @sys.locale =~/utf-?8/i # instead ucs for utf8 # String#encode Iñtërnâtiônàlizætiøn str=if defined? dob.obj then dob.obj - elsif dob.class==String then dob + elsif dob.is_a?(String) then dob end if str #¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûü @@ -217,7 +217,7 @@ module SiSU_XML_Munge dob=if defined? dob.obj dob.obj=str dob - elsif dob.class==String + elsif dob.is_a?(String) str end dob diff --git a/lib/sisu/v3/sst_to_s_xml_sax.rb b/lib/sisu/v3/sst_to_s_xml_sax.rb index 20f68aca..cc08be70 100644 --- a/lib/sisu/v3/sst_to_s_xml_sax.rb +++ b/lib/sisu/v3/sst_to_s_xml_sax.rb @@ -427,7 +427,7 @@ WOK @sisu=new_file_data.scan(/.+/) SiSU_Env::FileOp.new(@md).mkdir filename_sxm=SiSU_Env::FileOp.new(@md,@md.fn[:sxs]).mkfile_pwd - if filename_sxm.class==File + if filename_sxm.is_a?(File) @sisu.each {|para| filename_sxm.puts para} filename_sxm.close else puts 'file not created, is directory writable?' diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index a9df7b2a..1c813fd8 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -467,8 +467,8 @@ module SiSU_Env filename=(@fns =~/\.ssm\.sst$/) \ ? @fns.gsub(/\.ssm\.sst$/,'.ssm') : @fns - unless (filename.nil? \ - or filename.empty?) + if filename.is_a?(String) \ + and not filename.empty? if output_dir_structure.by_language_code? m=/((.+?)(?:\~\w{2,3})?)\.(sst|ssm)$/ @fn[:b],@fn[:m],@fn[:t]=filename[m,1],filename[m,2],filename[m,3] @@ -988,7 +988,7 @@ module SiSU_Env elsif defined? @env.fnb \ and @env.fnb @env.fnb - elsif not @fns.nil? \ + elsif @fns.is_a?(String) \ and not @fns.empty? m=/(.+)?\.(?:(?:-|ssm\.)?sst|ssm)$/m @fns[m,1] if not @fns.empty? @@ -1191,25 +1191,25 @@ module SiSU_Env end def html_minitoc? flag=if defined? @rc['html']['minitoc'] \ - and not @rc['html']['minitoc'].nil? + and @rc['html']['minitoc'].is_a?(String) @rc['html']['minitoc'] else false end end def manifest_minitoc? - flag=if (defined? @rc['manifest']['minitoc'] \ - and not @rc['manifest']['minitoc'].nil?) + flag=if defined? @rc['manifest']['minitoc'] \ + and @rc['manifest']['minitoc'].is_a?(String) @rc['manifest']['minitoc'] else false end end def build def omit_list - @off_list ||=if (defined? @rc['omit_list'] \ - and not @rc['omit_list'].nil?) + @off_list ||=if defined? @rc['omit_list'] \ + and @rc['omit_list'].is_a?(String) @rc['omit_list'] - elsif (defined? @rc['omit']['list'] \ - and not @rc['omit']['list'].nil?) + elsif defined? @rc['omit']['list'] \ + and @rc['omit']['list'].is_a?(String) @rc['omit']['list'] else nil @@ -1388,7 +1388,7 @@ module SiSU_Env true elsif defined? @vz.widget_promo \ and not @vz.widget_promo.nil? \ - and @vz.widget_promo.class==Array \ + and @vz.widget_promo.is_a?(Array) \ and @vz.widget_promo.length > 0 @flag[:sk]=true true @@ -2075,8 +2075,7 @@ WOK end def dal pth=if defined? @rc['processing']['dal'] \ - and not @rc['processing']['dal'].nil? \ - and not @rc['processing']['dal'].empty? + and @rc['processing']['dal'].is_a?(String) "#{processing}/#{@rc['processing']['dal']}" else "#{processing}/#{defaults[:processing_dal]}" end @@ -2085,8 +2084,7 @@ WOK end def tune pth=if defined? @rc['processing']['tune'] \ - and not @rc['processing']['tune'].nil? \ - and not @rc['processing']['tune'].empty? + and @rc['processing']['tune'].is_a?(String) "#{processing}/#{@rc['processing']['tune']}" else "#{processing}/#{defaults[:processing_tune]}" end @@ -2100,8 +2098,7 @@ WOK end def git pth=if defined? @rc['git']['dir'] \ - and not @rc['git']['dir'].nil? \ - and not @rc['git']['dir'].empty? + and @rc['git']['dir'].is_a?(String) x=(@rc['git']['dir'] =~/^(?:~|home)$/) \ ? home + '/' + Gt[:git] : @rc['git']['dir'] + '/' + Gt[:git] @@ -2166,8 +2163,7 @@ WOK end def tex pth=if defined? @rc['processing']['latex'] \ - and not @rc['processing']['latex'].nil? \ - and not @rc['processing']['latex'].empty? + and @rc['processing']['latex'].is_a?(String) "#{processing}/#{@rc['processing']['latex']}" else "#{processing}/#{defaults[:processing_latex]}" end @@ -2176,8 +2172,7 @@ WOK end def texi pth=if defined? @rc['processing']['texinfo'] \ - and not @rc['processing']['texinfo'].nil? \ - and not @rc['processing']['texinfo'].empty? + and @rc['processing']['texinfo'].is_a?(String) "#{processing}/#{@rc['processing']['texinfo']}" else "#{processing}/#{defaults[:processing_texinfo]}" end @@ -2192,8 +2187,7 @@ WOK end def lout pth=if defined? @rc['processing']['lout'] \ - and not @rc['processing']['lout'].nil? \ - and not @rc['processing']['lout'].empty? + and @rc['processing']['lout'].is_a?(String) "#{processing}/#{@rc['processing']['lout']}" else "#{processing}/#{defaults[:processing_lout]}" end @@ -2207,8 +2201,7 @@ WOK end def sqlite pth=if defined? @rc['processing']['sqlite'] \ - and not @rc['processing']['sqlite'].nil? \ - and not @rc['processing']['sqlite'].empty? + and @rc['processing']['sqlite'].is_a?(String) "#{processing}/#{@rc['processing']['sqlite']}" else "#{processing}/#{defaults[:processing_sqlite]}" end @@ -2217,8 +2210,7 @@ WOK end def postgresql pth=if defined? @rc['processing']['postgresql'] \ - and not @rc['processing']['postgresql'].nil? \ - and not @rc['processing']['postgresql'].empty? + and @rc['processing']['postgresql'].is_a?(String) "#{processing}/#{@rc['processing']['postgresql']}" else "#{processing}/#{defaults[:processing_postgresql]}" end @@ -2333,7 +2325,7 @@ WOK end def webserv_cgi #web url for local webserv (localhost, or hostname) if defined? @rc['webserv_cgi']['host'] \ - and not @rc['webserv_cgi']['host'].nil? + and @rc['webserv_cgi']['host'].is_a?(String) http=((@rc['webserv_cgi']['host'] =~ /https?:\/\//) ? '' : 'http://') #check https? missing if webserv_port_cgi "#{http}#{@rc['webserv_cgi']['host']}:#{webserv_port_cgi}/#{@stub_pwd}" @@ -2349,7 +2341,7 @@ WOK end def webserv_base_cgi #web url for local webserv (localhost, or hostname) if defined? @rc['webserv_cgi']['host'] \ - and not @rc['webserv_cgi']['host'].nil? + and @rc['webserv_cgi']['host'].is_a?(String) http=((@rc['webserv_cgi']['host'] =~ /https?:\/\//) ? '' : 'http://') if webserv_port_cgi "#{http}#{@rc['webserv_cgi']['host']}:#{webserv_port_cgi}" @@ -2365,7 +2357,7 @@ WOK end def webrick #must have a port #REMOVE if defined? @rc['webserv_cgi']['host'] \ - and not @rc['webserv_cgi']['host'].nil? + and @rc['webserv_cgi']['host'].is_a?(String) http=if @rc['webserv_cgi']['host'] =~/http:\/\// 'http://' elsif @rc['webserv_cgi']['host'] =~/https:\/\// @@ -2374,7 +2366,7 @@ WOK end "#{http}#{@rc['webserv_cgi']['host']}" elsif webserv_host_base \ - and not webserv_host_base.nil? + and webserv_host_base.is_a?(String) "#{http}#{webserv_host_base}" else "#{http}localhost" end end @@ -2743,48 +2735,42 @@ WOK end def cf_0 #processing flag shortcuts if defined? @rc['flag']['default'] \ - and not (@rc['flag']['default'].nil? \ - or @rc['flag']['default'].empty?) + and @rc['flag']['default'].is_a?(String) @rc['flag']['default'] else '-NQhewpotbxXdyYv' end end def cf_1 #processing flag shortcuts if defined? @rc['flag']['i'] \ - and not (@rc['flag']['i'].nil? \ - or @rc['flag']['i'].empty?) + and @rc['flag']['i'].is_a?(String) @rc['flag']['i'] else '-Qhewpoty' end end def cf_2 #processing flag shortcuts if defined? @rc['flag']['ii'] \ - and not (@rc['flag']['ii'].nil? \ - or @rc['flag']['ii'].empty?) + and @rc['flag']['ii'].is_a?(String) @rc['flag']['ii'] else '-NQhewpotbxXdy' end end def cf_3 #processing flag shortcuts if defined? @rc['flag']['iii'] \ - and not (@rc['flag']['iii'].nil? \ - or @rc['flag']['iii'].empty?) + and @rc['flag']['iii'].is_a?(String) @rc['flag']['iii'] else '-NQhewpotbxXdyY' end end def cf_4 #processing flag shortcuts if defined? @rc['flag']['iv'] \ - and not (@rc['flag']['iv'].nil? \ - or @rc['flag']['iv'].empty?) + and @rc['flag']['iv'].is_a?(String) @rc['flag']['iv'] else '-NQhewpotbxXdDyY --update' end end def cf_5 #processing flag shortcuts if defined? @rc['flag']['v'] \ - and not (@rc['flag']['v'].nil? \ - or @rc['flag']['v'].empty?) + and @rc['flag']['v'].is_a?(String) @rc['flag']['v'] else '-NQhewpotbxXdDyYv --update' end @@ -2982,7 +2968,7 @@ WOK def remote_host #see InfoRemote remote_host_base_general r=[] r=if (defined? @rc['remote'] \ - and @rc['remote'].class==Array) + and @rc['remote'].is_a?(Array)) r_array=@rc['remote'] r_array.each_with_index do |renv,i| r[i]={} @@ -2999,7 +2985,7 @@ WOK end r elsif (defined? @rc['remote'] \ - and @rc['remote'].class==Hash \ + and @rc['remote'].is_a?(Hash) \ and defined? @rc['remote']['user'] \ and defined? @rc['remote']['host']) r[0]={} @@ -3877,7 +3863,7 @@ WOK def port #PGPORT ((defined? @rc['db']['postgresql']['port']) \ && ( @rc['db']['postgresql']['port'] =~/\d+/ \ - || @rc['db']['postgresql']['port'].class==Fixnum)) \ + || @rc['db']['postgresql']['port'].is_a?(Fixnum))) \ ? @rc['db']['postgresql']['port'] : (@defaults[:postgresql_port]) end @@ -5641,7 +5627,7 @@ WOK class InfoSkin def initialize(md=nil,skin=nil) @md=md - @d_sk=if skin.class==String + @d_sk=if skin.is_a?(String) skin elsif defined? md.doc_skin \ and md.doc_skin diff --git a/lib/sisu/v3/texinfo_format.rb b/lib/sisu/v3/texinfo_format.rb index 7374d01e..78f2a188 100644 --- a/lib/sisu/v3/texinfo_format.rb +++ b/lib/sisu/v3/texinfo_format.rb @@ -66,10 +66,10 @@ module SiSU_TexInfoFormat @@tex_pattern_margin_number="\\\\marginpar.+?\s+" def initialize(md,dob=nil) @md,@dob=md,dob - if dob.class==Hash + if dob.is_a?(Hash) p dob.class p caller - elsif dob.class==String + elsif dob.is_a?(String) p dob.class p caller end diff --git a/lib/sisu/v3/texpdf.rb b/lib/sisu/v3/texpdf.rb index fc007a4f..0665c9b4 100644 --- a/lib/sisu/v3/texpdf.rb +++ b/lib/sisu/v3/texpdf.rb @@ -401,8 +401,8 @@ module SiSU_TeX def tables(data) @tex_file=[] data.each do |dob| - @tex_file << if dob.class==String \ - or dob.class==Hash + @tex_file << if dob.is_a?(String) \ + or dob.is_a?(Hash) dob elsif dob.is==:table tables_hash(@md,dob) #Hash result @@ -538,12 +538,12 @@ module SiSU_TeX idx_arr=[] idx=SiSU_Particulars::CombinedSingleton.instance.get_idx_raw(@md.opt).raw_idx idx.each do |x| - x=if x.class==String + x=if x.is_a?(String) x=SiSU_TeX_Pdf::SpecialCharacters.new(@md,x).special_characters x=SiSU_TeX_Pdf::FormatTextObject.new(@md,x).url_str_internal(x,true) else x=nil end - idx_arr << x.sub(/,$/,'') if x.class==String + idx_arr << x.sub(/,$/,'') if x.is_a?(String) end idx_str=idx_arr.join(br) l=heading + br + idx_str @@ -582,7 +582,7 @@ module SiSU_TeX dob.tmp=dob.tmp.strip unless dob.is==:code dob=enclose(dob) unless dob.tmp =~/^$/ end - if dob.class==String + if dob.is_a?(String) dob.tmp=dob.tmp.gsub(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,' \newline '). #% tread with care gsub(/(\.#{Tex[:tilde]}\S*\s*|<:\S+>|#{Mx[:fa_o]}.*?#{Mx[:fa_c]}|#{Mx[:gr_o]}.*?#{Mx[:gr_c]}||)/,' ') #% tread with care end @@ -776,7 +776,7 @@ WOK @tex_file << x x=nil data.each do |dob| #% case follows with levels 1-6 indents & graphics - if dob.class==Hash + if dob.is_a?(Hash) elsif dob.of==:para \ || dob.of==:block #GATEWAY FIX FIX stuff dob=markup_common(dob) @@ -797,7 +797,7 @@ WOK end end end - elsif dob.tmp.class==Hash \ + elsif dob.tmp.is_a?(Hash) \ and (dob.tmp[:p] and dob.tmp[:l]) dob = { p: markup_common(dob.tmp[:p]), @@ -844,7 +844,7 @@ WOK def number_paras(data) tex_file=[] data.each do |dob| - dob=if dob.class==Hash + dob=if dob.is_a?(Hash) if ( dob['a4'] \ or dob['a5'] \ or dob['b5'] \ @@ -932,7 +932,7 @@ WOK file[:portrait] << @@tex_head[ps][:p] file[:landscape] << @@tex_head[ps][:l] array.each do |morph| - if morph.class==String + if morph.is_a?(String) #morph.gsub!(/^\s+/,'') if morph !~/\A\s*\Z/ file[:portrait].puts morph,"\n" @@ -940,7 +940,7 @@ WOK end elsif morph.class.inspect =~ /SiSU_DAL_DocumentStructure/ \ and morph.tmp \ - and morph.tmp.class==String + and morph.tmp.is_a?(String) if morph.is !=:code \ && morph.of !=:block morph.tmp=morph.tmp.gsub(/^\s+/,'') @@ -951,10 +951,10 @@ WOK file[:portrait].puts morph.tmp,"\n" file[:landscape].puts morph.tmp,"\n" end - elsif morph.class==Hash #inserted headers and the like, only + elsif morph.is_a?(Hash) #inserted headers and the like, only h={ ps: ps, h: morph, filename: file } output_morph_hash(h) - elsif morph.tmp.class==Hash #tables & images? + elsif morph.tmp.is_a?(Hash) #tables & images? h={ ps: ps, h: morph.tmp, filename: file } output_morph_hash(h) end diff --git a/lib/sisu/v3/texpdf_format.rb b/lib/sisu/v3/texpdf_format.rb index 43763157..a7331447 100644 --- a/lib/sisu/v3/texpdf_format.rb +++ b/lib/sisu/v3/texpdf_format.rb @@ -719,7 +719,7 @@ module SiSU_TeX_Pdf def initialize(md,t_o) @md,@t_o=md,t_o @env=SiSU_Env::InfoEnv.new(@md.fns) - if t_o.class==Hash + if t_o.is_a?(Hash) @txt =t_o[:txt] || nil @subtitle=t_o[:subtitle] || nil @ps=t_o[:paper_size] || nil diff --git a/lib/sisu/v3/xhtml_table.rb b/lib/sisu/v3/xhtml_table.rb index 753b0242..30701433 100644 --- a/lib/sisu/v3/xhtml_table.rb +++ b/lib/sisu/v3/xhtml_table.rb @@ -84,7 +84,7 @@ module SiSU_XHTML_Table end nc+=1 end - trc=trc.class==Array ? trc.flatten.join : trc + trc=(trc.is_a?(Array)) ? trc.flatten.join : trc trc=" #{trc}\n" nr+=1 table_rows << trc diff --git a/lib/sisu/v3/xml_format.rb b/lib/sisu/v3/xml_format.rb index a9f6fb01..54d889cd 100644 --- a/lib/sisu/v3/xml_format.rb +++ b/lib/sisu/v3/xml_format.rb @@ -999,7 +999,7 @@ WOK attr_accessor :md,:dob,:txt,:ocn,:format,:table,:link,:linkname,:paranum,:p_num,:headname,:banner,:url def initialize(md,t_o) @md,@t_o=md,t_o - if t_o.class==Hash + if t_o.is_a?(Hash) @txt =t_o[:txt] || nil @ocn =t_o[:ocn] || nil @ocn_display =t_o[:ocn_display] || nil -- cgit v1.2.3