Class: Stylio::Generators::Component
- Inherits:
-
Object
- Object
- Stylio::Generators::Component
- Defined in:
- lib/stylio/generators/component.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(name) ⇒ Component
constructor
A new instance of Component.
Constructor Details
#initialize(name) ⇒ Component
Returns a new instance of Component.
7 8 9 |
# File 'lib/stylio/generators/component.rb', line 7 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/stylio/generators/component.rb', line 5 def name @name end |
Instance Method Details
#generate ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/stylio/generators/component.rb', line 11 def generate puts "Generating component with name #{name}".yellow FileUtils::mkdir_p "components/#{name}" puts "Created folder components/#{name}".green File.open("components/#{name}/#{name}.yml", 'w') do |f| f.write('') end puts "Created file components/#{name}/#{name}.yml".green File.open("components/#{name}/#{name}.html.erb", 'w') do |f| f.write('') end puts "Created file components/#{name}/#{name}.html.erb".green puts "Generated component with name #{name}".green end |