Class: SwitchFile::Project

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

Defined Under Namespace

Classes: NoMatchingFileTypeForShortcut

Instance Method Summary collapse

Instance Method Details

#config_pathObject



5
6
7
# File 'lib/switch_file/project.rb', line 5

def config_path
  "#{path}/.switch_file"
end

#file_type_attributesObject



9
10
11
# File 'lib/switch_file/project.rb', line 9

def file_type_attributes
  eval(Pow(config_path).read)
end

#file_type_with_shortcut!(shortcut) ⇒ Object



13
14
15
16
17
# File 'lib/switch_file/project.rb', line 13

def file_type_with_shortcut!(shortcut)
  file_types.detect{|file_type| shortcut.to_s == file_type.shortcut.to_s}.tap do |result|
    raise NoMatchingFileTypeForShortcut.new(shortcut.to_s) if result.nil?
  end
end

#file_typesObject



19
20
21
# File 'lib/switch_file/project.rb', line 19

def file_types
  @file_types ||= file_type_attributes.map{|attributes| FileType.new(attributes) }
end