class Embedda

Attributes

options[R]
string[R]

Public Class Methods

new(string_to_process, options = {}) click to toggle source
# File lib/embedda.rb, line 12
def initialize(string_to_process, options = {})
  @options = defaultize_options(options)
  @string  = string_to_process.to_s
end

Public Instance Methods

embed() click to toggle source
# File lib/embedda.rb, line 17
def embed
  return @string if @string.empty?
  process_string_with_all_filters
  @string
end

Private Instance Methods

defaultize_options(options) click to toggle source
# File lib/embedda.rb, line 25
def defaultize_options(options)
  {:filters => [:youtube, :vimeo, :soundcloud]}.merge(options)
end
filter_provider() click to toggle source
# File lib/embedda.rb, line 45
def filter_provider
  Filters::Provider.new(options)
end
filters() click to toggle source
# File lib/embedda.rb, line 29
def filters
  Array(options[:filters])
end
get_filter(filter_name) click to toggle source
# File lib/embedda.rb, line 41
def get_filter(filter_name)
  filter_provider.get(filter_name)
end
process_string_with_all_filters() click to toggle source
# File lib/embedda.rb, line 33
def process_string_with_all_filters
  filters.each{|filter_name| process_with_filter(filter_name) }
end
process_with_filter(filter_name) click to toggle source
# File lib/embedda.rb, line 37
def process_with_filter(filter_name)
  get_filter(filter_name).process(string)
end