Class: Topsy::Page
- Inherits:
-
Object
- Object
- Topsy::Page
- Defined in:
- lib/rtopsy/page.rb
Instance Attribute Summary collapse
-
#list ⇒ Object
Returns the value of attribute list.
-
#page ⇒ Object
Returns the value of attribute page.
-
#perpage ⇒ Object
Returns the value of attribute perpage.
-
#total ⇒ Object
Returns the value of attribute total.
-
#window ⇒ Object
Returns the value of attribute window.
Instance Method Summary collapse
-
#get_authors_list(hash_list) ⇒ Object
converts a list of Hash objects into Author objects.
-
#get_linkposts_list(hash_list) ⇒ Object
converts a list of Hash objects into Linkpost objects.
-
#get_linksearchresult_list(hash_list) ⇒ Object
converts a list of Hash objects into LinkSearchResult objects.
-
#get_tags_list(hash_list) ⇒ Object
converts a list of Hash objects into Tag objects.
-
#get_trends_list(hash_list) ⇒ Object
converts a list of Hash objects into Trend objects.
-
#get_tweets_list(hash_list) ⇒ Object
converts a list of Hash objects into Tweet objects.
-
#initialize(hash, content_type) ⇒ Page
constructor
creates a Page instance from a hash, setting attributes and a list of Author instances for the page.
- #to_s ⇒ Object
Constructor Details
#initialize(hash, content_type) ⇒ Page
creates a Page instance from a hash, setting attributes and a list of Author instances for the page
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/rtopsy/page.rb', line 77 def initialize(hash, content_type) hash.each do |key, value| if key == 'list' if content_type == :author instance_variable_set("@#{key}", (value)) elsif content_type == :link_post instance_variable_set("@#{key}", get_linkposts_list(value)) elsif content_type == :tag instance_variable_set("@#{key}", (value)) elsif content_type == :trend instance_variable_set("@#{key}", get_trends_list(value)) elsif content_type == :tweet instance_variable_set("@#{key}", get_tweets_list(value)) else instance_variable_set("@#{key}", get_linksearchresult_list(value)) end else instance_variable_set("@#{key}", value) end end end |
Instance Attribute Details
#list ⇒ Object
Returns the value of attribute list.
15 16 17 |
# File 'lib/rtopsy/page.rb', line 15 def list @list end |
#page ⇒ Object
Returns the value of attribute page.
15 16 17 |
# File 'lib/rtopsy/page.rb', line 15 def page @page end |
#perpage ⇒ Object
Returns the value of attribute perpage.
15 16 17 |
# File 'lib/rtopsy/page.rb', line 15 def perpage @perpage end |
#total ⇒ Object
Returns the value of attribute total.
15 16 17 |
# File 'lib/rtopsy/page.rb', line 15 def total @total end |
#window ⇒ Object
Returns the value of attribute window.
15 16 17 |
# File 'lib/rtopsy/page.rb', line 15 def window @window end |
Instance Method Details
#get_authors_list(hash_list) ⇒ Object
converts a list of Hash objects into Author objects
22 23 24 25 26 27 28 |
# File 'lib/rtopsy/page.rb', line 22 def (hash_list) result = [] for hash in hash_list result << Author.new(hash) end return result end |
#get_linkposts_list(hash_list) ⇒ Object
converts a list of Hash objects into Linkpost objects
31 32 33 34 35 36 37 |
# 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 |
#get_linksearchresult_list(hash_list) ⇒ Object
converts a list of Hash objects into LinkSearchResult objects
40 41 42 43 44 45 46 |
# 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 |
#get_tags_list(hash_list) ⇒ Object
converts a list of Hash objects into Tag objects
49 50 51 52 53 54 55 |
# File 'lib/rtopsy/page.rb', line 49 def (hash_list) result = [] for hash in hash_list result << Tag.new(hash) end return result end |
#get_trends_list(hash_list) ⇒ Object
converts a list of Hash objects into Trend objects
58 59 60 61 62 63 64 |
# File 'lib/rtopsy/page.rb', line 58 def get_trends_list(hash_list) result = [] for hash in hash_list result << Trend.new(hash) end return result end |
#get_tweets_list(hash_list) ⇒ Object
converts a list of Hash objects into Tweet objects
67 68 69 70 71 72 73 |
# File 'lib/rtopsy/page.rb', line 67 def get_tweets_list(hash_list) result = [] for hash in hash_list result << Tweet.new(hash) end return result end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/rtopsy/page.rb', line 17 def to_s "Topsy Page: #{page} of #{total}, #{list.size} authors" end |