Class: MotionAL::Representation
- Inherits:
-
Object
- Object
- MotionAL::Representation
- Defined in:
- lib/motional/representation.rb
Overview
A wrapper of ALRepresentation class.
An ALAssetRepresentation object encapsulates one of the representations of a given ALAsset object.
A given asset in the library may have more than one representation. For example, if a camera provides RAW and JPEG versions of an image, the resulting asset will have two representations—one for the RAW file and one for the JPEG file.
And added some convinience methods.
Instance Attribute Summary collapse
-
#al_asset_representation ⇒ Object
readonly
Returns the value of attribute al_asset_representation.
-
#asset ⇒ Object
readonly
Returns the value of attribute asset.
Instance Method Summary collapse
-
#:UTI(: UTI) ⇒ String
The representation’s :UTI.
-
#cg_image_with_options(options) ⇒ CGImageRef
A full resolution CGImage of the representation.
-
#data ⇒ NSConcreteData
return a NSConcreteData(kind of NSData) object for the representation file.
-
#dimensions ⇒ CGSize
The representation’s dimensions.
-
#filename ⇒ String
(also: #name)
The representation’s filename.
-
#full_resolution_image ⇒ CGImageRef?
(also: #cg_image)
A CGImage of the representation.
-
#full_screen_image ⇒ CGImageRef?
A CGImage of the representation that is appropriate for displaying full screen.
-
#initialize(asset, al_asset_representation) ⇒ Representation
constructor
A new instance of Representation.
-
#metadata ⇒ Hash?
Metadata of the representation.
-
#orientation ⇒ Symbol
The orientation of the representation.
-
#scale ⇒ Float
The representation’s scale.
-
#size ⇒ Fixnum
The representation’s size.
-
#url ⇒ NSURL
The representation’s url.
Constructor Details
#initialize(asset, al_asset_representation) ⇒ Representation
Returns a new instance of Representation.
17 18 19 20 |
# File 'lib/motional/representation.rb', line 17 def initialize(asset, al_asset_representation) @asset = asset @al_asset_representation = al_asset_representation end |
Instance Attribute Details
#al_asset_representation ⇒ Object (readonly)
Returns the value of attribute al_asset_representation.
13 14 15 |
# File 'lib/motional/representation.rb', line 13 def al_asset_representation @al_asset_representation end |
#asset ⇒ Object (readonly)
Returns the value of attribute asset.
13 14 15 |
# File 'lib/motional/representation.rb', line 13 def asset @asset end |
Instance Method Details
#:UTI(: UTI) ⇒ String
The representation’s :UTI
98 |
# File 'lib/motional/representation.rb', line 98 make_wrapper_for_method(:UTI, "String") |
#cg_image_with_options(options) ⇒ CGImageRef
Returns A full resolution CGImage of the representation.
40 41 42 |
# File 'lib/motional/representation.rb', line 40 def () @al_asset_representation.CGImageWithOptions() end |
#data ⇒ NSConcreteData
return a NSConcreteData(kind of NSData) object for the representation file.
support only jpeg and png.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/motional/representation.rb', line 27 def data ui_image = UIImage.imageWithCGImage(self.cg_image) if self.filename =~ /.jpe?g$/i NSData.alloc.initWithData(UIImageJPEGRepresentation(ui_image, 0.0)) elsif self.filename =~ /.png$/i NSData.alloc.initWithData(UIImagePNGRepresentation(ui_image)) else nil end end |
#dimensions ⇒ CGSize
The representation’s dimensions
94 |
# File 'lib/motional/representation.rb', line 94 make_wrapper_for_method(:dimensions, "CGSize") |
#filename ⇒ String Also known as: name
The representation’s filename
95 |
# File 'lib/motional/representation.rb', line 95 make_wrapper_for_method(:filename, "String") |
#full_resolution_image ⇒ CGImageRef? Also known as: cg_image
A CGImage of the representation.
57 58 59 |
# File 'lib/motional/representation.rb', line 57 def full_resolution_image @al_asset_representation.fullResolutionImage end |
#full_screen_image ⇒ CGImageRef?
A CGImage of the representation that is appropriate for displaying full screen.
66 67 68 |
# File 'lib/motional/representation.rb', line 66 def full_screen_image @al_asset_representation.fullScreenImage end |
#metadata ⇒ Hash?
Metadata of the representation.
74 75 76 |
# File 'lib/motional/representation.rb', line 74 def @al_asset_representation. end |
#orientation ⇒ Symbol
The orientation of the representation.
49 50 51 |
# File 'lib/motional/representation.rb', line 49 def orientation MotionAL.asset_orientations.key(@al_asset.valueForProperty(ALAssetPropertyOrientation)) end |
#scale ⇒ Float
The representation’s scale
93 |
# File 'lib/motional/representation.rb', line 93 make_wrapper_for_method(:scale, "Float") |
#size ⇒ Fixnum
The representation’s size
96 |
# File 'lib/motional/representation.rb', line 96 make_wrapper_for_method(:size, "Fixnum") |
#url ⇒ NSURL
The representation’s url
97 |
# File 'lib/motional/representation.rb', line 97 make_wrapper_for_method(:url, "NSURL") |