Class: Hokusai::Padding

Inherits:
Object
  • Object
show all
Defined in:
ui/src/hokusai/types.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(top, right, bottom, left) ⇒ Padding

Returns a new instance of Padding.



87
88
89
90
91
92
# File 'ui/src/hokusai/types.rb', line 87

def initialize(top, right, bottom, left)
  @top = top
  @left = left
  @right = right
  @bottom = bottom
end

Instance Attribute Details

#bottomObject (readonly) Also known as: b

Returns the value of attribute bottom.



86
87
88
# File 'ui/src/hokusai/types.rb', line 86

def bottom
  @bottom
end

#leftObject (readonly) Also known as: l

Returns the value of attribute left.



86
87
88
# File 'ui/src/hokusai/types.rb', line 86

def left
  @left
end

#rightObject (readonly) Also known as: r

Returns the value of attribute right.



86
87
88
# File 'ui/src/hokusai/types.rb', line 86

def right
  @right
end

#topObject (readonly) Also known as: t

Returns the value of attribute top.



86
87
88
# File 'ui/src/hokusai/types.rb', line 86

def top
  @top
end

Class Method Details

.convert(value) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'ui/src/hokusai/types.rb', line 99

def self.convert(value)
  case value
  when String
    if value =~ /,/
      convert(value.split(",").map(&:to_f))
    else
      convert(value.to_i)
    end
  when Integer
    new(value, value, value, value)
  when Array
    new(value[0], value[1], value[2], value[3])
  when Padding
    value
  else
    raise Hokusai::Error.new("Unsupported conversion type #{value.class} for Hokusai::Padding")
  end
end

Instance Method Details

#hashObject



118
119
120
# File 'ui/src/hokusai/types.rb', line 118

def hash
  [self.class, top, right, bottom, left].hash
end