Class: UserAgentGenerator::Application

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Application

Returns a new instance of Application.



4
5
6
7
8
9
10
# File 'lib/User_Agent_Generator/application.rb', line 4

def initialize(argv)
  @options = parse_options(argv)

  @display = UserAgentGenerator::Display.new(@options)
  @logic   = UserAgentGenerator::Logic.new(@options)
  @output  = UserAgentGenerator::Output.new(@options)
end

Instance Method Details

#parse_options(argv) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/User_Agent_Generator/application.rb', line 17

def parse_options(argv)
  options = {}

  opt_parser = OptionParser.new do |opt|
    opt.banner = 'Usage: user_agent_generater [OPTIONS]'
    opt.separator ''
    opt.separator 'Options'

    opt.on('-w', '--windows', 'Use Windows OS') do
      options[:windows] = true
    end

    opt.on('-a', '--android', 'Use Android Mobile OS') do
      options[:android] = true
    end

    opt.on('-i', '--iOS', 'Use iOS Mobile OS') do
      options[:iOS] = true
    end

    opt.on('-c', '--chrome', 'Use Chrome browser') do
      options[:chrome] = true
    end

    opt.on('-f', '--firefox', 'Use Firefox browser') do
      options[:firefox] = true
    end

    opt.on('-s', '--safari', 'Use Safari browser Note: mobile only') do
      options[:safari] = true
    end

    opt.on('-v', '--version VERSION', 'Version number, REQUIRED') do |v|
      options[:version] = v
    end

    opt.on_tail('-h', '--help', 'Print this help!') do
      puts opt_parser
      exit
    end
  end

  opt_parser.parse!(argv)

  options
end

#runObject



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

def run
  agent_strings = @logic.run
  @display.render(@output.to_file(agent_strings))
end