Module: Wexpr

Defined in:
lib/wexpr.rb,
lib/wexpr/uvlq64.rb,
lib/wexpr/version.rb,
lib/wexpr/exception.rb,
lib/wexpr/expression.rb,
lib/wexpr/private_parser_state.rb

Overview

Ruby-Wexpr library

Currently does not handle Binary Wexpr.

Defined Under Namespace

Modules: UVLQ64 Classes: ArrayMissingEndParenError, BinaryChunkNotBigEnoughError, EmptyStringError, Exception, Expression, ExtraDataAfterParsingRootError, InvalidStringEscapeError, InvalidUTF8Error, MapKeyMustBeAValueError, MapMissingEndParenError, MapNoValueError, PrivateParserState, ReferenceInsertMissingEndBracketError, ReferenceInvalidNameError, ReferenceMissingEndBracketError, ReferenceUnknownReferenceError, StringMissingQuoteError

Constant Summary collapse

VERSION =
"0.1.6"

Class Method Summary collapse

Class Method Details

.dump(variable, writeFlags = []) ⇒ Object

Emit a hash as the equivilant wexpr string, human readable or not. See possible writeflags in Expression. We also support :returnAsExpression which will return the expression, and not the string (for internal use).



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/wexpr.rb', line 26

def self.dump(variable, writeFlags=[])
	# first step, go through the variable and create the equivilant wexpr expressions
	expr = Expression::create_from_ruby(variable)
	
	if writeFlags.include? :returnAsExpression
		return expr
	end
	
	# then have it write out the string
	return expr.create_string_representation(0, writeFlags)
end

.load(str, flags = []) ⇒ Object

Parse Wexpr and turn it into a ruby hash Will thrown an Exception on failure



17
18
19
20
# File 'lib/wexpr.rb', line 17

def self.load(str, flags=[])
	expr = Expression::create_from_string(str, flags)
	return expr.to_ruby
end