Class: OpenX::Image

Inherits:
Object
  • Object
show all
Includes:
XMLRPC::Marshallable
Defined in:
lib/openx/image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash_or_file) ⇒ Image

Returns a new instance of Image.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/openx/image.rb', line 6

def initialize(hash_or_file)
  @editswf = 0
  if hash_or_file.is_a?(File)
    @filename = File.basename(hash_or_file.path)
    @editswf = File.basename(@filename, '.swf') == @filename ? 0 : 1
    @content  = XMLRPC::Base64.new(hash_or_file.read)
  else
    raise ArgumentError unless hash_or_file.key?(:filename)
    raise ArgumentError unless hash_or_file.key?(:content)
    hash_or_file.each { |k,v| send(:"#{k}=", v) }
    unless self.content.is_a?(XMLRPC::Base64)
      self.content = XMLRPC::Base64.new(self.content)
    end
  end
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



4
5
6
# File 'lib/openx/image.rb', line 4

def content
  @content
end

#editswfObject

Returns the value of attribute editswf.



4
5
6
# File 'lib/openx/image.rb', line 4

def editswf
  @editswf
end

#filenameObject

Returns the value of attribute filename.



4
5
6
# File 'lib/openx/image.rb', line 4

def filename
  @filename
end