Class: Phlexing::Options

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(component: false, component_name: "Component", parent_component: "Phlex::HTML", whitespace: true) ⇒ Options

Returns a new instance of Options.



10
11
12
13
14
15
# File 'lib/phlexing/options.rb', line 10

def initialize(component: false, component_name: "Component", parent_component: "Phlex::HTML", whitespace: true)
  @component = component
  @component_name = safe_constant_name(component_name)
  @parent_component = safe_constant_name(parent_component)
  @whitespace = whitespace
end

Instance Attribute Details

#componentObject Also known as: component?

Returns the value of attribute component.



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

def component
  @component
end

#component_nameObject

Returns the value of attribute component_name.



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

def component_name
  @component_name
end

#parent_componentObject

Returns the value of attribute parent_component.



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

def parent_component
  @parent_component
end

#whitespaceObject Also known as: whitespace?

Returns the value of attribute whitespace.



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

def whitespace
  @whitespace
end

Instance Method Details

#safe_constant_name(name) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/phlexing/options.rb', line 17

def safe_constant_name(name)
  name = name.to_s

  if name[0] == "0" || name[0].to_i != 0
    "A#{name}"
  else
    name
  end
end