-
Notifications
You must be signed in to change notification settings - Fork 0
/
extensions.rb
66 lines (53 loc) · 925 Bytes
/
extensions.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# frozen_string_literal: true
# 文字コード変換用のメソッド。
class String
def to_utf8
encode('UTF-8')
end
def to_sjis
encode('CP932')
end
def to_utf8!
encode!('UTF-8')
end
def to_sjis!
encode!('CP932')
end
def as_utf8
dup.force_encoding('UTF-8')
end
def as_sjis
dup.force_encoding('CP932')
end
def as_utf8!
force_encoding('UTF-8')
end
def as_sjis!
force_encoding('CP932')
end
end
# ファイルパス作成用のメソッド。
class String
def /(other)
File.join(self, other)
end
end
class Object
def blank?
case self
when String then empty?
when nil then true
else false
end
end
def true?
self ? true : false
end
end
require_relative 'post_builder'
# 日付を2ちゃんねる形式の文字列に変換する。
class Time
def to_nichan
Genkai::PostBuilder.format_date(self)
end
end