Sha256: a243467a1164995f84a82f21822199a26cd803cf5076fd3c057fa84771b2b9f3

Contents?: true

Size: 888 Bytes

Versions: 39

Compression:

Stored size: 888 Bytes

Contents

// -*- c++ -*-
#include "rucy/symbol.h"


#include "rucy/rucy.h"
#include "rucy/value.h"


namespace Rucy
{


	Symbol::Symbol ()
	:	sym(0)
	{
	}

	Symbol::Symbol (const char* s)
	:	sym(rb_intern(s))
	{
	}

	Symbol::Symbol (const char* s, size_t len)
	:	sym(rb_intern2(s, len))
	{
	}

	Symbol::Symbol (RubySymbol symbol)
	:	sym(symbol)
	{
	}

	RubySymbol
	Symbol::symbol () const
	{
		return sym;
	}

	Value
	Symbol::value () const
	{
		if (sym == 0) return nil();
		return ID2SYM(sym);
	}

	const char*
	Symbol::c_str () const
	{
		return rb_id2name(sym);
	}

	Symbol::operator bool () const
	{
		return sym != 0;
	}

	bool
	Symbol::operator ! () const
	{
		return !operator bool();
	}

	bool
	operator == (const Symbol& lhs, const Symbol& rhs)
	{
		return lhs.sym == rhs.sym;
	}

	bool
	operator != (const Symbol& lhs, const Symbol& rhs)
	{
		return !operator==(lhs, rhs);
	}


}// Rucy

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
rucy-0.3 src/symbol.cpp
rucy-0.2.1 src/symbol.cpp
rucy-0.2 src/symbol.cpp
rucy-0.1.44 src/symbol.cpp
rucy-0.1.43 src/symbol.cpp
rucy-0.1.42 src/symbol.cpp
rucy-0.1.41 src/symbol.cpp
rucy-0.1.40 src/symbol.cpp
rucy-0.1.39 src/symbol.cpp
rucy-0.1.38 src/symbol.cpp
rucy-0.1.37 src/symbol.cpp
rucy-0.1.36 src/symbol.cpp
rucy-0.1.35 src/symbol.cpp
rucy-0.1.34 src/symbol.cpp
rucy-0.1.33 src/symbol.cpp
rucy-0.1.32 src/symbol.cpp
rucy-0.1.31 src/symbol.cpp
rucy-0.1.30 src/symbol.cpp
rucy-0.1.29 src/symbol.cpp
rucy-0.1.28 src/symbol.cpp