Class: TypePadTemplate::Blog

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/type_pad_template/blog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account, blog_id, name) ⇒ Blog

Returns a new instance of Blog.



9
10
11
12
13
# File 'lib/type_pad_template/blog.rb', line 9

def initialize(, blog_id, name)
  @account = 
  @blog_id = blog_id
  @name = name
end

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



7
8
9
# File 'lib/type_pad_template/blog.rb', line 7

def 
  @account
end

#blog_idObject (readonly)

Returns the value of attribute blog_id.



7
8
9
# File 'lib/type_pad_template/blog.rb', line 7

def blog_id
  @blog_id
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/type_pad_template/blog.rb', line 7

def name
  @name
end

Instance Method Details

#templatesObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/type_pad_template/blog.rb', line 15

def templates
  return [] unless design_id = current_design_id

  request("/site/blogs/#{@blog_id}/design/#{design_id}/templates") do |response|
    response.
    doc.
    search("//td[@class='index-templates' or @class='archive-templates' or @class='template-modules']/a[@class='link']").
    map do |element|
      name = element.text

      output_file_element = element.at("../..//td[@class='output-file']")

      filename = if output_file_element
        output_file_element.text
      else
        "#{name.downcase.gsub(/[\- ]/, "_")}.template"
      end

      Template.new(self, name, filename, element["href"])
    end
  end
end