Class: TDD::Ease_Object

Inherits:
Object
  • Object
show all
Defined in:
TDD Easing/tdd_ease_object.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Ease_Object) initialize(method, target, frames, attributes = {}, options = {})

Returns a new instance of Ease_Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'TDD Easing/tdd_ease_object.rb', line 42

def initialize(method, target, frames, attributes={}, options={})
  @method     = method
  @target     = target
  @frames     = frames
  @attributes = attributes
  @options    = default_options.merge(options)

  # Current frame starts at 0
  @frame = 0

  # Set overwrite attribute
  @overwrite = @options[:overwrite]

  # Setup if no delay
  setup if delay == 0

  return self
end

Instance Attribute Details

- (Object) attributes (readonly)

Returns the value of attribute attributes



34
35
36
# File 'TDD Easing/tdd_ease_object.rb', line 34

def attributes
  @attributes
end

- (Object) attributes_origin (readonly)

Returns the value of attribute attributes_origin



35
36
37
# File 'TDD Easing/tdd_ease_object.rb', line 35

def attributes_origin
  @attributes_origin
end

- (Object) frame

Returns the value of attribute frame



39
40
41
# File 'TDD Easing/tdd_ease_object.rb', line 39

def frame
  @frame
end

- (Object) frames

Returns the value of attribute frames



38
39
40
# File 'TDD Easing/tdd_ease_object.rb', line 38

def frames
  @frames
end

- (Object) method (readonly)

Returns the value of attribute method



32
33
34
# File 'TDD Easing/tdd_ease_object.rb', line 32

def method
  @method
end

- (Object) overwrite

Returns the value of attribute overwrite



40
41
42
# File 'TDD Easing/tdd_ease_object.rb', line 40

def overwrite
  @overwrite
end

- (Object) setup_complete (readonly)

Returns the value of attribute setup_complete



36
37
38
# File 'TDD Easing/tdd_ease_object.rb', line 36

def setup_complete
  @setup_complete
end

- (Object) target (readonly)

Returns the value of attribute target



33
34
35
# File 'TDD Easing/tdd_ease_object.rb', line 33

def target
  @target
end

Instance Method Details

- (Object) call_on_complete



81
82
83
# File 'TDD Easing/tdd_ease_object.rb', line 81

def call_on_complete
  @options[:call_on_complete]
end

- (Object) call_on_update



77
78
79
# File 'TDD Easing/tdd_ease_object.rb', line 77

def call_on_update
  @options[:call_on_update]
end

- (Object) default_options (private)



107
108
109
110
111
112
113
114
115
116
# File 'TDD Easing/tdd_ease_object.rb', line 107

def default_options
  {
    :easing           => Easing::LINEAR,
    :observers        => [],
    :delay            => 0,
    :overwrite        => false,
    :call_on_update   => false,
    :call_on_complete => false
  }
end

- (Object) delay



65
66
67
# File 'TDD Easing/tdd_ease_object.rb', line 65

def delay
  @options[:delay] || 0
end

- (Object) delay=(value)



69
70
71
# File 'TDD Easing/tdd_ease_object.rb', line 69

def delay=(value)
  @options[:delay] = value
end

- (Object) easing



61
62
63
# File 'TDD Easing/tdd_ease_object.rb', line 61

def easing
  @options[:easing]
end

- (Object) observers



73
74
75
# File 'TDD Easing/tdd_ease_object.rb', line 73

def observers
  @options[:observers]
end

- (Object) setup



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'TDD Easing/tdd_ease_object.rb', line 85

def setup
  return if setup_complete?

  # Set origin of attributes for ease
  @attributes_origin = {}
  @attributes.each_pair do |attr, val|
    if target.is_a? Hash
      @attributes_origin[attr] = target[attr]
    else
      @attributes_origin[attr] = target.send(attr)
    end
  end

  # Setup complete
  @setup_complete = true
end

- (Boolean) setup_complete?

Returns:

  • (Boolean)


102
103
104
# File 'TDD Easing/tdd_ease_object.rb', line 102

def setup_complete?
  @setup_complete
end