Class: Gares::Search

Inherits:
StationList show all
Defined in:
lib/gares/search.rb

Overview

Search Gares-en-mouvement for a station name

Constant Summary collapse

GARES_LIST_URL =

This is a file containing minimal information (name and slug) of all stations of gares-en-mouvement.com

"https://www.kimonolabs.com/api/7jys32dy?apikey=lsOO4tNm78cH9JxqWg9gAk9l4nYaou9j&kimmodify=1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query) ⇒ Search

Initialize a new Station search with the specified query

search = Gares::Search.new("Aix")

Gares::Search is lazy loaded, meaning that unless you access the stations attribute, no remomte query is made.


16
17
18
# File 'lib/gares/search.rb', line 16

def initialize(query)
  @query = query
end

Instance Attribute Details

#queryObject (readonly)

Returns the value of attribute query


4
5
6
# File 'lib/gares/search.rb', line 4

def query
  @query
end

Instance Method Details

#stationsObject

Returns an array of Gares::Station objects in order to easily search result yielded. If the query was an exact match, a single element array will be returned.


22
23
24
# File 'lib/gares/search.rb', line 22

def stations
  @stations ||= (exact_match? ? parse_station : parse_stations)
end