Class: Display

Inherits:
Object
  • Object
show all
Defined in:
app/display.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(frame, arg, fmt, number) ⇒ Display

Returns a new instance of Display.



112
113
114
115
116
117
118
# File 'app/display.rb', line 112

def initialize(frame, arg, fmt, number)
  @signature = display_signature(frame)
  @fmt       = fmt
  @arg       = arg
  @enabled   = true
  @number    = number
end

Instance Attribute Details

#enabledObject

Returns the value of attribute enabled.



110
111
112
# File 'app/display.rb', line 110

def enabled
  @enabled
end

#numberObject (readonly)

Returns the value of attribute number.



108
109
110
# File 'app/display.rb', line 108

def number
  @number
end

#signatureObject (readonly)

Returns the value of attribute signature.



109
110
111
# File 'app/display.rb', line 109

def signature
  @signature
end

Instance Method Details

#disableObject



120
121
122
# File 'app/display.rb', line 120

def disable
  @enabled = false
end

#disabled?Boolean

Returns:

  • (Boolean)


124
125
126
# File 'app/display.rb', line 124

def disabled?
  !@enabled
end

#enableObject



128
129
130
# File 'app/display.rb', line 128

def enable
  @enabled = true
end

#enabled?Boolean

Returns:

  • (Boolean)


132
133
134
# File 'app/display.rb', line 132

def enabled?
  @enabled
end

#format(show_enabled = true) ⇒ Object

format display item



149
150
151
152
153
154
155
156
# File 'app/display.rb', line 149

def format(show_enabled=true)
  what = ''
  what += @enabled ? ' y ' : ' n ' if
    show_enabled
  what += (@fmt + ' ') if @fmt
  what += @arg if @arg
  '%3d: %s' % [@number, what]
end

#to_s(frame) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
# File 'app/display.rb', line 136

def to_s(frame)
  return 'No symbol "' + @arg + '" in current context.' unless frame

  begin
    val = eval(@arg, frame.binding)
  rescue
    return "No symbol \"#{@arg}\" in current context."
  end
  s = "#{self.format(false)} = #{val}"
  return s
end