Class: Grammar::Ruby::Code::Def
- Inherits:
-
List
show all
- Defined in:
- lib/grammar/ruby/code.rb
Constant Summary
False, FalseTerminator, Implicit, Nil, Self, True
Instance Method Summary
collapse
Methods inherited from List
#_operator, #_operator0, #_paren
[], #_and, #_assign, #_classname, #_code_self, #_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(name, args, body) ⇒ Def
952
953
954
955
956
|
# File 'lib/grammar/ruby/code.rb', line 952
def initialize(name, args, body)
@name = name
@operands = args
@body = body
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
977
978
979
|
# File 'lib/grammar/ruby/code.rb', line 977
def _always
false
end
|
#_codes ⇒ Object
957
958
959
|
# File 'lib/grammar/ruby/code.rb', line 957
def _codes
@operands+[@body]
end
|
#_data ⇒ Object
960
961
962
|
# File 'lib/grammar/ruby/code.rb', line 960
def _data
@name
end
|
#_lines(text, indent = 0, op = nil, maxlen = 72) ⇒ Object
963
964
965
966
967
968
969
970
971
972
973
974
975
976
|
# File 'lib/grammar/ruby/code.rb', line 963
def _lines(text, indent=0, op=nil, maxlen=72)
text << indent << "" unless text.last.empty?
(last = text.last).concat("def ").concat(@name.to_s)
unless @operands.empty?
last << ?\(
super(text, indent+3, nil, maxlen) or
text << indent+2 << ""
text.last << ?\)
end
text << (indent+2) << ""
@body._lines(text, indent+2, nil, maxlen)
text << indent << "end"
nil
end
|
#_never ⇒ Object
980
981
982
|
# File 'lib/grammar/ruby/code.rb', line 980
def _never
false
end
|