Class: GHtml2Pdf::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/ghtml2pdf/application.rb

Overview

Main GHtml2Pdf application. Orchestrates the Gtk+ objects needed to load and print a web page to PDF.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Application

Returns a new instance of Application.



12
13
14
15
16
# File 'lib/ghtml2pdf/application.rb', line 12

def initialize(argv)
  argument_parser = ArgumentParser.new(argv)
  @input = argument_parser.input
  @output = argument_parser.output
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



10
11
12
# File 'lib/ghtml2pdf/application.rb', line 10

def input
  @input
end

#outputObject (readonly)

Returns the value of attribute output.



10
11
12
# File 'lib/ghtml2pdf/application.rb', line 10

def output
  @output
end

Instance Method Details

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ghtml2pdf/application.rb', line 18

def run
  web_view.signal_connect 'load-changed' do |_, event, _|
    case event
    when :finished
      print_operation.print
      sleep 2
      Gtk.main_quit
    end
  end

  web_view.load_uri(input_uri)

  Gtk.main

  web_view.destroy
end