Class: SublimePS::FilesManipulation::Preset

Inherits:
Object
  • Object
show all
Defined in:
lib/sublime_ps/files_manipulation/preset.rb

Constant Summary collapse

@@path_dir =
"#{File.expand_path('~')}/.sublime_ps"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(preset_name) ⇒ Preset

Returns a new instance of Preset.



7
8
9
# File 'lib/sublime_ps/files_manipulation/preset.rb', line 7

def initialize(preset_name)
  @preset_name = preset_name
end

Class Method Details

.file_content(preset_name) ⇒ Object



11
12
13
# File 'lib/sublime_ps/files_manipulation/preset.rb', line 11

def self.file_content(preset_name)
  self.new(preset_name).load_file_content
end

Instance Method Details

#load_file_contentObject



15
16
17
18
19
20
21
22
# File 'lib/sublime_ps/files_manipulation/preset.rb', line 15

def load_file_content
  if File.exists?(preset_path(@preset_name))
    JSON.parse(File.open(preset_path(@preset_name)).read)
  else
    puts "Preset '#{@preset_name}' not find on #{@@path_dir} dir \e[31m[FAIL]\e[0m"
    exit
  end
end