Class: StyleTrain::ThemedSheet

Inherits:
Sheet
  • Object
show all
Defined in:
lib/style_train/themed_sheet.rb

Constant Summary

Constants inherited from Sheet

Sheet::TAGS

Instance Attribute Summary

Attributes inherited from Sheet

#contexts, #level, #output

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Sheet

#add_style_to_queue, #alpha, #attr, #background, #background_repeat_value, #border, #border_value, #child, #concat, #content, #context, #corner_bottom_left, #corner_bottom_right, #corner_top_left, #corner_top_right, #corners, #default_shadow_color, #default_shadow_offset, #export, #gradient, #header, #id, #initialize, #list, #margin, #opacity, #outline, #overflow, #padding, #position, #property, #render, render, #render_array, #shadow, #shadow_options, #style, #style_options, #table_options, #text

Constructor Details

This class inherits a constructor from StyleTrain::Sheet

Class Method Details

.exportObject



23
24
25
26
27
28
29
# File 'lib/style_train/themed_sheet.rb', line 23

def self.export
  sheet = new
  themes.keys.each do |key|
    sheet.theme = key
    sheet.export
  end
end

.themes(klass = nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/style_train/themed_sheet.rb', line 3

def self.themes(klass=nil)
  if klass
    if !klass.ancestors.include?(StyleTrain::Theme)
      raise ArgumentError, "themes must be a StyleTrain::Theme class"
    end
    @themes = klass
  else
    raise ArgumentError, "No themes class is defined. Please add one with the class method #themes" unless @themes
    @themes
  end
end

Instance Method Details

#file_name(name = nil) ⇒ Object



31
32
33
# File 'lib/style_train/themed_sheet.rb', line 31

def file_name name=nil
  (name || self.class.to_s.underscore) + "_#{theme.name.to_s.underscore}"
end

#themeObject



15
16
17
# File 'lib/style_train/themed_sheet.rb', line 15

def theme
  @theme || self.class.themes[:default] || raise( "No theme has been set" )
end

#theme=(key) ⇒ Object



19
20
21
# File 'lib/style_train/themed_sheet.rb', line 19

def theme=(key)
  (@theme = self.class.themes[key]) || raise( ArgumentError, "Theme #{key.inspect} not found in #{self.class.themes}")
end