openhab-scripting 3.1.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2c9b98ae8645ba9006e801fb670b8858442117e731f9eddd37186824f655704
4
- data.tar.gz: b594df3783cbce82b7d1a80187f4455e2afa5ffad3230b1c64f7c7be8a7b6a66
3
+ metadata.gz: beab2ee97613a8a2016969c8410f4abcddc9c780ad16c5683e382bee28526122
4
+ data.tar.gz: 33f9ecf81357a4812e59188ad3d3f5b7ef034e79e874ec942e3bc880352853d4
5
5
  SHA512:
6
- metadata.gz: 8d9dacf04c0bdeec592a0bd4742009754eb32433523b6f88a9abe34f1294d17fd41a93b940b5701f6b2dc28d1a7d29fef04d5eb07d98e9b0eeb9473aa25e1967
7
- data.tar.gz: cb5585d43b36d101db8b3d81686eb503e6393e0336d0ff626a3ad7d33b6c0720ce13993886453176df2f245c3feea5c10dd42b19908d31ae4734919c72c4f09f
6
+ metadata.gz: 97b3a91ecda58df5763a79b6f9d0c3020f7064774e84f62c3716cbb6fc441a0848dee14778126f01cde1ca327e0c5413ea3f5e37e3b3fda1a0d5e432bfe36007
7
+ data.tar.gz: cece3de478210c8236d6d74a04af2edb1efe136bf4e380f86225df8b76b7b7edf3fcf83fde9dcc376dbcbcc62e443bbd5719cbb2efdc2949249467f06fa677ae
@@ -43,7 +43,7 @@ module OpenHAB
43
43
  # @return [Java::OrgOpenhabCoreLibraryTypes::PercentType] the position of the rollershutter
44
44
  #
45
45
  def position
46
- state.as(PercentType)
46
+ state&.as(PercentType)
47
47
  end
48
48
 
49
49
  #
@@ -54,6 +54,8 @@ module OpenHAB
54
54
  # @return [Integer] -1, 0 or 1 depending on the result of the comparison
55
55
  #
56
56
  def <=>(other)
57
+ return nil unless state?
58
+
57
59
  case other
58
60
  when PercentType, Java::OrgOpenhabCoreLibraryTypes::DecimalType then position.compare_to(other)
59
61
  when Numeric then position.int_value <=> other
@@ -73,8 +75,8 @@ module OpenHAB
73
75
  raise ArgumentError, "Cannot coerce to #{other.class}" unless other.is_a? Numeric
74
76
 
75
77
  case other
76
- when Integer then [other, position.int_value]
77
- when Float then [other, position.float_value]
78
+ when Integer then [other, position&.int_value]
79
+ when Float then [other, position&.float_value]
78
80
  end
79
81
  end
80
82
 
@@ -84,7 +86,7 @@ module OpenHAB
84
86
  %i[+ - * / %].each do |operator|
85
87
  define_method(operator) do |other|
86
88
  right, left = coerce(other)
87
- left.send(operator, right)
89
+ left&.send(operator, right)
88
90
  end
89
91
  end
90
92
  end
@@ -5,5 +5,5 @@
5
5
  #
6
6
  module OpenHAB
7
7
  # @return [String] Version of OpenHAB helper libraries
8
- VERSION = '3.1.0'
8
+ VERSION = '3.1.1'
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: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian O'Connell