Class: Punchfork::Recipe

Inherits:
Object
  • Object
show all
Defined in:
lib/punchfork/recipe.rb

Overview

Wrapper for recipe search results. Provides dot syntax support.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Recipe

Returns a new instance of Recipe.



6
7
8
9
10
11
12
13
14
# File 'lib/punchfork/recipe.rb', line 6

def initialize(*args)
  @hash = args[0]
  @attributes = {}
  @hash.each do |k, v|
    instance_variable_set("@#{k}", v)
    self.class.class_eval{attr_reader k}
    @attributes[k] = v
  end
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



16
17
18
# File 'lib/punchfork/recipe.rb', line 16

def attributes
  @attributes
end

Class Method Details

.secure_url(url) ⇒ Object



22
23
24
25
26
# File 'lib/punchfork/recipe.rb', line 22

def self.secure_url(url)
  return url if url.match(/^https/)
  uri = URI.parse(url).tap{ |uri| uri.scheme = 'https'; uri.path = File.join('/', uri.host, uri.path); uri.host = 's3.amazonaws.com' }
  return uri.to_s
end

Instance Method Details

#secure_thumbObject



18
19
20
# File 'lib/punchfork/recipe.rb', line 18

def secure_thumb
  return Recipe.secure_url(thumb)
end