Class: Roebe::Shell::Session
- Defined in:
- lib/roebe/shell/session/session.rb
Overview
Roebe::Session
Instance Method Summary collapse
-
#[](i) ⇒ Object
# === Roebe::Shell::Session[] ========================================================================= #.
-
#consider_enabling_colours ⇒ Object
# === consider_enabling_colours ========================================================================= #.
-
#disable_colours ⇒ Object
# === disable_colours ========================================================================= #.
-
#enable_colours ⇒ Object
# === enable_colours ========================================================================= #.
-
#has_this_variable?(i) ⇒ Boolean
(also: #has_this_key?)
# === has_this_variable?.
-
#hash_ivars? ⇒ Boolean
(also: #hash?, #ivars?)
# === hash_ivars? ========================================================================= #.
-
#initialize(use_colours = true, run_already = true) ⇒ Session
constructor
# === initialize.
-
#report ⇒ Object
# === report.
-
#report_ivars ⇒ Object
# === report_ivars ========================================================================= #.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#run ⇒ Object
# === run ========================================================================= #.
-
#set_this_ivar(name_of_ivar, value) ⇒ Object
(also: #set)
# === set_this_ivar.
-
#set_this_lvar(name_of_lvar, value) ⇒ Object
# === set_this_lvar.
-
#set_use_colours(i) ⇒ Object
# === set_use_colours ========================================================================= #.
-
#simp(i) ⇒ Object
# === simp ========================================================================= #.
Constructor Details
Instance Method Details
#[](i) ⇒ Object
#
Roebe::Shell::Session[]
#
196 197 198 |
# File 'lib/roebe/shell/session/session.rb', line 196 def [](i) @hash_ivars[i] end |
#consider_enabling_colours ⇒ Object
#
consider_enabling_colours
#
73 74 75 |
# File 'lib/roebe/shell/session/session.rb', line 73 def consider_enabling_colours enable_colours if @use_colours end |
#disable_colours ⇒ Object
#
disable_colours
#
140 141 142 |
# File 'lib/roebe/shell/session/session.rb', line 140 def disable_colours @use_colours = false end |
#enable_colours ⇒ Object
#
enable_colours
#
133 134 135 |
# File 'lib/roebe/shell/session/session.rb', line 133 def enable_colours @use_colours = true end |
#has_this_variable?(i) ⇒ Boolean Also known as: has_this_key?
#
has_this_variable?
Query the hash that contains the ivars whether the given key passed is included in the hash.
#
125 126 127 128 |
# File 'lib/roebe/shell/session/session.rb', line 125 def has_this_variable?(i) i.prepend('@') unless i.start_with? '@' @hash_ivars.has_key? i end |
#hash_ivars? ⇒ Boolean Also known as: hash?, ivars?
#
hash_ivars?
#
147 148 149 |
# File 'lib/roebe/shell/session/session.rb', line 147 def hash_ivars? @hash_ivars end |
#report ⇒ Object
#
report
We bundle together several report-statements here.
#
182 183 184 |
# File 'lib/roebe/shell/session/session.rb', line 182 def report report_ivars end |
#report_ivars ⇒ Object
#
report_ivars
#
155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/roebe/shell/session/session.rb', line 155 def report_ivars if @hash_ivars.empty? e 'We do not have any instance variable stored.' else e "The available ('#{simp('environment-defined')}) instance "\ "variables are:" ivars?.each_pair {|key, value| the_type = value.class # This is the class, such as Range. value = value.inspect # String representation required for display-purposes. e ' '+simp(key)+' -> '+value+' ('+simp(the_type.to_s)+')' } end end |
#reset ⇒ Object
#
reset
#
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/roebe/shell/session/session.rb', line 51 def reset # ======================================================================= # # === @use_colours # ======================================================================= # @use_colours = true # ======================================================================= # # === @hash_ivars # ======================================================================= # @hash_ivars = {} # The instance variables. @hash_lvars = {} # The local variables. end |
#run ⇒ Object
#
run
#
189 190 191 |
# File 'lib/roebe/shell/session/session.rb', line 189 def run consider_enabling_colours end |
#set_this_ivar(name_of_ivar, value) ⇒ Object Also known as: set
#
set_this_ivar
Usage examples from within the Roebe Shell:
@foo = 5; @bar = 'hi'; ses?
Usage examples:
@session.set_this_ivar('foo','value_here')
@session.set_this_ivar('bar','5')
#
90 91 92 93 94 95 96 |
# File 'lib/roebe/shell/session/session.rb', line 90 def set_this_ivar(name_of_ivar, value) name_of_ivar = name_of_ivar.to_s # We always require a String. unless name_of_ivar.start_with? '@' name_of_ivar.prepend '@' end @hash_ivars[name_of_ivar] = value # Append only if it does not yet exist. end |
#set_this_lvar(name_of_lvar, value) ⇒ Object
#
set_this_lvar
Set local variable here.
#
103 104 105 106 |
# File 'lib/roebe/shell/session/session.rb', line 103 def set_this_lvar(name_of_lvar, value) name_of_lvar = name_of_lvar.to_s # We always require a String. @hash_lvars[name_of_livar] = value # Append only if it does not yet exist. end |
#set_use_colours(i) ⇒ Object
#
set_use_colours
#
66 67 68 |
# File 'lib/roebe/shell/session/session.rb', line 66 def set_use_colours(i) @use_colours = i end |