Class: Symbol
Overview
Symbol extension.
Instance Method Summary collapse
- #*(multi) ⇒ Object
- #+(other_str) ⇒ Object (also: #concat)
- #<=>(symbol) ⇒ Object
- #[](*args) ⇒ Object (also: #slice)
- #append(string) ⇒ Object
- #end_with?(*suffix) ⇒ Boolean
- #prepend(string) ⇒ Object
- #split(separator = " ", count = 0) ⇒ Object
- #start_with?(*prefix) ⇒ Boolean
- #strip ⇒ Object
Instance Method Details
#*(multi) ⇒ Object
21 22 23 |
# File 'lib/hash-utils/symbol.rb', line 21 def *(multi) (self.to_s * multi).to_sym end |
#+(other_str) ⇒ Object Also known as: concat
36 37 38 |
# File 'lib/hash-utils/symbol.rb', line 36 def +(other_str) (self.to_s + other_str.to_s).to_sym end |
#<=>(symbol) ⇒ Object
165 166 167 |
# File 'lib/hash-utils/symbol.rb', line 165 def <=>(symbol) self.to_s <=> symbol.to_s end |
#[](*args) ⇒ Object Also known as: slice
54 55 56 |
# File 'lib/hash-utils/symbol.rb', line 54 def [](*args) self.to_s[*args] end |
#append(string) ⇒ Object
105 106 107 |
# File 'lib/hash-utils/symbol.rb', line 105 def append(string) (self.to_s << string.to_s).to_sym end |
#end_with?(*suffix) ⇒ Boolean
90 91 92 93 |
# File 'lib/hash-utils/symbol.rb', line 90 def end_with?(*suffix) suffix.map! { |i| i.to_s } self.to_s.end_with?(*suffix) end |
#prepend(string) ⇒ Object
119 120 121 |
# File 'lib/hash-utils/symbol.rb', line 119 def prepend(string) (string.to_s + self.to_s).to_sym end |
#split(separator = " ", count = 0) ⇒ Object
133 134 135 136 137 |
# File 'lib/hash-utils/symbol.rb', line 133 def split(separator = " ", count = 0) self.to_s.split(separator, count).map! do |i| i.to_sym end end |
#start_with?(*prefix) ⇒ Boolean
74 75 76 77 |
# File 'lib/hash-utils/symbol.rb', line 74 def start_with?(*prefix) prefix.map! { |i| i.to_s } self.to_s.start_with?(*prefix) end |
#strip ⇒ Object
150 151 152 |
# File 'lib/hash-utils/symbol.rb', line 150 def strip self.to_s.strip!.to_sym end |