Skip to content

Instantly share code, notes, and snippets.

@TorbenKoehn
Created November 15, 2013 13:09
Show Gist options
  • Save TorbenKoehn/7484093 to your computer and use it in GitHub Desktop.
Save TorbenKoehn/7484093 to your computer and use it in GitHub Desktop.
namespace OwnScript.MyNamespace
use OwnScript.SomeOtherNamespace //kein * nötig, da OwnScript keine Klasse, sondern ein Namespace ist
use Vendor.Some.Other.Stuff
class MyClass > DerivedClass:
public myProperty:
get:
return property
end
set:
this.observer.notifyPropertyChanged( property, value )
property = value
end
end
public String typedProperty
public myPropertyBrackets {
get {
return property
}
set {
property = value
}
}
public webRelated():
Response.header( 'Content-type', 'text/html' )
"Dies ist ein String \" mit '' Escaping und so"
'und dies \' ein anderer " " mit escaping'
Response.contentType = 'text/html'
Response.header( 'X-Custom-Header', 'content...' )
Response.flush()
//print actually will do something like
Response.append( "print arguments" )
Request.query.each( ( el, i ):
print( el + " - "+ i )
end
)
print( Request.query.myQueryArg )
//The POST data
Request.data
//the raw request (Actually some kind of RawRequest Instance which holds properties "body" and "header")
//toString on RawRequest renders the full request
Request.raw
Session.mySessionVariable = 'test';
Session.timeOut( 3600 );
Session.handler = new MyOwnSessionHandler;
Request.handle( ':controller/:action/:id', ( data ):
data.controller = value.toInnerCaps()
data.action = value.toLower()
data.action.id = value.toInt()
MyFrontController.dispatch( data );
end
)
end
public myMethod( String myString, Int myInt ):
max = 14
range = ( 14...28 )
0.to( max ).odd().each( ( el, i ):
i.print
end
).even().each( ( el, i ):
i.print
end
)
range.each()
( 0...max ).each( ( el, i ):
i.toString().print()
end
)
end
public MyClass( a, b, MyType c ):
this.a = a or defaultValue
this.b = b or error( "Missing argument b", ClassInitialization )
this.c = this.myMethod() or defaultValue
end
public -MyClass():
//destruct this shit
end
public doSomething( String b..., Bool a ):
b.each( ( i, el ):
el.print()
end
)
end
public myHandlerBrackets( Array myArray ) {
myArray.each( ( el, i ) {
el.print()
idx.print()
}
)
}
public myHandler( Array myArray ):
myArray.each( ( el, i ):
yield "-> " + idx + " <-"
end
)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment