Class: Phlexing::Converter

Inherits:
Object
  • Object
show all
Defined in:
lib/phlexing/converter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source = nil, **options) ⇒ Converter

Returns a new instance of Converter.



21
22
23
24
25
26
# File 'lib/phlexing/converter.rb', line 21

def initialize(source = nil, **options)
  @custom_elements = Set.new
  @options = Options.new(**options)

  call(source)
end

Instance Attribute Details

#custom_elementsObject

Returns the value of attribute custom_elements.



5
6
7
# File 'lib/phlexing/converter.rb', line 5

def custom_elements
  @custom_elements
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/phlexing/converter.rb', line 5

def options
  @options
end

#sourceObject

Returns the value of attribute source.



5
6
7
# File 'lib/phlexing/converter.rb', line 5

def source
  @source
end

Class Method Details

.call(source, **options) ⇒ Object



7
8
9
# File 'lib/phlexing/converter.rb', line 7

def self.call(source, **options)
  new(**options).call(source)
end

.convert(source, **options) ⇒ Object



11
12
13
# File 'lib/phlexing/converter.rb', line 11

def self.convert(source, **options)
  new(**options).call(source)
end

Instance Method Details

#call(source) ⇒ Object



15
16
17
18
19
# File 'lib/phlexing/converter.rb', line 15

def call(source)
  @source = source

  code
end

#codeObject



28
29
30
# File 'lib/phlexing/converter.rb', line 28

def code
  options.component? ? component_code : template_code
end

#component_codeObject



38
39
40
# File 'lib/phlexing/converter.rb', line 38

def component_code
  ComponentGenerator.call(self)
end

#template_codeObject

private



34
35
36
# File 'lib/phlexing/converter.rb', line 34

def template_code
  TemplateGenerator.call(self, source)
end