Class: Node::IF
- Defined in:
- ext/internal/node/nodeinfo.c,
ext/internal/node/nodeinfo.c,
ext/cached/ruby-1.8.4/internal/node/nodeinfo.c,
ext/cached/ruby-1.8.4/internal/node/nodeinfo.c,
ext/cached/ruby-1.8.5/internal/node/nodeinfo.c,
ext/cached/ruby-1.8.5/internal/node/nodeinfo.c,
ext/cached/ruby-1.8.6/internal/node/nodeinfo.c,
ext/cached/ruby-1.8.6/internal/node/nodeinfo.c,
ext/cached/ruby-1.8.7/internal/node/nodeinfo.c,
ext/cached/ruby-1.8.7/internal/node/nodeinfo.c,
ext/cached/ruby-1.9.1/internal/node/nodeinfo.c,
ext/cached/ruby-1.9.1/internal/node/nodeinfo.c,
ext/cached/ruby-1.9.2/internal/node/nodeinfo.c,
ext/cached/ruby-1.9.2/internal/node/nodeinfo.c,
ext/cached/ruby-1.9.3/internal/node/nodeinfo.c,
ext/cached/ruby-1.9.3/internal/node/nodeinfo.c
Overview
Represents a conditional of the form:
if cond then
body
end
or the form:
if cond then
body
else
else
end
The condition is first evaluated. If it is true, then body is evaluated, otherwise else is evaluated. The result is the value of the expression evaluated, or nil if there was no expression present.
A conditional block using elsif has another IF node as the else expression.
Class Method Summary collapse
-
.members ⇒ Array
Return an array of strings containing the names of the node class’s members.
Instance Method Summary collapse
-
#body ⇒ Object
Return the Node’s body member.
-
#cond ⇒ Object
Return the Node’s cond member.
-
#else ⇒ Object
Return the Node’s else member.
Methods inherited from Node
#[], #_dump, _load, #address, #bytecode_compile, compile_string, #eval, #flags, #inspect, #members, #nd_file, #nd_line, #nd_type, #obfusc, #pretty_print, #swap, #to_a, #tree, type
Class Method Details
.members ⇒ Array
Return an array of strings containing the names of the node class’s members.
2793 2794 2795 2796 |
# File 'ext/internal/node/nodeinfo.c', line 2793
VALUE node_s_members(VALUE klass)
{
return rb_iv_get(klass, "__member__");
}
|
Instance Method Details
#body ⇒ Object
Return the Node’s body member. The return type is either a Node or an Object.
2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 |
# File 'ext/internal/node/nodeinfo.c', line 2076
static VALUE node_body(VALUE self)
{
NODE * n;
Data_Get_Struct(self, NODE, n);
if(TYPE(n->nd_body) == T_NODE)
{
if(0 && nd_type(n) == NODE_OP_ASGN2)
{
return wrap_node_as(
(NODE *)n->nd_body,
rb_cNodeSubclass[NODE_OP_ASGN2_ARG]);
}
else
{
return wrap_node((NODE *)n->nd_body);
}
}
else
{
return (VALUE)n->nd_body;
}
}
|
#cond ⇒ Object
Return the Node’s cond member. The return type is either a Node or an Object.
2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 |
# File 'ext/internal/node/nodeinfo.c', line 2129
static VALUE node_cond(VALUE self)
{
NODE * n;
Data_Get_Struct(self, NODE, n);
if(TYPE(n->nd_cond) == T_NODE)
{
if(0 && nd_type(n) == NODE_OP_ASGN2)
{
return wrap_node_as(
(NODE *)n->nd_cond,
rb_cNodeSubclass[NODE_OP_ASGN2_ARG]);
}
else
{
return wrap_node((NODE *)n->nd_cond);
}
}
else
{
return (VALUE)n->nd_cond;
}
}
|
#else ⇒ Object
Return the Node’s else member. The return type is either a Node or an Object.
2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 |
# File 'ext/internal/node/nodeinfo.c', line 2237
static VALUE node_else(VALUE self)
{
NODE * n;
Data_Get_Struct(self, NODE, n);
if(TYPE(n->nd_else) == T_NODE)
{
if(0 && nd_type(n) == NODE_OP_ASGN2)
{
return wrap_node_as(
(NODE *)n->nd_else,
rb_cNodeSubclass[NODE_OP_ASGN2_ARG]);
}
else
{
return wrap_node((NODE *)n->nd_else);
}
}
else
{
return (VALUE)n->nd_else;
}
}
|