Sha256: abe0c1eebdb47e76397d4deddb87c5b54a50527816a584cb14bddf48b1aacc00
Contents?: true
Size: 1.2 KB
Versions: 26
Compression:
Stored size: 1.2 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 def empty? !value end # 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 def to_s value.to_s end end end end end end end require 'ecoportal/api/v2/page/component/gauge_stop'
Version data entries
26 entries across 26 versions & 1 rubygems