Module: LibLouis

Defined in:
ext/liblouis/liblouis.c

Defined Under Namespace

Classes: BrailleCharacter, BrailleTable, BrailleText, Error, TranslationError

Constant Summary collapse

VERSION =
rb_obj_freeze(rb_usascii_str_new_cstr("0.1.1"))
TABLES_PATH =
rb_obj_freeze(rb_utf8_str_new_cstr(LIBLOUIS_RB_TABLES_DIR))

Class Method Summary collapse

Class Method Details

.debug=(enabled) ⇒ Object



125
126
127
128
129
130
131
132
133
134
# File 'ext/liblouis/liblouis.c', line 125

static VALUE
ll_set_debug(VALUE module, VALUE enabled)
{
    (void)module;
    if (enabled != Qtrue && enabled != Qfalse)
        rb_raise(rb_eTypeError, "debug must be true or false");
    ll_log_level = enabled == Qtrue ? LOU_LOG_DEBUG : LOU_LOG_OFF;
    lou_setLogLevel(ll_log_level);
    return enabled;
}

.debug?Boolean

Returns:



118
119
120
121
122
123
# File 'ext/liblouis/liblouis.c', line 118

static VALUE
ll_debug_p(VALUE module)
{
    (void)module;
    return ll_log_level == LOU_LOG_DEBUG ? Qtrue : Qfalse;
}

.find_table(query) ⇒ Object



149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'ext/liblouis/braille_table.c', line 149

static VALUE
ll_table_find(VALUE owner, VALUE query)
{
    VALUE string = StringValue(query);
    char *file = lou_findTable(StringValueCStr(string));
    VALUE result;

    (void)owner;
    if (!file)
        return Qnil;
    result = ll_table_build(rb_utf8_str_new_cstr(file));
    lou_freeTableFile(file);
    return result;
}

.find_tables(query) ⇒ Object



164
165
166
167
168
169
170
171
# File 'ext/liblouis/braille_table.c', line 164

static VALUE
ll_table_find_all(VALUE owner, VALUE query)
{
    VALUE string = StringValue(query);

    (void)owner;
    return ll_table_list(lou_findTables(StringValueCStr(string)));
}

.freeObject



109
110
111
112
113
114
115
116
# File 'ext/liblouis/liblouis.c', line 109

static VALUE
ll_free_native(VALUE module)
{
    (void)module;
    lou_free();
    ll_restore_native_state();
    return Qnil;
}

.table_pathObject



78
79
80
81
82
83
84
85
# File 'ext/liblouis/liblouis.c', line 78

static VALUE
ll_table_path(VALUE module)
{
    const char *path = getenv("LOUIS_TABLEPATH");

    (void)module;
    return rb_utf8_str_new_cstr(path && path[0] ? path : LIBLOUIS_RB_TABLES_DIR);
}

.table_path=(path) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'ext/liblouis/liblouis.c', line 87

static VALUE
ll_set_table_path(VALUE module, VALUE path)
{
    VALUE string = StringValue(path);
    VALUE environment = rb_const_get(rb_cObject, rb_intern("ENV"));

    (void)module;
    StringValueCStr(string);
    rb_funcall(environment, rb_intern("[]="), 2,
               rb_str_new_cstr("LOUIS_TABLEPATH"), string);
    lou_free();
    return path;
}

.tablesObject



142
143
144
145
146
147
# File 'ext/liblouis/braille_table.c', line 142

static VALUE
ll_table_all(VALUE owner)
{
    (void)owner;
    return ll_table_list(lou_listTables());
}

.versionObject



71
72
73
74
75
76
# File 'ext/liblouis/liblouis.c', line 71

static VALUE
ll_version(VALUE module)
{
    (void)module;
    return rb_usascii_str_new_cstr(lou_version());
}