Last change
on this file since 398 was 321, checked in by coas-nagasima, 7 years ago |
文字コードを設定
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-ruby;charset=UTF-8
|
File size:
1.1 KB
|
Line | |
---|
1 | class Symbol
|
---|
2 | include Comparable
|
---|
3 |
|
---|
4 | alias intern to_sym
|
---|
5 |
|
---|
6 | def to_proc
|
---|
7 | ->(obj,*args,&block) do
|
---|
8 | obj.__send__(self, *args, &block)
|
---|
9 | end
|
---|
10 | end
|
---|
11 |
|
---|
12 | ##
|
---|
13 | # call-seq:
|
---|
14 | # sym.capitalize -> symbol
|
---|
15 | #
|
---|
16 | # Same as <code>sym.to_s.capitalize.intern</code>.
|
---|
17 |
|
---|
18 | def capitalize
|
---|
19 | (self.to_s.capitalize! || self).to_sym
|
---|
20 | end
|
---|
21 |
|
---|
22 | ##
|
---|
23 | # call-seq:
|
---|
24 | # sym.downcase -> symbol
|
---|
25 | #
|
---|
26 | # Same as <code>sym.to_s.downcase.intern</code>.
|
---|
27 |
|
---|
28 | def downcase
|
---|
29 | (self.to_s.downcase! || self).to_sym
|
---|
30 | end
|
---|
31 |
|
---|
32 | ##
|
---|
33 | # call-seq:
|
---|
34 | # sym.upcase -> symbol
|
---|
35 | #
|
---|
36 | # Same as <code>sym.to_s.upcase.intern</code>.
|
---|
37 |
|
---|
38 | def upcase
|
---|
39 | (self.to_s.upcase! || self).to_sym
|
---|
40 | end
|
---|
41 |
|
---|
42 | ##
|
---|
43 | # call-seq:
|
---|
44 | # sym.casecmp(other) -> -1, 0, +1 or nil
|
---|
45 | #
|
---|
46 | # Case-insensitive version of <code>Symbol#<=></code>.
|
---|
47 |
|
---|
48 | def casecmp(other)
|
---|
49 | return nil unless other.kind_of?(Symbol)
|
---|
50 | lhs = self.to_s; lhs.upcase!
|
---|
51 | rhs = other.to_s; rhs.upcase!
|
---|
52 | lhs <=> rhs
|
---|
53 | end
|
---|
54 |
|
---|
55 | #
|
---|
56 | # call-seq:
|
---|
57 | # sym.empty? -> true or false
|
---|
58 | #
|
---|
59 | # Returns that _sym_ is :"" or not.
|
---|
60 |
|
---|
61 | def empty?
|
---|
62 | self.length == 0
|
---|
63 | end
|
---|
64 |
|
---|
65 | end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.