Class: Wikiloc::Interactor
- Inherits:
-
Object
- Object
- Wikiloc::Interactor
- Defined in:
- lib/wikiloc/interactor.rb
Instance Method Summary collapse
- #get_data_type ⇒ Object
- #get_info ⇒ Object
- #get_location ⇒ Object
-
#initialize(output) ⇒ Interactor
constructor
A new instance of Interactor.
- #set_data_type(data_type) ⇒ Object
- #set_location(location) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(output) ⇒ Interactor
Returns a new instance of Interactor.
3 4 5 6 7 |
# File 'lib/wikiloc/interactor.rb', line 3 def initialize(output) @output = output @location = "Israel" #default location @data_type = "Capital" #default data type end |
Instance Method Details
#get_data_type ⇒ Object
21 22 23 |
# File 'lib/wikiloc/interactor.rb', line 21 def get_data_type @data_type end |
#get_info ⇒ Object
41 42 43 44 |
# File 'lib/wikiloc/interactor.rb', line 41 def get_info info_getter = InfoGetter.new(@location, @data_type) info_getter.get_info end |
#get_location ⇒ Object
17 18 19 |
# File 'lib/wikiloc/interactor.rb', line 17 def get_location @location end |
#set_data_type(data_type) ⇒ Object
13 14 15 |
# File 'lib/wikiloc/interactor.rb', line 13 def set_data_type(data_type) @data_type = data_type end |
#set_location(location) ⇒ Object
9 10 11 |
# File 'lib/wikiloc/interactor.rb', line 9 def set_location(location) @location = location end |
#start ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/wikiloc/interactor.rb', line 25 def start @output.puts 'Welcome to Wikiloc!' @output.puts 'Enter location:' location = gets.chomp set_location(location) @output.puts 'What do you want to know?' data_type = gets.chomp set_data_type(data_type) info = get_info if info != :invalid @output.puts "The #{@data_type} of #{@location} is: #{info}" else @output.puts "Invalid Query. Please try again." end end |