Module: Rucoa::NodeConcerns::Variable

Instance Method Summary collapse

Instance Method Details

#nameString

Examples:

returns variable name

node = Rucoa::Source.new(
  content: <<~RUBY,
    foo = 1
    foo
  RUBY
  uri: 'file:///path/to/example.rb'
).node_at(
  Rucoa::Position.new(
    column: 0,
    line: 2
  )
)
expect(node.name).to eq('foo')

Returns:

  • (String)


21
22
23
# File 'lib/rucoa/node_concerns/variable.rb', line 21

def name
  children[0].to_s
end