Class: Chronar::Parser::ArgumentList

Inherits:
AbstractParslet show all
Defined in:
lib/chronar/parser/argument_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractParslet

#blanks, #bracketed, root

Constructor Details

#initialize(specifiers = [statement], list_range = (0..nil), allow_no_list: true) ⇒ ArgumentList

Returns a new instance of ArgumentList.

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/chronar/parser/argument_list.rb', line 11

def initialize(specifiers = [statement], list_range = (0..nil), allow_no_list: true)
  super()
  if specifiers.is_a?(Range)
    list_range = specifiers
    specifiers = [statement]
  end
  raise ArgumentError, "must use at least one specifier" if specifiers.empty?
  if list_range.end && list_range.end < specifiers.size
    raise ArgumentError, "more specifiers than allowed by list range"
  end

  @specifiers = specifiers
  @list_range = list_range
  @allow_no_list = allow_no_list
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Chronar::Parser::AbstractParslet

Instance Attribute Details

#allow_no_listObject (readonly)

Returns the value of attribute allow_no_list.



9
10
11
# File 'lib/chronar/parser/argument_list.rb', line 9

def allow_no_list
  @allow_no_list
end

#list_rangeObject (readonly)

Returns the value of attribute list_range.



9
10
11
# File 'lib/chronar/parser/argument_list.rb', line 9

def list_range
  @list_range
end

#specifiersObject (readonly)

Returns the value of attribute specifiers.



9
10
11
# File 'lib/chronar/parser/argument_list.rb', line 9

def specifiers
  @specifiers
end