Class: App

Inherits:
Object
  • Object
show all
Defined in:
bin/barometer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arguments, stdin) ⇒ App

Returns a new instance of App.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'bin/barometer', line 62

def initialize(arguments, stdin)
  @arguments = arguments.dup
  
  # Set defaults
  @options = OpenStruct.new
  @options.timeout = 15
  @options.geocode = false
  @options.timezone = false
  @options.metric = true
  @options.sources = []
  @options.verbode = false
  @options.at = nil
  @options.default = true
  
  # thresholds
  @options.windy_m = 10
  @options.windy_i = 7
  @options.pop = 50
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



60
61
62
# File 'bin/barometer', line 60

def options
  @options
end

Instance Method Details

#runObject

Parse options, check arguments, then process the command



83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'bin/barometer', line 83

def run
  if parsed_options? && arguments_valid? 
    puts "Start at #{DateTime.now}\n\n" if @options.verbose
    output_options if @options.verbose # [Optional]
          
    process_arguments            
    process_command
    
    puts "\nFinished at #{DateTime.now}" if @options.verbose
  else
    output_usage
  end
end