Add "to_json" and "to_jpn_wday"

This commit is contained in:
takumi091111
2017-10-14 12:38:09 +09:00
parent 8d65887797
commit b1bc125624

View File

@ -2,4 +2,15 @@ class String
def with_comma
self.gsub(/(\d)(?=\d{3}+$)/, '\\1,')
end
# jsonpをjsonに変換
def to_json
self.match(/.*callback\((.*)\)/)[1]
end
# 英語3文字の曜日を日本語1文字に変換
def to_jpn_wday
i = %w(sun mon tue wed thu fri sat).index{|w| w == self}
self.replace(%w(日 月 火 水 木 金 土)[i])
end
end