Class: LinhaStrans
- Inherits:
-
Object
- Object
- LinhaStrans
- Defined in:
- lib/linha.rb
Instance Attribute Summary collapse
-
#circular ⇒ Object
Returns the value of attribute circular.
-
#codigoLinha ⇒ Object
Returns the value of attribute codigoLinha.
-
#denominacao ⇒ Object
Returns the value of attribute denominacao.
-
#origem ⇒ Object
Returns the value of attribute origem.
-
#paradas ⇒ Object
Returns the value of attribute paradas.
-
#retorno ⇒ Object
Returns the value of attribute retorno.
-
#veiculos ⇒ Object
Returns the value of attribute veiculos.
Instance Method Summary collapse
-
#initialize(fields) ⇒ LinhaStrans
constructor
A new instance of LinhaStrans.
- #load_objs(objs, k) ⇒ Object
- #to_json(*a) ⇒ Object
Constructor Details
#initialize(fields) ⇒ LinhaStrans
Returns a new instance of LinhaStrans.
9 10 11 12 13 14 15 16 17 |
# File 'lib/linha.rb', line 9 def initialize(fields) @codigoLinha = fields['CodigoLinha'] || fields[:codigoLinha] @denominacao = fields['Denomicao'] || fields[:denomicao] @origem = fields['Origem'] || fields[:origem] @retorno = fields['Retorno'] || fields[:retorno] @circular = fields['Circular'] || fields[:circular] @veiculos = load_objs(fields['Veiculos'], VeiculoStrans) @paradas = load_objs(fields['Paradas'], ParadaStrans) end |
Instance Attribute Details
#circular ⇒ Object
Returns the value of attribute circular.
6 7 8 |
# File 'lib/linha.rb', line 6 def circular @circular end |
#codigoLinha ⇒ Object
Returns the value of attribute codigoLinha.
6 7 8 |
# File 'lib/linha.rb', line 6 def codigoLinha @codigoLinha end |
#denominacao ⇒ Object
Returns the value of attribute denominacao.
6 7 8 |
# File 'lib/linha.rb', line 6 def denominacao @denominacao end |
#origem ⇒ Object
Returns the value of attribute origem.
6 7 8 |
# File 'lib/linha.rb', line 6 def origem @origem end |
#paradas ⇒ Object
Returns the value of attribute paradas.
6 7 8 |
# File 'lib/linha.rb', line 6 def paradas @paradas end |
#retorno ⇒ Object
Returns the value of attribute retorno.
6 7 8 |
# File 'lib/linha.rb', line 6 def retorno @retorno end |
#veiculos ⇒ Object
Returns the value of attribute veiculos.
6 7 8 |
# File 'lib/linha.rb', line 6 def veiculos @veiculos end |
Instance Method Details
#load_objs(objs, k) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/linha.rb', line 19 def load_objs(objs, k) if objs.is_a?(Array) map = objs.map do |o| o = k.new(o) o.linha = self o end end map end |
#to_json(*a) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/linha.rb', line 30 def to_json(*a) serialized = {} serialized[:codigoLinha] = @codigo if @codigo serialized[:denominacao] = @denominacao if @denominacao serialized[:origem] = @origem if @denominacao serialized[:retorno] = @retorno if @retorno serialized[:Circular] = @circular if @circular serialized[:veiculos] = @veiculos if @veiculos serialized[:paradas] = @paradas if @paradas serialized.to_json *a end |