openhab-scripting 4.47.0 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/openhab/core/actions/audio.rb +54 -0
- data/lib/openhab/core/actions/ephemeris.rb +39 -0
- data/lib/openhab/core/actions/exec.rb +51 -0
- data/lib/openhab/core/actions/http.rb +80 -0
- data/lib/openhab/core/actions/ping.rb +30 -0
- data/lib/openhab/core/actions/transformation.rb +32 -0
- data/lib/openhab/core/actions/voice.rb +36 -0
- data/lib/openhab/core/actions.rb +82 -0
- data/lib/openhab/core/dependency_tracking.rb +34 -0
- data/lib/openhab/core/dto/item_channel_link.rb +33 -0
- data/lib/openhab/core/dto/thing.rb +27 -0
- data/lib/openhab/core/dto.rb +11 -0
- data/lib/openhab/core/entity_lookup.rb +152 -70
- data/lib/openhab/core/events/abstract_event.rb +18 -0
- data/lib/openhab/core/events/abstract_item_registry_event.rb +36 -0
- data/lib/openhab/core/events/abstract_thing_registry_event.rb +40 -0
- data/lib/openhab/core/events/item_command_event.rb +78 -0
- data/lib/openhab/core/events/item_event.rb +22 -0
- data/lib/openhab/core/events/item_state_changed_event.rb +75 -0
- data/lib/openhab/core/events/item_state_event.rb +79 -0
- data/lib/openhab/core/events/item_state_updated_event.rb +22 -0
- data/lib/openhab/core/events/thing_status_info_event.rb +55 -0
- data/lib/openhab/core/events.rb +10 -0
- data/lib/openhab/core/items/accepted_data_types.rb +29 -0
- data/lib/openhab/core/items/color_item.rb +52 -0
- data/lib/openhab/core/items/contact_item.rb +52 -0
- data/lib/openhab/core/items/date_time_item.rb +59 -0
- data/lib/openhab/core/items/dimmer_item.rb +148 -0
- data/lib/openhab/core/items/generic_item.rb +292 -0
- data/lib/openhab/core/items/group_item.rb +176 -0
- data/lib/openhab/{dsl → core}/items/image_item.rb +35 -29
- data/lib/openhab/core/items/item.rb +273 -0
- data/lib/openhab/core/items/location_item.rb +34 -0
- data/lib/openhab/core/items/metadata/hash.rb +433 -0
- data/lib/openhab/core/items/metadata/namespace_hash.rb +475 -0
- data/lib/openhab/core/items/metadata/provider.rb +48 -0
- data/lib/openhab/core/items/metadata.rb +11 -0
- data/lib/openhab/core/items/number_item.rb +62 -0
- data/lib/openhab/core/items/numeric_item.rb +22 -0
- data/lib/openhab/core/items/persistence.rb +416 -0
- data/lib/openhab/core/items/player_item.rb +66 -0
- data/lib/openhab/core/items/provider.rb +44 -0
- data/lib/openhab/core/items/proxy.rb +136 -0
- data/lib/openhab/core/items/registry.rb +86 -0
- data/lib/openhab/core/items/rollershutter_item.rb +68 -0
- data/lib/openhab/core/items/semantics/enumerable.rb +177 -0
- data/lib/openhab/core/items/semantics.rb +473 -0
- data/lib/openhab/core/items/state_storage.rb +53 -0
- data/lib/openhab/core/items/string_item.rb +28 -0
- data/lib/openhab/core/items/switch_item.rb +78 -0
- data/lib/openhab/core/items.rb +108 -0
- data/lib/openhab/{dsl → core}/lazy_array.rb +9 -3
- data/lib/openhab/core/profile_factory.rb +132 -0
- data/lib/openhab/core/provider.rb +230 -0
- data/lib/openhab/core/proxy.rb +130 -0
- data/lib/openhab/core/registry.rb +40 -0
- data/lib/openhab/core/rules/module.rb +26 -0
- data/lib/openhab/core/rules/provider.rb +25 -0
- data/lib/openhab/core/rules/registry.rb +94 -0
- data/lib/openhab/core/rules/rule.rb +174 -0
- data/lib/openhab/core/rules.rb +25 -0
- data/lib/openhab/core/script_handling.rb +78 -20
- data/lib/openhab/core/things/channel.rb +48 -0
- data/lib/openhab/core/things/channel_uid.rb +51 -0
- data/lib/openhab/core/things/item_channel_link.rb +33 -0
- data/lib/openhab/core/things/links/provider.rb +78 -0
- data/lib/openhab/core/things/profile_callback.rb +52 -0
- data/lib/openhab/core/things/provider.rb +29 -0
- data/lib/openhab/core/things/proxy.rb +87 -0
- data/lib/openhab/core/things/registry.rb +73 -0
- data/lib/openhab/core/things/thing.rb +194 -0
- data/lib/openhab/core/things.rb +22 -0
- data/lib/openhab/core/timer.rb +148 -0
- data/lib/openhab/{dsl → core}/types/comparable_type.rb +5 -3
- data/lib/openhab/{dsl → core}/types/date_time_type.rb +55 -127
- data/lib/openhab/{dsl → core}/types/decimal_type.rb +50 -48
- data/lib/openhab/{dsl → core}/types/hsb_type.rb +35 -83
- data/lib/openhab/core/types/increase_decrease_type.rb +34 -0
- data/lib/openhab/core/types/next_previous_type.rb +34 -0
- data/lib/openhab/{dsl → core}/types/numeric_type.rb +20 -7
- data/lib/openhab/core/types/on_off_type.rb +46 -0
- data/lib/openhab/core/types/open_closed_type.rb +41 -0
- data/lib/openhab/{dsl → core}/types/percent_type.rb +19 -20
- data/lib/openhab/core/types/play_pause_type.rb +38 -0
- data/lib/openhab/core/types/point_type.rb +117 -0
- data/lib/openhab/core/types/quantity_type.rb +325 -0
- data/lib/openhab/core/types/raw_type.rb +26 -0
- data/lib/openhab/core/types/refresh_type.rb +27 -0
- data/lib/openhab/core/types/rewind_fastforward_type.rb +38 -0
- data/lib/openhab/core/types/stop_move_type.rb +34 -0
- data/lib/openhab/{dsl → core}/types/string_type.rb +17 -28
- data/lib/openhab/{dsl → core}/types/type.rb +42 -40
- data/lib/openhab/core/types/un_def_type.rb +38 -0
- data/lib/openhab/core/types/up_down_type.rb +50 -0
- data/lib/openhab/core/types.rb +82 -0
- data/lib/openhab/{dsl → core}/uid.rb +4 -23
- data/lib/openhab/core/value_cache.rb +188 -0
- data/lib/openhab/core.rb +98 -0
- data/lib/openhab/core_ext/between.rb +32 -0
- data/lib/openhab/core_ext/ephemeris.rb +53 -0
- data/lib/openhab/core_ext/java/class.rb +34 -0
- data/lib/openhab/core_ext/java/duration.rb +142 -0
- data/lib/openhab/core_ext/java/list.rb +436 -0
- data/lib/openhab/core_ext/java/local_date.rb +104 -0
- data/lib/openhab/core_ext/java/local_time.rb +118 -0
- data/lib/openhab/core_ext/java/map.rb +66 -0
- data/lib/openhab/core_ext/java/month.rb +71 -0
- data/lib/openhab/core_ext/java/month_day.rb +119 -0
- data/lib/openhab/core_ext/java/period.rb +103 -0
- data/lib/openhab/core_ext/java/temporal_amount.rb +34 -0
- data/lib/openhab/core_ext/java/time.rb +62 -0
- data/lib/openhab/core_ext/java/unit.rb +15 -0
- data/lib/openhab/core_ext/java/zoned_date_time.rb +213 -0
- data/lib/openhab/core_ext/ruby/array.rb +21 -0
- data/lib/openhab/core_ext/ruby/date.rb +96 -0
- data/lib/openhab/core_ext/ruby/date_time.rb +55 -0
- data/lib/openhab/core_ext/ruby/module.rb +15 -0
- data/lib/openhab/core_ext/ruby/numeric.rb +195 -0
- data/lib/openhab/core_ext/ruby/range.rb +70 -0
- data/lib/openhab/core_ext/ruby/symbol.rb +7 -0
- data/lib/openhab/core_ext/ruby/time.rb +108 -0
- data/lib/openhab/core_ext.rb +18 -0
- data/lib/openhab/dsl/debouncer.rb +259 -0
- data/lib/openhab/dsl/events/watch_event.rb +18 -0
- data/lib/openhab/dsl/events.rb +9 -0
- data/lib/openhab/dsl/gems.rb +1 -1
- data/lib/openhab/dsl/items/builder.rb +578 -0
- data/lib/openhab/dsl/items/ensure.rb +73 -82
- data/lib/openhab/dsl/items/timed_command.rb +214 -159
- data/lib/openhab/dsl/rules/automation_rule.rb +129 -116
- data/lib/openhab/dsl/rules/builder.rb +1935 -0
- data/lib/openhab/dsl/rules/guard.rb +51 -114
- data/lib/openhab/dsl/rules/name_inference.rb +66 -25
- data/lib/openhab/dsl/rules/property.rb +48 -75
- data/lib/openhab/dsl/rules/rule_triggers.rb +22 -27
- data/lib/openhab/dsl/rules/terse.rb +58 -14
- data/lib/openhab/dsl/rules/triggers/changed.rb +48 -94
- data/lib/openhab/dsl/rules/triggers/channel.rb +9 -40
- data/lib/openhab/dsl/rules/triggers/command.rb +14 -63
- data/lib/openhab/dsl/rules/triggers/conditions/duration.rb +34 -69
- data/lib/openhab/dsl/rules/triggers/conditions/proc.rb +6 -14
- data/lib/openhab/dsl/rules/triggers/cron/cron.rb +48 -82
- data/lib/openhab/dsl/rules/triggers/cron/cron_handler.rb +30 -47
- data/lib/openhab/dsl/rules/triggers/trigger.rb +7 -28
- data/lib/openhab/dsl/rules/triggers/updated.rb +21 -45
- data/lib/openhab/dsl/rules/triggers/watch/watch_handler.rb +257 -102
- data/lib/openhab/dsl/rules/triggers.rb +12 -0
- data/lib/openhab/dsl/rules.rb +8 -0
- data/lib/openhab/dsl/things/builder.rb +299 -0
- data/lib/openhab/{core → dsl}/thread_local.rb +27 -17
- data/lib/openhab/dsl/timer_manager.rb +204 -0
- data/lib/openhab/dsl/version.rb +9 -0
- data/lib/openhab/dsl.rb +979 -0
- data/lib/openhab/log.rb +355 -0
- data/lib/openhab/osgi.rb +68 -0
- data/lib/openhab/rspec/configuration.rb +56 -0
- data/lib/openhab/rspec/example_group.rb +132 -0
- data/lib/openhab/rspec/helpers.rb +458 -0
- data/lib/openhab/rspec/hooks.rb +113 -0
- data/lib/openhab/rspec/jruby.rb +46 -0
- data/lib/openhab/rspec/karaf.rb +851 -0
- data/lib/openhab/rspec/mocks/bundle_install_support.rb +25 -0
- data/lib/openhab/rspec/mocks/bundle_resolver.rb +30 -0
- data/lib/openhab/rspec/mocks/event_admin.rb +146 -0
- data/lib/openhab/rspec/mocks/instance_method_stasher.rb +22 -0
- data/lib/openhab/rspec/mocks/persistence_service.rb +155 -0
- data/lib/openhab/rspec/mocks/safe_caller.rb +40 -0
- data/lib/openhab/rspec/mocks/space.rb +23 -0
- data/lib/openhab/rspec/mocks/synchronous_executor.rb +63 -0
- data/lib/openhab/rspec/mocks/thing_handler.rb +76 -0
- data/lib/openhab/rspec/mocks/timer.rb +134 -0
- data/lib/openhab/rspec/openhab/core/actions.rb +38 -0
- data/lib/openhab/rspec/openhab/core/items/proxy.rb +15 -0
- data/lib/openhab/rspec/openhab/core/things/proxy.rb +27 -0
- data/lib/openhab/rspec/shell.rb +31 -0
- data/lib/openhab/rspec/suspend_rules.rb +50 -0
- data/lib/openhab/rspec.rb +26 -0
- data/lib/openhab/yard/base_helper.rb +19 -0
- data/lib/openhab/yard/cli/stats.rb +23 -0
- data/lib/openhab/yard/code_objects/group_object.rb +23 -0
- data/lib/openhab/yard/code_objects/java/base.rb +31 -0
- data/lib/openhab/yard/code_objects/java/class_object.rb +11 -0
- data/lib/openhab/yard/code_objects/java/field_object.rb +15 -0
- data/lib/openhab/yard/code_objects/java/interface_object.rb +15 -0
- data/lib/openhab/yard/code_objects/java/package_object.rb +11 -0
- data/lib/openhab/yard/code_objects/java/proxy.rb +23 -0
- data/lib/openhab/yard/coderay.rb +17 -0
- data/lib/openhab/yard/handlers/jruby/base.rb +58 -0
- data/lib/openhab/yard/handlers/jruby/class_handler.rb +18 -0
- data/lib/openhab/yard/handlers/jruby/constant_handler.rb +18 -0
- data/lib/openhab/yard/handlers/jruby/java_import_handler.rb +30 -0
- data/lib/openhab/yard/handlers/jruby/mixin_handler.rb +23 -0
- data/lib/openhab/yard/html_helper.rb +78 -0
- data/lib/openhab/yard/markdown_helper.rb +148 -0
- data/lib/openhab/yard/tags/constant_directive.rb +20 -0
- data/lib/openhab/yard/tags/group_directive.rb +24 -0
- data/lib/openhab/yard/tags/library.rb +3 -0
- data/lib/openhab/yard.rb +38 -0
- metadata +476 -106
- data/lib/openhab/core/item_proxy.rb +0 -29
- data/lib/openhab/core/load_path.rb +0 -19
- data/lib/openhab/core/openhab_setup.rb +0 -29
- data/lib/openhab/core/osgi.rb +0 -58
- data/lib/openhab/core/services.rb +0 -24
- data/lib/openhab/dsl/actions.rb +0 -114
- data/lib/openhab/dsl/between.rb +0 -25
- data/lib/openhab/dsl/channel.rb +0 -43
- data/lib/openhab/dsl/dsl.rb +0 -59
- data/lib/openhab/dsl/group.rb +0 -54
- data/lib/openhab/dsl/imports.rb +0 -21
- data/lib/openhab/dsl/items/color_item.rb +0 -76
- data/lib/openhab/dsl/items/comparable_item.rb +0 -62
- data/lib/openhab/dsl/items/contact_item.rb +0 -41
- data/lib/openhab/dsl/items/date_time_item.rb +0 -65
- data/lib/openhab/dsl/items/dimmer_item.rb +0 -65
- data/lib/openhab/dsl/items/generic_item.rb +0 -229
- data/lib/openhab/dsl/items/group_item.rb +0 -127
- data/lib/openhab/dsl/items/item_equality.rb +0 -59
- data/lib/openhab/dsl/items/item_registry.rb +0 -54
- data/lib/openhab/dsl/items/items.rb +0 -109
- data/lib/openhab/dsl/items/location_item.rb +0 -59
- data/lib/openhab/dsl/items/metadata.rb +0 -326
- data/lib/openhab/dsl/items/number_item.rb +0 -17
- data/lib/openhab/dsl/items/numeric_item.rb +0 -87
- data/lib/openhab/dsl/items/persistence.rb +0 -307
- data/lib/openhab/dsl/items/player_item.rb +0 -58
- data/lib/openhab/dsl/items/rollershutter_item.rb +0 -51
- data/lib/openhab/dsl/items/semantics/enumerable.rb +0 -91
- data/lib/openhab/dsl/items/semantics.rb +0 -227
- data/lib/openhab/dsl/items/string_item.rb +0 -51
- data/lib/openhab/dsl/items/switch_item.rb +0 -70
- data/lib/openhab/dsl/monkey_patch/actions/actions.rb +0 -4
- data/lib/openhab/dsl/monkey_patch/actions/script_thing_actions.rb +0 -39
- data/lib/openhab/dsl/monkey_patch/events/events.rb +0 -7
- data/lib/openhab/dsl/monkey_patch/events/item_command.rb +0 -85
- data/lib/openhab/dsl/monkey_patch/events/item_event.rb +0 -28
- data/lib/openhab/dsl/monkey_patch/events/item_state.rb +0 -61
- data/lib/openhab/dsl/monkey_patch/events/item_state_changed.rb +0 -60
- data/lib/openhab/dsl/monkey_patch/events/thing_status_info.rb +0 -33
- data/lib/openhab/dsl/monkey_patch/java/java.rb +0 -4
- data/lib/openhab/dsl/monkey_patch/java/local_time.rb +0 -44
- data/lib/openhab/dsl/monkey_patch/java/time_extensions.rb +0 -50
- data/lib/openhab/dsl/monkey_patch/java/zoned_date_time.rb +0 -45
- data/lib/openhab/dsl/monkey_patch/ruby/number.rb +0 -104
- data/lib/openhab/dsl/monkey_patch/ruby/ruby.rb +0 -6
- data/lib/openhab/dsl/monkey_patch/ruby/string.rb +0 -47
- data/lib/openhab/dsl/monkey_patch/ruby/time.rb +0 -61
- data/lib/openhab/dsl/openhab.rb +0 -30
- data/lib/openhab/dsl/persistence.rb +0 -27
- data/lib/openhab/dsl/rules/item_event.rb +0 -19
- data/lib/openhab/dsl/rules/rule.rb +0 -160
- data/lib/openhab/dsl/rules/rule_config.rb +0 -147
- data/lib/openhab/dsl/rules/triggers/generic.rb +0 -31
- data/lib/openhab/dsl/rules/triggers/triggers.rb +0 -11
- data/lib/openhab/dsl/rules/triggers/watch/watch.rb +0 -81
- data/lib/openhab/dsl/states.rb +0 -89
- data/lib/openhab/dsl/things.rb +0 -147
- data/lib/openhab/dsl/time/month_day.rb +0 -180
- data/lib/openhab/dsl/time/time_of_day.rb +0 -235
- data/lib/openhab/dsl/timers/manager.rb +0 -119
- data/lib/openhab/dsl/timers/reentrant_timer.rb +0 -38
- data/lib/openhab/dsl/timers/timer.rb +0 -132
- data/lib/openhab/dsl/timers.rb +0 -77
- data/lib/openhab/dsl/types/increase_decrease_type.rb +0 -23
- data/lib/openhab/dsl/types/next_previous_type.rb +0 -23
- data/lib/openhab/dsl/types/on_off_type.rb +0 -28
- data/lib/openhab/dsl/types/open_closed_type.rb +0 -29
- data/lib/openhab/dsl/types/play_pause_type.rb +0 -27
- data/lib/openhab/dsl/types/point_type.rb +0 -180
- data/lib/openhab/dsl/types/quantity_type.rb +0 -265
- data/lib/openhab/dsl/types/refresh_type.rb +0 -18
- data/lib/openhab/dsl/types/rewind_fastforward_type.rb +0 -33
- data/lib/openhab/dsl/types/stop_move_type.rb +0 -23
- data/lib/openhab/dsl/types/types.rb +0 -83
- data/lib/openhab/dsl/types/un_def_type.rb +0 -22
- data/lib/openhab/dsl/types/up_down_type.rb +0 -32
- data/lib/openhab/dsl/units.rb +0 -45
- data/lib/openhab/log/configuration.rb +0 -21
- data/lib/openhab/log/logger.rb +0 -282
- data/lib/openhab/version.rb +0 -9
- data/lib/openhab.rb +0 -38
@@ -1,147 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'java'
|
4
|
-
require 'forwardable'
|
5
|
-
require_relative 'property'
|
6
|
-
require_relative 'triggers/triggers'
|
7
|
-
require_relative 'guard'
|
8
|
-
require_relative 'rule_triggers'
|
9
|
-
require 'openhab/core/entity_lookup'
|
10
|
-
require 'openhab/dsl/between'
|
11
|
-
require 'openhab/dsl/timers'
|
12
|
-
|
13
|
-
module OpenHAB
|
14
|
-
module DSL
|
15
|
-
#
|
16
|
-
# Creates and manages OpenHAB Rules
|
17
|
-
#
|
18
|
-
module Rules
|
19
|
-
#
|
20
|
-
# Rule configuration for OpenHAB Rules engine
|
21
|
-
#
|
22
|
-
class RuleConfig
|
23
|
-
include OpenHAB::Log
|
24
|
-
include OpenHAB::Core::EntityLookup
|
25
|
-
prepend OpenHAB::DSL::Rules::Triggers
|
26
|
-
include OpenHAB::DSL::Rules::Guard
|
27
|
-
include OpenHAB::DSL::Rules::Property
|
28
|
-
extend Forwardable
|
29
|
-
|
30
|
-
# Provide backwards compatibility for these fields
|
31
|
-
delegate %i[triggers trigger_conditions attachments] => :@rule_triggers
|
32
|
-
|
33
|
-
# @return [Array] Of trigger guards
|
34
|
-
attr_accessor :guard
|
35
|
-
|
36
|
-
# @return [Object] object that invoked rule method
|
37
|
-
attr_accessor :caller
|
38
|
-
|
39
|
-
# @return [Array] Of trigger definitions as passed in Ruby
|
40
|
-
attr_reader :ruby_triggers
|
41
|
-
|
42
|
-
#
|
43
|
-
# Struct holding a run block
|
44
|
-
#
|
45
|
-
Run = Struct.new(:block)
|
46
|
-
|
47
|
-
#
|
48
|
-
# Struct holding a Triggered block
|
49
|
-
#
|
50
|
-
Trigger = Struct.new(:block)
|
51
|
-
|
52
|
-
#
|
53
|
-
# Struct holding an otherwise block
|
54
|
-
#
|
55
|
-
Otherwise = Struct.new(:block)
|
56
|
-
|
57
|
-
#
|
58
|
-
# Struct holding rule delays
|
59
|
-
#
|
60
|
-
Delay = Struct.new(:duration)
|
61
|
-
|
62
|
-
prop_array :run, :array_name => :run_queue, :wrapper => Run
|
63
|
-
prop_array :triggered, :array_name => :run_queue, :wrapper => Trigger
|
64
|
-
prop_array :delay, :array_name => :run_queue, :wrapper => Delay
|
65
|
-
prop_array :otherwise, :array_name => :run_queue, :wrapper => Otherwise
|
66
|
-
|
67
|
-
prop :uid
|
68
|
-
prop :name
|
69
|
-
prop :description
|
70
|
-
prop :tags
|
71
|
-
prop :enabled
|
72
|
-
prop :between
|
73
|
-
|
74
|
-
#
|
75
|
-
# Create a new RuleConfig
|
76
|
-
#
|
77
|
-
# @param [Object] caller_binding The object initializing this configuration.
|
78
|
-
# Used to execute within the object's context
|
79
|
-
#
|
80
|
-
def initialize(caller_binding)
|
81
|
-
@rule_triggers = RuleTriggers.new
|
82
|
-
@caller = caller_binding.eval 'self'
|
83
|
-
@ruby_triggers = []
|
84
|
-
enabled(true)
|
85
|
-
on_start(false)
|
86
|
-
tags([])
|
87
|
-
end
|
88
|
-
|
89
|
-
#
|
90
|
-
# Start this rule on system startup
|
91
|
-
#
|
92
|
-
# @param [Boolean] run_on_start Run this rule on start, defaults to True
|
93
|
-
# @param [Object] attach object to be attached to the trigger
|
94
|
-
#
|
95
|
-
# rubocop: disable Style/OptionalBooleanParameter
|
96
|
-
# Disabled cop due to use in a DSL
|
97
|
-
def on_start(run_on_start = true, attach: nil)
|
98
|
-
@on_start = Struct.new(:enabled, :attach).new(run_on_start, attach)
|
99
|
-
end
|
100
|
-
# rubocop: enable Style/OptionalBooleanParameter
|
101
|
-
|
102
|
-
#
|
103
|
-
# Checks if this rule should run on start
|
104
|
-
#
|
105
|
-
# @return [Boolean] True if rule should run on start, false otherwise.
|
106
|
-
#
|
107
|
-
def on_start?
|
108
|
-
@on_start.enabled
|
109
|
-
end
|
110
|
-
|
111
|
-
#
|
112
|
-
# Get the optional start attachment
|
113
|
-
#
|
114
|
-
# @return [Object] optional user provided attachment to the on_start method
|
115
|
-
#
|
116
|
-
def start_attachment
|
117
|
-
@on_start.attach
|
118
|
-
end
|
119
|
-
|
120
|
-
#
|
121
|
-
# Run the supplied block inside the object instance of the object that created the rule config
|
122
|
-
#
|
123
|
-
# @yield [] Block executed in context of the object creating the rule config
|
124
|
-
#
|
125
|
-
#
|
126
|
-
def my(&block)
|
127
|
-
@caller.instance_eval(&block)
|
128
|
-
end
|
129
|
-
|
130
|
-
#
|
131
|
-
# Inspect the config object
|
132
|
-
#
|
133
|
-
# @return [String] details of the config object
|
134
|
-
#
|
135
|
-
def inspect
|
136
|
-
"Name: (#{name}) " \
|
137
|
-
"Triggers: (#{triggers}) " \
|
138
|
-
"Run blocks: (#{run}) " \
|
139
|
-
"on_start: (#{on_start?}) " \
|
140
|
-
"Trigger Conditions: #{trigger_conditions} " \
|
141
|
-
"Trigger UIDs: #{triggers.map(&:id).join(', ')} " \
|
142
|
-
"Attachments: #{attachments}"
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'openhab/log/logger'
|
4
|
-
require_relative 'trigger'
|
5
|
-
|
6
|
-
module OpenHAB
|
7
|
-
module DSL
|
8
|
-
module Rules
|
9
|
-
#
|
10
|
-
# Module holds rule triggers
|
11
|
-
#
|
12
|
-
module Triggers
|
13
|
-
include OpenHAB::Log
|
14
|
-
|
15
|
-
#
|
16
|
-
# Create a generic trigger given the trigger type uid and a configuration hash
|
17
|
-
#
|
18
|
-
# @param [Type] type Trigger type UID
|
19
|
-
# @param [Object] attach object to be attached to the trigger
|
20
|
-
# @param [Configuration] configuration A hash containing the trigger configuration entries
|
21
|
-
#
|
22
|
-
# @return [Trigger] Trigger object
|
23
|
-
#
|
24
|
-
def trigger(type, attach: nil, **configuration)
|
25
|
-
logger.trace("Creating a generic trigger for type(#{type}) with configuration(#{configuration})")
|
26
|
-
Trigger.new(rule_triggers: @rule_triggers).append_trigger(type: type, config: configuration, attach: attach)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'cron/cron'
|
4
|
-
require_relative 'cron/cron_handler'
|
5
|
-
require_relative 'changed'
|
6
|
-
require_relative 'channel'
|
7
|
-
require_relative 'command'
|
8
|
-
require_relative 'updated'
|
9
|
-
require_relative 'generic'
|
10
|
-
require_relative 'watch/watch'
|
11
|
-
require_relative 'watch/watch_handler'
|
@@ -1,81 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'openhab/log/logger'
|
4
|
-
require 'openhab/dsl/rules/triggers/trigger'
|
5
|
-
|
6
|
-
module OpenHAB
|
7
|
-
module DSL
|
8
|
-
module Rules
|
9
|
-
#
|
10
|
-
# Module holds rule triggers
|
11
|
-
#
|
12
|
-
module Triggers
|
13
|
-
#
|
14
|
-
# Module for watching directories/files
|
15
|
-
#
|
16
|
-
|
17
|
-
#
|
18
|
-
# Create a trigger to watch a path
|
19
|
-
#
|
20
|
-
# @param [String] path to watch
|
21
|
-
# @param [String] glob
|
22
|
-
# @param [Array, Symbol] for types of changes to watch: +:created+, +:deleted+, +:modified+
|
23
|
-
# @param [Object] attach object to be attached to the trigger
|
24
|
-
#
|
25
|
-
# @return [Trigger] Trigger object
|
26
|
-
#
|
27
|
-
def watch(path, glob: '*', for: %i[created deleted modified], attach: nil)
|
28
|
-
glob, path = Watch.glob_for_path(Pathname.new(path), glob)
|
29
|
-
types = [binding.local_variable_get(:for)].flatten
|
30
|
-
config = { path: path.to_s, types: types.map(&:to_s), glob: glob.to_s }
|
31
|
-
|
32
|
-
logger.state 'Creating a watch trigger', path: path, glob: glob, types: types
|
33
|
-
Watch.new(rule_triggers: @rule_triggers).trigger(config: config, attach: attach)
|
34
|
-
end
|
35
|
-
|
36
|
-
#
|
37
|
-
# Creates watch triggers
|
38
|
-
#
|
39
|
-
class Watch < Trigger
|
40
|
-
# Characters in an fnmatch compatible glob
|
41
|
-
GLOB_CHARS = ['**', '*', '?', '[', ']', '{', '}'].freeze
|
42
|
-
private_constant :GLOB_CHARS
|
43
|
-
|
44
|
-
#
|
45
|
-
# Automatically creates globs for supplied paths if necessary
|
46
|
-
#
|
47
|
-
# @param [Pathname] path to check
|
48
|
-
# @param [String] glob
|
49
|
-
#
|
50
|
-
# @return [Pathname,String] Pathname to watch and glob to match
|
51
|
-
#
|
52
|
-
def self.glob_for_path(path, glob)
|
53
|
-
# Checks if the supplied pathname last element contains a glob char
|
54
|
-
if GLOB_CHARS.any? { |char| path.basename.to_s.include? char }
|
55
|
-
# Splits the supplied pathname into a glob string and parent path
|
56
|
-
[path.basename.to_s, path.parent]
|
57
|
-
elsif path.file? || !path.exist?
|
58
|
-
# glob string matching end of Pathname and parent path
|
59
|
-
["*/#{path.basename}", path.parent]
|
60
|
-
else
|
61
|
-
[glob, path]
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
#
|
66
|
-
# Create a watch trigger based on item type
|
67
|
-
#
|
68
|
-
# @param [Config] config Rule configuration
|
69
|
-
# @param [Object] attach object to be attached to the trigger
|
70
|
-
#
|
71
|
-
#
|
72
|
-
def trigger(config:, attach:)
|
73
|
-
append_trigger(type: WatchHandler::WATCH_TRIGGER_MODULE_ID,
|
74
|
-
config: config,
|
75
|
-
attach: attach)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
data/lib/openhab/dsl/states.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'delegate'
|
4
|
-
|
5
|
-
module OpenHAB
|
6
|
-
module DSL
|
7
|
-
#
|
8
|
-
# Manages storing and restoring item state
|
9
|
-
#
|
10
|
-
module States
|
11
|
-
module_function
|
12
|
-
|
13
|
-
#
|
14
|
-
# Store states of supplied items
|
15
|
-
#
|
16
|
-
# @param [Array] items to store states of
|
17
|
-
#
|
18
|
-
# @return [StateStorage] item states
|
19
|
-
#
|
20
|
-
def store_states(*items)
|
21
|
-
items = items.flatten.map do |item|
|
22
|
-
item.respond_to?(:__getobj__) ? item.__getobj__ : item
|
23
|
-
end
|
24
|
-
states = OpenHAB::DSL::Support::StateStorage.from_items(*items)
|
25
|
-
if block_given?
|
26
|
-
yield
|
27
|
-
states.restore
|
28
|
-
end
|
29
|
-
states
|
30
|
-
end
|
31
|
-
|
32
|
-
#
|
33
|
-
# Check if all the given items have a state (not UNDEF or NULL)
|
34
|
-
#
|
35
|
-
# @param [Array] items whose state must be non-nil
|
36
|
-
# @param [<Type>] things when true, also ensures that all linked things are online
|
37
|
-
#
|
38
|
-
# @return [Boolean] true if all the items have a state, false otherwise
|
39
|
-
#
|
40
|
-
def state?(*items, things: false)
|
41
|
-
items.flatten.all? { |item| (!things || item.things.all?(&:online?)) && item.state? }
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
module Support
|
46
|
-
java_import org.openhab.core.model.script.actions.BusEvent
|
47
|
-
#
|
48
|
-
# Delegates state storage to a Hash providing methods to operate with states
|
49
|
-
#
|
50
|
-
class StateStorage < SimpleDelegator
|
51
|
-
#
|
52
|
-
# Create a StateStorage object that stores the states of the given items
|
53
|
-
#
|
54
|
-
# @param [Array<Item>] items A list of items
|
55
|
-
#
|
56
|
-
# @return [StateStorage] A state storage object
|
57
|
-
#
|
58
|
-
def self.from_items(*items)
|
59
|
-
StateStorage.new(BusEvent.storeStates(*items).to_h)
|
60
|
-
end
|
61
|
-
|
62
|
-
#
|
63
|
-
# Restore the stored states of all items
|
64
|
-
#
|
65
|
-
#
|
66
|
-
def restore
|
67
|
-
BusEvent.restoreStates(to_h)
|
68
|
-
end
|
69
|
-
|
70
|
-
#
|
71
|
-
# Restore states for items that have changed
|
72
|
-
#
|
73
|
-
#
|
74
|
-
def restore_changes
|
75
|
-
BusEvent.restoreStates(select { |item, value| item != value })
|
76
|
-
end
|
77
|
-
|
78
|
-
#
|
79
|
-
# Detect if any item have changed states since being stored
|
80
|
-
#
|
81
|
-
# @return [Boolean] True if any items have changed states, false otherwise
|
82
|
-
#
|
83
|
-
def changed?
|
84
|
-
any? { |item, value| item != value }
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
data/lib/openhab/dsl/things.rb
DELETED
@@ -1,147 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'delegate'
|
4
|
-
require 'java'
|
5
|
-
require 'singleton'
|
6
|
-
|
7
|
-
require 'openhab/log/logger'
|
8
|
-
require 'openhab/dsl/actions'
|
9
|
-
require 'openhab/dsl/lazy_array'
|
10
|
-
|
11
|
-
module OpenHAB
|
12
|
-
module DSL
|
13
|
-
#
|
14
|
-
# Support for OpenHAB Things
|
15
|
-
#
|
16
|
-
module Things
|
17
|
-
java_import org.openhab.core.thing.ThingStatus
|
18
|
-
include OpenHAB::Log
|
19
|
-
|
20
|
-
#
|
21
|
-
# Ruby Delegator for Thing
|
22
|
-
#
|
23
|
-
class Thing < SimpleDelegator
|
24
|
-
# Array wrapper class to allow searching a list of channels
|
25
|
-
# by channel id
|
26
|
-
class ChannelsArray < Array
|
27
|
-
# Allows indexing by both integer as an array or channel id acting like a hash.
|
28
|
-
# @param [Integer, String] index Numeric index or string channel id to search for.
|
29
|
-
def [](index)
|
30
|
-
if index.respond_to?(:to_str)
|
31
|
-
key = index.to_str
|
32
|
-
return find { |channel| channel.uid.id == key }
|
33
|
-
end
|
34
|
-
|
35
|
-
super
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
include OpenHAB::DSL::Actions
|
40
|
-
include OpenHAB::Log
|
41
|
-
|
42
|
-
def initialize(thing)
|
43
|
-
super
|
44
|
-
define_action_methods
|
45
|
-
end
|
46
|
-
|
47
|
-
#
|
48
|
-
# Defines boolean thing status methods
|
49
|
-
# uninitialized?
|
50
|
-
# initializing?
|
51
|
-
# unknown?
|
52
|
-
# online?
|
53
|
-
# offline?
|
54
|
-
# removing?
|
55
|
-
# removed?
|
56
|
-
#
|
57
|
-
# @return [Boolean] true if the thing status matches the name
|
58
|
-
#
|
59
|
-
ThingStatus.constants.each do |thingstatus|
|
60
|
-
define_method("#{thingstatus.to_s.downcase}?") { status == ThingStatus.value_of(thingstatus) }
|
61
|
-
end
|
62
|
-
|
63
|
-
# Returns the list of channels associated with this Thing
|
64
|
-
# @return [Array] channels
|
65
|
-
def channels
|
66
|
-
ChannelsArray.new(super.to_a)
|
67
|
-
end
|
68
|
-
|
69
|
-
private
|
70
|
-
|
71
|
-
java_import org.openhab.core.automation.annotation.RuleAction
|
72
|
-
|
73
|
-
#
|
74
|
-
# Define methods from actions mapped to this thing
|
75
|
-
#
|
76
|
-
#
|
77
|
-
def define_action_methods
|
78
|
-
actions_for_thing(uid).each do |action|
|
79
|
-
methods = action.java_class.declared_instance_methods
|
80
|
-
methods.select { |method| method.annotation_present?(RuleAction.java_class) }
|
81
|
-
.each { |method| define_action_method(action: action, method: method.name) }
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
#
|
86
|
-
# Define a method, delegating to supplied action class
|
87
|
-
#
|
88
|
-
# @param [Object] action object to delegate method to
|
89
|
-
# @param [String] method Name of method to delegate
|
90
|
-
#
|
91
|
-
#
|
92
|
-
def define_action_method(action:, method:)
|
93
|
-
logger.trace("Adding action method '#{method}' to thing '#{uid}'")
|
94
|
-
define_singleton_method(method) do |*args|
|
95
|
-
action.public_send(method, *args)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
#
|
101
|
-
# Wraps all Things in a delegator to underlying set and provides lookup method
|
102
|
-
#
|
103
|
-
class Things
|
104
|
-
include LazyArray
|
105
|
-
include Singleton
|
106
|
-
|
107
|
-
# Gets a specific thing by name in the format binding_id:type_id:thing_id or via the ThingUID
|
108
|
-
# @return Thing specified by name/UID or nil if name/UID does not exist in thing registry
|
109
|
-
def [](uid)
|
110
|
-
uid = generate_thing_uid(uid) unless uid.is_a?(org.openhab.core.thing.ThingUID)
|
111
|
-
thing = $things.get(uid)
|
112
|
-
return unless thing
|
113
|
-
|
114
|
-
logger.trace("Retrieved Thing(#{thing}) from registry for uid: #{uid}")
|
115
|
-
Thing.new(thing)
|
116
|
-
end
|
117
|
-
alias include? []
|
118
|
-
alias key? []
|
119
|
-
|
120
|
-
# explicit conversion to array
|
121
|
-
def to_a
|
122
|
-
$things.getAll.map { |thing| Thing.new(thing) }
|
123
|
-
end
|
124
|
-
|
125
|
-
private
|
126
|
-
|
127
|
-
# Returns a ThingUID given a string like object
|
128
|
-
#
|
129
|
-
# @return ThingUID generated by given name
|
130
|
-
def generate_thing_uid(uid)
|
131
|
-
org.openhab.core.thing.ThingUID.new(*uid.split(':'))
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
module_function
|
136
|
-
|
137
|
-
#
|
138
|
-
# Get all things known to OpenHAB
|
139
|
-
#
|
140
|
-
# @return [Things] all Thing objects known to OpenHAB
|
141
|
-
#
|
142
|
-
def things
|
143
|
-
Things.instance
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
@@ -1,180 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'java'
|
4
|
-
|
5
|
-
module OpenHAB
|
6
|
-
module DSL
|
7
|
-
# Support for time related functions
|
8
|
-
module Between
|
9
|
-
# Manages Month Day Ranges
|
10
|
-
module MonthDayRange
|
11
|
-
include OpenHAB::Log
|
12
|
-
|
13
|
-
# Creates a range that can be compared against MonthDay objects, strings
|
14
|
-
# or anything responding to 'to_date' to see if they are within the range
|
15
|
-
# @return Range object representing a MonthDay Range
|
16
|
-
def self.range(range)
|
17
|
-
raise ArgumentError, 'Supplied object must be a range' unless range.is_a? Range
|
18
|
-
|
19
|
-
start = MonthDay.parse(range.begin)
|
20
|
-
ending = MonthDay.parse(range.end)
|
21
|
-
|
22
|
-
start_range = DayOfYear.new(month_day: start, range: start..ending)
|
23
|
-
ending_range = DayOfYear.new(month_day: ending, range: start..ending)
|
24
|
-
logger.trace "Month Day Range Start(#{start}) - End (#{ending}) - Created from (#{range})"
|
25
|
-
|
26
|
-
range.exclude_end? ? (start_range...ending_range) : (start_range..ending_range)
|
27
|
-
end
|
28
|
-
|
29
|
-
# Checks if supplied range can be converted to a month day range
|
30
|
-
# @param [Range] range to check begin and end values of
|
31
|
-
# @return [Boolean] Returns true if supplied range can be converted to a month day range
|
32
|
-
def self.range?(range)
|
33
|
-
return false unless range.is_a? Range
|
34
|
-
|
35
|
-
MonthDay.day_of_month?(range.begin) && MonthDay.day_of_month?(range.end)
|
36
|
-
end
|
37
|
-
|
38
|
-
# Converts a MonthDay to a day of year
|
39
|
-
# which is represented as a number from 1 to 732 to support comparisions when the range overlaps a year boundary
|
40
|
-
class DayOfYear
|
41
|
-
include Comparable
|
42
|
-
include OpenHAB::Log
|
43
|
-
java_import java.time.LocalDate
|
44
|
-
|
45
|
-
attr_accessor :month_day
|
46
|
-
|
47
|
-
# Number of days in a leap year
|
48
|
-
DAYS_IN_YEAR = 366
|
49
|
-
|
50
|
-
# Create a new MonthDayRange element
|
51
|
-
# @param [MonthDay] month_day MonthDay element
|
52
|
-
# @param [Range] range Underlying MonthDay range
|
53
|
-
#
|
54
|
-
def initialize(month_day:, range:)
|
55
|
-
@month_day = month_day
|
56
|
-
@range = range
|
57
|
-
end
|
58
|
-
|
59
|
-
# Returns the MonthDay advanced by 1 day
|
60
|
-
# Required by Range class
|
61
|
-
def succ
|
62
|
-
next_day_of_month = @month_day.day_of_month + 1
|
63
|
-
next_month = @month_day.month_value
|
64
|
-
|
65
|
-
if next_day_of_month > @month_day.month.max_length
|
66
|
-
next_day_of_month = 1
|
67
|
-
next_month = @month_day.month.plus(1).value
|
68
|
-
end
|
69
|
-
|
70
|
-
DayOfYear.new(month_day: MonthDay.of(next_month, next_day_of_month), range: @range)
|
71
|
-
end
|
72
|
-
|
73
|
-
#
|
74
|
-
# Offset by 1 year if the range begin is greater than the range end
|
75
|
-
# and if the month day is less than the begining of the range
|
76
|
-
# @return [Number] 366 if the month_day should be offset by a year
|
77
|
-
def offset
|
78
|
-
@range.begin > @range.end && month_day < @range.begin ? DAYS_IN_YEAR : 0
|
79
|
-
end
|
80
|
-
|
81
|
-
#
|
82
|
-
# Calculate the day within the range for the underlying month day
|
83
|
-
# @return [Number] Representation of the MonthDay as a number from 1 to 732
|
84
|
-
def day_in_range
|
85
|
-
@day_in_range ||= month_day.max_day_of_year + offset
|
86
|
-
end
|
87
|
-
|
88
|
-
# Compare MonthDayRangeElement to other objects as required by Range class
|
89
|
-
def <=>(other) # rubocop:disable Metrics/AbcSize
|
90
|
-
case other
|
91
|
-
when DayOfYear then day_in_range.<=>(other.day_in_range)
|
92
|
-
when MonthDay then self.<=>(DayOfYear.new(month_day: other, range: @range))
|
93
|
-
when LocalDate then self.<=>(MonthDay.of(other.month_value, other.day_of_month))
|
94
|
-
when Date then self.<=>(MonthDay.of(other.month, other.day))
|
95
|
-
else
|
96
|
-
return self.<=>(other.to_local_date) if other.respond_to?(:to_local_date)
|
97
|
-
return self.<=>(other.to_date) if other.respond_to?(:to_date)
|
98
|
-
|
99
|
-
raise "Unable to convert #{other.class} to compare to MonthDay"
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
java_import java.time.MonthDay
|
106
|
-
# Extend MonthDay java object with some helper methods
|
107
|
-
class MonthDay
|
108
|
-
include OpenHAB::Log
|
109
|
-
java_import java.time.format.DateTimeFormatter
|
110
|
-
java_import java.time.Month
|
111
|
-
|
112
|
-
#
|
113
|
-
# Constructor
|
114
|
-
#
|
115
|
-
# @param [Integer] m month
|
116
|
-
# @param [Integer] d day of month
|
117
|
-
#
|
118
|
-
# @return [Object] MonthDay object
|
119
|
-
#
|
120
|
-
def self.new(m:, d:) # rubocop:disable Naming/MethodParameterName
|
121
|
-
MonthDay.of(m, d)
|
122
|
-
end
|
123
|
-
|
124
|
-
# Calcalute the maximum number of days in a year before a supplied month
|
125
|
-
# @return [Number] maximum nummber of days in a year before this month
|
126
|
-
def max_days_before(month)
|
127
|
-
java.time.Month.values.select { |i| i < month }.sum(&:max_length)
|
128
|
-
end
|
129
|
-
|
130
|
-
# Parse MonthDay string as defined with by Monthday class without leading double dash "--"
|
131
|
-
def self.parse(string)
|
132
|
-
logger.trace("#{self.class}.parse #{string} (#{string.class})")
|
133
|
-
java_send :parse, [java.lang.CharSequence, java.time.format.DateTimeFormatter],
|
134
|
-
string.to_s,
|
135
|
-
DateTimeFormatter.ofPattern('[--]M-d')
|
136
|
-
end
|
137
|
-
|
138
|
-
# Can the supplied object be parsed into a MonthDay
|
139
|
-
def self.day_of_month?(obj)
|
140
|
-
/^-*[01][0-9]-[0-3]\d$/.match? obj.to_s
|
141
|
-
end
|
142
|
-
|
143
|
-
# Get the maximum (supports leap years) day of the year this month day could be
|
144
|
-
def max_day_of_year
|
145
|
-
day_of_month + max_days_before(month)
|
146
|
-
end
|
147
|
-
|
148
|
-
# Remove -- from MonthDay string representation
|
149
|
-
def to_s
|
150
|
-
to_string.delete_prefix('--')
|
151
|
-
end
|
152
|
-
|
153
|
-
# Checks if MonthDay is between the dates of the supplied range
|
154
|
-
# @param [Range] range to check against MonthDay
|
155
|
-
# @return [true,false] true if the MonthDay falls within supplied range, false otherwise
|
156
|
-
def between?(range)
|
157
|
-
MonthDayRange.range(range).cover? self
|
158
|
-
end
|
159
|
-
|
160
|
-
# remove the inherited #== method to use our <=> below
|
161
|
-
remove_method :==
|
162
|
-
|
163
|
-
# Extends MonthDay comparison to support Strings
|
164
|
-
# Necessary to support mixed ranges of Strings and MonthDay types
|
165
|
-
# @return [Number, nil] -1,0,1 if other MonthDay is less than, equal to, or greater than this MonthDay
|
166
|
-
def <=>(other)
|
167
|
-
case other
|
168
|
-
when String
|
169
|
-
self.<=>(MonthDay.parse(other))
|
170
|
-
when OpenHAB::DSL::Between::MonthDayRange::DayOfYear
|
171
|
-
# Compare with DayOfYear and invert result
|
172
|
-
-(other <=> self)
|
173
|
-
else
|
174
|
-
super
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|