[#9811] Ruby book — WATANABE Tetsuya <tetsu@...>

今日のひとこと(10/05)

22 messages 1998/10/05
[#9812] Re: Ruby book — matz@... (Yukihiro Matsumoto) 1998/10/05

まつもと ゆきひろです

[#9813] Re: Ruby book — "D.Kanda" <MAP2303@...> 1998/10/05

[#9815] Re: Ruby book — matz@... (Yukihiro Matsumoto) 1998/10/05

まつもと ゆきひろです

[#9827] Are there any NNTP Client Class? — Takeshi UME Imai <takeshi@...>

はじめまして。今井といいます。

17 messages 1998/10/05
[#9828] Re: Are there any NNTP Client Class? — aamine@... 1998/10/05

はじめまして、あおきともうします。

[#9869] man-1.1/Marshal.html — ttate@...

立石です。

47 messages 1998/10/07
[#9872] Re: man-1.1/Marshal.html — matz@... (Yukihiro Matsumoto) 1998/10/08

まつもと ゆきひろです

[#9880] comments on manual (Re: man-1.1/Marshal.html) — Motoyuki Kasahara <m-kasahr@...> 1998/10/08

SRA の笠原です。

[#9881] Re: comments on manual (Re: man-1.1/Marshal.html) — matz@... (Yukihiro Matsumoto) 1998/10/08

まつもと ゆきひろです

[#9909] Re: comments on manual (Re: man-1.1/Marshal.html) — Motoyuki Kasahara <m-kasahr@...> 1998/10/09

SRA の笠原です。

[#9936] Re: comments on manual (Re: man-1.1/Marshal.html) — matz@... (Yukihiro Matsumoto) 1998/10/09

まつもと ゆきひろです

[#9939] Re: comments on manual (Re: man-1.1/Marshal.html) — Shin-ichro Hara <sinara@...> 1998/10/09

原です。

[#9940] Re: comments on manual (Re: man-1.1/Marshal.html) — matz@... (Yukihiro Matsumoto) 1998/10/09

まつもと ゆきひろです

[#9941] Re: comments on manual (Re: man-1.1/Marshal.html) — Shin-ichro Hara <sinara@...> 1998/10/09

原です。

[#9942] Re: comments on manual (Re: man-1.1/Marshal.html) — matz@... (Yukihiro Matsumoto) 1998/10/09

まつもと ゆきひろです

[#9944] read(nil) (Re: comments on manual) — Shin-ichro Hara <sinara@...> 1998/10/09

原です。

[#9884] List of UserInterface Kits for Ruby ? — a.furudo@...

20 messages 1998/10/08
[#9906] Re: List of UserInterface Kits for Ruby ? — matz@... (Yukihiro Matsumoto) 1998/10/09

まつもと ゆきひろです

[#9885] 文字化け失礼、再送 — Akihiro Furudo <a.furudo@...>

26 messages 1998/10/08
[#9888] Re: 文字化け失礼、再送 — ttate@... 1998/10/08

立石です。

[#9897] お礼と、 Ruby/Gtk(i18n) について質問 — Akihiro Furudo <A.Furudo@...> 1998/10/08

[#9982] Re: お礼と、 Ruby/Gtk(i18n) について質問 — Daisuke Kanda <MAP2303@...> 1998/10/11

[#10320] Ruby/Gtk を FreeBSD にインストール (re:9982) — Akihiro Furudo <a.furudo@...> 1998/10/24

[#10328] Re: Ruby/Gtk を FreeBSD にインストール (re:9982) — Daisuke Kanda <MAP2303@...> 1998/10/25

[#9976] ruby:struct -> ext module -> ruby — Kikutani Makoto <kikutani@...>

きくたにです。

17 messages 1998/10/11

[#9999] ruby on HP-UX — AU6M-IWM@... (Iwama Misao)

20 messages 1998/10/12
[#10001] Re: ruby on HP-UX — matz@... (Yukihiro Matsumoto) 1998/10/12

まつもと ゆきひろです

[#10030] Ruby/Gtk text widget — TAKAHASHI Masayoshi <maki@...>

高橋です。

29 messages 1998/10/12
[#10035] Re: Ruby/Gtk text widget — Daisuke Kanda <MAP2303@...> 1998/10/12

[#10038] ruby/gtk method naming (Re: Re: Ruby/Gtk text widget) — "D.Kanda" <MAP2303@...> 1998/10/13

[#10067] Re: ruby/gtk method naming (Re: Re: Ruby/Gtk text widget) — Kazumi Okamoto <kazusan@...> 1998/10/13

岡本です。

[#10092] for が修飾子だったら — ARIMA Yasuhiro <fit0298@...>

有馬@FITECです。

46 messages 1998/10/14
[#10093] Re: for が修飾子だったら — matz@... (Yukihiro Matsumoto) 1998/10/14

まつもと ゆきひろです

[#10236] Array.html again — Motoyuki Kasahara <m-kasahr@...>

笠原です。こんにちは。

18 messages 1998/10/22
[#10237] Re: Array.html again — Kanda <MAP2303@...> 1998/10/22

[#10239] Re: Array.html again — matz@... (Yukihiro Matsumoto) 1998/10/22

まつもと ゆきひろです

[#10311] Re: 大規模プログラムの友 — m_seki@... (SEKI)

At 11:23 PM 98.10.23 +0900, Takashi Nakai wrote:

24 messages 1998/10/23
[#10312] Re: 大規模プログラムの友 — Takashi Nakai <nakai@...1.sys.to.casio.co.jp> 1998/10/23

ど〜も、(またしても)中井です。

[#10369] Re: 大規模プログラムの友 — matz@... (Yukihiro Matsumoto) 1998/10/27

まつもと ゆきひろです

[#10415] split — flare@... (Takashi Ikeda)

ふれあです。

20 messages 1998/10/28

[#10473] case with Class — MineroAoki <aamine@...>

あおきです。

46 messages 1998/10/29
[#10483] Re: case with Class — matz@... (Yukihiro Matsumoto) 1998/10/30

まつもと ゆきひろです

[#10521] Re: case with Class — aamine@... 1998/10/30

こんにちは。あおきです。

[#10523] Re: case with Class — gotoken@... (GOTO Kentaro) 1998/10/30

ごとけんです

[#10530] Re: case with Class — aamine@... 1998/10/31

あおきです。

[#10544] Re: case with Class — shugo@... (MAEDA Shugo) 1998/10/31

前田です。

[#10548] Re: case with Class — Wakou Aoyama <wakou@...> 1998/10/31

青山です。

[#10555] Re: case with Class — shugo@... (MAEDA Shugo) 1998/11/01

前田です。

[#10566] Re: case with Class — Wakou Aoyama <wakou@...> 1998/11/01

青山です。

[ruby-list:10172] Re: syntax of compare strings

From: ARIMA Yasuhiro <fit0298@...>
Date: 1998-10-19 01:16:18 UTC
List: ruby-list #10172
Regard to "[ruby-list:10165] syntax of compare strings"

有馬@FITECです。

>rubyでのスクリプト解析みたいなことをやったことがある方は
>いらっしゃいませんか?

Windows の Ini ファイルの形式のデータを扱うために、以下のようなものを
書きました。読み込んだデータは Hash に貯えていきます。
元ネタは、Windows 用の処理系である Delphi の TInifile クラスです。

inifile = IniFile.open("a.ini")

と書くための、open の定義の仕方がよくわからないので不細工ですが、
参考になりますでしょうか?

#
#	inifile.rb
#
#	def new
#	def read(section, key)
#	def write(section, key, value)
#	def deleteKey(section, key)
#	def deleteSection(section)
#	def loadfromfile(filename = @inifilename)
#	def savetofile(filename = @inifilename)
#	def clear
#
class IniFile
	def initialize 
#		@inifilename = filename)
		@sections = []
		@keys = {}
		@values = {}
	end
	def read(section, key)
		@values[section+"="+key]
	end
	def write(section, key, value)
		@sections |= [section]
		@keys[section] = [] if @keys[section] == nil
		@keys[section] |= [key]
		@values[section+"="+key] = value
	end
	def deleteKey(section, key)
		write section, key, nil
		@keys[section] -= [key]
	end
	def deleteSection(section)
		@keys[section].each do |key|
			deleteKey section, key
		end
		@sections -= [section]
	end
	def loadfromfile(filename = @inifilename)
		return nil if not File.exist?(filename)
		f = File.open(filename, "r")
		begin
			while s = f.gets do
				s.chop!.strip!
				next if s == ""
				next if s =~ /^;.*/
				if s =~ /\[([^]]+)\]/ then
					section = $1
					next
				end
				if s =~ /([^=]+)=(.*)/ then
					key   = $1
					value = $2
					write section, key, value
				end
			end
		ensure
			f.close
		end
	end
	def savetofile(filename = @inifilename)
		f = File.open(filename, "w")
		begin
			@sections.each do |section|
				f.printf "[%s]\n\n", section
				@keys[section].each do |key|
					value = read(section, key)
					f.printf "%s=%s\n", key, value
				end
				f.printf "\n\n", section
			end
		ensure
			f.close
		end
	end
	def clear
		@sections = []
		@keys = {}
		@values = {}
	end
end

def test
inifile = IniFile.new
inifile.loadfromfile "a.ini"
print "----\n"
#inifile.savetofile "b.ini"
inifile.savetofile "conout$"
print "----\n"
inifile.deleteKey "a", "a1"
inifile.savetofile "conout$"
print "----\n"
inifile.deleteSection "b"
inifile.savetofile "conout$"
print "----\n"
inifile.write "About", "Copyright", "Anonymouse"
inifile.savetofile "conout$"
end

--
 有馬 康弘 <fit0298@fitec.co.jp>

In This Thread