Class: Curly::ComponentScanner

Inherits:
Object
  • Object
show all
Defined in:
lib/curly/component_scanner.rb

Class Method Summary collapse

Class Method Details

.scan(component) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/curly/component_scanner.rb', line 5

def self.scan(component)
  first, rest = component.strip.split(/\s+/, 2)
  contexts = first.split(":")
  name_and_identifier = contexts.pop

  name, identifier = name_and_identifier.split(".", 2)

  if identifier && identifier.end_with?("?")
    name += "?"
    identifier = identifier[0..-2]
  end

  attributes = AttributeScanner.scan(rest)

  [name, identifier, attributes, contexts]
end