Class: Moon::Transform

Inherits:
Object show all
Defined in:
lib/moon/packages/std/transform.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.load(data) ⇒ Object


33
34
35
# File 'lib/moon/packages/std/transform.rb', line 33

def self.load(data)
  new(*data['data'])
end

.rotate(*args) ⇒ Object


41
42
43
# File 'lib/moon/packages/std/transform.rb', line 41

def self.rotate(*args)
  new.rotate(*args)
end

.scale(*args) ⇒ Object


45
46
47
# File 'lib/moon/packages/std/transform.rb', line 45

def self.scale(*args)
  new.scale(*args)
end

.translate(*args) ⇒ Object


37
38
39
# File 'lib/moon/packages/std/transform.rb', line 37

def self.translate(*args)
  new.translate(*args)
end

Instance Method Details

#exportHash

Creates a valida Hash for serializing.

Returns:


15
16
17
# File 'lib/moon/packages/std/transform.rb', line 15

def export
  to_h.merge('&class' => self.class.to_s).stringify_keys
end

#import(data) ⇒ self

Imports data from an #export data set

Parameters:

Returns:

  • (self)

23
24
25
26
27
28
29
30
# File 'lib/moon/packages/std/transform.rb', line 23

def import(data)
  dat = data['data']
  self[0] = dat[0, 4]
  self[1] = dat[4, 4]
  self[2] = dat[8, 4]
  self[3] = dat[12, 4]
  self
end

#to_hHash

Converts the Transform to a Hash.

Returns:


6
7
8
9
10
# File 'lib/moon/packages/std/transform.rb', line 6

def to_h
  {
    data: to_a
  }
end