class Response

Public Class Methods

new(resp) click to toggle source
# File lib/response.rb, line 6
def initialize(resp)
  @resp = resp
end

Public Instance Methods

linhas() click to toggle source
# File lib/response.rb, line 32
def linhas
  @resp.map{ |l| LinhaStrans.new(l) }
end
model(path) click to toggle source
# File lib/response.rb, line 10
def model(path)
  @resp = JSON.parse(@resp.body)
  case path
  when :signin
    token
  when :linhas
    linhas
  when :veiculos
    veiculos
  when :veiculos_linha
    veiculos_linha
  when :paradas
    paradas
  when :paradas_linha
    paradas_linha
  end
end
paradas() click to toggle source
# File lib/response.rb, line 49
def paradas
  @resp.map{|p| ParadaStrans.new(p) }
end
paradas_linha() click to toggle source
# File lib/response.rb, line 53
def paradas_linha
  @resp['Paradas'].map{|p| ParadaStrans.new(p) }
end
token() click to toggle source
# File lib/response.rb, line 28
def token
  @resp
end
veiculos() click to toggle source
# File lib/response.rb, line 36
def veiculos
  v = @resp.map do |node|
    linha = LinhaStrans.new(node['Linha'])
    linha.veiculos
  end
  v.reduce(:concat)
end
veiculos_linha() click to toggle source
# File lib/response.rb, line 44
def veiculos_linha
  linha = LinhaStrans.new(@resp['Linha'])
  linha.veiculos
end