• Ruby class and ensure

    From =?UTF-8?Q?Une_B=c3=a9vue?=@21:1/5 to All on Thu Jun 22 17:34:33 2017
    I've to write a class opening remote session, and I wonder if it is
    possible to write it such a way that ensure a closing session ?

    say I've a class :

    class Toto

    def self.open
    // do the job to open a session
    end

    def self.getSomething
    return something
    end

    def self.close
    // close the session
    end

    end

    I'd like to have Toto.close automatically called when no more method
    used (it supposes a certain amount of time ?)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert Klemme@21:1/5 to All on Sat Jun 24 11:24:08 2017
    On 22.06.2017 17:34, Une Bévue wrote:
    I've to write a class opening remote session, and I wonder if it is
    possible to write it such a way that ensure a closing session ?

    say I've a class :

    class Toto

    def self.open
    // do the job to open a session
    end

    def self.getSomething
    return something
    end

    def self.close
    // close the session
    end

    end

    I do not think it is wise to use class methods for that. I'd rather
    create an instance for that - even if it is a singleton or assigned to a
    global variable.

    I'd like to have Toto.close automatically called when no more method
    used (it supposes a certain amount of time ?)

    http://ruby-doc.org/stdlib-2.4.1/libdoc/timeout/rdoc/index.html

    Cheers

    robert

    --
    remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Une_B=c3=a9vue?=@21:1/5 to All on Sun Jun 25 16:17:35 2017
    Le 24/06/2017 à 11:24, Robert Klemme a écrit :

    I do not think it is wise to use class methods for that. I'd rather
    create an instance for that - even if it is a singleton or assigned to a global variable.

    I'd like to have Toto.close automatically called when no more method
    used (it supposes a certain amount of time ?)

    http://ruby-doc.org/stdlib-2.4.1/libdoc/timeout/rdoc/index.html

    Cheers


    yes thanks, timeout might be the right answer !

    Yvon

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)