esp-idf-lib/devtools/spec/copyright.rb

Mon, 03 Apr 2023 16:07:34 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 03 Apr 2023 16:07:34 +0200
changeset 12
bb72d448e282
parent 1
1c9894662795
permissions
-rw-r--r--

In the esp-idf-lib the adps9930 driver uses a device descriptor structure instead of just i2c_dev_t. Fixed a linking issue. Added APDS9930 task. Added getLightValues function. Added wifi quality value to the MQTT payload. The payload is complete and will be published.

# frozen_string_literal: true

require_relative "person"

class Copyright
  VALID_KEYS = %w[
    author
    name
    year
  ].freeze

  def initialize(hash)
    raise ArgumentError, "expect Hash, got `#{hash.class}`" unless hash.is_a?(Hash)

    validate_keys(hash)
    @metadata = hash
  end

  attr_reader :metadata

  def validate_keys(hash)
    hash.each_key do |k|
      raise ArgumentError, "unknown key: `#{k}`. valid keys are: #{VALID_KEYS.join(' ')}" unless VALID_KEYS.include? k
    end
  end

  def author?
    metadata.key?("author")
  end

  def author
    Person.new(metadata["author"])
  end

  def name
    Person.new("name" => metadata["name"])
  end

  def name?
    metadata.key?("name")
  end

  def year
    metadata["year"]
  end

  def year?
    metadata.key?("year")
  end
end

mercurial