Sha256: 065fabec834f4508b488db9da69f58888cf562fadca7dd86e9f6b267c8413a7f

Contents?: true

Size: 955 Bytes

Versions: 5

Compression:

Stored size: 955 Bytes

Contents

# -*- coding: utf-8 -*-
require 'active_record'

# Données persistantes
module Velibe
  class Station < ActiveRecord::Base
    has_many :status

    def self.find_by_number(number)
      self.find_by number: number
    end
    # §todo: get status

  end

  class Status < ActiveRecord::Base
    belongs_to :station

    def self.create_from_json(json)
      # maybe pass by the station?
      status = self.create({status: json[:status], #§todo
                            available_bikes: json[:available_bikes],
                            available_bike_stands: json[:available_bike_stands],
                            bike_stands: json[:bike_stands],
                            last_update: json[:last_update]}) #§see: convert
      # TODO: voir si objet de base marche

      status.station = Station.find_by_number(json[:number])

    end
    # §maybe: delegate?

  end

  # > §later:favorite station: or store
  # nick name, and so on

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
velibe-0.2.3 lib/velibe/db/models.rb
velibe-0.2.2 lib/velibe/db/models.rb
velibe-0.2.1 lib/velibe/db/models.rb
velibe-0.2.0 lib/velibe/db/models.rb
velibe-0.1.1 lib/velibe/db/models.rb