diff --git a/Rakefile b/Rakefile index 031d8d5..8485690 100644 --- a/Rakefile +++ b/Rakefile @@ -8,7 +8,7 @@ FileList['src/*.src.md'].each do |file| srcfiles << Sec_file.new(file) end srcfiles = Sec_files.new srcfiles -srcfiles.renum +srcfiles.renum! mdfilenames = srcfiles.map {|srcfile| srcfile.to_md} htmlfilenames = srcfiles.map {|srcfile| "html/"+srcfile.to_html} @@ -129,7 +129,7 @@ task all: [:md, :html, :pdf] task md: mdfilenames+["Readme.md"] -file "Readme.md" do +file "Readme.md" => mdfilenames do buf = [ "# Gtk4 Tutorial for beginners\n", "\n" ] buf << abstract buf << "\n" diff --git a/lib/lib_sec_file.rb b/lib/lib_sec_file.rb index 6001ece..f315ea3 100644 --- a/lib/lib_sec_file.rb +++ b/lib/lib_sec_file.rb @@ -67,7 +67,7 @@ class Sec_file < String def is_i? self.to_f == self.to_f.floor end - def renum n + def renum! n if n.instance_of?(String) n = n.to_i if n =~ /^\d+$/ n = n.to_f if n =~ /^\d+\.\d+/ @@ -99,7 +99,7 @@ class Sec_files < Array raise "#{sec_files} is not an array." end end - def renum + def renum! self.sort! tbl = [] n = 1 @@ -138,7 +138,7 @@ private end end unless found # OK to replace - self[i].renum n + self[i].renum! n tbl[i][2] = true # tbl[0] (old number (String) is kept in the array 'tbl') changed = true