Class: Svgeez::Destination

Inherits:
Object
  • Object
show all
Defined in:
lib/svgeez/destination.rb

Constant Summary collapse

DEFAULT_DESTINATION_FILE_NAME =
'svgeez.svg'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Destination

Returns a new instance of Destination.



5
6
7
# File 'lib/svgeez/destination.rb', line 5

def initialize(options = {})
  @destination = File.expand_path(options.fetch('destination', "./#{DEFAULT_DESTINATION_FILE_NAME}"))
end

Instance Method Details

#file_idObject



9
10
11
# File 'lib/svgeez/destination.rb', line 9

def file_id
  @file_id ||= File.basename(file_name, '.svg').tr(' ', '-')
end

#file_nameObject



13
14
15
16
17
18
19
20
# File 'lib/svgeez/destination.rb', line 13

def file_name
  @file_name ||=
    if @destination.end_with?('.svg')
      File.split(@destination)[1]
    else
      DEFAULT_DESTINATION_FILE_NAME
    end
end

#file_pathObject



22
23
24
# File 'lib/svgeez/destination.rb', line 22

def file_path
  @file_path ||= File.join(folder_path, file_name)
end

#folder_pathObject



26
27
28
29
30
31
32
33
# File 'lib/svgeez/destination.rb', line 26

def folder_path
  @folder_path ||=
    if @destination.end_with?('.svg')
      File.split(@destination)[0]
    else
      @destination
    end
end