Class: Spout::Models::Bucket

Inherits:
Object
  • Object
show all
Defined in:
lib/spout/models/bucket.rb

Overview

Defines a continuous or discrete bucket for tables and graphs

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#startObject

Returns the value of attribute start.



7
8
9
# File 'lib/spout/models/bucket.rb', line 7

def start
  @start
end

#stopObject

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_nameObject



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

Returns:

  • (Boolean)


15
16
17
# File 'lib/spout/models/bucket.rb', line 15

def in_bucket?(value)
  value >= @start && value <= @stop
end