Class: TreeHaver::Backends::Psych::Language
- Inherits:
-
Object
- Object
- TreeHaver::Backends::Psych::Language
- Includes:
- Comparable
- 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 collapse
-
#backend ⇒ Symbol
readonly
The backend this language is for.
-
#name ⇒ Symbol
readonly
The language name (always :yaml for Psych).
Class Method Summary collapse
-
.yaml ⇒ Language
Create a YAML language instance.
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer?
Comparison for sorting/equality.
-
#initialize(name = :yaml) ⇒ Language
constructor
Create a new Psych language instance.
-
#inspect ⇒ String
Human-readable representation.
Constructor Details
#initialize(name = :yaml) ⇒ Language
Create a new Psych language instance
91 92 93 94 |
# File 'lib/tree_haver/backends/psych.rb', line 91 def initialize(name = :yaml) @name = name.to_sym @backend = :psych end |
Instance Attribute Details
#backend ⇒ Symbol (readonly)
The backend this language is for
86 87 88 |
# File 'lib/tree_haver/backends/psych.rb', line 86 def backend @backend end |
#name ⇒ Symbol (readonly)
The language name (always :yaml for Psych)
82 83 84 |
# File 'lib/tree_haver/backends/psych.rb', line 82 def name @name end |
Class Method Details
.yaml ⇒ Language
Create a YAML language instance
100 101 102 |
# File 'lib/tree_haver/backends/psych.rb', line 100 def yaml new(:yaml) end |
Instance Method Details
#<=>(other) ⇒ Integer?
Comparison for sorting/equality
109 110 111 112 |
# File 'lib/tree_haver/backends/psych.rb', line 109 def <=>(other) return unless other.is_a?(Language) name <=> other.name end |
#inspect ⇒ String
Returns human-readable representation.
115 116 117 |
# File 'lib/tree_haver/backends/psych.rb', line 115 def inspect "#<TreeHaver::Backends::Psych::Language name=#{name}>" end |