Class: Foliokit::AssetRendition::Slice

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#boundsObject (readonly)

Returns the value of attribute bounds.



31
32
33
# File 'lib/foliokit/asset_rendition.rb', line 31

def bounds
  @bounds
end

#renditionObject (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

#srcObject



38
39
40
# File 'lib/foliokit/asset_rendition.rb', line 38

def src
  rendition.package.store_asset(rendition.source, nil, bounds)
end