Class: ChartLine

Inherits:
Object
  • Object
show all
Defined in:
app/models/chart_line.rb

Overview

Class to handle line definition on a Chart

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag, color, value_method, options = {}) ⇒ ChartLine

constructor taking tag string, line colour and a getter method of Sample to get the value



6
7
8
9
10
11
# File 'app/models/chart_line.rb', line 6

def initialize( tag, color, value_method, options={} )
  @tag = tag
  @color = color
  @value_method = value_method
  @options = options
end

Instance Attribute Details

#colorObject (readonly)

Returns the value of attribute color.



3
4
5
# File 'app/models/chart_line.rb', line 3

def color
  @color
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'app/models/chart_line.rb', line 3

def options
  @options
end

#tagObject (readonly)

Returns the value of attribute tag.



3
4
5
# File 'app/models/chart_line.rb', line 3

def tag
  @tag
end

#value_methodObject (readonly)

Returns the value of attribute value_method.



3
4
5
# File 'app/models/chart_line.rb', line 3

def value_method
  @value_method
end

Class Method Details

.value_methods(lines) ⇒ Object

class method given an array of lines returns an array of value_methods (not necessarily unique)



19
20
21
# File 'app/models/chart_line.rb', line 19

def self.value_methods( lines )
  lines.map { |l| l.value_method }
end

Instance Method Details

#as_hashObject

returns the values that are to be passed to the client browser, as a hash



14
15
16
# File 'app/models/chart_line.rb', line 14

def as_hash
  {:tag => @tag, :color => @color, :value_method => @value_method, :options => @options}
end