openhab-scripting 2.12.0 → 2.13.0

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: a2d12cc054e377bd657e80ef28661155676fa325526ceb2b787cd64772af876b
4
- data.tar.gz: 27152a95a1526ebb15bb63224197bbb96d8da6a25a5548b50ae796e4f2371fbd
3
+ metadata.gz: 9e3db2fe066cd7fe8c314eda96c2ce182611c1af9be801fb179896eaeebbca6e
4
+ data.tar.gz: a91ab773ddff831028cf3ef9839cca92f8772f3e9c10eb6c49d610282a4f998b
5
5
  SHA512:
6
- metadata.gz: e533069444e06d2d6bbb656c5d43f8295195a9d73c325fa12fa2d16fb0a0296aaa51ce5d036233429703f9b8d4c9f22f7298673f3579f6e1c1c6dadb841d8821
7
- data.tar.gz: 48ef8d6d80f28d974b1e42da67b904c4ac524b687ef1f4be1ea50edf970e8c48de0dac3503a97043130a1d6c88cb915a1c3b972d093961e174208435f0a03a56
6
+ metadata.gz: a7ada2d4a291c47f44531f47e7556799c800f83ec9fa2d23d3cd708ddba11bd958a84d0df74c999ca49e0f14f5f9067a7a5c7d5ac766bab31bdc5e969bab236f
7
+ data.tar.gz: b06aae6303a62bf4b53144c9cf0e1ad0d2457be0a76e1930f1558d156259ccd1dbe89ed9a1121c1ffb0a728052665c57cc5736ed1932d78cc61ff88bbdcc2c24
@@ -14,6 +14,7 @@ Dimmer = DimmerItem
14
14
  #
15
15
  # rubocop:disable Style/ClassAndModuleChildren
16
16
  class Java::OrgOpenhabCoreLibraryItems::DimmerItem
17
+ include Comparable
17
18
  # rubocop:enable Style/ClassAndModuleChildren
18
19
  java_import org.openhab.core.library.types.DecimalType
19
20
  java_import org.openhab.core.library.types.IncreaseDecreaseType
@@ -85,6 +86,38 @@ class Java::OrgOpenhabCoreLibraryItems::DimmerItem
85
86
  target
86
87
  end
87
88
 
89
+ #
90
+ # Compare DimmerItem to supplied object
91
+ #
92
+ # @param [Object] other object to compare to
93
+ #
94
+ # @return [Integer] -1,0,1 or nil depending on value supplied, nil comparison to supplied object is not possible.
95
+ #
96
+ def <=>(other)
97
+ logger.trace("Comparing #{self} to #{other}")
98
+ case other
99
+ when DimmerItem, NumberItem
100
+ state <=> other.state
101
+ when DecimalType
102
+ state <=> other
103
+ else
104
+ to_i <=> other.to_i
105
+ end
106
+ end
107
+
108
+ #
109
+ # Compare DimmerItem to supplied object.
110
+ # The == operator needs to be overridden because the parent java object
111
+ # has .equals which overrides the <=> operator above
112
+ #
113
+ # @param [Object] other object to compare to
114
+ #
115
+ # @return [Integer] true if the two objects contain the same value, false otherwise
116
+ #
117
+ def ==(other)
118
+ (self <=> other).zero?
119
+ end
120
+
88
121
  #
89
122
  # Check if dimmer has a state and state is not zero
90
123
  #
@@ -105,6 +138,15 @@ class Java::OrgOpenhabCoreLibraryItems::DimmerItem
105
138
 
106
139
  alias to_int to_i
107
140
 
141
+ #
142
+ # Return the string representation of the dimmer item
143
+ #
144
+ # @return [String] String version of the dimmer value
145
+ #
146
+ def to_s
147
+ to_i.to_s
148
+ end
149
+
108
150
  #
109
151
  # Check if dimmer is on
110
152
  #
@@ -5,5 +5,5 @@
5
5
  #
6
6
  module OpenHAB
7
7
  # @return [String] Version of OpenHAB helper libraries
8
- VERSION = '2.12.0'
8
+ VERSION = '2.13.0'
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openhab-scripting
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.12.0
4
+ version: 2.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian O'Connell