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

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContext

Returns a new instance of Context.

Parameters:

  • module_function: (Boolean)
  • singleton: (Boolean)
  • namespace: (Namespace)
  • in_def: (Boolean)


17
# File 'sig/prototype/rb.rbs', line 17

def initialize: (module_function: bool, singleton: bool, namespace: Namespace, in_def: bool) -> void

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) ⇒ Context

Parameters:

  • namespace: (Namespace) (defaults to: Namespace.root)

Returns:



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_kind:singleton, :instance

Returns:

  • (:singleton, :instance)


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) ⇒ Context

Parameters:

Returns:



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

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

#method_kindmethod_kind

Returns:



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) ⇒ Context

Parameters:

  • module_function: (Boolean) (defaults to: self.module_function)
  • singleton: (Boolean) (defaults to: self.singleton)
  • in_def: (Boolean) (defaults to: self.in_def)

Returns:



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