Class: Skanetrafiken::Line

Inherits:
Object
  • Object
show all
Defined in:
lib/skanetrafiken/line.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dic) ⇒ Line

Returns a new instance of Line.



10
11
12
13
14
15
16
17
# File 'lib/skanetrafiken/line.rb', line 10

def initialize dic
  $properties_line.each{ |key,value|
     val = dic[key]
     instance_variable_set("@#{key.to_s}", val)
  }
  #puts @name
  #puts dic.map{ |k,v| "#{k}: #{v}" }.join('; ')
end

Instance Attribute Details

#is_timing_pointObject (readonly)

Returns the value of attribute is_timing_point.



7
8
9
# File 'lib/skanetrafiken/line.rb', line 7

def is_timing_point
  @is_timing_point
end

#journey_date_timeObject (readonly)

Returns the value of attribute journey_date_time.



7
8
9
# File 'lib/skanetrafiken/line.rb', line 7

def journey_date_time
  @journey_date_time
end

#line_type_idObject (readonly)

Returns the value of attribute line_type_id.



7
8
9
# File 'lib/skanetrafiken/line.rb', line 7

def line_type_id
  @line_type_id
end

#line_type_nameObject (readonly)

Returns the value of attribute line_type_name.



7
8
9
# File 'lib/skanetrafiken/line.rb', line 7

def line_type_name
  @line_type_name
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/skanetrafiken/line.rb', line 7

def name
  @name
end

#noObject (readonly)

Returns the value of attribute no.



7
8
9
# File 'lib/skanetrafiken/line.rb', line 7

def no
  @no
end

#stop_pointObject (readonly)

Returns the value of attribute stop_point.



7
8
9
# File 'lib/skanetrafiken/line.rb', line 7

def stop_point
  @stop_point
end

#towardsObject (readonly)

Returns the value of attribute towards.



7
8
9
# File 'lib/skanetrafiken/line.rb', line 7

def towards
  @towards
end

Instance Method Details

#==(another) ⇒ Object

puts @name puts dic.map{ |k,v| “#k: #v” }.join(‘; ’)



18
19
20
21
22
23
# File 'lib/skanetrafiken/line.rb', line 18

def ==(another)
  return $properties_line.map{ |key,value|
    k = "@#{key.to_s}"
    instance_variable_get(k) == another.instance_variable_get(k)
  }.inject(true){ |result, element| result and element}
end

#to_sObject



24
25
26
27
28
29
30
31
# File 'lib/skanetrafiken/line.rb', line 24

def to_s
  a = []
  $properties_line.each{ |key,value|
    val = instance_variable_get("@#{key.to_s}")
    a.push(":#{key.to_s}=> '#{val}'")
  }
  return a.join(", ")
end