Check out example codes for "ruby filename from path". It will help you in understanding the concepts better.

Code Example 1

path = "/path/to/file.ext"

File.basename(path) # 'file.ext'

Learn ReactJs, React Native from akashmittal.com