mirror of
https://github.com/ToshioCP/Gtk4-tutorial.git
synced 2025-02-05 08:45:57 +01:00
Method name renum is changed to renum! because it's destructive.
This commit is contained in:
parent
ee82d53dff
commit
c2ecbf15b0
2 changed files with 5 additions and 5 deletions
4
Rakefile
4
Rakefile
|
@ -8,7 +8,7 @@ FileList['src/*.src.md'].each do |file|
|
||||||
srcfiles << Sec_file.new(file)
|
srcfiles << Sec_file.new(file)
|
||||||
end
|
end
|
||||||
srcfiles = Sec_files.new srcfiles
|
srcfiles = Sec_files.new srcfiles
|
||||||
srcfiles.renum
|
srcfiles.renum!
|
||||||
|
|
||||||
mdfilenames = srcfiles.map {|srcfile| srcfile.to_md}
|
mdfilenames = srcfiles.map {|srcfile| srcfile.to_md}
|
||||||
htmlfilenames = srcfiles.map {|srcfile| "html/"+srcfile.to_html}
|
htmlfilenames = srcfiles.map {|srcfile| "html/"+srcfile.to_html}
|
||||||
|
@ -129,7 +129,7 @@ task all: [:md, :html, :pdf]
|
||||||
|
|
||||||
task md: mdfilenames+["Readme.md"]
|
task md: mdfilenames+["Readme.md"]
|
||||||
|
|
||||||
file "Readme.md" do
|
file "Readme.md" => mdfilenames do
|
||||||
buf = [ "# Gtk4 Tutorial for beginners\n", "\n" ]
|
buf = [ "# Gtk4 Tutorial for beginners\n", "\n" ]
|
||||||
buf << abstract
|
buf << abstract
|
||||||
buf << "\n"
|
buf << "\n"
|
||||||
|
|
|
@ -67,7 +67,7 @@ class Sec_file < String
|
||||||
def is_i?
|
def is_i?
|
||||||
self.to_f == self.to_f.floor
|
self.to_f == self.to_f.floor
|
||||||
end
|
end
|
||||||
def renum n
|
def renum! n
|
||||||
if n.instance_of?(String)
|
if n.instance_of?(String)
|
||||||
n = n.to_i if n =~ /^\d+$/
|
n = n.to_i if n =~ /^\d+$/
|
||||||
n = n.to_f if n =~ /^\d+\.\d+/
|
n = n.to_f if n =~ /^\d+\.\d+/
|
||||||
|
@ -99,7 +99,7 @@ class Sec_files < Array
|
||||||
raise "#{sec_files} is not an array."
|
raise "#{sec_files} is not an array."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def renum
|
def renum!
|
||||||
self.sort!
|
self.sort!
|
||||||
tbl = []
|
tbl = []
|
||||||
n = 1
|
n = 1
|
||||||
|
@ -138,7 +138,7 @@ private
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
unless found # OK to replace
|
unless found # OK to replace
|
||||||
self[i].renum n
|
self[i].renum! n
|
||||||
tbl[i][2] = true
|
tbl[i][2] = true
|
||||||
# tbl[0] (old number (String) is kept in the array 'tbl')
|
# tbl[0] (old number (String) is kept in the array 'tbl')
|
||||||
changed = true
|
changed = true
|
||||||
|
|
Loading…
Add table
Reference in a new issue