Class: Embedda
- Inherits:
-
Object
- Object
- Embedda
- Defined in:
- lib/embedda.rb
Defined Under Namespace
Classes: UnknownFilter
Instance Method Summary collapse
- #embed ⇒ Object
-
#initialize(string, options = {}) ⇒ Embedda
constructor
A new instance of Embedda.
Constructor Details
#initialize(string, options = {}) ⇒ Embedda
Returns a new instance of Embedda.
10 11 12 13 14 15 |
# File 'lib/embedda.rb', line 10 def initialize(string, = {}) = {:filters => [:youtube, :vimeo, :soundcloud]}.merge() @filters = Array([:filters]) @protocol = [:ssl] ? 'https' : 'http' @string = string end |
Instance Method Details
#embed ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/embedda.rb', line 17 def return "" if @string.to_s.empty? @filters.each do |filter_name| begin @string = send("#{filter_name}_replace", @string) rescue NoMethodError raise UnknownFilter.new(filter_name) end end @string end |