Class Topsy::Page
In: lib/rtopsy/page.rb
Parent: Object

Methods

Attributes

list  [RW] 
page  [RW] 
perpage  [RW] 
total  [RW] 
window  [RW] 

Public Class methods

creates a Page instance from a hash, setting attributes and a list of Author instances for the page

[Source]

# File lib/rtopsy/page.rb, line 50
    def initialize(hash, content_type)
      hash.each do |key, value|
        if key == 'list' 
          if content_type == :author
            instance_variable_set("@#{key}", get_authors_list(value))  
          elsif content_type == :link_post
            instance_variable_set("@#{key}", get_linkposts_list(value))
          else
            instance_variable_set("@#{key}", get_linksearchresult_list(value))
          end
          
        else
          instance_variable_set("@#{key}", value)  
        end
      end
    end

Public Instance methods

converts a list of Hash objects into Author objects

[Source]

# File lib/rtopsy/page.rb, line 22
    def get_authors_list(hash_list)
      result = []
      for hash in hash_list
        result << Author.new(hash)
      end
      return result
    end

converts a list of Hash objects into Linkpost objects

[Source]

# File lib/rtopsy/page.rb, line 31
    def get_linkposts_list(hash_list)
      result = []
      for hash in hash_list
        result << Linkpost.new(hash)
      end
      return result
    end

converts a list of Hash objects into LinkSearchResult objects

[Source]

# File lib/rtopsy/page.rb, line 40
    def get_linksearchresult_list(hash_list)
      result = []
      for hash in hash_list
        result << LinkSearchResult.new(hash)
      end
      return result
    end

[Source]

# File lib/rtopsy/page.rb, line 17
    def to_s
      "Topsy Page: #{page} of #{total}, #{list.size} authors"
    end

[Validate]