Class: SwitchFile::SourcePath

Inherits:
Valuable
  • Object
show all
Defined in:
lib/switch_file/source_path.rb

Overview

Path to a source file

Instance Method Summary collapse

Instance Method Details

#class_nameObject



6
7
8
# File 'lib/switch_file/source_path.rb', line 6

def class_name
  value.match(file_type.path_regex)[1]
end

#file_typeObject



10
11
12
# File 'lib/switch_file/source_path.rb', line 10

def file_type
  FileType.all.detect{|file_type| value =~ file_type.path_regex }
end

#prompt_messageObject



14
15
16
17
18
19
20
# File 'lib/switch_file/source_path.rb', line 14

def prompt_message
  file_type_options = FileType.all.map{|file_type|
    "[#{file_type.shortcut}] #{file_type.name}: #{file_type.generate_open_command(self)}"
  }

  "Enter the shortcut of the file you want to open:\n\n#{file_type_options.join("\n")}\n\n"
end