class Ecoportal::API::V2::Page::Component::GaugeStop
Public Class Methods
new_doc()
click to toggle source
# File lib/ecoportal/api/v2/page/component/gauge_stop.rb, line 9 def new_doc { "id" => new_uuid, "threshold" => nil, "color" => nil } end
Public Instance Methods
color=(value)
click to toggle source
Assign the color to the stop. @note These are the available colors:
- :blue, :blue_greyed, :blue_light - :turquoise, :jade, :green, :pistachio, :avocado - :yellow, :orange, :pumpkin, :red, :magenta, :fuchsia, :purple, :violet
@param value [String, Symbol] you can use a `symbol` to specify a color
# File lib/ecoportal/api/v2/page/component/gauge_stop.rb, line 28 def color=(value) value = to_color(value) if value.is_a?(Symbol) doc["color"] = value end
color_sym()
click to toggle source
@return [Symbol] to get the `color` sym code
# File lib/ecoportal/api/v2/page/component/gauge_stop.rb, line 34 def color_sym color_maps.each do |k, v| return k if color == v end :undefined end
Private Instance Methods
color_maps()
click to toggle source
# File lib/ecoportal/api/v2/page/component/gauge_stop.rb, line 62 def color_maps @color_maps ||= [ [:blue, "#5656e2"], [:blue_greyed, "#568be2"], [:blue_light, "#56c0e2"], [:turquoise, "#56e2cf"], [:jade, "#56e29b"], [:green, "#56e267"], [:pistachio, "#79e256"], [:avocado, "#aee256"], [:yellow, "#e2e156"], [:orange, "#e2ad56"], [:pumpkin, "#e27956"], [:red, "#e25667"], [:magenta, "#e2569c"], [:fuchsia, "#e256d1"], [:purple, "#be56e2"], [:violet, "#8a56e2"] ].to_h end
color_syms()
click to toggle source
# File lib/ecoportal/api/v2/page/component/gauge_stop.rb, line 54 def color_syms @color_syms ||= color_maps.keys end
colors()
click to toggle source
# File lib/ecoportal/api/v2/page/component/gauge_stop.rb, line 58 def colors @colors ||= color_maps.values end
to_color(value)
click to toggle source
# File lib/ecoportal/api/v2/page/component/gauge_stop.rb, line 43 def to_color(value) return nil unless valid_color?(value) return value if value.is_a?(String) color_maps[value] end
valid_color?(value)
click to toggle source
# File lib/ecoportal/api/v2/page/component/gauge_stop.rb, line 49 def valid_color?(value) return true if value.is_a?(String) && colors.any? {|c| c == value} return true if value.is_a?(Symbol) && color_syms.any? {|s| s == value} end