Class: Swordfish::Stylesheet
- Inherits:
-
Object
- Object
- Swordfish::Stylesheet
- Defined in:
- lib/swordfish/stylesheet.rb
Constant Summary collapse
- SUPPORTED_STYLES =
Define all supported values here
[ # Inline styles :bold, :italic, :underline, :superscript, :subscript, :strikethrough, :strong, :emphasis, # List enumeration styles :bullet, :decimal, :lowerLetter, :lowerRoman ]
Instance Attribute Summary collapse
-
#font_size ⇒ Object
Returns the value of attribute font_size.
-
#styles ⇒ Object
readonly
Returns the value of attribute styles.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Test stylesheets for equality (same styles).
-
#initialize(styles) ⇒ Stylesheet
constructor
Initialize a stylesheet with an optional list of styles.
-
#merge(styles) ⇒ Object
Take a style or list of styles and add them to an existing stylesheet.
Constructor Details
#initialize(styles) ⇒ Stylesheet
Initialize a stylesheet with an optional list of styles
18 19 20 21 |
# File 'lib/swordfish/stylesheet.rb', line 18 def initialize(styles) @styles = [] merge styles end |
Instance Attribute Details
#font_size ⇒ Object
Returns the value of attribute font_size.
7 8 9 |
# File 'lib/swordfish/stylesheet.rb', line 7 def font_size @font_size end |
#styles ⇒ Object (readonly)
Returns the value of attribute styles.
6 7 8 |
# File 'lib/swordfish/stylesheet.rb', line 6 def styles @styles end |
Instance Method Details
#==(other) ⇒ Object
Test stylesheets for equality (same styles)
30 31 32 |
# File 'lib/swordfish/stylesheet.rb', line 30 def ==(other) @styles.sort == other.styles.sort end |
#merge(styles) ⇒ Object
Take a style or list of styles and add them to an existing stylesheet
24 25 26 27 |
# 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 |