Class: Ptero::Generator::PHPClassGenerator

Inherits:
PHPGenerator show all
Defined in:
lib/ptero/generators/phpclassgenerator.rb

Overview

A generator for PHP classes

Direct Known Subclasses

ControllerGenerator, ModelGenerator

Instance Attribute Summary collapse

Attributes inherited from Ptero::Generator

#app, #dir, #name

Instance Method Summary collapse

Methods inherited from PHPGenerator

#extension, #path

Methods inherited from Ptero::Generator

const_missing, #content, #content_params, #extension, #filename, #generate, #generated?, #location, #path, #reload, #remove, #template_path, #to_s, #type

Constructor Details

#initialize(name, parent = nil) ⇒ PHPClassGenerator

Returns a new instance of PHPClassGenerator.

Parameters:

  • name (String)

    the name of the class, it will be capitalized

  • parent (String) (defaults to: nil)

    the name of the class’s superclass



15
16
17
18
19
# File 'lib/ptero/generators/phpclassgenerator.rb', line 15

def initialize(name,parent=nil)
  # Capitalize class names
	super("#{name[0].upcase}#{name[1,name.length-1]}")
  @parent = "#{parent[0].upcase}#{parent[1,parent.length-1]}"if parent
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



21
22
23
# File 'lib/ptero/generators/phpclassgenerator.rb', line 21

def parent
  @parent
end