Skip to Content Skip to Search
Methods
A
C
P
V
W
Y

Constants

VIMEO_RECURRING_REGEX = %r{^https?://vimeo.com/event/([^/]+)/?$}
 
VIMEO_REGEX = %r{^https?://vimeo.com/(?!event)[^/]+/?[^/]+/?$}
 

Instance Public methods

as_json(options = {})

# File app/models/db/content_video.rb, line 41
def as_json(options = {})
  super.as_json(options).merge({
    "plan_names" => plan_names.sort,
    "plan_ids" => plan_ids.sort,
    "content_type" => "video",
    "content_link" => content_link
  })
end

content_type()

# File app/models/db/content_video.rb, line 50
def content_type
  "video"
end

player_id()

# File app/models/db/content_video.rb, line 29
def player_id
  if vimeo?
    url.split("vimeo.com/").last.split("/").first
  elsif vimeo_recurring?
    url.match(VIMEO_RECURRING_REGEX).try(:[], 1)
  elsif wistia?
    url.split("medias/").last
  elsif youtube?
    get_youtube_player_id
  end
end

vimeo?()

# File app/models/db/content_video.rb, line 15
def vimeo?
  # https://vimeo.com/{videoID} or https://vimeo.com/{videoID}/{token}
  url.match(VIMEO_REGEX).present?
end

vimeo_recurring?()

# File app/models/db/content_video.rb, line 20
def vimeo_recurring?
  # https://vimeo.com/event/{eventID}
  url.match(VIMEO_RECURRING_REGEX).present?
end

wistia?()

# File app/models/db/content_video.rb, line 25
def wistia?
  url.include? "wistia"
end

youtube?()

# File app/models/db/content_video.rb, line 11
def youtube?
  ["youtu.be", "youtube"].any? { |yt| url.include? yt }
end