Class: Dovico::ConfigParser

Inherits:
Object
  • Object
show all
Defined in:
lib/dovico/config_parser.rb

Constant Summary collapse

AVAILABLE_ACTIONS =
[:myself, :tasks, :show, :fill, :submit, :clear]
DATE_REQUIRED_ACTIONS =
[:show, :fill, :submit, :clear]

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ ConfigParser

Returns a new instance of ConfigParser.



6
7
8
9
# File 'lib/dovico/config_parser.rb', line 6

def initialize(config)
  @config = config
  @start_date, @end_date = parse_date_options
end

Instance Method Details

#date_optionsObject



23
24
25
# File 'lib/dovico/config_parser.rb', line 23

def date_options
  [start_date, end_date]
end

#needs_help?Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dovico/config_parser.rb', line 11

def needs_help?
  if config[:help]
    true
  elsif AVAILABLE_ACTIONS.map{|action| config[action] }.compact.empty?
    true
  elsif !(@start_date && @end_date) && !DATE_REQUIRED_ACTIONS.map{|action| config[action] }.compact.empty?
    true
  else
    false
  end
end