Class: Psd2Html

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

Constant Summary collapse

CONVERTING_MAP =
{
	"text" => ::Psd2html::PsConvertor::Text,
	"text-link" => ::Psd2html::PsConvertor::TextLink,
	"block" => ::Psd2html::PsConvertor::Block,
	"block-link" => ::Psd2html::PsConvertor::BlockLink,
	"img" => ::Psd2html::PsConvertor::Img,
	"img-link" => ::Psd2html::PsConvertor::ImgLink,
	"img-bg" => ::Psd2html::PsConvertor::ImgBackground,
	"root" => ::Psd2html::PsConvertor::Root
}

Instance Method Summary collapse

Constructor Details

#initialize(psdPath, dstHtmlPath) ⇒ Psd2Html

Returns a new instance of Psd2Html.



19
20
21
22
23
24
25
26
27
# File 'lib/psd2html.rb', line 19

def initialize(psdPath,dstHtmlPath)
  @dstHtmlPath = dstHtmlPath
psd = PSD.new(psdPath)
psd.parse! 
blockRoot = psd.tree
rootConvertor = get_convertor(blockRoot,1)
@treeRoot = format_tree(rootConvertor)
  Until.log("start generate psd tree....")
end

Instance Method Details

#renderObject



38
39
40
41
42
43
44
45
46
47
# File 'lib/psd2html.rb', line 38

def render
	return <<-STR
	<meta charset="utf-8" />
	<style type="text/css">
	#{@treeRoot.render_css}
	</style>
	#{@treeRoot.render_html}
STR

end

#render_cssObject



29
30
31
32
# File 'lib/psd2html.rb', line 29

def render_css
  Until.log("start render css....")
	return @treeRoot.render_css
end

#render_htmlObject



33
34
35
36
# File 'lib/psd2html.rb', line 33

def render_html
  Until.log("start render html....")
	return @treeRoot.render_html
end