Class: Steep::Errors::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/steep/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node:) ⇒ Base

Returns a new instance of Base.



6
7
8
# File 'lib/steep/errors.rb', line 6

def initialize(node:)
  @node = node
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



4
5
6
# File 'lib/steep/errors.rb', line 4

def node
  @node
end

Instance Method Details

#location_to_strObject



10
11
12
# File 'lib/steep/errors.rb', line 10

def location_to_str
  Rainbow("#{node.loc.expression.source_buffer.name}:#{node.loc.first_line}:#{node.loc.column}").red
end


14
15
16
17
# File 'lib/steep/errors.rb', line 14

def print_to(io)
  source = node.loc.expression.source
  io.puts "#{to_s} (#{Rainbow(source.split(/\n/).first).blue})"
end