class YandexMusic

Constants

VERSION

Attributes

url[RW]

Public Class Methods

new(url, options = {}) click to toggle source
# File lib/yandex_music.rb, line 5
def initialize(url, options = {})
  @url = url
end

Public Instance Methods

embed_code(options = {}) click to toggle source
# File lib/yandex_music.rb, line 14
def embed_code(options = {})
  iframe_attributes = options.fetch(:iframe_attributes, {})
  iframe_attrs = ["src=\"#{_embed_url}\"", 'frameborder="0" width="100%" height="100" style="border:none;width:100%;height:100px;"']
  iframe_attrs << iframe_attributes
  "<iframe #{iframe_attrs.reject(&:empty?).join(' ')}></iframe>"
end
track_id() click to toggle source

get yandex audio track id

# File lib/yandex_music.rb, line 10
def track_id
  @url.gsub(_url_regex, '')
end

Private Instance Methods

_embed_url() click to toggle source
# File lib/yandex_music.rb, line 27
def _embed_url
  "https://music.yandex.ru/iframe/#track/#{track_id}"
end
_url_regex() click to toggle source
# File lib/yandex_music.rb, line 23
def _url_regex
  %r{\Ahttp(s?):\/\/music.yandex.ru\/(|album\/\d+\/)track\/}i
end