Module: EmbedRb::Base

Included in:
BasicAudio, BasicImage, BasicVideo, Flickr, Instagram, OpenGraph, Ted, Ustream, YouTube
Defined in:
lib/embedrb/base.rb

Instance Method Summary collapse

Instance Method Details

#embedObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/embedrb/base.rb', line 9

def embed()
  @input.scan(@regex) {|match|
    url = match[0]
    if !@options[:served].include? url && EmbedRb.process_more?(@options, @service, @embeds)
      text = url_to_text match
      if text
        @options[:served] << url
        @embeds << {
          :key => url,
          :text => text
        }
      end
    end
  }
end

#processObject



4
5
6
7
# File 'lib/embedrb/base.rb', line 4

def process()
  embed
  @output
end

#shorten(url) ⇒ Object



30
31
32
# File 'lib/embedrb/base.rb', line 30

def shorten(url)
  url.gsub(/http(s?):\/\/(www\.|m\.|)/, '')
end

#url_to_text(matched) ⇒ Object



25
26
27
28
# File 'lib/embedrb/base.rb', line 25

def url_to_text(matched)
  url = matched[0]
  return render url
end