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.



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

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.



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

def enabled
  @enabled
end

#numberObject (readonly)

Returns the value of attribute number.



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

def number
  @number
end

#signatureObject (readonly)

Returns the value of attribute signature.



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

def signature
  @signature
end

Instance Method Details

#disableObject



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

def disable
  @enabled = false
end

#disabled?Boolean

Returns:

  • (Boolean)


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

def disabled?
  !@enabled
end

#enableObject



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

def enable
  @enabled = true
end

#enabled?Boolean

Returns:

  • (Boolean)


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

def enabled?
  @enabled
end

#format(show_enabled = true) ⇒ Object

format display item



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

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



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

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