Class: Terry::ApiService

Inherits:
Object
  • Object
show all
Defined in:
lib/terry/api_service.rb

Class Method Summary collapse

Class Method Details

.list_allObject



5
6
7
8
# File 'lib/terry/api_service.rb', line 5

def self.list_all
  parsed_aliases = HTTParty.get("http://192.81.217.228/bash_aliases.json")
  bash_aliases = parsed_aliases.map { |ba|  Terry::BashAlias.new(ba)}
end

.search(search_term) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/terry/api_service.rb', line 10

def self.search(search_term)
  parsed_aliases = HTTParty.get("http://192.81.217.228/bash_aliases.json")
  matches = []
  parsed_aliases.each do |a|
    if a["command"].include?(search_term)
      matches << Terry::BashAlias.new(a)
    end
  end
  matches
end