Class: Clian::Config::Syntax
- Inherits:
-
Object
- Object
- Clian::Config::Syntax
- Defined in:
- lib/clian/config.rb
Overview
Syntax table manipulation
Instance Method Summary collapse
-
#initialize(syntax_config) ⇒ Syntax
constructor
A new instance of Syntax.
- #instance_variable_name(word) ⇒ Object
- #item_class(word) ⇒ Object
- #keyword?(word) ⇒ Boolean
- #keyword_symbols ⇒ Object
- #keywords ⇒ Object
Constructor Details
#initialize(syntax_config) ⇒ Syntax
Returns a new instance of Syntax.
9 10 11 |
# File 'lib/clian/config.rb', line 9 def initialize(syntax_config) @syntax_config = syntax_config end |
Instance Method Details
#instance_variable_name(word) ⇒ Object
30 31 32 33 |
# File 'lib/clian/config.rb', line 30 def instance_variable_name(word) return nil unless keyword?(word) return '@' + as_symbol(word).to_s end |
#item_class(word) ⇒ Object
35 36 37 38 |
# File 'lib/clian/config.rb', line 35 def item_class(word) return nil unless keyword?(word) @syntax_config[as_symbol(word)] end |
#keyword?(word) ⇒ Boolean
21 22 23 24 25 26 27 28 |
# File 'lib/clian/config.rb', line 21 def keyword?(word) if word.is_a?(Symbol) keyword_symbols.member?(word) else # String keywords.member?(word) end end |
#keyword_symbols ⇒ Object
13 14 15 |
# File 'lib/clian/config.rb', line 13 def keyword_symbols @syntax_config.keys end |
#keywords ⇒ Object
17 18 19 |
# File 'lib/clian/config.rb', line 17 def keywords keyword_symbols.map {|sym| sym.to_s.upcase } end |