Class: RBS::Prototype::RB::Context

Inherits:
Struct
  • Object
show all
Defined in:
lib/rbs/prototype/rb.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#in_defObject

Returns the value of attribute in_def

Returns:

  • (Object)

    the current value of in_def



8
9
10
# File 'lib/rbs/prototype/rb.rb', line 8

def in_def
  @in_def
end

#module_functionObject

Returns the value of attribute module_function

Returns:

  • (Object)

    the current value of module_function



8
9
10
# File 'lib/rbs/prototype/rb.rb', line 8

def module_function
  @module_function
end

#namespaceObject

Returns the value of attribute namespace

Returns:

  • (Object)

    the current value of namespace



8
9
10
# File 'lib/rbs/prototype/rb.rb', line 8

def namespace
  @namespace
end

#singletonObject

Returns the value of attribute singleton

Returns:

  • (Object)

    the current value of singleton



8
9
10
# File 'lib/rbs/prototype/rb.rb', line 8

def singleton
  @singleton
end

Class Method Details

.initial(namespace: Namespace.root) ⇒ Object



11
12
13
# File 'lib/rbs/prototype/rb.rb', line 11

def self.initial(namespace: Namespace.root)
  self.new(module_function: false, singleton: false, namespace: namespace, in_def: false)
end

Instance Method Details

#attribute_kindObject



25
26
27
28
29
30
31
# File 'lib/rbs/prototype/rb.rb', line 25

def attribute_kind
  if singleton
    :singleton
  else
    :instance
  end
end

#enter_namespace(namespace) ⇒ Object



33
34
35
# File 'lib/rbs/prototype/rb.rb', line 33

def enter_namespace(namespace)
  Context.initial(namespace: self.namespace + namespace)
end

#method_kindObject



15
16
17
18
19
20
21
22
23
# File 'lib/rbs/prototype/rb.rb', line 15

def method_kind
  if singleton
    :singleton
  elsif module_function
    :singleton_instance
  else
    :instance
  end
end

#update(module_function: self.module_function, singleton: self.singleton, in_def: self.in_def) ⇒ Object



37
38
39
# File 'lib/rbs/prototype/rb.rb', line 37

def update(module_function: self.module_function, singleton: self.singleton, in_def: self.in_def)
  Context.new(module_function: module_function, singleton: singleton, namespace: namespace, in_def: in_def)
end