Class: CoercibleString
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from String
#previous, #previous!, #remove_extended, #remove_extended!, #tap, #to_header, #underscore, #valid_utf8?
Class Method Details
.coerce(string) ⇒ Object
130
131
132
|
# File 'lib/aliyun/oss/extensions.rb', line 130
def coerce(string)
new(string).coerce
end
|
Instance Method Details
135
136
137
138
139
140
141
142
143
144
145
|
# File 'lib/aliyun/oss/extensions.rb', line 135
def coerce
case self
when 'true'; true
when 'false'; false
when /^[1-9]+\d*$/; Integer(self)
when datetime_format; Time.parse(self)
else
self
end
end
|