Module: Psych::Pure::CommentExtensions::Node

Defined in:
lib/psych/pure.rb

Overview

Extend the nodes to be able to store comments.

Instance Method Summary collapse

Instance Method Details

#commentsObject



808
809
810
# File 'lib/psych/pure.rb', line 808

def comments
  @comments ||= Comments.new
end

#comments?Boolean

Returns:



817
818
819
# File 'lib/psych/pure.rb', line 817

def comments?
  defined?(@comments)
end

#initialize_dup(other) ⇒ Object



812
813
814
815
# File 'lib/psych/pure.rb', line 812

def initialize_dup(other)
  super
  @comments = other.comments.dup if other.comments?
end

#leading_comment(comment) ⇒ Object



800
801
802
# File 'lib/psych/pure.rb', line 800

def leading_comment(comment)
  comments.leading_comment(comment)
end

#to_ruby(symbolize_names: false, freeze: false, strict_integer: false, parse_symbols: true, comments: false) ⇒ Object



821
822
823
# File 'lib/psych/pure.rb', line 821

def to_ruby(symbolize_names: false, freeze: false, strict_integer: false, parse_symbols: true, comments: false)
  Visitors::ToRuby.create(symbolize_names: symbolize_names, freeze: freeze, strict_integer: strict_integer, parse_symbols: parse_symbols, comments: comments).accept(self)
end

#trailing_comment(comment) ⇒ Object



804
805
806
# File 'lib/psych/pure.rb', line 804

def trailing_comment(comment)
  comments.trailing_comment(comment)
end