Class: Spout::Models::Bucket
- Inherits:
-
Object
- Object
- Spout::Models::Bucket
- Defined in:
- lib/spout/models/bucket.rb
Overview
Defines a continuous or discrete bucket for tables and graphs
Instance Attribute Summary collapse
-
#start ⇒ Object
Returns the value of attribute start.
-
#stop ⇒ Object
Returns the value of attribute stop.
Instance Method Summary collapse
- #display_name ⇒ Object
- #in_bucket?(value) ⇒ Boolean
-
#initialize(start, stop, discrete: false) ⇒ Bucket
constructor
A new instance of Bucket.
Constructor Details
#initialize(start, stop, discrete: false) ⇒ Bucket
Returns a new instance of Bucket.
9 10 11 12 13 |
# File 'lib/spout/models/bucket.rb', line 9 def initialize(start, stop, discrete: false) @start = start @stop = stop @discrete = discrete end |
Instance Attribute Details
#start ⇒ Object
Returns the value of attribute start.
7 8 9 |
# File 'lib/spout/models/bucket.rb', line 7 def start @start end |
#stop ⇒ Object
Returns the value of attribute stop.
7 8 9 |
# File 'lib/spout/models/bucket.rb', line 7 def stop @stop end |
Instance Method Details
#display_name ⇒ Object
19 20 21 22 |
# File 'lib/spout/models/bucket.rb', line 19 def display_name return "#{@start}" if @discrete "#{@start} to #{@stop}" end |
#in_bucket?(value) ⇒ Boolean
15 16 17 |
# File 'lib/spout/models/bucket.rb', line 15 def in_bucket?(value) value >= @start && value <= @stop end |