Method: RSpotify::Base#embed
- Defined in:
- lib/rspotify/base.rb
#embed(options = {}) ⇒ Object
Generate an embed code for an album, artist or track. For full documentation on widgets/embeds, check out the official documentation:
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/rspotify/base.rb', line 138 def ( = {}) = { width: 300, height: 380, frameborder: 0, allowtransparency: true, view: nil, theme: nil } = .merge() src = "https://embed.spotify.com/?uri=#{@uri}" src << "&view=#{[:view]}" unless [:view].nil? src << "&theme=#{[:theme]}" unless [:theme].nil? template = <<-HTML <iframe src="#{src}" width="#{[:width]}" height="#{[:height]}" frameborder="#{[:frameborder]}" allowtransparency="#{[:allowtransparency]}"> </iframe> HTML template.gsub(/\s+/, " ").strip end |