Class: Syntax::Command

Inherits:
Treetop::Runtime::SyntaxNode
  • Object
show all
Defined in:
lib/dandy/routing/syntax/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#entity_methodObject (readonly)

Returns the value of attribute entity_method.



3
4
5
# File 'lib/dandy/routing/syntax/command.rb', line 3

def entity_method
  @entity_method
end

#entity_nameObject (readonly)

Returns the value of attribute entity_name.



3
4
5
# File 'lib/dandy/routing/syntax/command.rb', line 3

def entity_name
  @entity_name
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/dandy/routing/syntax/command.rb', line 3

def name
  @name
end

#result_nameObject (readonly)

Returns the value of attribute result_name.



3
4
5
# File 'lib/dandy/routing/syntax/command.rb', line 3

def result_name
  @result_name
end

Instance Method Details

#async?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/dandy/routing/syntax/command.rb', line 30

def async?
  @is_async
end

#entity?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/dandy/routing/syntax/command.rb', line 42

def entity?
  @entity_name && @entity_method
end

#parallel?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/dandy/routing/syntax/command.rb', line 34

def parallel?
  @is_parallel
end

#parseObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/dandy/routing/syntax/command.rb', line 5

def parse
  @is_async = text_value.start_with? '=*'
  @is_parallel = text_value.start_with? '=>'
  @is_sequential = text_value.start_with? '*>'

  full_name = text_value.sub('*>', '').sub('=*', '').sub('=>', '')

  if full_name.include? '@'
    parts = full_name.split('@')
    @result_name = parts[0]
    @name = parts[1]
  else
    @result_name = "#{full_name}_result"
    @name = full_name
  end

  if full_name.include? '.'
    parts = full_name.split('.')
    @entity_name = parts[0]
    @entity_method = parts[1]
  end

  self
end

#sequential?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/dandy/routing/syntax/command.rb', line 38

def sequential?
  @is_sequential
end