Class: Libexttextcat::Candidates
- Inherits:
-
Object
- Object
- Libexttextcat::Candidates
- Includes:
- Enumerable
- Defined in:
- lib/libexttextcat.rb,
ext/libexttextcat/libexttextcat.c
Instance Method Summary collapse
-
#[] ⇒ Object
:call-seq: candidates -> Libexttextcat::Candidate.
-
#each ⇒ Object
:call-seq: each { |candidate| ... } each -> Enumerable.
-
#empty? ⇒ Boolean
:call-seq: empty? -> true or false.
-
#length ⇒ Object
(also: #size)
:call-seq: length -> Integer.
Instance Method Details
#[] ⇒ Object
:call-seq:
candidates[index] -> Libexttextcat::Candidate
181 182 183 184 185 186 187 188 189 190 191 |
# File 'ext/libexttextcat/libexttextcat.c', line 181
static VALUE
rbe_candidates_m_get (VALUE self, VALUE index)
{
RbeCandidates *cs = rb_check_typeddata (self, &rbe_candidates_type);
size_t i = RB_NUM2SIZE (index);
if (i >= cs->num)
rb_raise (rbe_eError, "out of range");
VALUE v = rb_obj_alloc (rbe_cCandidate);
RTYPEDDATA_DATA (v) = &cs->candidates[i];
return v;
}
|
#each ⇒ Object
:call-seq:
each { |candidate| ... }
each -> Enumerable
Yields Libexttextcat::Candidate.
41 42 43 44 45 46 47 |
# File 'lib/libexttextcat.rb', line 41 def each block_given? and return enum_for(:each) (0...length).each do |i| yield self[i] end self end |
#empty? ⇒ Boolean
:call-seq:
empty? -> true or false
52 53 54 |
# File 'lib/libexttextcat.rb', line 52 def empty? 0 == length end |
#length ⇒ Object Also known as: size
:call-seq:
length -> Integer
157 158 159 160 161 162 |
# File 'ext/libexttextcat/libexttextcat.c', line 157
static VALUE
rbe_candidates_m_length (VALUE self)
{
RbeCandidates *cs = rb_check_typeddata (self, &rbe_candidates_type);
return RB_SIZE2NUM (cs->num);
}
|