Class: Facebooker::Attachment
- Inherits:
-
Object
- Object
- Facebooker::Attachment
- Defined in:
- lib/facebooker/attachment.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_flash(swfsource, imgsource, width = nil, height = nil, expanded_width = nil, expanded_height = nil) ⇒ Object
- #add_image(source, href) ⇒ Object
- #add_media(hash) ⇒ Object
- #add_mp3(source, title = nil, artist = nil, album = nil) ⇒ Object
-
#initialize ⇒ Attachment
constructor
A new instance of Attachment.
- #to_hash ⇒ Object
Constructor Details
#initialize ⇒ Attachment
Returns a new instance of Attachment.
3 4 5 |
# File 'lib/facebooker/attachment.rb', line 3 def initialize @storage = {} end |
Class Method Details
.hash_populating_accessor(*names) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/facebooker/attachment.rb', line 7 def self.hash_populating_accessor(*names) names.each do |name| define_method(name) do @storage[name] end define_method("#{name}=") do |val| @storage[name]=val end end end |
Instance Method Details
#add_flash(swfsource, imgsource, width = nil, height = nil, expanded_width = nil, expanded_height = nil) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/facebooker/attachment.rb', line 37 def add_flash(swfsource, imgsource, width=nil, height=nil, =nil, =nil) params={:type=>"flash",:swfsrc=>swfsource,:imgsrc=>imgsource} params[:width] = width unless width.nil? params[:height] = height unless height.nil? params[:expanded_width] = unless .nil? params[:expanded_height] = unless .nil? add_media(params) end |
#add_image(source, href) ⇒ Object
25 26 27 |
# File 'lib/facebooker/attachment.rb', line 25 def add_image(source,href) add_media({:type=>"image",:src=>source,:href=>href}) end |
#add_media(hash) ⇒ Object
20 21 22 23 |
# File 'lib/facebooker/attachment.rb', line 20 def add_media(hash) @storage[:media]||=[] @storage[:media] << hash end |
#add_mp3(source, title = nil, artist = nil, album = nil) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/facebooker/attachment.rb', line 29 def add_mp3(source,title=nil,artist=nil,album=nil) params = {:src=>source,:type=>"mp3"} params[:title] = title unless title.nil? params[:artist] = artist unless artist.nil? params[:album] = album unless album.nil? add_media(params) end |
#to_hash ⇒ Object
46 47 48 |
# File 'lib/facebooker/attachment.rb', line 46 def to_hash @storage end |