Class: ChimpContact::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/chimp_contact/template.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template_info) ⇒ Template

Returns a new instance of Template.



5
6
7
# File 'lib/chimp_contact/template.rb', line 5

def initialize(template_info)
  @template_info = template_info
end

Class Method Details

.allObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/chimp_contact/template.rb', line 19

def self.all
  ChimpContact.hominid.templates["user"].inject([]) do |result, element|
    result << {:name => element["name"], :id => element["id"]}
    result
  end
rescue EOFError
  unless @all_failed
    @all_failed = true
    retry
  end
end

.find(id) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/chimp_contact/template.rb', line 9

def self.find(id)
  id = id.gsub(".0", "").to_i
  new(ChimpContact.hominid.template_info(id))
rescue EOFError
  unless @find_failed
    @find_failed = true
    retry
  end
end

Instance Method Details

#contentObject



31
32
33
# File 'lib/chimp_contact/template.rb', line 31

def content
  @template_info["source"]
end

#to_inline_cssObject



35
36
37
38
39
40
41
42
# File 'lib/chimp_contact/template.rb', line 35

def to_inline_css
  ChimpContact.hominid.inline_css(content, true)
rescue EOFError
  unless @to_inline_css_failed
    @to_inline_css_failed = true
    retry
  end
end