Class: WCC::Media::Message

Inherits:
Base
  • Object
show all
Defined in:
lib/wcc/media/message.rb

Instance Attribute Summary

Attributes inherited from Base

#headers, #raw

Instance Method Summary collapse

Methods inherited from Base

#_links, #id, #initialize, #legacy_id

Methods included from ActiveRecordShim

included

Methods included from Cacheable

#cache_key, hash_cache_key, #last_modified

Constructor Details

This class inherits a constructor from WCC::Media::Base

Instance Method Details

#archived?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/wcc/media/message.rb', line 49

def archived?
  raw.dig('flags', 'archived') || false
end

#has_audio?Boolean

rubocop:disable Naming/PredicateName

Returns:

  • (Boolean)


102
103
104
105
# File 'lib/wcc/media/message.rb', line 102

def has_audio? # rubocop:disable Naming/PredicateName
  assets.each_pair
        .any? { |k, v| /^audio/.match(k) && v && !v.empty? }
end

#has_video?Boolean

rubocop:disable Naming/PredicateName

Returns:

  • (Boolean)


97
98
99
100
# File 'lib/wcc/media/message.rb', line 97

def has_video? # rubocop:disable Naming/PredicateName
  assets.each_pair
        .any? { |k, v| /video/.match(k) && v && !v.empty? }
end

#hide_from_internal_searchObject



45
46
47
# File 'lib/wcc/media/message.rb', line 45

def hide_from_internal_search
  raw.dig('flags', 'hide_from_internal_search') || false
end

#playlistsObject



57
58
59
# File 'lib/wcc/media/message.rb', line 57

def playlists
  (raw['playlists'] || []).map { |val| WCC::Media::Playlist.new(val) }
end

#seriesObject



74
75
76
# File 'lib/wcc/media/message.rb', line 74

def series
  WCC::Media::Series.new(raw['series']) if raw['series']
end

#speakersObject



53
54
55
# File 'lib/wcc/media/message.rb', line 53

def speakers
  (raw['speakers'] || []).map { |val| WCC::Media::Speaker.new(val) }
end

#tagsObject



61
62
63
# File 'lib/wcc/media/message.rb', line 61

def tags
  (raw['tags'] || []).map { |val| WCC::Media::Tag.new(val) }
end

#to_paramObject



107
108
109
# File 'lib/wcc/media/message.rb', line 107

def to_param
  "#{id}-#{slug}"
end