Class: TreeHaver::Backends::Psych::Language
- Inherits:
-
TreeHaver::Base::Language
- Object
- TreeHaver::Base::Language
- TreeHaver::Backends::Psych::Language
- Defined in:
- lib/tree_haver/backends/psych.rb
Overview
Psych language wrapper
Unlike tree-sitter which supports many languages via grammar files, Psych only parses YAML. This class exists for API compatibility with other tree_haver backends.
Instance Attribute Summary
Attributes inherited from TreeHaver::Base::Language
Class Method Summary collapse
-
.from_library(_path = nil, symbol: nil, name: nil) ⇒ Language
Load language from library path (API compatibility).
-
.yaml ⇒ Language
Create a YAML language instance.
Instance Method Summary collapse
-
#initialize(name = :yaml) ⇒ Language
constructor
Create a new Psych language instance.
Methods inherited from TreeHaver::Base::Language
Constructor Details
#initialize(name = :yaml) ⇒ Language
Create a new Psych language instance
85 86 87 |
# File 'lib/tree_haver/backends/psych.rb', line 85 def initialize(name = :yaml) super(name, backend: :psych, options: {}) end |
Class Method Details
.from_library(_path = nil, symbol: nil, name: nil) ⇒ Language
Load language from library path (API compatibility)
Psych only supports YAML, so path and symbol parameters are ignored.
106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/tree_haver/backends/psych.rb', line 106 def from_library(_path = nil, symbol: nil, name: nil) # rubocop:disable Lint/UnusedMethodArgument lang_name = name || :yaml unless lang_name == :yaml raise TreeHaver::NotAvailable, "Psych backend only supports YAML, not #{lang_name}. " \ "Use a tree-sitter backend for #{lang_name} support." end yaml end |
.yaml ⇒ Language
Create a YAML language instance
93 94 95 |
# File 'lib/tree_haver/backends/psych.rb', line 93 def yaml new(:yaml) end |