Class: PointInTime

Inherits:
Object
  • Object
show all
Defined in:
lib/ip-world-map/point_in_time.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y, initial_opacity, lifetime) ⇒ PointInTime

Returns a new instance of PointInTime.



4
5
6
7
8
# File 'lib/ip-world-map/point_in_time.rb', line 4

def initialize x, y, initial_opacity, lifetime
  @x, @y = x, y
  @time = 0
  @decay = Decay.new(initial_opacity, lifetime)
end

Instance Attribute Details

#xObject (readonly)

Returns the value of attribute x.



2
3
4
# File 'lib/ip-world-map/point_in_time.rb', line 2

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



2
3
4
# File 'lib/ip-world-map/point_in_time.rb', line 2

def y
  @y
end

Instance Method Details

#ageObject



19
20
21
# File 'lib/ip-world-map/point_in_time.rb', line 19

def age
  @time += 1
end

#opacityObject



15
16
17
# File 'lib/ip-world-map/point_in_time.rb', line 15

def opacity
  @decay.value(@time)
end

#opacity_in_time(time) ⇒ Object



10
11
12
13
# File 'lib/ip-world-map/point_in_time.rb', line 10

def opacity_in_time time
  @time = time if time
  opacity
end