Class: Radiodan::PlaylistSync

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/radiodan/playlist_sync.rb

Defined Under Namespace

Classes: SyncError

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

included, level, level=, #logger, output, output=

Constructor Details

#initialize(expected = nil, current = nil) ⇒ PlaylistSync

Returns a new instance of PlaylistSync.



11
12
13
14
15
# File 'lib/radiodan/playlist_sync.rb', line 11

def initialize(expected = nil, current = nil)
  @expected = expected
  @current  = current
  @errors   = []
end

Instance Attribute Details

#currentObject

Returns the value of attribute current.



8
9
10
# File 'lib/radiodan/playlist_sync.rb', line 8

def current
  @current
end

#errorsObject (readonly)

Returns the value of attribute errors.



9
10
11
# File 'lib/radiodan/playlist_sync.rb', line 9

def errors
  @errors
end

#expectedObject

Returns the value of attribute expected.



8
9
10
# File 'lib/radiodan/playlist_sync.rb', line 8

def expected
  @expected
end

Instance Method Details

#ready?Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
# File 'lib/radiodan/playlist_sync.rb', line 23

def ready?
  if expected.nil? || current.nil?
    logger.warn 'Require two playlists to compare'
    false
  else
    true
  end
end

#sync?Boolean

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/radiodan/playlist_sync.rb', line 17

def sync?
  if ready?
    compare_playback_state & compare_playback_mode & compare_tracks & compare_volume
  end
end