Class: Cat::Style::Stroke
- Inherits:
-
Object
- Object
- Cat::Style::Stroke
- Defined in:
- lib/cat/style/stroke.rb
Instance Method Summary collapse
-
#initialize(width, color = nil, only = [:top, :right, :bottom, :left]) ⇒ Stroke
constructor
A new instance of Stroke.
- #to_s ⇒ Object
Constructor Details
#initialize(width, color = nil, only = [:top, :right, :bottom, :left]) ⇒ Stroke
Returns a new instance of Stroke.
4 5 6 7 8 9 10 11 |
# File 'lib/cat/style/stroke.rb', line 4 def initialize(width, color = nil, only = [:top, :right, :bottom, :left]) @width = width || '3' @color = color || 'black' @only = only @width = "#{@width}px" if @width.is_a?(Integer) @width = '3px' unless (@width =~ /px|%|em|rem$/) > 0 end |
Instance Method Details
#to_s ⇒ Object
13 14 15 |
# File 'lib/cat/style/stroke.rb', line 13 def to_s @only.map { |direction| "border-#{direction}: #{@width} solid #{@color};" }.join("\n") end |