Class: DeviceMap::Pattern
- Inherits:
-
Object
- Object
- DeviceMap::Pattern
- Includes:
- Comparable
- Defined in:
- lib/device_map/pattern.rb
Instance Attribute Summary collapse
-
#device_id ⇒ Object
readonly
Returns the value of attribute device_id.
-
#keywords ⇒ Object
readonly
Returns the value of attribute keywords.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
-
#initialize(keywords, device_id, priority) ⇒ Pattern
constructor
A new instance of Pattern.
- #matches?(other_keywords) ⇒ Boolean
Constructor Details
Instance Attribute Details
#device_id ⇒ Object (readonly)
Returns the value of attribute device_id.
5 6 7 |
# File 'lib/device_map/pattern.rb', line 5 def device_id @device_id end |
#keywords ⇒ Object (readonly)
Returns the value of attribute keywords.
5 6 7 |
# File 'lib/device_map/pattern.rb', line 5 def keywords @keywords end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
5 6 7 |
# File 'lib/device_map/pattern.rb', line 5 def priority @priority end |
Instance Method Details
#<=>(other) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/device_map/pattern.rb', line 18 def <=>(other) if priority == other.priority keywords.join.size <=> other.keywords.join.size else priority <=> other.priority end end |
#==(other) ⇒ Object
26 27 28 29 30 |
# File 'lib/device_map/pattern.rb', line 26 def ==(other) keywords == other.keywords && device_id == other.device_id && priority == other.priority end |
#matches?(other_keywords) ⇒ Boolean
13 14 15 16 |
# File 'lib/device_map/pattern.rb', line 13 def matches?(other_keywords) diff = keywords - other_keywords diff.empty? end |