Class: Graphene::Point
- Inherits:
-
Object
- Object
- Graphene::Point
- Defined in:
- lib/graphene1/point.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Point
constructor
A new instance of Point.
- #initialize_raw ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(*args) ⇒ Point
Returns a new instance of Point.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/graphene1/point.rb', line 32 def initialize(*args) super() case args.size when 0 when 1 arg = args[0] case arg when Point init_from_point(arg) when Vec2 init_from_vec2(arg) else = +"source must be Graphene::Point or Graphene::Vec2: " << "#{arg.inspect}" raise ArgumentError, end when 2 init(*args) else = +"wrong number of arguments " << "(given #{args.size}, expected 0..2)" raise ArgumentError, end end |
Class Method Details
.try_convert(value) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/graphene1/point.rb', line 20 def try_convert(value) case value when Array return nil unless value.size == 2 new(*value) else nil end end |
Instance Method Details
#initialize_raw ⇒ Object
31 |
# File 'lib/graphene1/point.rb', line 31 alias_method :initialize_raw, :initialize |
#to_a ⇒ Object
57 58 59 |
# File 'lib/graphene1/point.rb', line 57 def to_a [x, y] end |