Class: MeteoPl::Utility::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/meteo_pl/utility/command.rb

Constant Summary collapse

PERIODS =
{ short: 60, long: 84 }.freeze
DEFAULT_PERIOD =
:short
DEFAULT_TIMEOUT =
2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Command

Returns a new instance of Command.



12
13
14
15
16
17
18
# File 'lib/meteo_pl/utility/command.rb', line 12

def initialize(args)
  @args = args
  @options = {
    timeout: DEFAULT_TIMEOUT,
    period: PERIODS[DEFAULT_PERIOD]
  }
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



10
11
12
# File 'lib/meteo_pl/utility/command.rb', line 10

def location
  @location
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/meteo_pl/utility/command.rb', line 10

def options
  @options
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
# File 'lib/meteo_pl/utility/command.rb', line 20

def call
  parse_input
  set_location
  valid?
ensure
  print_help unless valid?
end