Class: Alx::Viewer

Inherits:
Object
  • Object
show all
Includes:
Executer
Defined in:
lib/alx/viewer.rb

Instance Method Summary collapse

Methods included from Executer

#start

Constructor Details

#initialize(conf) ⇒ Viewer

Returns a new instance of Viewer.



6
7
8
# File 'lib/alx/viewer.rb', line 6

def initialize( conf )
  @conf = conf
end

Instance Method Details

#view(file_name) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/alx/viewer.rb', line 10

def view( file_name )
  if @conf[ :stdout ]
    File.open( file_name ) do | file |
      while line = file.gets
        $stdout.puts line
      end
    end

    return true
  end

  if @conf[ :html ]
    start( @conf[ :html_viewer ] + " " + file_name )
    return true
  end

  start( @conf[ :terminal_viewer ] + " " + file_name )
end