本文整理汇总了C#中Ruby.Array类的典型用法代码示例。如果您正苦于以下问题:C# Array类的具体用法?C# Array怎么用?C# Array使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Array类属于Ruby命名空间,在下文中一共展示了Array类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Call
public override object Call(Class last_class, object recv, Frame caller, Proc block, Array rest)
{
object time, t;
long seconds = 0;
long uSeconds = 0;
if (Class.rb_scan_args(caller, rest, 1, 1, false) == 2)
{
time = rest[0];
t = rest[1];
seconds = Numeric.rb_num2long(rest[0], caller);
uSeconds = Numeric.rb_num2long(rest[1], caller);
}
else
{
time = rest[0];
Time.rb_time_timeval(rest[0], out seconds, out uSeconds, caller);
}
if (time is Time)
{
bool gmt = ((Time)time).gmt;
t = Time.time_new_internal(seconds, uSeconds, gmt, caller);
}
else
{
t = Time.time_new_internal(seconds, uSeconds, false, caller);
((Time)t).value = ((Time)t).value.ToLocalTime();
}
return t;
}
示例2: GETASTER
internal static int GETASTER(ref int t, ref int p, out int n, int end,
string fmtString, ref int posArg, ref int nextArg,
object nextValue, object tmp, Array argv, Frame caller)
{
t = p++;
n = 0;
for (; p < end && char.IsDigit(fmtString[p]); p++)
{
n = 10 * n + (fmtString[p] - '0');
}
if (p >= end)
{
throw new ArgumentError("malformed format string - %*[0-9]").raise(caller);
}
if (fmtString[p] == '$')
{
tmp = GETPOSARG(caller, n, ref posArg, argv);
}
else
{
tmp = GETARG(caller, ref posArg, ref nextArg, nextValue, argv);
p = t;
}
return Numeric.rb_num2long(tmp, caller);
}
示例3: Call
public override object Call(Class last_class, object recv, Frame caller, Proc block, Array rest)
{
if ((rest.Count == 0) || ((rest.Count == 0) && (rest.value[0].Equals(recv))))
return recv;
return Eval.CallPrivate(rest.value[0], caller, "new", block, rest);
}
示例4: Call
public override object Call(Class last_class, object str, Frame caller, Proc block, Array argv)
{
int argc = argv.Count;
object result;
if (argc < 1 || 2 < argc)
{
throw new ArgumentError(string.Format(CultureInfo.InvariantCulture, "wrong number of arguments ({0} for 1)", argc)).raise(caller);
}
Array buf = new Array();
int i;
for (i = 0; i < argc; i++)
{
buf.Add(argv[i]);
}
result = rb_str_aref_m.singleton.Call(last_class, str, caller, null, buf);
if (result != null)
{
buf.Add(new String());
rb_str_aset_m.singleton.Call(last_class, str, caller, null, buf);
}
return result;
}
示例5: Call
public override object Call(Class klass, object recv, Frame caller, Proc block, Array rest)
{
int count = Class.rb_scan_args(caller, rest, 1, 1, false);
if (block != null && count == 2)
{
Errors.rb_warn("block supersedes default value argument");
}
object if_none = null;
if (count == 2)
if_none = rest[1];
string name = String.StringValue(rest[0], caller);
string val = System.Environment.GetEnvironmentVariable(name);
if (val == null)
{
if (block != null)
return Proc.rb_yield(block, caller, rest[0]);
if (if_none != null)
return if_none;
throw new IndexError("key not found").raise(caller);
}
else if (Env.PATH_ENV.Equals(name, System.StringComparison.OrdinalIgnoreCase) && !Env.rb_env_path_tainted())
return new String(val);
else
return Env.env_str_new2(caller, val);
}
示例6: Call
public override object Call(Class last_class, object recv, Frame caller, Proc block, Array rest)
{
int i = Numeric.rb_num2long(recv, caller);
if (rest.Count == 0)
return new String(i.ToString(CultureInfo.InvariantCulture));
return rb_big_to_s.singleton.Call(last_class, new Bignum(i), caller, block, rest);
}
示例7: rb_struct_define
internal static Class rb_struct_define(string name, Frame caller, params string[] members)
{
Array ary = new Array();
foreach (string mem in members)
ary.Add(new Symbol(mem));
return make_struct(name, ary, Ruby.Runtime.Init.rb_cStruct, caller);
}
示例8: Call0
public override object Call0(Class last_class, object recv, Frame caller, Proc block)
{
Array memo = new Array();
Eval.CallPrivate(recv, caller, "each", new Proc(null, null, new to_a(memo), 1));
return memo;
}
示例9: Call0
public override object Call0(Class last_class, object recv, Frame caller, Proc block)
{
Array ary = new Array();
foreach (uint id in Symbol.sym_tbl.Values)
{
ary.Add(new Symbol(id));
}
return ary;
}
示例10: Call
public override object Call(Class last_class, object recv, Frame caller, Proc block, Array rest)
{
if (rest.Count > 0)
if (rest[0] is Class)
return each_object((Class)rest[0], caller, block);
else
throw new TypeError("class or module required").raise(caller);
else
return each_object(null, caller, block);
}
示例11: GETNTHARG
internal static object GETNTHARG(Frame caller, int nth, Array argv)
{
if (nth >= argv.Count)
{
throw new ArgumentError("too few arguments.").raise(caller);
}
else
{
return argv[nth];
}
}
示例12: Call
public override object Call(Class last_class, object recv, Frame caller, Proc block, Array rest)
{
Array ary;
if (rest.Count < 0)
throw new ArgumentError("negative number of arguments").raise(caller);
if (rest.Count > 0)
ary = new Array((Class)recv, rest);
else
ary = new Array((Class)recv);
return ary;
}
示例13: raise
public RubyException raise(Frame caller)
{
Array backtrace = new Array();
Frame frame = caller;
while (frame != null)
{
backtrace.Add(new String(frame.callPoint()));
frame = frame.caller;
}
this.instance_variable_set("bt", backtrace);
return rubyException;
}
示例14: Call
public override object Call(Class last_class, object recv, Frame caller, Proc block, Array rest)
{
if (((IO)recv).f != null)
throw new RuntimeError("reinitializing File").raise(caller);
int fd;
if (0 < rest.Count && rest.Count < 3)
{
fd = Object.CheckConvert<int>(rest[0], "to_int", caller);
if (fd > 0)
return rb_io_initialize.singleton.Call(last_class, recv, caller, block, fd, rest);
}
return IO.rb_open_file((IO)recv, caller, rest);
}
示例15: make_struct
internal static Class make_struct(string name, Array members, Class klass, Frame caller)
{
// Compiler Bug???: Found bug here the following code crashes this method:
// Customer = Struct.new( :name, :address, :zip )
// FIXME: OBJ_FREEZE(members);
Class nstr = null;
if (name == null)
{
nstr = new Class(null, klass, Class.Type.Class);
Class.rb_make_metaclass(nstr, klass.my_class);
nstr.class_inherited(klass, caller);
}
else
{
if (!Symbol.is_const_id(name))
{
throw new NameError("identifier " + name + " needs to be constant").raise(caller);
}
if (klass.const_defined(name, false))
{
// rb_warn
klass.remove_const(name);
}
nstr = Class.rb_define_class_under(klass, name, klass, caller);
}
nstr.instance_variable_set("__size__", members.Count);
nstr.instance_variable_set("__members__", members);
Class.rb_define_alloc_func(nstr, Methods.struct_alloc.singleton);
Class.rb_define_singleton_method(nstr, "new", Methods.rb_class_new_instance.singleton, -1, caller);
Class.rb_define_singleton_method(nstr, "[]", Methods.rb_class_new_instance.singleton, -1, caller);
Class.rb_define_singleton_method(nstr, "members", Methods.rb_struct_s_members.singleton, 0, caller);
foreach (object m in members)
{
string id = Symbol.rb_to_id(caller, m);
if (Symbol.is_local_id(id) || Symbol.is_const_id(id))
{
Class.rb_define_method(nstr, id, new AttrReaderMethodBody(id), 0, caller);
Class.rb_define_method(nstr, id + "=", new AttrWriterMethodBody(id), 1, caller);
}
}
return nstr;
}