Class: Y2R::AST::Ruby::Node

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

Constant Summary collapse

INDENT_STEP =
2

Instance Method Summary collapse

Instance Method Details

#ends_with_comment?Boolean

Returns:

  • (Boolean)


117
118
119
# File 'lib/y2r/ast/ruby.rb', line 117

def ends_with_comment?
  comment_after
end

#ensure_separatedObject



129
130
131
132
133
134
135
# File 'lib/y2r/ast/ruby.rb', line 129

def ensure_separated
  if comment_before && !comment_before.start_with?("\n")
    self.comment_before = "\n#{comment_before}"
  else
    self.comment_before = ""
  end
end

#has_comment?Boolean

Returns:

  • (Boolean)


121
122
123
# File 'lib/y2r/ast/ruby.rb', line 121

def has_comment?
  starts_with_comment? || ends_with_comment?
end

#hates_to_stand_alone?Boolean

Returns:

  • (Boolean)


109
110
111
# File 'lib/y2r/ast/ruby.rb', line 109

def hates_to_stand_alone?
  false
end

#pass_trailer?Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/y2r/ast/ruby.rb', line 125

def pass_trailer?
  false
end

#single_line_width(context) ⇒ Object



101
102
103
104
105
106
107
# File 'lib/y2r/ast/ruby.rb', line 101

def single_line_width(context)
  wrap_width_with_comments context do |comments_context|
    wrap_width_with_parens comments_context do |parens_context|
      single_line_width_base(parens_context)
    end
  end
end

#starts_with_comment?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/y2r/ast/ruby.rb', line 113

def starts_with_comment?
  comment_before
end

#to_ruby(context) ⇒ Object



93
94
95
96
97
98
99
# File 'lib/y2r/ast/ruby.rb', line 93

def to_ruby(context)
  wrap_code_with_comments context do |comments_context|
    wrap_code_with_parens comments_context do |parens_context|
      to_ruby_base(parens_context)
    end
  end
end