class MdlSearch::Searcher

Constants

MDL_API_FOR_ALL_ICONS_INFO_SUFFIX
MDL_API_SUFFIX
MDL_BASE

Attributes

agent[RW]
result[RW]

Public Class Methods

new() click to toggle source
# File lib/mdl_search/searcher.rb, line 10
def initialize
  @agent = create_agent
  @result = all_icons_info_json
end

Public Instance Methods

groups_as_yaml() click to toggle source
# File lib/mdl_search/searcher.rb, line 19
def groups_as_yaml
  show_as_yaml groups
end
icons_as_yaml() click to toggle source
# File lib/mdl_search/searcher.rb, line 15
def icons_as_yaml
  show_as_yaml icons
end

Private Instance Methods

all_icons_info_json() click to toggle source
# File lib/mdl_search/searcher.rb, line 49
def all_icons_info_json
  res = @agent.get all_icons_info_path
  json_raw = res.read_body
  JSON.parse json_raw
end
all_icons_info_path() click to toggle source
# File lib/mdl_search/searcher.rb, line 55
def all_icons_info_path
  "#{MDL_API_SUFFIX}#{MDL_API_FOR_ALL_ICONS_INFO_SUFFIX}"
end
create_agent() click to toggle source
# File lib/mdl_search/searcher.rb, line 42
def create_agent
  url = URI.parse MDL_BASE
  agent = Net::HTTP.new url.host, url.port
  agent.use_ssl = true
  agent
end
data() click to toggle source
# File lib/mdl_search/searcher.rb, line 25
def data
  pp @result
end
groups() click to toggle source
# File lib/mdl_search/searcher.rb, line 34
def groups
  @result['groups']
end
icons() click to toggle source
# File lib/mdl_search/searcher.rb, line 30
def icons
  @result['icons']
end
show_as_yaml(data) click to toggle source
# File lib/mdl_search/searcher.rb, line 38
def show_as_yaml data
  YAML.dump(data)
end