Class: Acme::Smileage::Blog::Ameblo

Inherits:
Object
  • Object
show all
Defined in:
lib/acme/smileage/blog/ameblo.rb

Constant Summary collapse

@@cache =
{}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(blog_link, author = nil) ⇒ Ameblo

Returns a new instance of Ameblo.



13
14
15
16
17
# File 'lib/acme/smileage/blog/ameblo.rb', line 13

def initialize(blog_link, author = nil)
  @blog_link = blog_link
  @author = author
  @downloader = Acme::Smileage::Blog::AmebloDownloader.new
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



11
12
13
# File 'lib/acme/smileage/blog/ameblo.rb', line 11

def author
  @author
end

Returns the value of attribute blog_link.



11
12
13
# File 'lib/acme/smileage/blog/ameblo.rb', line 11

def blog_link
  @blog_link
end

Instance Method Details

#get_entry_body(entry_header) ⇒ Object



29
30
31
32
# File 'lib/acme/smileage/blog/ameblo.rb', line 29

def get_entry_body(entry_header)
  entry_link = coerce_entry_link(entry_header)
  @@cache[entry_link] ||= @downloader.get_entry_body(entry_link)
end

#get_entry_list(page = 1) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/acme/smileage/blog/ameblo.rb', line 19

def get_entry_list(page = 1)
  c = (@@cache[[self.blog_link, page]] ||= @downloader.get_entry_list(self, self.blog_link, page))

  r = c.dup
  if self.author
    r.entries = r.entries.select {|e| e.author == self.author }
  end
  r
end