Class: Foliokit::AssetRendition::Slice
- Inherits:
-
Object
- Object
- Foliokit::AssetRendition::Slice
- Defined in:
- lib/foliokit/asset_rendition.rb
Instance Attribute Summary collapse
-
#bounds ⇒ Object
readonly
Returns the value of attribute bounds.
-
#rendition ⇒ Object
readonly
Returns the value of attribute rendition.
Instance Method Summary collapse
- #export(document) ⇒ Object
-
#initialize(rendition, bounds = nil) ⇒ Slice
constructor
A new instance of Slice.
- #src ⇒ Object
Constructor Details
#initialize(rendition, bounds = nil) ⇒ Slice
Returns a new instance of Slice.
33 34 35 36 |
# File 'lib/foliokit/asset_rendition.rb', line 33 def initialize(rendition, bounds = nil) @rendition = rendition @bounds = bounds end |
Instance Attribute Details
#bounds ⇒ Object (readonly)
Returns the value of attribute bounds.
31 32 33 |
# File 'lib/foliokit/asset_rendition.rb', line 31 def bounds @bounds end |
#rendition ⇒ Object (readonly)
Returns the value of attribute rendition.
31 32 33 |
# File 'lib/foliokit/asset_rendition.rb', line 31 def rendition @rendition end |
Instance Method Details
#export(document) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/foliokit/asset_rendition.rb', line 42 def export(document) node_bounds = bounds || rendition.bounds node = Nokogiri::XML::Node.new("img", document) node["class"] = "overlay-image" node["style"] = "height: #{node_bounds.height}px; width: #{node_bounds.width}px; left: #{node_bounds.x}px; top: #{node_bounds.y}px;" node["swipable"] = true node["touchable"] = true node["src"] = src node end |
#src ⇒ Object
38 39 40 |
# File 'lib/foliokit/asset_rendition.rb', line 38 def src rendition.package.store_asset(rendition.source, nil, bounds) end |