Class: UserAgentGenerator::Application
- Inherits:
-
Object
- Object
- UserAgentGenerator::Application
- Defined in:
- lib/User_Agent_Generator/application.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(argv) ⇒ Application
constructor
A new instance of Application.
- #parse_options(argv) ⇒ Object
- #run ⇒ Object
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) = (argv) @display = UserAgentGenerator::Display.new() @logic = UserAgentGenerator::Logic.new() @output = UserAgentGenerator::Output.new() 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 (argv) = {} opt_parser = OptionParser.new do |opt| opt. = 'Usage: user_agent_generater [OPTIONS]' opt.separator '' opt.separator 'Options' opt.on('-w', '--windows', 'Use Windows OS') do [:windows] = true end opt.on('-a', '--android', 'Use Android Mobile OS') do [:android] = true end opt.on('-i', '--iOS', 'Use iOS Mobile OS') do [:iOS] = true end opt.on('-c', '--chrome', 'Use Chrome browser') do [:chrome] = true end opt.on('-f', '--firefox', 'Use Firefox browser') do [:firefox] = true end opt.on('-s', '--safari', 'Use Safari browser Note: mobile only') do [:safari] = true end opt.on('-v', '--version VERSION', 'Version number, REQUIRED') do |v| [:version] = v end opt.on_tail('-h', '--help', 'Print this help!') do puts opt_parser exit end end opt_parser.parse!(argv) end |
#run ⇒ Object
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 |