Module: PSD::EngineData::Export::CSS

Included in:
PSD::EngineData::Export
Defined in:
lib/psd/enginedata/exporters/css.rb

Overview

Exports the document to a CSS string.

Instance Method Summary collapse

Instance Method Details

#to_cssObject

Creates the CSS string and returns it. Each property is newline separated and not all properties may be present depending on the document.

Colors are returned in rgba() format and fonts may include some internal Photoshop fonts.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/psd/enginedata/exporters/css.rb', line 12

def to_css
  parse! unless parsed?
  
  definition = {}
  definition.merge! font_family
  definition.merge! font_size
  definition.merge! font_color

  css = []
  definition.each do |k, v|
    css << "#{k}: #{v};"
  end

  css.join("\n")
end