Class: NewsFetcher::Command

Inherits:
Simple::CommandParser::Command
  • Object
show all
Defined in:
lib/newsfetcher/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dirObject

Returns the value of attribute dir.



5
6
7
# File 'lib/newsfetcher/command.rb', line 5

def dir
  @dir
end

#log_levelObject

Returns the value of attribute log_level.



6
7
8
# File 'lib/newsfetcher/command.rb', line 6

def log_level
  @log_level
end

#max_threadsObject

Returns the value of attribute max_threads.



7
8
9
# File 'lib/newsfetcher/command.rb', line 7

def max_threads
  @max_threads
end

Instance Method Details

#run(args) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/newsfetcher/command.rb', line 9

def run(args)
  dir = Path.new(@dir || DefaultProfileDir)
  config_file = dir / ConfigFileName
  config = config_file.exist? ? BaseConfig.load(config_file) : BaseConfig.make
  config.log_level = @log_level.downcase.to_sym if @log_level
  config.max_threads = @max_threads&.to_i if @max_threads
  @profile = Profile.new(dir: dir, config: config) or raise Error, "Profile not loaded"
end