Class: Blender3d::Pointer

Inherits:
Object
  • Object
show all
Defined in:
lib/blender-3d/pointer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location) ⇒ Pointer

Returns a new instance of Pointer.


5
6
7
# File 'lib/blender-3d/pointer.rb', line 5

def initialize(location)
  @location = location
end

Instance Attribute Details

#locationObject (readonly) Also known as: to_i

Returns the value of attribute location.


3
4
5
# File 'lib/blender-3d/pointer.rb', line 3

def location
  @location
end

Instance Method Details

#!=(other) ⇒ Object


27
28
29
# File 'lib/blender-3d/pointer.rb', line 27

def !=(other)
  !(self == other)
end

#+(other) ⇒ Object

Raises:

  • (TypeError)

35
36
37
38
# File 'lib/blender-3d/pointer.rb', line 35

def +(other)
  return Pointer.new(@location + other) if other.is_a?(Integer)
  raise TypeError, "#{other.class} cannot be implicitly converted into an Integer"
end

#-(other) ⇒ Object

Raises:

  • (TypeError)

40
41
42
43
44
# File 'lib/blender-3d/pointer.rb', line 40

def -(other)
  return Pointer.new(@location - other) if other.is_a?(Integer)
  return @location - other.location if other.is_a?(Pointer)
  raise TypeError, "#{other.class} cannot be implicitly converted into a Pointer"
end

#<=>(other) ⇒ Object


19
20
21
# File 'lib/blender-3d/pointer.rb', line 19

def <=>(other)
  other.is_a?(Pointer) || other.is_a?(Integer) ? to_i <=> other.to_i : 1
end

#==(other) ⇒ Object Also known as: eql?


23
24
25
# File 'lib/blender-3d/pointer.rb', line 23

def ==(other)
  (self <=> other) == 0
end

#hashObject


31
32
33
# File 'lib/blender-3d/pointer.rb', line 31

def hash
  @location.hash
end

#inspectObject


13
14
15
16
17
# File 'lib/blender-3d/pointer.rb', line 13

def inspect
  return '0x0' if @location == 0
  return '0x%08x' % @location if @location < (1 << 32)
  '0x%016x' % @location
end

#to_sObject


9
10
11
# File 'lib/blender-3d/pointer.rb', line 9

def to_s
  "Pointer(#{inspect})"
end