Class: ComplexTest

Inherits:
Object show all
Defined in:
lib/rpdf2txt-rockit/profiler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(real, imaginary) ⇒ ComplexTest

Returns a new instance of ComplexTest.



135
136
137
138
139
# File 'lib/rpdf2txt-rockit/profiler.rb', line 135

def initialize(real, imaginary)
  Profiler.__enter__(:initialize, real, imaginary) 
  @real, @imaginary = real, imaginary
  Profiler.__leave__(:initialize, self)
end

Instance Attribute Details

#imaginaryObject (readonly)

Returns the value of attribute imaginary.



134
135
136
# File 'lib/rpdf2txt-rockit/profiler.rb', line 134

def imaginary
  @imaginary
end

#realObject (readonly)

Returns the value of attribute real.



134
135
136
# File 'lib/rpdf2txt-rockit/profiler.rb', line 134

def real
  @real
end

Instance Method Details

#add(other) ⇒ Object



140
141
142
143
144
# File 'lib/rpdf2txt-rockit/profiler.rb', line 140

def add(other)
  Profiler.__enter__(:add, other)
  real_add(other)
  Profiler.__leave__(:add, self)
end

#inspectObject



151
152
153
# File 'lib/rpdf2txt-rockit/profiler.rb', line 151

def inspect
  "#{real} + i*#{imaginary}"
end

#real_add(other) ⇒ Object



145
146
147
148
149
150
# File 'lib/rpdf2txt-rockit/profiler.rb', line 145

def real_add(other)
  Profiler.__enter__(:real_add, other)
  @real += other.real
  @imaginary += other.imaginary
  Profiler.__leave__(:real_add, self)
end