Class: Display
- Inherits:
-
Object
- Object
- Display
- Defined in:
- app/display.rb
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
Instance Method Summary collapse
- #disable ⇒ Object
- #disabled? ⇒ Boolean
- #enable ⇒ Object
- #enabled? ⇒ Boolean
-
#format(show_enabled = true) ⇒ Object
format display item.
-
#initialize(frame, arg, fmt, number) ⇒ Display
constructor
A new instance of Display.
- #to_s(frame) ⇒ Object
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
#enabled ⇒ Object
Returns the value of attribute enabled.
109 110 111 |
# File 'app/display.rb', line 109 def enabled @enabled end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
107 108 109 |
# File 'app/display.rb', line 107 def number @number end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
108 109 110 |
# File 'app/display.rb', line 108 def signature @signature end |
Instance Method Details
#disable ⇒ Object
119 120 121 |
# File 'app/display.rb', line 119 def disable @enabled = false end |
#disabled? ⇒ Boolean
123 124 125 |
# File 'app/display.rb', line 123 def disabled? !@enabled end |
#enable ⇒ Object
127 128 129 |
# File 'app/display.rb', line 127 def enable @enabled = true end |
#enabled? ⇒ 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 |