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