Class: CfSim::Portal

Inherits:
Object
  • Object
show all
Defined in:
lib/cf_sim/portal.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, latitude, longitude) ⇒ Portal

Returns a new instance of Portal.



4
5
6
7
8
# File 'lib/cf_sim/portal.rb', line 4

def initialize(name, latitude, longitude)
  @name = name
  @latitude = latitude
  @longitude = longitude
end

Instance Attribute Details

#latitudeObject (readonly)

Returns the value of attribute latitude.



2
3
4
# File 'lib/cf_sim/portal.rb', line 2

def latitude
  @latitude
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



2
3
4
# File 'lib/cf_sim/portal.rb', line 2

def longitude
  @longitude
end

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/cf_sim/portal.rb', line 2

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



10
11
12
# File 'lib/cf_sim/portal.rb', line 10

def ==(other)
  eql?(other)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/cf_sim/portal.rb', line 14

def eql?(other)
  @name == other.name && @latitude == other.latitude && @longitude == other.longitude
end

#hashObject



18
19
20
# File 'lib/cf_sim/portal.rb', line 18

def hash
  @name.hash + @latitude + @longitude
end

#to_sObject



22
23
24
# File 'lib/cf_sim/portal.rb', line 22

def to_s
  "#{name}(#{latitude}, #{longitude})"
end