The document discusses various topics in Ruby including:
1. Singleton classes in Ruby and how to include the Singleton module to define a singleton class.
2. Differences between Time and DateTime in Ruby and how DateTime can represent dates further in the past or future compared to Time.
3. Character encoding conversions in Ruby using the kconv library and examples of converting between UTF-8 and EUC encodings.
9. require ‘singleton’
class SingletonClass
include Singleton
end
>> SingletonClass.new
NoMethodError: private method `new' called for SingletonClass:Class
>>SingletonClass.instance
=> #<SingletonClass:0x1005f7a98>
14. Time
• Time Unix Time
Time.now + 30 * 365 * 24 * 3600 # 30
RangeError: time + 946080000.000000 out of Time range
Ubuntu Linux(32bit) NG MacOS 10(64bit) OK
Windows
Time.now + 30 * 365 * 24 * 3600
=> Mon Oct 21 11:34:29 +0900 2041
17. kconv UTF-8 EUC
UTF-8
• JIS (Ruby 1.8.7 )
• https://gist.github.com/1273188
require ‘kconv’
kanji5020_503F = <<KANJI
KANJI
p kanji5020_503F
p kanji5020_503F.toeuc.toutf8
" n n"
"С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Яnа б в г д е ж з и й к л м н о пn"