Class: FluidCLI::Theme::Syncer::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/fluid_cli/theme/syncer/operation.rb

Constant Summary collapse

COLOR_BY_STATUS =
{
  error: :red,
  synced: :green,
  warning: :yellow,
  fixed: :cyan,
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ctx, method, file, options = {}) ⇒ Operation

Returns a new instance of Operation.



16
17
18
19
20
21
# File 'lib/fluid_cli/theme/syncer/operation.rb', line 16

def initialize(ctx, method, file, options = {})
  @ctx = ctx
  @method = method
  @file = file
  @options = options
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



7
8
9
# File 'lib/fluid_cli/theme/syncer/operation.rb', line 7

def file
  @file
end

#methodObject

Returns the value of attribute method.



7
8
9
# File 'lib/fluid_cli/theme/syncer/operation.rb', line 7

def method
  @method
end

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/fluid_cli/theme/syncer/operation.rb', line 7

def options
  @options
end

Instance Method Details

#as_error_messageObject



27
28
29
# File 'lib/fluid_cli/theme/syncer/operation.rb', line 27

def as_error_message
  as_message_with(status: :error)
end

#as_fix_messageObject



35
36
37
# File 'lib/fluid_cli/theme/syncer/operation.rb', line 35

def as_fix_message
  as_message_with(status: :fixed)
end

#as_synced_message(color: :green) ⇒ Object



31
32
33
# File 'lib/fluid_cli/theme/syncer/operation.rb', line 31

def as_synced_message(color: :green)
  as_message_with(status: :synced, color: color)
end

#file_pathObject



39
40
41
# File 'lib/fluid_cli/theme/syncer/operation.rb', line 39

def file_path
  file&.relative_path
end

#to_sObject



23
24
25
# File 'lib/fluid_cli/theme/syncer/operation.rb', line 23

def to_s
  "#{method} #{file_path}"
end