Class: Cat::Style::Size
- Inherits:
-
Object
- Object
- Cat::Style::Size
- Defined in:
- lib/cat/style/size.rb
Instance Method Summary collapse
-
#initialize(width, height = nil) ⇒ Size
constructor
A new instance of Size.
- #to_s ⇒ Object
Constructor Details
#initialize(width, height = nil) ⇒ Size
Returns a new instance of Size.
4 5 6 7 8 9 10 11 |
# File 'lib/cat/style/size.rb', line 4 def initialize(width, height = nil) @width = width @height = height || width @width = "#{@width}px" if @width.is_a?(Integer) @height = "#{@height}px" if @height.is_a?(Integer) @width = '100px' unless (@width =~ /px|%|em|rem$/) > 0 @height = '100px' unless (@height =~ /px|%|em|rem$/) > 0 end |
Instance Method Details
#to_s ⇒ Object
13 14 15 16 17 18 |
# File 'lib/cat/style/size.rb', line 13 def to_s %{ width: #{@width}; height: #{@height}; } end |