Class: HammerCLI::Options::Normalizers::File

Inherits:
AbstractNormalizer show all
Defined in:
lib/hammer_cli/options/normalizers.rb

Direct Known Subclasses

JSONInput

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractNormalizer

#completion_type, #description, inherited

Class Method Details

.common_descriptionObject



267
268
269
# File 'lib/hammer_cli/options/normalizers.rb', line 267

def common_description
  _('Path to a file')
end

.completion_typeObject



263
264
265
# File 'lib/hammer_cli/options/normalizers.rb', line 263

def completion_type
  :file
end

Instance Method Details

#complete(value) ⇒ Object



276
277
278
279
280
281
282
283
284
# File 'lib/hammer_cli/options/normalizers.rb', line 276

def complete(value)
  Dir[value.to_s+'*'].collect do |file|
    if ::File.directory?(file)
      file+'/'
    else
      file+' '
    end
  end
end

#format(path) ⇒ Object



272
273
274
# File 'lib/hammer_cli/options/normalizers.rb', line 272

def format(path)
  ::File.read(::File.expand_path(path))
end