Class: Osheet::Style
- Inherits:
-
Object
- Object
- Osheet::Style
- Defined in:
- lib/osheet/style.rb
Constant Summary collapse
- BORDER_POSITIONS =
this class is essentially a set of collectors for style settings each setting collects any arguments passed to it and it is up to the writer to determine how to use the settings
[:top, :right, :bottom, :left]
- BORDERS =
BORDER_POSITIONS.collect{|p| "border_#{p}".to_sym}
- SETTINGS =
[:align, :font, :bg] + BORDERS
Instance Attribute Summary collapse
-
#build ⇒ Object
readonly
Returns the value of attribute build.
-
#selectors ⇒ Object
readonly
Returns the value of attribute selectors.
Instance Method Summary collapse
- #align(*args) ⇒ Object
- #bg(*args) ⇒ Object
- #border(*args) ⇒ Object
- #border_bottom(*args) ⇒ Object
- #border_left(*args) ⇒ Object
- #border_right(*args) ⇒ Object
- #border_top(*args) ⇒ Object
- #font(*args) ⇒ Object
-
#initialize(*selectors, &build) ⇒ Style
constructor
A new instance of Style.
- #match?(style_class) ⇒ Boolean
Constructor Details
Instance Attribute Details
#build ⇒ Object (readonly)
Returns the value of attribute build.
12 13 14 |
# File 'lib/osheet/style.rb', line 12 def build @build end |
#selectors ⇒ Object (readonly)
Returns the value of attribute selectors.
12 13 14 |
# File 'lib/osheet/style.rb', line 12 def selectors @selectors end |
Instance Method Details
#align(*args) ⇒ Object
20 |
# File 'lib/osheet/style.rb', line 20 def align(*args); @align += args; end |
#bg(*args) ⇒ Object
22 |
# File 'lib/osheet/style.rb', line 22 def bg(*args); @bg += args; end |
#border(*args) ⇒ Object
29 30 31 |
# File 'lib/osheet/style.rb', line 29 def border(*args) BORDERS.each { |border| send(border, *args) } end |
#border_bottom(*args) ⇒ Object
26 |
# File 'lib/osheet/style.rb', line 26 def border_bottom(*args); @border_bottom += args; end |
#border_left(*args) ⇒ Object
27 |
# File 'lib/osheet/style.rb', line 27 def border_left(*args); @border_left += args; end |
#border_right(*args) ⇒ Object
25 |
# File 'lib/osheet/style.rb', line 25 def border_right(*args); @border_right += args; end |
#border_top(*args) ⇒ Object
24 |
# File 'lib/osheet/style.rb', line 24 def border_top(*args); @border_top += args; end |
#font(*args) ⇒ Object
21 |
# File 'lib/osheet/style.rb', line 21 def font(*args); @font += args; end |
#match?(style_class) ⇒ Boolean
33 34 35 36 37 38 39 |
# File 'lib/osheet/style.rb', line 33 def match?(style_class) selectors.inject(false) do |match, s| match ||= s.split('.').inject(true) do |result, part| result && (part.empty? || style_class.include?(part)) end end end |