Class: Styles::Properties::Padding

Inherits:
Base
  • Object
show all
Defined in:
lib/styles/properties/padding.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#name, #selector, #value

Instance Method Summary collapse

Methods inherited from Base

#colors, multiple_names?, names, other_names, sub_engine, sub_engines, to_sym

Constructor Details

#initialize(*args) ⇒ Padding

Returns a new instance of Padding.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/styles/properties/padding.rb', line 9

def initialize(*args)
  if args.size == 1 && args.first.is_a?(Array)
    @name = :padding
    @sub_properties = args.first
  else
    if (val = args[2]).is_a?(String)
      @name = :padding
      @sub_properties = []
      side_values = args[2].split.map(&:to_i)
      %w[top right bottom left].each_with_index do |side, idx|
        side_value = side_values[idx]
        if side_value
          @sub_properties << self.class.new(args[0], "padding_#{side}".to_sym, side_value)
        end
      end
    else
      super
      @sub_properties = nil
    end
  end
  compute_all_padding
end

Instance Attribute Details

#bottomObject (readonly)

Returns the value of attribute bottom.



7
8
9
# File 'lib/styles/properties/padding.rb', line 7

def bottom
  @bottom
end

#leftObject (readonly)

Returns the value of attribute left.



7
8
9
# File 'lib/styles/properties/padding.rb', line 7

def left
  @left
end

#rightObject (readonly)

Returns the value of attribute right.



7
8
9
# File 'lib/styles/properties/padding.rb', line 7

def right
  @right
end

#topObject (readonly)

Returns the value of attribute top.



7
8
9
# File 'lib/styles/properties/padding.rb', line 7

def top
  @top
end

Instance Method Details

#all_paddingObject



32
33
34
# File 'lib/styles/properties/padding.rb', line 32

def all_padding
  [top, right, bottom, left]
end