Class: Texico::Template::FileStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/texico/template/file_status.rb

Overview

FileStatus

The FileStatus object represents the result of a copy command on a template file. This class should never be used directly.

Constant Summary collapse

STATUS =
i[successful target_exist replaced_target].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, status = STATUS[0]) ⇒ FileStatus

Returns a new instance of FileStatus.



12
13
14
15
16
17
18
19
20
21
# File 'lib/texico/template/file_status.rb', line 12

def initialize(file, status = STATUS[0])
  unless STATUS.include?(status) || status.is_a?(Exception)
    raise ArgumentError, 'Unknown status'
  end

  @status    = status
  @file      = file

  freeze
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



10
11
12
# File 'lib/texico/template/file_status.rb', line 10

def file
  @file
end

Instance Method Details

#statusObject



27
28
29
# File 'lib/texico/template/file_status.rb', line 27

def status
  @status.is_a?(Exception) ? :template_error : @status
end

#to_sObject



23
24
25
# File 'lib/texico/template/file_status.rb', line 23

def to_s
  "#{file.basename} [#{status}]"
end