lib/times_topics.rb in times_topics-0.2.0 vs lib/times_topics.rb in times_topics-0.3.0
- old
+ new
@@ -1,18 +1,19 @@
require 'times_tags'
class TimesTopics
BASE_URI = 'http://topics.nytimes.com/top/reference/timestopics/'
- attr_accessor :query, :type, :url, :result, :related_results, :num_results
+ attr_accessor :query, :type, :url, :result, :related_results, :num_results, :tag
def initialize(query, type = 'person')
@type = type
@query = query
if @result = TimesTags.search(query, type)
@num_results = @result["num_results"]
if @num_results > 0
top_result = @result["results"].shift
+ @tag = top_result
case @type
when /person/
@url = build_person_url(top_result)
when /organization/
@url = build_organization_url(top_result)