Sha256: bee7b309aae3325a33a49ff81b543cbc51c77cbde7011036e565baf0ef32241c
Contents?: true
Size: 1.06 KB
Versions: 8
Compression:
Stored size: 1.06 KB
Contents
module Ecoportal module API class V2 class Page class Component class GaugeField < Page::Component passthrough :value, :max passthrough :active_color, read_only: true embeds_many :stops, klass: "Ecoportal::API::V2::Page::Component::GaugeStop", order_key: :threshold # Adds a stop at `threshold` with `color` # @return [Ecoportal::API::V2::Page::Component::GaugeStop] def add_stop(threshold: 0.0, color: '#e256d1') stop_doc = stops.items_class.new_doc stops.upsert!(stop_doc) do |stop| stop.threshold = threshold stop.color = color yield(stop) if block_given? end end def ordered_stops stops.sort_by.with_index do |stop, index| [stop.threshold, index] end end end end end end end end require 'ecoportal/api/v2/page/component/gauge_stop'
Version data entries
8 entries across 8 versions & 1 rubygems