Module: EZML::AttributeParser

Defined in:
lib/ezml/attribute_parser.rb

Defined Under Namespace

Classes: UnexpectedKeyError, UnexpectedTokenError

Constant Summary collapse

TYPE =
1
TEXT =
2
IGNORED_TYPES =
i[on_sp on_ignored_nl]

Class Method Summary collapse

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/ezml/attribute_parser.rb', line 18

def available?
  defined?(Ripper) && Temple::StaticAnalyzer.available?
end

.parse(exp) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ezml/attribute_parser.rb', line 22

def parse(exp)
  return nil unless hash_literal?(exp)

  hash = {}
  each_attribute(exp) do |key, value|
    hash[key] = value
  end
  hash
rescue UnexpectedTokenError, UnexpectedKeyError
  nil
end