Class: Naksh::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/naksh/session.rb

Overview

an a subclass of Array which represents a record of entered scripts

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(history = History.new, vars = Hash.new) ⇒ Session

Returns a new instance of Session.



45
46
47
48
49
50
51
52
# File 'lib/naksh/session.rb', line 45

def initialize(history=History.new,vars=Hash.new)
  @history = history
  @vars    = vars
  @id=Naksh.sessions.length
  Naksh.sessions<<self
  Naksh.current_session=self unless Naksh.current_session
  super()
end

Instance Attribute Details

#historyObject

Returns the value of attribute history.



55
56
57
# File 'lib/naksh/session.rb', line 55

def history
  @history
end

#idObject (readonly)

Returns the value of attribute id.



56
57
58
# File 'lib/naksh/session.rb', line 56

def id
  @id
end

#varsObject

Returns the value of attribute vars.



55
56
57
# File 'lib/naksh/session.rb', line 55

def vars
  @vars
end

Instance Method Details

#==(other_session) ⇒ Object

two Sessions are == if and only if their history and vars are ==



59
60
61
62
63
64
# File 'lib/naksh/session.rb', line 59

def == other_session
  return false unless other_session.kind_of? self.class
  return false unless other_session.history==history
  return false unless other_session.vars==   vars
  true
end

#forkObject



66
67
68
# File 'lib/naksh/session.rb', line 66

def fork
  Session.new history,vars
end