Class: Frepl::Subroutine

Inherits:
MultilineStatement show all
Defined in:
lib/frepl/statements/subroutine.rb

Instance Attribute Summary

Attributes inherited from MultilineStatement

#lines

Instance Method Summary collapse

Methods inherited from MultilineStatement

#complete?, #incomplete?, #initialize, #output

Methods inherited from Statement

#incomplete?, #output

Constructor Details

This class inherits a constructor from Frepl::MultilineStatement

Instance Method Details

#==(other) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/frepl/statements/subroutine.rb', line 15

def ==(other)
  if other.is_a?(Subroutine)
    self.name == other.name
  else
    super(other)
  end
end

#accept(visitor) ⇒ Object



7
8
9
# File 'lib/frepl/statements/subroutine.rb', line 7

def accept(visitor)
  visitor.visit_subroutine(self)
end

#nameObject



11
12
13
# File 'lib/frepl/statements/subroutine.rb', line 11

def name
  @name ||= lines.first.match(Frepl::Classifier::SUBROUTINE_REGEX)[1]
end

#terminal_regexObject



3
4
5
# File 'lib/frepl/statements/subroutine.rb', line 3

def terminal_regex
  /end subroutine\s?#{Frepl::Classifier::VARIABLE_NAME_REGEX}/
end