Class: Jade::Parsing::Error

Inherits:
Error
  • Object
show all
Defined in:
lib/jade/parsing/error.rb

Instance Attribute Summary collapse

Attributes inherited from Error

#entry, #span

Instance Method Summary collapse

Methods inherited from Error

#candidates, #label, #message, #notes, #queried_name, #to_diagnostic

Constructor Details

#initialize(entry:, span:, actual:, expected:, committed: false, context: []) ⇒ Error

Returns a new instance of Error.



7
8
9
10
11
12
13
# File 'lib/jade/parsing/error.rb', line 7

def initialize(entry:, span:, actual:, expected:, committed: false, context: [])
  super(entry:, span:)
  @actual    = actual
  @expected  = expected
  @committed = committed
  @context   = context
end

Instance Attribute Details

#actualObject (readonly)

Returns the value of attribute actual.



35
36
37
# File 'lib/jade/parsing/error.rb', line 35

def actual
  @actual
end

#contextObject (readonly)

Returns the value of attribute context.



35
36
37
# File 'lib/jade/parsing/error.rb', line 35

def context
  @context
end

#expectedObject (readonly)

Returns the value of attribute expected.



35
36
37
# File 'lib/jade/parsing/error.rb', line 35

def expected
  @expected
end

Instance Method Details

#commitObject



19
20
21
22
# File 'lib/jade/parsing/error.rb', line 19

def commit
  @committed = true
  self
end

#committed?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/jade/parsing/error.rb', line 15

def committed?
  @committed
end

#with_context(name) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/jade/parsing/error.rb', line 24

def with_context(name)
  self.class.new(
    entry:     @entry,
    span:      @span,
    actual:    @actual,
    expected:  @expected,
    committed: @committed,
    context:   [name, *@context],
  )
end