Class: Graphene::Rect

Inherits:
Object
  • Object
show all
Defined in:
lib/graphene1/rect.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Rect

Returns a new instance of Rect.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/graphene1/rect.rb', line 32

def initialize(*args)
  super()
  case args.size
  when 0
  when 1
    init_from_rect(args[0])
  when 4
    init(*args)
  else
    message = +"wrong number of arguments "
    message << "(given #{args.size}, expected 0, 1 or 4)"
    raise ArgumentError, message
  end
end

Class Method Details

.try_convert(value) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/graphene1/rect.rb', line 20

def try_convert(value)
  case value
  when Array
    return nil unless value.size == 4
    new(*value)
  else
    nil
  end
end

Instance Method Details

#initialize_rawObject



31
# File 'lib/graphene1/rect.rb', line 31

alias_method :initialize_raw, :initialize

#to_aObject



47
48
49
# File 'lib/graphene1/rect.rb', line 47

def to_a
  [x, y, width, height]
end