Class: CombineHashtags::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/combine_hashtags/cli/cli.rb

Overview

methods for CLI implementation

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



10
11
12
13
14
15
16
17
# File 'lib/combine_hashtags/cli/cli.rb', line 10

def initialize
  @file_path = ENV["FILE_PATH"]
  @profile = CombineHashtags::Profile.new(@file_path)
  fetch_all

  @controller = CombineHashtags::Controller.new(@profile)
  @router = CombineHashtags::Router.new(@controller)
end

Instance Method Details

#fetch_allObject

sets new file_path/name for results of query's “next” pagination, update the profile, rinse repeat



20
21
22
23
24
25
# File 'lib/combine_hashtags/cli/cli.rb', line 20

def fetch_all
  10.times do |i|
    new_path = ENV["FILE_PATH"].gsub("00", "0#{i}")
    @profile.update(new_path)
  end
end

#startObject

start cli



28
29
30
# File 'lib/combine_hashtags/cli/cli.rb', line 28

def start
  @router.run
end