openhab-scripting 4.32.0 → 4.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 737517891b51326c4c0ab343c448cca3f07a4855ca44222a8564d107d5101cf4
4
- data.tar.gz: 0cd4aea92b89e152c7bc7bb0b1e759a22609d833f1022510ec348ff4ad634812
3
+ metadata.gz: 89c274fd9901e8ccc5d1890a7cf41dbf17ab6d79eb2b798b4e86dde9101cdd11
4
+ data.tar.gz: dea8df6ebfb5b572745df0f4ab2b33ac251d74f0fe694ca4759e227f0588b4c3
5
5
  SHA512:
6
- metadata.gz: c479724e15cb266f9f797f2e6c5646384f089ff83164890cfd2c6924d1ec0b07011015d4195a4e6de30dfa06da8c2617d2528de4652f8432afd4b2cef4c9bb21
7
- data.tar.gz: 6e52ab144a7ba4118c39b9d843ba33a16a9f66903b6f9cdd6fd1cb585febdc121b5934bdd59ae813422c2e6325755302a0285f002427258762ae275214f686ce
6
+ metadata.gz: 7ddee7681015930c085afe7fa68a6c6b913e414097d8da32ed9519b2d701ad71699f9bc585186f9cf229fb67633f3781995b04099290b67dd781ba9d5e167e93
7
+ data.tar.gz: a8d606a0b5c1fe02822955ad03fd6affbf111a774581cb1706ab7661af874ef907004c73e21bfa445f16780e27f65090b140ab83487b3dc2b6729ac1fba01b03
@@ -54,29 +54,6 @@ module OpenHAB
54
54
  super
55
55
  end
56
56
 
57
- #
58
- # Convert the ColorItem to a hash
59
- # @param [:hsb, :rgb] format for hash
60
- # @return [Hash] in requested format
61
- def to_h(format = :hsb)
62
- values = to_a(format)
63
- keys = (format == :hsb ? %i[hue saturation brightness] : %i[red green blue])
64
- keys.zip(values).to_h
65
- end
66
-
67
- #
68
- # Convert the ColorItem to an array of values
69
- # @param [:hsb, :rgb] format for elements in the array
70
- # @return [Array] of ColorItem components in requested format
71
- def to_a(format = :hsb)
72
- case format
73
- when :hsb then [hue, saturation, brightness]
74
- when :rgb then [red, green, blue].map(&:to_byte)
75
- else
76
- raise ArgumentError, "Unsupported format #{format}"
77
- end
78
- end
79
-
80
57
  private
81
58
 
82
59
  # Mapping of hash values sets to conversion methods
@@ -105,13 +105,15 @@ module OpenHAB
105
105
  #
106
106
  # nil is returned if the two values are incomparable
107
107
  #
108
- def <=>(other)
108
+ def <=>(other) # rubocop:disable Metrics
109
109
  logger.trace("(#{self.class}) #{self} <=> #{other} (#{other.class})")
110
110
  if other.is_a?(Items::ColorItem) ||
111
111
  (other.is_a?(Items::GroupItem) && other.base_item.is_a?(ColorItem))
112
- return false unless other.state?
112
+ return nil unless other.state?
113
113
 
114
114
  self <=> other.state
115
+ elsif other.is_a?(HSBType)
116
+ to_a <=> other.to_a
115
117
  elsif other.respond_to?(:to_str)
116
118
  self <=> HSBType.new(other)
117
119
  else
@@ -178,6 +180,29 @@ module OpenHAB
178
180
  "#{hue},#{saturation},#{brightness}"
179
181
  end
180
182
 
183
+ #
184
+ # Convert the ColorItem to a hash
185
+ # @param [:hsb, :rgb] format for hash
186
+ # @return [Hash] in requested format
187
+ def to_h(format = :hsb)
188
+ values = to_a(format)
189
+ keys = (format == :hsb ? %i[hue saturation brightness] : %i[red green blue])
190
+ keys.zip(values).to_h
191
+ end
192
+
193
+ #
194
+ # Convert the ColorItem to an array of values
195
+ # @param [:hsb, :rgb] format for elements in the array
196
+ # @return [Array] of ColorItem components in requested format
197
+ def to_a(format = :hsb)
198
+ case format
199
+ when :hsb then [hue, saturation, brightness]
200
+ when :rgb then [red, green, blue].map(&:to_byte)
201
+ else
202
+ raise ArgumentError, "Unsupported format #{format}"
203
+ end
204
+ end
205
+
181
206
  # @!attribute [r] saturation
182
207
  # @return [PercentType]
183
208
 
@@ -5,5 +5,5 @@
5
5
  #
6
6
  module OpenHAB
7
7
  # @return [String] Version of OpenHAB helper libraries
8
- VERSION = '4.32.0'
8
+ VERSION = '4.32.1'
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openhab-scripting
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.32.0
4
+ version: 4.32.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian O'Connell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-23 00:00:00.000000000 Z
11
+ date: 2022-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler