Module: RedSnow

Includes:
Binding
Defined in:
lib/redsnow/object.rb,
lib/redsnow.rb,
lib/redsnow/version.rb,
lib/redsnow/binding.rb,
lib/redsnow/blueprint.rb,
lib/redsnow/parseresult.rb

Overview

The classes in this module should be 1:1 with the Snow Crash AST counterparts (github.com/apiaryio/snowcrash/blob/master/src/Blueprint.h).

Defined Under Namespace

Modules: Binding Classes: Action, Blueprint, BlueprintNode, ErrorCodes, Headers, KeyValueCollection, Location, Metadata, NamedBlueprintNode, Object, Parameter, Parameters, ParseResult, Payload, Resource, ResourceGroup, TransactionExample, WarningCodes

Constant Summary

VERSION =

Gem version

"0.0.8"

Class Method Summary (collapse)

Class Method Details

+ (Blueprint, ParseResult) parse(rawBlueprint, options = 0)

parse parsing API Blueprint into Ruby objects

Parameters:

  • rawBlueprint (String)

    API Blueprint

  • options (Number) (defaults to: 0)

    Parsing Options

Returns:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/redsnow.rb', line 15

def self.parse(rawBlueprint, options = 0)
  blueprint = FFI::MemoryPointer.new :pointer
  result = FFI::MemoryPointer.new :pointer
  ret = RedSnow::Binding.sc_c_parse(rawBlueprint, options, result, blueprint)

  blueprint = blueprint.get_pointer(0)
  result = result.get_pointer(0)

  bp = Blueprint.new(blueprint)
  parseResult = ParseResult.new(result)

  return bp, parseResult
ensure
  RedSnow::Binding.sc_blueprint_free(blueprint)
  RedSnow::Binding.sc_result_free(result)
end