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



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/paggio/css/definition.rb', line 271

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



287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/paggio/css/definition.rb', line 287

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)


302
303
304
# File 'lib/paggio/css/definition.rb', line 302

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

#vertical?Boolean

Returns:

  • (Boolean)


306
307
308
# File 'lib/paggio/css/definition.rb', line 306

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