Class: Paggio::CSS::Definition::Gradient

Inherits:
Object
  • Object
show all
Defined in:
lib/paggio/css/definition.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Gradient

TODO: all of it, seriously



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/paggio/css/definition.rb', line 181

def initialize(*args)
  options = ::Hash === args.last ? args.pop : {}

  @to   = options[:to]
  @from = options[:from]

  if @to && !@from
    @from = other(@to)
  elsif @from && !@to
    @to = other(@from)
  end

  @start = args.shift
  @end   = args.shift
end

Instance Method Details

#each(&block) ⇒ Object



197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/paggio/css/definition.rb', line 197

def each(&block)
  block.call style("-moz-linear-gradient(#@to, #@start 0%, #@end 100%)")

  if horizontal?
    block.call style("-webkit-gradient(linear, #@from top, #@to top, color-stop(0%, #@start), color-stop(100%, #@end))")
  else
    block.call style("-webkit-gradient(linear, left #@from, left #@to, color-stop(0%, #@start), color-stop(100%, #@end))")
  end

  block.call style("-webkit-linear-gradient(#@to, #@start 0%, #@end 100%)")
  block.call style("-o-linear-gradient(#@to, #@start 0%, #@end 100%)")
  block.call style("-ms-linear-gradient(#@to, #@start 0%, #@end 100%)")
  block.call style("linear-gradient(to #@to, #@start 0%, #@end 100%)")
end

#horizontal?Boolean

Returns:

  • (Boolean)


212
213
214
# File 'lib/paggio/css/definition.rb', line 212

def horizontal?
  @to == :left || @to == :right
end

#vertical?Boolean

Returns:

  • (Boolean)


216
217
218
# File 'lib/paggio/css/definition.rb', line 216

def vertical?
  @to == :top || @to == :bottom
end