Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/react_native_util/core_ext/string.rb

Instance Method Summary collapse

Instance Method Details

#is_mp4?Boolean

Determine whether the path represented by the receiver is an MP4 video, whether or not it exists.

Returns:

  • (Boolean)

    true If the file extension is .mp4, false Otherwise



28
29
30
# File 'lib/react_native_util/core_ext/string.rb', line 28

def is_mp4?
  video_type == :mp4
end

#obfuscateString

Get an obfuscated copy of the string.

Returns:

  • (String)

    An obfuscated copy of self

See Also:



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’.

Returns:

  • nil

See Also:



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_typeSymbol

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.

Returns:

  • (Symbol)

    The file extension as a lowercase symbol



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