Class: CopyTunerIncompatibleSearch::ReplaceCommand::Usage

Inherits:
Object
  • Object
show all
Defined in:
lib/copy_tuner_incompatible_search/replace_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, key:, file:, line:) ⇒ Usage

Returns a new instance of Usage.



87
88
89
90
91
92
# File 'lib/copy_tuner_incompatible_search/replace_command.rb', line 87

def initialize(type:, key:, file:, line:)
  @type = type
  @key = key.to_s
  @file = file.to_s
  @line = line.to_s
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



85
86
87
# File 'lib/copy_tuner_incompatible_search/replace_command.rb', line 85

def file
  @file
end

#keyObject (readonly)

Returns the value of attribute key.



85
86
87
# File 'lib/copy_tuner_incompatible_search/replace_command.rb', line 85

def key
  @key
end

#typeObject (readonly)

Returns the value of attribute type.



85
86
87
# File 'lib/copy_tuner_incompatible_search/replace_command.rb', line 85

def type
  @type
end

Instance Method Details

#dynamic?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/copy_tuner_incompatible_search/replace_command.rb', line 102

def dynamic?
  @type == 'dynamic'
end

#lazy?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/copy_tuner_incompatible_search/replace_command.rb', line 98

def lazy?
  @type == 'lazy'
end

#lazy_keyObject



110
111
112
113
114
115
# File 'lib/copy_tuner_incompatible_search/replace_command.rb', line 110

def lazy_key
  return unless lazy?

  last_key = key.split('.').last
  ".#{last_key}"
end

#lineObject



117
118
119
120
121
# File 'lib/copy_tuner_incompatible_search/replace_command.rb', line 117

def line
  raise 'line is not set' if @line.empty?

  @line.to_i
end

#static?Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/copy_tuner_incompatible_search/replace_command.rb', line 94

def static?
  @type == 'static'
end

#used?Boolean

Returns:

  • (Boolean)


106
107
108
# File 'lib/copy_tuner_incompatible_search/replace_command.rb', line 106

def used?
  !dynamic? && !@file.to_s.strip.empty?
end