Class: GetaroundUtils::Utils::HealthCheckFile

Inherits:
Object
  • Object
show all
Defined in:
lib/getaround_utils/utils/health_check_file.rb

Constant Summary collapse

FILE_NAME =
'health_check_file'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ HealthCheckFile

Returns a new instance of HealthCheckFile.

Raises:

  • (ArgumentError)


15
16
17
18
19
20
# File 'lib/getaround_utils/utils/health_check_file.rb', line 15

def initialize(name)
  raise ArgumentError, "Expected name as String, got: #{name.inspect}" if !name.is_a?(String) || name.empty?

  @base_path = root_path.join('tmp', name)
  @path = @base_path.join(FILE_NAME)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



13
14
15
# File 'lib/getaround_utils/utils/health_check_file.rb', line 13

def path
  @path
end

Instance Method Details

#createObject



22
23
24
25
# File 'lib/getaround_utils/utils/health_check_file.rb', line 22

def create
  FileUtils.mkdir_p(@base_path)
  FileUtils.touch(@path)
end

#deleteObject



27
28
29
# File 'lib/getaround_utils/utils/health_check_file.rb', line 27

def delete
  FileUtils.rm_f(@path)
end

#exists?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/getaround_utils/utils/health_check_file.rb', line 31

def exists?
  File.exist?(@path)
end