Class: CqlRuby::HierarchyPattern
- Inherits:
-
Object
- Object
- CqlRuby::HierarchyPattern
- Defined in:
- lib/cql_ruby/filter_reader.rb
Overview
TODO Move this under filter reader namespace.
Constant Summary collapse
- SELF_MARKER =
'X'
Instance Attribute Summary collapse
-
#ancestors ⇒ Object
readonly
Returns the value of attribute ancestors.
-
#descendants ⇒ Object
readonly
Returns the value of attribute descendants.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ancestors, descendants) ⇒ HierarchyPattern
constructor
A new instance of HierarchyPattern.
Constructor Details
#initialize(ancestors, descendants) ⇒ HierarchyPattern
Returns a new instance of HierarchyPattern.
24 25 26 27 |
# File 'lib/cql_ruby/filter_reader.rb', line 24 def initialize(ancestors, descendants) @ancestors = ancestors @descendants = descendants end |
Instance Attribute Details
#ancestors ⇒ Object (readonly)
Returns the value of attribute ancestors.
21 22 23 |
# File 'lib/cql_ruby/filter_reader.rb', line 21 def ancestors @ancestors end |
#descendants ⇒ Object (readonly)
Returns the value of attribute descendants.
22 23 24 |
# File 'lib/cql_ruby/filter_reader.rb', line 22 def descendants @descendants end |
Class Method Details
.from(raw_value) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/cql_ruby/filter_reader.rb', line 10 def self.from(raw_value) parts = raw_value.split('-') self_marker_idx = parts.index(SELF_MARKER) raise "Missing self marker '#{SELF_MARKER}' in hierarchy pattern." if self_marker_idx.nil? ancestors = parts[0...self_marker_idx] descendants = parts[self_marker_idx + 1..] new(ancestors, descendants) end |