class TypedRb::ParsingContext
Helper class used to keep an stack of type signatures being parsed.
Public Class Methods
new()
click to toggle source
# File lib/typed/runtime/parser_context.rb, line 5 def initialize @types_stack = [] end
Public Instance Methods
context_name()
click to toggle source
# File lib/typed/runtime/parser_context.rb, line 24 def context_name @types_stack.last.join('::') end
path_name()
click to toggle source
# File lib/typed/runtime/parser_context.rb, line 28 def path_name @types_stack.map { |key| key[1] }.join('::') end
pop()
click to toggle source
# File lib/typed/runtime/parser_context.rb, line 13 def pop @types_stack.pop end
push(type)
click to toggle source
# File lib/typed/runtime/parser_context.rb, line 9 def push(type) @types_stack << type end
singleton_class?()
click to toggle source
# File lib/typed/runtime/parser_context.rb, line 32 def singleton_class? @types_stack.last.first == :self rescue false end
with_type(type) { || ... }
click to toggle source
# File lib/typed/runtime/parser_context.rb, line 17 def with_type(type) push type result = yield pop result end