class Swordfish::Stylesheet

Constants

SUPPORTED_STYLES

Define all supported values here

Attributes

font_size[RW]
styles[R]

Public Class Methods

new(styles) click to toggle source

Initialize a stylesheet with an optional list of styles

# File lib/swordfish/stylesheet.rb, line 18
def initialize(styles)
  @styles = []
  merge styles
end

Public Instance Methods

==(other) click to toggle source

Test stylesheets for equality (same styles)

# File lib/swordfish/stylesheet.rb, line 30
def ==(other)
  @styles.sort == other.styles.sort
end
merge(styles) click to toggle source

Take a style or list of styles and add them to an existing stylesheet

# File lib/swordfish/stylesheet.rb, line 24
def merge(styles)
  styles = [styles] unless styles.is_a?(Array)
  @styles |= styles.select{|s| SUPPORTED_STYLES.include?(s)}
end

Private Instance Methods

has_style?(style) click to toggle source

Check if a style is included in a stylesheet

# File lib/swordfish/stylesheet.rb, line 45
def has_style?(style)
  @styles.include? style
end