class M2H::Base

Attributes

cover[R]
files[R]
header[R]
serif[R]
sys_enc[R]
toc[R]

Public Class Methods

new(argv, option) click to toggle source
# File lib/m2h/base.rb, line 5
def initialize(argv, option)
  @errors  = []
  @files   = path_inspect(argv)
  @sys_enc = Encoding.locale_charmap
  @serif   = option[:serif] ? true : false
  @header  = option[:header] ? true : false
  @cover   = option[:cover] ? true : false
  @toc     = option[:toc] ? true : false
  if @errors.empty?
    return self
  else
    @errors.each do |e|
      puts e
    end
    exit 3
  end
end

Public Instance Methods

path_inspect(files) click to toggle source
# File lib/m2h/base.rb, line 23
def path_inspect(files)
  is_valid = true
  expanded_paths = []
  files.each { |f|
    unless File.exists?(File.expand_path(f))
      is_valid = false
      @errors.push("PathError: Could not found #{f}")
    else
      expanded_paths.push(File.expand_path(f))
    end
  }
  return expanded_paths
end