Class: TwitterType::ProfileFactory
- Inherits:
-
Object
- Object
- TwitterType::ProfileFactory
- Defined in:
- lib/profilefactory.rb
Instance Method Summary collapse
- #build(tweets) ⇒ Object
-
#initialize(user) ⇒ ProfileFactory
constructor
A new instance of ProfileFactory.
Constructor Details
#initialize(user) ⇒ ProfileFactory
Returns a new instance of ProfileFactory.
7 8 9 10 |
# File 'lib/profilefactory.rb', line 7 def initialize(user) raise ArgumentError.new("No user name supplied") if user.nil? or !user.is_a?(String) @user = user end |
Instance Method Details
#build(tweets) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/profilefactory.rb', line 12 def build(tweets) raise ArgumentError.new("No tweets to analyse") if tweets.nil? raise ArgumentError.new("Tweets are not enumerable") if !tweets.is_a?(Enumerable) profile = TweeterProfile.new(@user) tweets.each do |tweet| profile.update_from(tweet) end return profile end |