Class: HMap::Command::Reader

Inherits:
HMap::Command show all
Defined in:
lib/hmap/command/hmap_reader.rb

Overview

hmap file reader cmd

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Reader

Returns a new instance of Reader.

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
# File 'lib/hmap/command/hmap_reader.rb', line 18

def initialize(argv)
  super
  mapfile_path = argv.option('hmap-path')
  raise ArgumentError, "#{mapfile_path}: no such file!" if mapfile_path.nil? || !File.exist?(mapfile_path)

  @mapfile_path = Pathname.new(mapfile_path).expand_path 
end

Class Method Details

.optionsObject



32
33
34
35
36
# File 'lib/hmap/command/hmap_reader.rb', line 32

def self.options
  [
    ['--hmap-path=/hmap/dir/file', 'The path of the hmap file']
  ].concat(super)
end

Instance Method Details

#runObject



38
39
40
41
42
# File 'lib/hmap/command/hmap_reader.rb', line 38

def run
  UserInterface.puts "\n[hmapfile] Reader start..............\n".yellow
  HMap::MapFileReader.new(@mapfile_path)
  UserInterface.puts "\n[hmapfile] Reader finish..............\n".yellow
end

#validate!Object



26
27
28
29
30
# File 'lib/hmap/command/hmap_reader.rb', line 26

def validate!
  super
  # banner! if help?
  raise '[ERROR]: --hmap-path no set'.red unless File.exist?(@mapfile_path)
end