Class: ERLE::Ref

Inherits:
Term
  • Object
show all
Defined in:
lib/erle/elements/ref.rb

Instance Attribute Summary

Attributes inherited from Term

#input, #output

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Term

enclosure, pattern, to_ruby, until_any_closing

Constructor Details

#initialize(input) ⇒ Ref

Returns a new instance of Ref.



10
11
12
# File 'lib/erle/elements/ref.rb', line 10

def initialize(input)
  @input = input
end

Class Method Details

.parse(parser) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/erle/elements/ref.rb', line 20

def self.parse(parser)

  result = parser.scan(@pattern)

  if close && !parser.scan(close)
    raise parser.raise_unexpected_token("Expected term closure \" #{close.source} \"")
  end

  # Make sure we kill any trailing close
  # TODO: Consider raising if no match?
  # TODO: Consider doing only if we started with an opening...
  # parser.scan(ERLE::Registry.closings_regex)
  new(result)
end

Instance Method Details

#to_rubyObject

TODO: Leverage Enum, and refactor (Enum) to handle conflicting delimiters e.g. a “.” delimeter is preempted by the “float” pattern.



16
17
18
# File 'lib/erle/elements/ref.rb', line 16

def to_ruby
  @output ||= @input.split(".")
end