Class: Y2R::AST::Ruby::Def

Inherits:
Node
  • Object
show all
Defined in:
lib/y2r/ast/ruby.rb

Constant Summary

Constants inherited from Node

Node::INDENT_STEP

Instance Method Summary collapse

Methods inherited from Node

#ends_with_comment?, #ensure_separated, #has_comment?, #hates_to_stand_alone?, #pass_trailer?, #single_line_width, #starts_with_comment?, #to_ruby

Instance Method Details

#priorityObject



335
336
337
# File 'lib/y2r/ast/ruby.rb', line 335

def priority
  Priority::NONE
end

#single_line_width_base(context) ⇒ Object



331
332
333
# File 'lib/y2r/ast/ruby.rb', line 331

def single_line_width_base(context)
  Float::INFINITY   # always multiline
end

#to_ruby_base(context) ⇒ Object



319
320
321
322
323
324
325
326
327
328
329
# File 'lib/y2r/ast/ruby.rb', line 319

def to_ruby_base(context)
  args_shift   = 4 + name.size
  args_context = context.shifted(args_shift).with_priority(priority)
  args_code    = emit_args(args_context)

  combine do |parts|
    parts << "def #{name}#{args_code}"
    parts << indented(statements, context.with_priority(priority))
    parts << "end"
  end
end