Class: Psd2html::PsConvertor::Img
- Defined in:
- lib/psd2html/psconvertor/img.rb
Constant Summary
Constants inherited from Convertor
Convertor::CSS_HASH_BASE, Convertor::CSS_TPL, Convertor::HTML_HASH_BASE, Convertor::HTML_TPL
Instance Attribute Summary
Attributes inherited from Convertor
#childrenConvertors, #index, #parentConvertor, #psNode
Instance Method Summary collapse
Methods inherited from Convertor
#css_map, #curleft, #curtop, #get_css_tpl, #guid, #initialize, #render_css, #render_html, #sync_css, #sync_html
Constructor Details
This class inherits a constructor from Psd2html::Convertor
Instance Method Details
#css_skeleton ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/psd2html/psconvertor/img.rb', line 4 def css_skeleton cssRenderData = { "classname" => "img-#{guid}", "styles" => { "position" => "absolute", "display" => "inline-block", "border" => "none", "width" => "#{@psNode.width}px", "height" => "#{@psNode.height}px", "left" => curleft, "top" => curtop, "z-index" => "#{@psNode.depth}#{@parentConvertor.childrenConvertors.length - @index.to_i}" } } cssRenderData = CSS_HASH_BASE.merge(cssRenderData) end |
#get_html_tpl ⇒ Object
20 21 22 |
# File 'lib/psd2html/psconvertor/img.rb', line 20 def get_html_tpl "<{{tag}} {{#attributes}} {{key}}=\"{{value}}\" {{/attributes}} />" end |
#html_skeleton ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/psd2html/psconvertor/img.rb', line 23 def html_skeleton imgUrl = "#{File.dirname(@dstPath)}/img-source-#{guid}-#{Time.now.to_i}.png" @psNode.image.save_as_png(imgUrl) htmlRenderData = { "attributes" => { "class" => "img-#{guid}", "src" => imgUrl }, "tag" => "img" } htmlRenderData = HTML_HASH_BASE.merge(htmlRenderData) end |