Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This script generates setter and getter methods for PHP.
- class String
- def camelize
- result = ""
- self.split("_").each do |word|
- result += word.capitalize
- end
- result
- end
- def lower_camelize
- result = ""
- i = 0
- self.split("_").each do |word|
- if i == 0
- result += word.downcase
- else
- result += word.capitalize
- end
- i += 1
- end
- result
- end
- end
- %W!zip pref city town!.each do |prop|
- puts "
- /**
- * Setter for #{prop.camelize}
- *
- * @param
- * @return
- */
- public function set#{prop.camelize}($val)
- {
- $this->_#{prop.lower_camelize} = $val;
- return $this;
- }
- /**
- * Getter for #{prop.camelize}
- *
- * @param void
- * @return
- */
- public function get#{prop.camelize}()
- {
- return $this->_#{prop.lower_camelize};
- }
- "
- end
Add Comment
Please, Sign In to add comment