Sha256: 05e9e372a0ff5a0aa631e89ff0a2439a1ed2ac88fe3524733df71e507b3c1dc4

Contents?: true

Size: 702 Bytes

Versions: 3

Compression:

Stored size: 702 Bytes

Contents

# frozen_string_literal: true

require 'delegate'

module WeatherLink
  class SensorDataCollection < SimpleDelegator
    attr_reader :client

    def initialize(client, sensors)
      @client = client
      super(sensors)
    end

    def to_s
      "#<#{self.class.name} (#{size} sensors)>"
    end

    def inspect
      to_s
    end

    def current_conditions
      SensorDataCollection.new(client, select(&:current_conditions?))
    end

    def archive
      SensorDataCollection.new(client, select(&:archive?))
    end

    def weather
      SensorDataCollection.new(client, select(&:weather?))
    end

    def health
      SensorDataCollection.new(client, select(&:health?))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
weatherlink-0.1.3 lib/weatherlink/sensor_data_collection.rb
weatherlink-0.1.2 lib/weatherlink/sensor_data_collection.rb
weatherlink-0.1.1 lib/weatherlink/sensor_data_collection.rb