Class: Zemus::Sound

Inherits:
Object
  • Object
show all
Defined in:
lib/zemus/sound.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Sound

Returns a new instance of Sound.



8
9
10
# File 'lib/zemus/sound.rb', line 8

def initialize(url)
  @url = url
end

Class Method Details

.valid?(url) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/zemus/sound.rb', line 4

def self.valid?(url)
  url =~ /.mp3/
end

Instance Method Details

#to_embedObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/zemus/sound.rb', line 12

def to_embed
  filename = @url.split("/").last

  embed = "<audio controls='controls' class='media-object'>"
  embed += "<source src='#{@url}' type='audio/mpeg' />"
  embed += "</audio>"
  embed += "<div><a href='#{@url}' target='_blank' class='img-thumbnail' download='#{filename}'><i class='glyphicon glyphicon-music'></i> Download this podcast.</a></div>"

  embed
end