Class: FileIO

Inherits:
Object
  • Object
show all
Defined in:
lib/file_io.rb

Direct Known Subclasses

LoaderCsv, LoaderTxt, LoaderXls

Class Method Summary collapse

Class Method Details

.encodePath(path) ⇒ Object

ファイル書き込み時、パス文字列のエンコードを変換してシステムに返却するためのメソッド



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/file_io.rb', line 4

def self.encodePath(path)
	case self.filesystem
	when 'u' # Linux Utf-8
		#utf8=>utf8なので何もしない
		path
	when 's' # Windows Shift-JIS(CP932)
		path = MyMatrix.tosjis(path)
	when 'm' # Mac utf8(UTF8-Mac)
		path = MyMatrix.toUtf8Mac(path)
   else
     path
	end
end

.filesystemObject

ファイルシステムを判定するメソッド。



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/file_io.rb', line 29

def self.filesystem
	#platform check
if(RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|cygwin|bccwin/)
	filesystem = 's' # Windows Shift-JIS(CP932)
elsif(RUBY_PLATFORM.downcase =~ /darwin/)
	filesystem = 'm' # Mac utf8(UTF8-Mac)
elsif(RUBY_PLATFORM.downcase =~ /linux/)
	filesystem = 'u' # Linux Utf-8
else
	filesystem = 'u'
end
  return filesystem
end

.readPath(path) ⇒ Object

ファイル読み込み時、パス文字列のエンコードをUTF8に変換して内部保持する為のメソッド。 Windowsからファイルを受け取る場合、ShiftJisで文字列が渡ってくるため。



19
20
21
22
23
24
25
26
# File 'lib/file_io.rb', line 19

def self.readPath(path)
  case self.filesystem
  when 's'
    MyMatrix.toutf8(path)
  else
    path
  end
end