Class: CqlRuby::NestRule

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

Constant Summary collapse

NAME_ANY =
'*'
ALLOWED_TYPE =
%w[class module def block].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



4
5
6
# File 'lib/cql_ruby/filter_reader.rb', line 4

def name
  @name
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



4
5
6
# File 'lib/cql_ruby/filter_reader.rb', line 4

def type
  @type
end

Class Method Details

.from(raw_value) ⇒ Object

Parameters:

  • raw_value (String)

    Format: TYPE(=NAME|=*) Accepted types: class, module, def, block



14
15
16
17
18
19
20
21
22
# File 'lib/cql_ruby/filter_reader.rb', line 14

def from(raw_value)
  type, name = raw_value.split('=')
  name ||= NAME_ANY

  raise "Unknown type: #{type}. Allowed: #{ALLOWED_TYPE}" unless ALLOWED_TYPE.include?(type)
  raise "Type #{type} cannot have a name." if %w[block].include?(type) && name != NAME_ANY

  new(type, name)
end

Instance Method Details

#restrict_name?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/cql_ruby/filter_reader.rb', line 25

def restrict_name?
  name != NAME_ANY
end