Skip to content

Commit 22c7333

Browse files
author
Jason Berlinsky
committed
Generalized Topic model
1 parent 6632e45 commit 22c7333

1 file changed

Lines changed: 22 additions & 8 deletions

File tree

lib/rmeetup/type/topic.rb

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,31 @@ module Type
77
# Used to access result attributes as well
88
# as progammatically fetch relative data types
99
# based on this topic.
10+
11+
# Edited by Jason Berlinsky on 1/20/11 to allow for arbitrary data access
12+
# See http://www.meetup.com/meetup_api/docs/topics/ for available fields
13+
1014
class Topic
11-
attr_accessor :name, :urlkey, :id, :description, :members, :link, :updated
15+
attr_accessor :topic
1216

1317
def initialize(topic = {})
14-
self.name = topic['name']
15-
self.urlkey = topic['urlkey']
16-
self.id = topic['id'].to_i
17-
self.description = topic['description']
18-
self.members = topic['members'].to_i
19-
self.link = topic['link']
20-
self.updated = DateTime.parse(topic['updated'])
18+
self.topic = topic
19+
end
20+
21+
def method_missing(id, *args)
22+
return self.topic[id.id2name].toutf8
23+
end
24+
25+
# Special accessors that need typecasting or other parsing
26+
27+
def id
28+
return self.topic['id'].to_i
29+
end
30+
def members
31+
return self.topic['members'].to_i
32+
end
33+
def updated
34+
return DateTime.parse(self.topic['updated'])
2135
end
2236
end
2337
end

0 commit comments

Comments
 (0)