Class: Foliokit::AssetRendition

Inherits:
Object
  • Object
show all
Includes:
Modules::Element
Defined in:
lib/foliokit/asset_rendition.rb

Defined Under Namespace

Classes: Slice

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Modules::Element

#initialize

Instance Attribute Details

#boundsObject

Returns the value of attribute bounds.



4
5
6
# File 'lib/foliokit/asset_rendition.rb', line 4

def bounds
  @bounds
end

Instance Method Details

#heightObject

clamp asset rendition height to device height, as the rendition can never visially exceet the device height



14
15
16
# File 'lib/foliokit/asset_rendition.rb', line 14

def height
  (@height > package.manifest.device_height) ? package.manifest.device_height : @height
end

#slicesObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/foliokit/asset_rendition.rb', line 18

def slices
  result = []
  # split up long images
  if bounds.height > package.manifest.device_height
    result.push(Slice.new(self, Types::Bounds.new(0, 0, bounds.width, package.manifest.device_height)))
    result.push(Slice.new(self, Types::Bounds.new(0, package.manifest.device_height, bounds.width, bounds.height - package.manifest.device_height)))
  else
    result.push(Slice.new(self))
  end
  result
end