Sha256: 87fd398f234e4854a166adfb75669e88bb56a971f45acb15162065a08cfaa306

Contents?: true

Size: 1.67 KB

Versions: 1944

Compression:

Stored size: 1.67 KB

Contents

# frozen_string_literal: true
module Psych
  ###
  # YAML event parser class.  This class parses a YAML document and calls
  # events on the handler that is passed to the constructor.  The events can
  # be used for things such as constructing a YAML AST or deserializing YAML
  # documents.  It can even be fed back to Psych::Emitter to emit the same
  # document that was parsed.
  #
  # See Psych::Handler for documentation on the events that Psych::Parser emits.
  #
  # Here is an example that prints out ever scalar found in a YAML document:
  #
  #   # Handler for detecting scalar values
  #   class ScalarHandler < Psych::Handler
  #     def scalar value, anchor, tag, plain, quoted, style
  #       puts value
  #     end
  #   end
  #
  #   parser = Psych::Parser.new(ScalarHandler.new)
  #   parser.parse(yaml_document)
  #
  # Here is an example that feeds the parser back in to Psych::Emitter.  The
  # YAML document is read from STDIN and written back out to STDERR:
  #
  #   parser = Psych::Parser.new(Psych::Emitter.new($stderr))
  #   parser.parse($stdin)
  #
  # Psych uses Psych::Parser in combination with Psych::TreeBuilder to
  # construct an AST of the parsed YAML document.

  class Parser
    class Mark < Struct.new(:index, :line, :column)
    end

    # The handler on which events will be called
    attr_accessor :handler

    # Set the encoding for this parser to +encoding+
    attr_writer :external_encoding

    ###
    # Creates a new Psych::Parser instance with +handler+.  YAML events will
    # be called on +handler+.  See Psych::Parser for more details.

    def initialize handler = Handler.new
      @handler = handler
      @external_encoding = ANY
    end
  end
end

Version data entries

1,944 entries across 1,941 versions & 20 rubygems

Version Path
ory-client-1.16.2 vendor/bundle/ruby/3.1.0/gems/psych-4.0.6/lib/psych/parser.rb
avalara_sdk-24.12.2 vendor/bundle/ruby/2.7.0/gems/psych-4.0.4/lib/psych/parser.rb
ory-client-1.16.1 vendor/bundle/ruby/3.1.0/gems/psych-4.0.6/lib/psych/parser.rb
ory-client-1.16.0 vendor/bundle/ruby/3.1.0/gems/psych-4.0.6/lib/psych/parser.rb
avalara_sdk-24.12.1 vendor/bundle/ruby/2.7.0/gems/psych-4.0.4/lib/psych/parser.rb
avalara_sdk-24.12.0 vendor/bundle/ruby/2.7.0/gems/psych-4.0.4/lib/psych/parser.rb
ory-client-1.15.17 vendor/bundle/ruby/3.1.0/gems/psych-4.0.6/lib/psych/parser.rb
ory-client-1.15.16 vendor/bundle/ruby/3.1.0/gems/psych-4.0.6/lib/psych/parser.rb
ory-client-1.15.15 vendor/bundle/ruby/3.1.0/gems/psych-4.0.6/lib/psych/parser.rb
ory-client-1.15.14 vendor/bundle/ruby/3.1.0/gems/psych-4.0.6/lib/psych/parser.rb
ory-client-1.15.13 vendor/bundle/ruby/3.1.0/gems/psych-4.0.6/lib/psych/parser.rb
mux_ruby-3.20.0 vendor/bundle/ruby/3.2.0/gems/psych-4.0.4/lib/psych/parser.rb
ory-client-1.15.12 vendor/bundle/ruby/3.1.0/gems/psych-4.0.6/lib/psych/parser.rb
ory-client-1.15.10 vendor/bundle/ruby/3.1.0/gems/psych-4.0.6/lib/psych/parser.rb
mux_ruby-3.19.0 vendor/bundle/ruby/3.2.0/gems/psych-4.0.4/lib/psych/parser.rb
ory-client-1.15.7 vendor/bundle/ruby/3.1.0/gems/psych-4.0.6/lib/psych/parser.rb
ory-client-1.15.6 vendor/bundle/ruby/3.1.0/gems/psych-4.0.6/lib/psych/parser.rb
ory-client-1.15.5 vendor/bundle/ruby/3.1.0/gems/psych-4.0.6/lib/psych/parser.rb
ory-client-1.15.4 vendor/bundle/ruby/3.1.0/gems/psych-4.0.6/lib/psych/parser.rb
ory-client-1.15.3 vendor/bundle/ruby/3.1.0/gems/psych-4.0.6/lib/psych/parser.rb