Class: Typerb::VariableName

Inherits:
Object
  • Object
show all
Defined in:
lib/typerb/variable_name.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(caller_loc) ⇒ VariableName

Returns a new instance of VariableName.



7
8
9
10
# File 'lib/typerb/variable_name.rb', line 7

def initialize(caller_loc)
  @file = caller_loc[0].path
  @line = caller_loc[0].lineno
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



5
6
7
# File 'lib/typerb/variable_name.rb', line 5

def file
  @file
end

#lineObject (readonly)

Returns the value of attribute line.



5
6
7
# File 'lib/typerb/variable_name.rb', line 5

def line
  @line
end

Instance Method Details

#getObject



12
13
14
15
16
17
18
# File 'lib/typerb/variable_name.rb', line 12

def get
  return unless defined?(RubyVM::AbstractSyntaxTree)
  return unless File.exist?(file)

  caller_method = caller_locations(1, 1)[0].label.to_sym
  from_ast(caller_method)
end