Class: Airstream::Device

Inherits:
Object
  • Object
show all
Defined in:
lib/airstream/device.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(receiver) ⇒ Device

Returns a new instance of Device


8
9
10
# File 'lib/airstream/device.rb', line 8

def initialize(receiver)
  @receiver = receiver
end

Instance Attribute Details

#playerObject (readonly)

Returns the value of attribute player


6
7
8
# File 'lib/airstream/device.rb', line 6

def player
  @player
end

#video_titleObject (readonly)

Returns the value of attribute video_title


6
7
8
# File 'lib/airstream/device.rb', line 6

def video_title
  @video_title
end

Instance Method Details

#block_while_loadingObject


23
24
25
# File 'lib/airstream/device.rb', line 23

def block_while_loading
  sleep 0.2 until position != 0
end

#durationObject


48
49
50
# File 'lib/airstream/device.rb', line 48

def duration
  self.scrub["duration"]
end

#file=(file) ⇒ Object


12
13
14
15
16
17
18
19
20
21
# File 'lib/airstream/device.rb', line 12

def file=(file)
  if file.class == Video
    self.video = file
  # when
    # TODO Image then self.image = file
  else
    raise "Unknown file type send to device"
  end
  block_while_loading
end

#image=(image_file) ⇒ Object


27
28
29
# File 'lib/airstream/device.rb', line 27

def image=(image_file)
  @receiver.send_image image_file
end

#pauseObject


36
37
38
# File 'lib/airstream/device.rb', line 36

def pause
  @player.pause
end

#positionObject


52
53
54
# File 'lib/airstream/device.rb', line 52

def position
  self.scrub["position"]
end

#resumeObject


40
41
42
# File 'lib/airstream/device.rb', line 40

def resume
  @player.resume
end

#scrub(seconds = nil) ⇒ Object


44
45
46
# File 'lib/airstream/device.rb', line 44

def scrub(seconds=nil)
  @player.scrub seconds
end

#video=(video) ⇒ Object


31
32
33
34
# File 'lib/airstream/device.rb', line 31

def video=(video)
  @player = @receiver.send_video video.url
  @video_title = video.to_s
end