Class: Thornbed::Providers::Memegenerator
- Defined in:
- lib/thornbed/providers/memegenerator.rb
Constant Summary
Constants inherited from Provider
Instance Attribute Summary collapse
-
#pattern ⇒ Object
Returns the value of attribute pattern.
Instance Method Summary collapse
- #get(url) ⇒ Object
-
#initialize ⇒ Memegenerator
constructor
A new instance of Memegenerator.
Methods inherited from Provider
inherited, #provider_name, #valid?
Constructor Details
#initialize ⇒ Memegenerator
Returns a new instance of Memegenerator.
8 9 10 |
# File 'lib/thornbed/providers/memegenerator.rb', line 8 def initialize self.pattern = /^http(s)?:\/\/(cdn\.)?memegenerator\.net\/instance(s)?\/(\d+x\/)?\d+(\.jpg)?(\?[\w\W]*)?$/ end |
Instance Attribute Details
#pattern ⇒ Object
Returns the value of attribute pattern.
6 7 8 |
# File 'lib/thornbed/providers/memegenerator.rb', line 6 def pattern @pattern end |
Instance Method Details
#get(url) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/thornbed/providers/memegenerator.rb', line 12 def get(url) raise Thornbed::NotValid, url if !valid?(url) url = URI.parse(url) ptype = "jpg" pic_id = /(\d+x\/)?\d+(\.jpg)?(\?[\w\W]*)?$/.match(url.path) { url: "http://cdn.memegenerator.net/instances/400x/#{pic_id}.#{ptype}", type: "photo", provider_name: provider_name, provider_url: "http://memegenerator.com", thumbnail_url: "http://cdn.memegenerator.net/instances/100x/#{pic_id}.#{ptype}", version: "1.0", page: "http://memegenerator.net/instance/#{pic_id}", width: nil, height: nil } end |