Class: SocialProfile::People::Album
- Inherits:
-
Object
- Object
- SocialProfile::People::Album
- Defined in:
- lib/social_profile/people/vkontakte.rb
Instance Method Summary collapse
- #http_client ⇒ Object
-
#identifier ⇒ Object
Get album id.
-
#initialize(response, target) ⇒ Album
constructor
A new instance of Album.
- #method_missing(method_name, *args, &block) ⇒ Object
-
#photo!(options) ⇒ Object
Upload photo to album.
- #respond_to?(method_name) ⇒ Boolean
Constructor Details
#initialize(response, target) ⇒ Album
Returns a new instance of Album.
232 233 234 235 |
# File 'lib/social_profile/people/vkontakte.rb', line 232 def initialize(response, target) @hash = normalize_hash(response) @target = target end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
270 271 272 273 274 275 276 |
# File 'lib/social_profile/people/vkontakte.rb', line 270 def method_missing(method_name, *args, &block) if @hash.has_key?(method_name.to_s) @hash[method_name.to_s] else super end end |
Instance Method Details
#http_client ⇒ Object
237 238 239 |
# File 'lib/social_profile/people/vkontakte.rb', line 237 def http_client @http_client ||= ::HTTPClient.new(:agent_name => 'SocialProfile robot/0.1') end |
#identifier ⇒ Object
Get album id
242 243 244 |
# File 'lib/social_profile/people/vkontakte.rb', line 242 def identifier @hash['aid'] end |
#photo!(options) ⇒ Object
Upload photo to album
album.photo!(
:source => File.new('/path/to/image')
:message => "some photo info"
)
255 256 257 258 259 260 261 262 263 264 |
# File 'lib/social_profile/people/vkontakte.rb', line 255 def photo!() return if identifier.nil? if upload_url = find_upload_url data = http_client.post(upload_url, 'file1' => [:source]) parsed_response = MultiJson.decode(data.body) @target.photos.save(parsed_response.merge('caption' => [:message])) end end |
#respond_to?(method_name) ⇒ Boolean
266 267 268 |
# File 'lib/social_profile/people/vkontakte.rb', line 266 def respond_to?(method_name) @hash.has_key?(method_name.to_s) ? true : super end |