Module: Velibe

Defined in:
lib/velibe/db/models.rb,
lib/velibe.rb,
lib/velibe/config.rb,
lib/velibe/version.rb,
lib/velibe/api_velib.rb,
lib/velibe/db/database.rb,
lib/velibe/db/kv_store.rb,
lib/velibe/station_status.rb

Overview

Données persistantes

Defined Under Namespace

Modules: Config, Database, KvStore Classes: ApiVelib, Station, StationStatus, Status

Constant Summary collapse

Favorites =
tmp_fav.nil? ? [10035, 19003, 19004, 10031] : tmp_fav
VERSION =
'0.2.3'

Class Method Summary collapse

Class Method Details

.add_favorite(stations) ⇒ Object



52
53
54
# File 'lib/velibe.rb', line 52

def self.add_favorite(stations)
  KvStore.add_favorite_station *stations
end


37
38
39
40
41
42
43
44
# File 'lib/velibe.rb', line 37

def self.print_favorites
  if Favorites.empty?
    puts 'No favorites so far, you can add some with `velibe favorite add <your> <number>`.'
  else
    puts "Favorites Stations: #{Favorites.join(', ')}"
  # TODO: print details with db
  end
end


22
23
24
25
26
# File 'lib/velibe.rb', line 22

def self.print_stations(stations)
  stations = Favorites if stations.empty? or !stations
  puts "Velibe >> Stations #{stations.join(', ')}:"
  stations.each { |station| puts "        > #{ApiVelib.get_station(station)}" }
end


28
29
30
31
32
# File 'lib/velibe.rb', line 28

def self.print_stations_bis(stations)
  stations = Favorites if stations.empty? or !stations
  puts "Velibe >> Stations #{stations.join(', ')}:"
  ApiVelib.get_stations(stations) { |station| StationStatus.print_from_json(station, '        > ') }
end

.reset_favorites(force = false) ⇒ Object

FIXME: text display from there



47
48
49
50
# File 'lib/velibe.rb', line 47

def self.reset_favorites(force = false)
  KvStore.reset_favorite_stations if force or KvStore.favorite_stations.empty?
  # FIXME: ensure backup!! [store in history array]
end

.setup_station_database(force = false) ⇒ Object



56
57
58
# File 'lib/velibe.rb', line 56

def self.setup_station_database(force = false)
  Database.create if not Database.exist? or force
end