Class: Parslet::Parser
- Inherits:
-
Object
- Object
- Parslet::Parser
- Defined in:
- lib/parslet-export/parser.rb
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
This turns a Hash into a Parslet::Parser.
Instance Method Summary collapse
-
#to_hash ⇒ Object
This turns a Parslet::Parser into a Hash.
Class Method Details
.from_hash(hash) ⇒ Object
This turns a Hash into a Parslet::Parser
12 13 14 15 16 17 18 19 |
# File 'lib/parslet-export/parser.rb', line 12 def self.from_hash(hash) new.tap do |parser| # Parsers have to have a #root method parser.define_singleton_method(hash["atom"]) do hash["parslet"].to_parslet end end end |
Instance Method Details
#to_hash ⇒ Object
This turns a Parslet::Parser into a Hash
4 5 6 7 8 9 |
# File 'lib/parslet-export/parser.rb', line 4 def to_hash { "atom" => "root", "parslet" => root.to_hash } end |