Module: Sexpr::Grammar::Options
- Included in:
- Sexpr::Grammar
- Defined in:
- lib/sexpr/grammar/options.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
Instance Method Summary collapse
- #compile_rules(rules) ⇒ Object
- #install_options(options) {|_self| ... } ⇒ Object
- #install_parser ⇒ Object
- #install_path ⇒ Object
- #install_root ⇒ Object
- #install_rules ⇒ Object
- #option(key) ⇒ Object
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/sexpr/grammar/options.rb', line 5 def @options end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
9 10 11 |
# File 'lib/sexpr/grammar/options.rb', line 9 def parser @parser end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/sexpr/grammar/options.rb', line 6 def path @path end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
8 9 10 |
# File 'lib/sexpr/grammar/options.rb', line 8 def root @root end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
7 8 9 |
# File 'lib/sexpr/grammar/options.rb', line 7 def rules @rules end |
Instance Method Details
#compile_rules(rules) ⇒ Object
47 48 49 |
# File 'lib/sexpr/grammar/options.rb', line 47 def compile_rules(rules) @rules = rules end |
#install_options(options) {|_self| ... } ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/sexpr/grammar/options.rb', line 11 def () @options = install_path install_rules install_root install_parser yield self if block_given? end |
#install_parser ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/sexpr/grammar/options.rb', line 39 def install_parser @parser = option(:parser) if @parser.is_a?(String) && !File.exists?(@parser) @parser = File.join(File.dirname(path), @parser) end @parser = Parser.factor(@parser) if @parser end |
#install_path ⇒ Object
24 25 26 |
# File 'lib/sexpr/grammar/options.rb', line 24 def install_path @path = option(:path) end |
#install_root ⇒ Object
33 34 35 36 37 |
# File 'lib/sexpr/grammar/options.rb', line 33 def install_root @root = option(:root) @root = rules.keys.first unless @root @root = root.to_sym if @root end |
#install_rules ⇒ Object
28 29 30 31 |
# File 'lib/sexpr/grammar/options.rb', line 28 def install_rules @rules = option(:rules) || {} @rules = compile_rules(@rules) end |
#option(key) ⇒ Object
20 21 22 |
# File 'lib/sexpr/grammar/options.rb', line 20 def option(key) @options[key.to_sym] || @options[key.to_s] end |