Class: Grammar::Ruby::Code::While
Direct Known Subclasses
Until
Constant Summary
False, FalseTerminator, Implicit, Nil, Self, True
Instance Method Summary
collapse
[], #_and, #_assign, #_classname, #_code_self, #_data, #_def, #_dot, #_else, #_ensure, #_equal, #_immediate, #_inspect, #_locals, #_mid, #_not, #_or, #_question, #_rand, #_rcond, #_rescue, #_ror, #_rstep, #_splat, #_step, #_to_block, #_unless, #_until, #_while, #method_missing
Constructor Details
#initialize(condition, body = nil) ⇒ While
Returns a new instance of While.
985
986
987
988
|
# File 'lib/grammar/ruby/code.rb', line 985
def initialize(condition, body=nil)
@condition = condition
@body = body && body._mid([])[0]
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Grammar::Ruby::Code
Instance Method Details
#_always ⇒ Object
1014
1015
1016
|
# File 'lib/grammar/ruby/code.rb', line 1014
def _always
false
end
|
#_codes ⇒ Object
989
990
991
992
993
|
# File 'lib/grammar/ruby/code.rb', line 989
def _codes
codes = [@condition]
codes << @body if @body
codes
end
|
994
995
996
|
# File 'lib/grammar/ruby/code.rb', line 994
def
"while"
end
|
#_lines(text, indent = 0, op = nil, maxlen = 72) ⇒ Object
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
|
# File 'lib/grammar/ruby/code.rb', line 997
def _lines(text, indent=0, op=nil, maxlen=72)
(last = text.last).concat() << ?\(
single = @condition._lines(text, indent+3, nil, maxlen) or
text << indent+2 << ""
text.last << ?\)
if @body
text << indent+2 << ""
@body._lines(text, indent+2, nil, maxlen)
single = nil
end
if single
text.last.concat("; end")
else
text << indent << "end"
nil
end
end
|
#_never ⇒ Object
1017
1018
1019
|
# File 'lib/grammar/ruby/code.rb', line 1017
def _never
false
end
|