openhab-scripting 2.21.0 → 2.22.0

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: b163016271e25f2e7e4607db6bb97d3e1fadc1e19b6d8a0396560278aa70c4ea
4
- data.tar.gz: e133649130e7c960f0e4b1174fe20644111d933f339aabe8256dbfcf39862f10
3
+ metadata.gz: 219fcaa44946f026fe4c8873e4c12ff6b44343b1abf63368134f26317ed7dc2a
4
+ data.tar.gz: 9b671ec4883980e7fbd21ead7e6f7e71bd2f60bc260ab41195879877df67e25e
5
5
  SHA512:
6
- metadata.gz: c93bb71565595e355f1e8a3669bff9a389bbc92bc1d7f1b27e534c055c6bbfb45bc39d2220672d06e061c099c48cc73fdfad72642959e2c0abc8329f13bd5811
7
- data.tar.gz: 5cf280a5718af694e89d2f5c8262bd6930ef8dea1bf61f697e72391bb0be58089e6c7677e1c2a22b6dfe31f7fb16c137706f1ecadcf76fcacd8f9280225b542b
6
+ metadata.gz: 3784775e6cb7847fbdab271de2363b781c34e9472c3a65e3694220f377f80ad6afc923a406e4e218605d140a95780bf22c9ed82a43ac9c69ecb2a32d5368728e
7
+ data.tar.gz: 0a4e16ce610516a48beec6cf1f951a64084c0f07557ec5f8ac72ab5e3245b315d8a223d4de6e943a6177a5b74e05431d2d68bf59ad37cf362e2455f386b6b38c
@@ -63,6 +63,27 @@ module OpenHAB
63
63
  logger.trace("#{self.class} #{self} == #{other} (#{other.class})")
64
64
  (self <=> other).zero?
65
65
  end
66
+
67
+ #
68
+ # Convert DecimalType to a Quantity
69
+ #
70
+ # @param [Object] other String or Unit representing an OpenHAB Unit
71
+ #
72
+ # @return [OpenHAB::Core::DSL::Types::Quantity] NumberItem converted to supplied Unit
73
+ #
74
+ def |(other)
75
+ other = SimpleUnitFormat.instance.unitFor(other) if other.is_a? String
76
+ Quantity.new(QuantityType.new(to_big_decimal, other))
77
+ end
78
+
79
+ #
80
+ # Provide details about DecimalType object
81
+ #
82
+ # @return [String] Representing details about the DecimalType object
83
+ #
84
+ def inspect
85
+ to_string
86
+ end
66
87
  end
67
88
  end
68
89
  end
@@ -22,6 +22,7 @@ module OpenHAB
22
22
  def_delegator :@quantity, :to_s
23
23
 
24
24
  java_import org.openhab.core.library.types.QuantityType
25
+ java_import org.openhab.core.library.types.DecimalType
25
26
  java_import 'tec.uom.se.format.SimpleUnitFormat'
26
27
  java_import 'tec.uom.se.AbstractUnit'
27
28
 
@@ -92,6 +93,7 @@ module OpenHAB
92
93
  case other
93
94
  when Quantity then [other.quantity, quantity]
94
95
  when QuantityType then [other, quantity]
96
+ when DecimalType then [Quantity.new(other.to_big_decimal.to_d), quantity]
95
97
  when NumberItem then [other.to_qt.quantity, quantity]
96
98
  when Numeric, String then [Quantity.new(other), self]
97
99
  end
@@ -5,5 +5,5 @@
5
5
  #
6
6
  module OpenHAB
7
7
  # @return [String] Version of OpenHAB helper libraries
8
- VERSION = '2.21.0'
8
+ VERSION = '2.22.0'
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: 2.21.0
4
+ version: 2.22.0
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: 2021-02-18 00:00:00.000000000 Z
11
+ date: 2021-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler