Class: Sol::LinearScale

Inherits:
Scale
  • Object
show all
Defined in:
lib/sol/scale.rb

Overview

Instance Attribute Summary

Attributes inherited from Scale

#spec, #type

Instance Method Summary collapse

Methods inherited from Scale

#range

Constructor Details

#initializeLinearScale





155
156
157
# File 'lib/sol/scale.rb', line 155

def initialize
  super("linear")
end

Instance Method Details

#domain(numbers) ⇒ Object





163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/sol/scale.rb', line 163

def domain(numbers)

  # If the array has more than two elements then 'range' needs to have the same number 
  # of elements
  @elements = numbers.size

  scale = "["
  numbers.each_with_index do |num, i|
    if (!num.is_a? Numeric)
      raise "Linear domain values should all be numbers. Invalid: #{num}"
    end
    scale << ", " if i > 0
    scale << "#{num}"
  end
  scale << "]"
  @spec << ".domain(#{scale})"

end