class ActionScriptClass
Takes an ActionScript 3 Interface
file and generates a ActionScript class from it.
Public Instance Methods
foot()
click to toggle source
Returns a string formatted as the footer of a ActionScript document.
# File lib/shed/mixers/actionscript_class.rb, line 40 def foot "\n}\n}\n" end
get(name,type)
click to toggle source
Returns a string formatted as a public ActionScript getter.
# File lib/shed/mixers/actionscript_class.rb, line 19 def get(name,type) template(name, '', type,'get ') end
head(name,interface)
click to toggle source
Returns a string formatted as the head of a ActionScript document.
# File lib/shed/mixers/actionscript_class.rb, line 12 def head(name,interface) "package\n{\n\nclass #{name} implements #{interface}\n{\n\n" end
method(name,arguments,returns)
click to toggle source
Returns a string formatted as a public ActionScript method.
# File lib/shed/mixers/actionscript_class.rb, line 33 def method(name,arguments,returns) template(name,arguments,returns) end
set(name,type)
click to toggle source
Returns a string formatted as a public ActionScript setter.
# File lib/shed/mixers/actionscript_class.rb, line 26 def set(name,type) template(name, "value:#{type}", 'void','set ') end
Protected Instance Methods
parameterize(arguments)
click to toggle source
Utility to convert the specified arguments to valid ActionScript method parameters.
# File lib/shed/mixers/actionscript_class.rb, line 50 def parameterize(arguments) arguments = arguments.join(', ') if arguments.is_a? Array arguments end
template(name,arguments,returns,type='')
click to toggle source
Returns a string formatted as a public ActionScript method. If a type is specified the method will be an implicit getter or setter.
# File lib/shed/mixers/actionscript_class.rb, line 59 def template(name,arguments,returns,type='') str = " public function #{type}#{name}(#{parameterize(arguments)}):#{returns}\n" str << " {\n" str << " return;\n" unless returns == 'void' str << " }\n\n" end