Class: Pincerna::Map

Inherits:
Base
  • Object
show all
Defined in:
lib/pincerna/map.rb

Overview

Shows addresses or coordinates on Google Maps.

Constant Summary

ICON =

The icon to show for each feedback item.

Pincerna::Base::ROOT + "/images/map.png"

Constants inherited from Base

Base::CACHE_ROOT, Base::FULL_NAME, Base::MATCHER, Base::RELEVANT_MATCHES, Base::ROOT, Base::TYPES, Base::WORKFLOW_ROOT

Instance Attribute Summary

Attributes inherited from Base

#format, #format_content_type, #output

Instance Method Summary (collapse)

Methods inherited from Base

#add_feedback_item, execute!, #filter, #format_float, #initialize, #output_feedback, #round_float

Constructor Details

This class inherits a constructor from Pincerna::Base

Instance Method Details

- (Array) perform_filtering(query)

Filters a query.

Parameters:

  • query (String)

    An address to show on Google Maps.

Returns:

  • (Array)

    A list of items to process.



17
18
19
# File 'lib/pincerna/map.rb', line 17

def perform_filtering(query)
  {query: query}
end

- (Array) process_results(results)

Processes items to obtain feedback items.

Parameters:

  • results (Array)

    The items to process.

Returns:

  • (Array)

    The feedback items.



25
26
27
28
# File 'lib/pincerna/map.rb', line 25

def process_results(results)
  type = results[:query] =~ /((-?)\d+(\.\d+)?)\s*,\s*((-?)\d+(\.\d+)?)/ ? "coordinates" : "location"
  [{title: "View #{type} on Google Maps", arg: CGI.escape(results[:query]), subtitle: "Action this item to open Google Maps in the browser.", icon: ICON}]
end