mpw-tools/split-help.rb

45 lines
505 B
Ruby
Raw Normal View History

2013-07-14 22:15:56 +00:00
#!/usr/bin/env ruby -w
#
# format
# -
# name # comment
#
file = nil
state = nil
#ARGF.binmode
#ARGF.set_encoding("BINARY")
ARGF.each { |line|
line.chomp!
case state
when nil
if line == '-'
state = :name
end
when :name
if line.match(/^([A-Za-z0-F]+)\s?#?/)
state = :data
filename = $1
file = File::new("Help.Files/#{filename}", "w")
#file.set_encoding("BINARY")
end
when :data
if line == '-'
state = :name
file = nil
else
file.puts(line)
end
end
}