Class: Cat::Style::Offset
- Inherits:
-
Object
- Object
- Cat::Style::Offset
- Defined in:
- lib/cat/style/offset.rb
Instance Method Summary collapse
-
#initialize(amount, direction) ⇒ Offset
constructor
A new instance of Offset.
- #to_s ⇒ Object
Constructor Details
#initialize(amount, direction) ⇒ Offset
Returns a new instance of Offset.
4 5 6 7 8 9 10 11 |
# File 'lib/cat/style/offset.rb', line 4 def initialize(amount, direction) @direction = direction @direction = :top unless [:top, :left, :right, :bottom].include?(@direction) @amount = amount.to_i @amount = "#{amount}px" if @amount.is_a?(Integer) @amount = "0px" unless (@amount =~ /px|%|em|rem$/) > 0 end |
Instance Method Details
#to_s ⇒ Object
13 14 15 |
# File 'lib/cat/style/offset.rb', line 13 def to_s "margin-#{@direction}: #{@amount};" end |