Class: String

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

Overview

Enhanced String methods for converting to AOZORA format

Instance Method Summary collapse

Instance Method Details

#for_tategakiObject

replace characters fitting to vertical lyout



22
23
24
# File 'lib/aozoragen/util.rb', line 22

def for_tategaki
	self.tr( '<>−', '∧∨‐' ).han2zen
end

#han2zenObject

Half width of Alphabet and Digit to Full width.



14
15
16
17
# File 'lib/aozoragen/util.rb', line 14

def han2zen
	self.tr( 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,',
		'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,' )
end

#normalize_charObject

normalize invalid charcters



38
39
40
41
42
43
# File 'lib/aozoragen/util.rb', line 38

def normalize_char
	self.tr(
		"\uff5e\u301d\u301f\u5699\u9830\u525d\u7626\u6451\u5653\u7e6b\uFF0D\u6414\u541e\u881f\u555e\u9e7c",
		"〜〃〃噛頬剥痩掴嘘繋─掻呑蝋唖鹸"
	)
end

#subheadObject

section heading format of Aozora



29
30
31
32
33
# File 'lib/aozoragen/util.rb', line 29

def subhead
	self.split( /\n/ ).map{|x|
		"\n[#小見出し]#{x}[#小見出し終わり]"
	}.join + "\n\n"
end