Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/aozoragen/util.rb,
lib/aozoragen/syosetu.rb
Overview
Enhanced String methods for converting to AOZORA format
Instance Method Summary collapse
- #fix_aozora_notation ⇒ Object
-
#for_tategaki ⇒ Object
replace characters fitting to vertical lyout.
-
#han2zen ⇒ Object
Half width of Alphabet and Digit to Full width.
-
#normalize_char ⇒ Object
normalize invalid charcters.
-
#subhead ⇒ Object
section heading format of Aozora.
Instance Method Details
#fix_aozora_notation ⇒ Object
10 11 12 |
# File 'lib/aozoragen/syosetu.rb', line 10 def fix_aozora_notation self.gsub(/[||](.+?)『(.+?)』/){"|#$1《#$2》"} end |
#for_tategaki ⇒ Object
replace characters fitting to vertical lyout
22 23 24 |
# File 'lib/aozoragen/util.rb', line 22 def for_tategaki self.tr( '<>-“”−', '∧∨―〃〃‐' ).han2zen end |
#han2zen ⇒ Object
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_char ⇒ Object
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 |
#subhead ⇒ Object
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 |