Class: M2H::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/m2h/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv, option) ⇒ Base

Returns a new instance of Base.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 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

Instance Attribute Details

#coverObject (readonly)

Returns the value of attribute cover.



3
4
5
# File 'lib/m2h/base.rb', line 3

def cover
  @cover
end

#filesObject (readonly)

Returns the value of attribute files.



3
4
5
# File 'lib/m2h/base.rb', line 3

def files
  @files
end

#headerObject (readonly)

Returns the value of attribute header.



3
4
5
# File 'lib/m2h/base.rb', line 3

def header
  @header
end

#serifObject (readonly)

Returns the value of attribute serif.



3
4
5
# File 'lib/m2h/base.rb', line 3

def serif
  @serif
end

#sys_encObject (readonly)

Returns the value of attribute sys_enc.



3
4
5
# File 'lib/m2h/base.rb', line 3

def sys_enc
  @sys_enc
end

#tocObject (readonly)

Returns the value of attribute toc.



3
4
5
# File 'lib/m2h/base.rb', line 3

def toc
  @toc
end

Instance Method Details

#path_inspect(files) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# 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