Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/react_native_util/core_ext/string.rb
Instance Method Summary collapse
-
#is_mp4? ⇒ Boolean
Determine whether the path represented by the receiver is an MP4 video, whether or not it exists.
-
#obfuscate ⇒ String
Get an obfuscated copy of the string.
-
#obfuscate! ⇒ Object
Obfuscates the receiver by first replacing all instances of the HOME environment variable with ‘~’ and then all instances of USER with ‘$USER’.
-
#video_type ⇒ Symbol
Returns the video type for the path represented by the receiver, whether or not the file exists.
Instance Method Details
#is_mp4? ⇒ Boolean
Determine whether the path represented by the receiver is an MP4 video, whether or not it exists.
28 29 30 |
# File 'lib/react_native_util/core_ext/string.rb', line 28 def is_mp4? video_type == :mp4 end |
#obfuscate ⇒ String
Get an obfuscated copy of the string.
6 7 8 9 10 |
# File 'lib/react_native_util/core_ext/string.rb', line 6 def obfuscate string = clone string.obfuscate! string end |
#obfuscate! ⇒ Object
Obfuscates the receiver by first replacing all instances of the HOME environment variable with ‘~’ and then all instances of USER with ‘$USER’.
18 19 20 21 22 |
# File 'lib/react_native_util/core_ext/string.rb', line 18 def obfuscate! gsub!(/#{Regexp.quote ENV['HOME']}/, '~') gsub!(/#{Regexp.quote ENV['USER']}/, '$USER') nil end |
#video_type ⇒ Symbol
Returns the video type for the path represented by the receiver, whether or not the file exists. This is just the file extension as a lowercase symbol, e.g. :mp4, :mov, :avi, etc.
38 39 40 41 |
# File 'lib/react_native_util/core_ext/string.rb', line 38 def video_type # Just file extension as a symbol File.extname(self).sub(/^\./, '').downcase.to_sym end |