الفرق بين المراجعتين ل"Ruby/InstructionSequence/path"

من موسوعة حسوب
اذهب إلى التنقل اذهب إلى البحث
ط (مراجعة وتدقيق.)
 
سطر 1: سطر 1:
<noinclude>{{DISPLAYTITLE: التابع <code>path‎</code> الخاص بالصنف <code>InstructionSequence</code> في روبي}}</noinclude>
+
<noinclude>{{DISPLAYTITLE: التابع <code>InstructionSequence.path‎</code> في روبي}}</noinclude>
 
[[تصنيف: Ruby]]
 
[[تصنيف: Ruby]]
 
[[تصنيف: Ruby Method]]
 
[[تصنيف: Ruby Method]]
سطر 6: سطر 6:
 
==البنية العامة==
 
==البنية العامة==
 
<syntaxhighlight lang="ruby">path()</syntaxhighlight>
 
<syntaxhighlight lang="ruby">path()</syntaxhighlight>
==القيمة المُعادة==
+
==القيمة المعادة==
يُعيد التابع <code>path</code> مسار [[Ruby/InstructionSequence|سلسلة التعليمات]] التي استُدعي معها، أو يعيد <code><compiled></code> إذا تم تقييم [[Ruby/InstructionSequence|سلسلة التعليمات]] انطلاقًا من [[Ruby/String|سلسلة نصية]].
+
يعاد مسار [[Ruby/InstructionSequence|سلسلة التعليمات]] المعطاة، أو يعاد <code><compiled></code> إذا تم تقييم [[Ruby/InstructionSequence|سلسلة التعليمات]] انطلاقًا من [[Ruby/String|سلسلة نصية]].
  
 
==أمثلة==
 
==أمثلة==
 
=== المثال الأول ===
 
 
مثال على استخدام التابع <code>path‎</code> مع irb:
 
مثال على استخدام التابع <code>path‎</code> مع irb:
 
<syntaxhighlight lang="ruby">iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
 
<syntaxhighlight lang="ruby">iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
 
#=> <RubyVM::InstructionSequence:<compiled>@<compiled>>
 
#=> <RubyVM::InstructionSequence:<compiled>@<compiled>>
 
iseq.path
 
iseq.path
#=> "<compiled>"‎</syntaxhighlight>
+
#=> "<compiled>"‎</syntaxhighlight>مثال آخر على استخدام التابع <code>path‎</code> مع <code>[[Ruby/InstructionSequence/compile_file|compile_file]]</code>:<syntaxhighlight lang="ruby"># /tmp/method.rb
 
 
=== المثال الثاني ===
 
مثال على استخدام التابع <code>path‎</code> مع <code>[[Ruby/InstructionSequence/compile_file|compile_file]]</code>:<syntaxhighlight lang="ruby"># /tmp/method.rb
 
 
def hello
 
def hello
 
   puts "hello, world"
 
   puts "hello, world"
سطر 28: سطر 23:
  
 
==انظر أيضا==
 
==انظر أيضا==
* التابع <code>[[Ruby/InstructionSequence/label|label]]</code>: يُعيد تسمية (label) [[Ruby/InstructionSequence|سلسلة التعليمات]] .
+
* التابع <code>[[Ruby/InstructionSequence/label|label]]</code>: يُعيد تسمية (label) [[Ruby/InstructionSequence|سلسلة التعليمات]] .
* التابع <code>[[Ruby/InstructionSequence/to_a|to_a]]</code>: يُعيد [[Ruby/Array|مصفوفة]] (<code>[[Ruby/Array|Array]]</code>) تتألف من 14 عنصرًا يمثلون [[Ruby/InstructionSequence|سلسلة التعليمات]] بالبيانات التالية:
+
* التابع <code>[[Ruby/InstructionSequence/to_a|to_a]]</code>: يُعيد [[Ruby/Array|مصفوفة]] تتألف من 14 عنصرًا يمثلون [[Ruby/InstructionSequence|سلسلة التعليمات]] بالبيانات التالية:
  
 
==مصادر==
 
==مصادر==
*[http://ruby-doc.org/core-2.5.1/RubyVM/InstructionSequence.html#method-i-path قسم التابع path‎ في الصنف InstructionSequence‎ في توثيق روبي الرسمي.]
+
*[http://ruby-doc.org/core-2.5.1/RubyVM/InstructionSequence.html#method-i-path قسم التابع path‎ في الصنف InstructionSequence‎ في توثيق روبي الرسمي.]

المراجعة الحالية بتاريخ 08:16، 4 ديسمبر 2018

يُعيد التابع path مسار سلسلة التعليمات التي استُدعي معها، أو يعيد <compiled> إذا تم تقييم سلسلة التعليمات انطلاقًا من سلسلة نصية.

البنية العامة

path()

القيمة المعادة

يعاد مسار سلسلة التعليمات المعطاة، أو يعاد <compiled> إذا تم تقييم سلسلة التعليمات انطلاقًا من سلسلة نصية.

أمثلة

مثال على استخدام التابع path‎ مع irb:

iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
#=> <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.path
#=> "<compiled>"‎

مثال آخر على استخدام التابع path‎ مع compile_file:

# /tmp/method.rb
def hello
  puts "hello, world"
end
# in irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.path #=> /tmp/method.rb‎

انظر أيضا

مصادر