基礎部分
とりあえずこんなもん?
バッククオートけすこと
#!/usr/bin/ruby -Ke require 'kakasi' class Page @@basedir='./data/' attr_accessor :name, :id, :mtime, :how2read def initialize(arg="2e23d54a-107a-47cd-93be-da204b20b26c") if arg=~/([a-z]|\d){8}-([a-z]|\d){4}-([a-z]|\d){4}-([a-z]|\d){4}-([a-z]|\d){12}/ @id=arg @name=File.open(@@basedir+arg+'/subject.txt'){|f| f.read} @mtime=File.mtime(@@basedir+arg+'/subject.txt') else @name=arg @id=`uuidgen`.chop Dir.glob(@@basedir+'*'){|dname| #高速化の必要あり? n=File.open(dname+'/subject.txt'){|f| f.read} if n==@name @id=File.basename(dname) @mtime=Time.now break end } end @how2read=Kakasi.kakasi('-JH -KH -U',@name).upcase # 別途ファイルを作る必要あるかも end def exist? @id!=''?true:false end def store(content='Damy') File.open(@@basedir+@id+'/subject.txt','w'){|f|f.write(@name)} File.rename(@@basedir+@id+'/content.txt',@@basedir+@id+"/#{File.mtime(fname).strftime('%Y%m%d%H%M%S')}.txt") if test(?e,@@basedir+@id+'/content.txt') File.open(@@basedir+@id+'/content.txt','w'){|f|f.write(content)} `touch #{@@basedir+@id}` end def to_s File.open(@@basedir+@id+'/content.txt'){|f|f.read} end end