Class: Tsunami::Bucket
- Inherits:
-
Object
- Object
- Tsunami::Bucket
- Extended by:
- Forwardable
- Defined in:
- lib/tsunami/bucket.rb
Instance Attribute Summary collapse
-
#frames ⇒ Object
readonly
Returns the value of attribute frames.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #frames_per_pixel ⇒ Object
- #index(frame) ⇒ Object
-
#initialize(frames, width, height) ⇒ Bucket
constructor
A new instance of Bucket.
- #set(frame, value) ⇒ Object
- #values(frame) ⇒ Object
Constructor Details
#initialize(frames, width, height) ⇒ Bucket
Returns a new instance of Bucket.
12 13 14 15 16 17 |
# File 'lib/tsunami/bucket.rb', line 12 def initialize(frames, width, height) @values = [] @frames = frames @width = width @height = height end |
Instance Attribute Details
#frames ⇒ Object (readonly)
Returns the value of attribute frames.
10 11 12 |
# File 'lib/tsunami/bucket.rb', line 10 def frames @frames end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
10 11 12 |
# File 'lib/tsunami/bucket.rb', line 10 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
10 11 12 |
# File 'lib/tsunami/bucket.rb', line 10 def width @width end |
Instance Method Details
#frames_per_pixel ⇒ Object
27 28 29 |
# File 'lib/tsunami/bucket.rb', line 27 def frames_per_pixel @frames_per_pixel ||= frames / @width end |
#index(frame) ⇒ Object
31 32 33 |
# File 'lib/tsunami/bucket.rb', line 31 def index(frame) frame / frames_per_pixel end |
#set(frame, value) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/tsunami/bucket.rb', line 19 def set(frame, value) frame_values = values(frame) frame_values[:min] = value if value < frame_values[:min] frame_values[:max] = value if value > frame_values[:max] end |
#values(frame) ⇒ Object
35 36 37 |
# File 'lib/tsunami/bucket.rb', line 35 def values(frame) @values[index(frame)] ||= { :max => -1, :min => 1 } end |