Class: RedSnow::ParseResult

Inherits:
Object
  • Object
show all
Defined in:
lib/redsnow/parseresult.rb

Overview

Parse Result

Constant Summary collapse

VERSION_KEY =

Version key

:_version
SUPPORTED_VERSIONS =

Supported version of Api Blueprint

['2.1']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parse_result) ⇒ ParseResult

Returns a new instance of ParseResult.

Parameters:

  • parse_result (string or nil)


23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/redsnow/parseresult.rb', line 23

def initialize(parse_result)
  parse_result = JSON.parse(parse_result)

  @ast = Blueprint.new(parse_result['ast'])
  @sourcemap = RedSnow::Sourcemap::Blueprint.new(parse_result['sourcemap'])

  @warnings = []
  parse_result.key?('warnings') && parse_result['warnings'].each do |warning|
    @warnings << source_annotation(warning)
  end

  @error = source_annotation(parse_result['error'])
end

Instance Attribute Details

#astObject

Returns the value of attribute ast.



11
12
13
# File 'lib/redsnow/parseresult.rb', line 11

def ast
  @ast
end

#errorObject

Returns the value of attribute error.



12
13
14
# File 'lib/redsnow/parseresult.rb', line 12

def error
  @error
end

#sourcemapObject

Returns the value of attribute sourcemap.



14
15
16
# File 'lib/redsnow/parseresult.rb', line 14

def sourcemap
  @sourcemap
end

#warningsObject

Returns the value of attribute warnings.



13
14
15
# File 'lib/redsnow/parseresult.rb', line 13

def warnings
  @warnings
end