Class: NewsFetcher::Commands::Init

Inherits:
NewsFetcher::Command show all
Defined in:
lib/newsfetcher/commands/init.rb

Instance Attribute Summary collapse

Attributes inherited from NewsFetcher::Command

#dir, #log_level, #max_threads

Instance Method Summary collapse

Instance Attribute Details

#mail_fromObject

Returns the value of attribute mail_from.



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

def mail_from
  @mail_from
end

#mail_toObject

Returns the value of attribute mail_to.



8
9
10
# File 'lib/newsfetcher/commands/init.rb', line 8

def mail_to
  @mail_to
end

Instance Method Details

#run(args) ⇒ Object

Raises:



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/newsfetcher/commands/init.rb', line 10

def run(args)
  super
  raise Error, "Must specify mail_from" unless @mail_from
  raise Error, "Must specify mail_to" unless @mail_to
  @profile = Profile.new(
    dir: @dir,
    config: BaseConfig.make(
      mail_from: @mail_from,
      mail_to: @mail_to,
    ),
  )
  profile.save
end