CypressMethod.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 13 Sep 2012 14:58:01 +0000
changeset 13 f90704544ca0
parent 12 ec118792047a
child 14 d5b81c30785e
permissions -rw-r--r--
More refactoring

"{ Package: 'stx:goodies/cypress' }"

CypressModel subclass:#CypressMethod
	instanceVariableNames:'klass meta category source'
	classVariableNames:''
	poolDictionaries:''
	category:'Cypress-New-Model'
!


!CypressMethod class methodsFor:'instance creation'!

fromFile: aStringOrFilename
    "Reads a CypressMethod from given file"
    ^self new initializeFromFile: aStringOrFilename

    "Created: / 13-09-2012 / 15:36:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

fromMethod: aMethod
    "Returns a Cypress method for given (real) method"
    ^self new initializeFromMethod: aMethod

    "Created: / 11-09-2012 / 00:03:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!CypressMethod methodsFor:'accessing'!

klass
    ^ klass
!

meta
    ^ meta
!

package
    "Returns a CypressPackage which the receiver belongs to"

    ^ self shouldImplement
!

selector
    ^self name

    "Created: / 11-09-2012 / 11:18:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!CypressMethod methodsFor:'initialization'!

initializeFromFile: aStringOrFilename
    self readFrom: aStringOrFilename

    "Created: / 13-09-2012 / 15:36:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

initializeFromMethod: aMethod
    name := aMethod selector.
    klass := aMethod mclass name.
    meta := aMethod mclass isMetaclass.
    category := aMethod category.
    source := aMethod source.

    "Created: / 11-09-2012 / 00:05:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!CypressMethod methodsFor:'reading & writing'!

readFrom:filename
    "Initializes the receiver from directory/file named 'filename'"

    ^ self shouldImplement
!

writeTo:filename notice:copyrightNotice
    "Writes the receiver into given 'directory' with
     copyrightNotice in each file"

    filename writingFileDo:[:s|
        s nextPut:$"; cr.
        s nextPutAll: 'notice: '; nextPutAll: copyrightNotice; cr.
        s nextPutAll: 'category: '; nextPutAll: category ? '* as yet unclassified *'; cr.
        s nextPut:$"; cr.
        s nextPutAll: source.
    ].

    "Modified: / 11-09-2012 / 11:36:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!CypressMethod class methodsFor:'documentation'!

version_SVN
    ^ '$Id::                                                                                                                        $'
! !