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.
253 254 255 256 |
# File 'lib/social_profile/people/vkontakte.rb', line 253 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
291 292 293 294 295 296 297 |
# File 'lib/social_profile/people/vkontakte.rb', line 291 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
258 259 260 |
# File 'lib/social_profile/people/vkontakte.rb', line 258 def http_client @http_client ||= ::HTTPClient.new(:agent_name => 'SocialProfile robot/0.1') end |
#identifier ⇒ Object
Get album id
263 264 265 |
# File 'lib/social_profile/people/vkontakte.rb', line 263 def identifier @hash['aid'] end |
#photo!(options) ⇒ Object
Upload photo to album
album.photo!(
:source => File.new('/path/to/image')
:message => "some photo info"
)
276 277 278 279 280 281 282 283 284 285 |
# File 'lib/social_profile/people/vkontakte.rb', line 276 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
287 288 289 |
# File 'lib/social_profile/people/vkontakte.rb', line 287 def respond_to?(method_name) @hash.has_key?(method_name.to_s) ? true : super end |