Class: Alfi::Providers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/alfi/providers/base.rb

Direct Known Subclasses

Bintray, Maven, Offline

Instance Method Summary collapse

Constructor Details

#initialize(query, search_type) ⇒ Base

Returns a new instance of Base.



2
3
4
5
6
7
8
9
10
# File 'lib/alfi/providers/base.rb', line 2

def initialize(query, search_type)
  @query = query
  @uri = URI.parse(query_url(query))
  @http = Net::HTTP.new(@uri.host, @uri.port)
  @request = Net::HTTP::Get.new(@uri.request_uri)
  @search_type = search_type
  @quote_symbol = $single_quotes ? "'" : "\""
  request_extensions if self.class.method_defined?(:request_extensions)
end

Instance Method Details

#add_repo_to_list(package) ⇒ Object



28
29
30
# File 'lib/alfi/providers/base.rb', line 28

def add_repo_to_list(package)
  $result_list << "  #{$prefix} #{@quote_symbol}#{package}#{@quote_symbol}".green
end

#add_suggestions(suggestions) ⇒ Object



24
25
26
# File 'lib/alfi/providers/base.rb', line 24

def add_suggestions(suggestions)
  $suggestions += Array(suggestions)
end

#add_to_list(helper_string) ⇒ Object



20
21
22
# File 'lib/alfi/providers/base.rb', line 20

def add_to_list(helper_string)
  $result_list << helper_string
end

#callObject



16
17
18
# File 'lib/alfi/providers/base.rb', line 16

def call
  fail NotImplementedError
end

#query_urlObject



12
13
14
# File 'lib/alfi/providers/base.rb', line 12

def query_url
  fail NotImplementedError
end