Class: CqlRuby::FilterReader

Inherits:
Object
  • Object
show all
Defined in:
lib/cql_ruby/filter_reader.rb

Overview

Reads and provides filters.

Accepted filters and syntax:

Type:

type:(,[name])* example: type:def,send

Defined Under Namespace

Classes: HierarchyPattern, NodeSpec

Constant Summary collapse

NESTING_ALLOWED_TYPES =
%w[class module def block].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_filters = []) ⇒ FilterReader

Returns a new instance of FilterReader.



71
72
73
74
75
76
77
78
79
80
# File 'lib/cql_ruby/filter_reader.rb', line 71

def initialize(raw_filters = [])
  super()

  @allowed_types = []
  @nest_under = []
  @has_leaves = []
  @patterns = []

  parse_raw_filters(raw_filters)
end

Instance Attribute Details

#allowed_typesObject (readonly)

Returns the value of attribute allowed_types.



63
64
65
# File 'lib/cql_ruby/filter_reader.rb', line 63

def allowed_types
  @allowed_types
end

#has_leavesObject (readonly)

Returns the value of attribute has_leaves.



67
68
69
# File 'lib/cql_ruby/filter_reader.rb', line 67

def has_leaves
  @has_leaves
end

#nest_underObject (readonly)

Returns the value of attribute nest_under.



65
66
67
# File 'lib/cql_ruby/filter_reader.rb', line 65

def nest_under
  @nest_under
end

#patternsObject (readonly)

Returns the value of attribute patterns.



69
70
71
# File 'lib/cql_ruby/filter_reader.rb', line 69

def patterns
  @patterns
end

Instance Method Details

#restrict_children?Boolean

Returns:



90
91
92
# File 'lib/cql_ruby/filter_reader.rb', line 90

def restrict_children?
  !@has_leaves.empty?
end

#restrict_nesting?Boolean

Returns:



86
87
88
# File 'lib/cql_ruby/filter_reader.rb', line 86

def restrict_nesting?
  !@nest_under.empty?
end

#restrict_pattern?Boolean

Returns:



94
95
96
# File 'lib/cql_ruby/filter_reader.rb', line 94

def restrict_pattern?
  !@patterns.empty?
end

#restrict_types?Boolean

Returns:



82
83
84
# File 'lib/cql_ruby/filter_reader.rb', line 82

def restrict_types?
  !@allowed_types.empty?
end