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.
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
#enabled ⇒ Object
Returns the value of attribute enabled.
110 111 112 |
# File 'app/display.rb', line 110 def enabled @enabled end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
108 109 110 |
# File 'app/display.rb', line 108 def number @number end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
109 110 111 |
# File 'app/display.rb', line 109 def signature @signature end |
Instance Method Details
#disable ⇒ Object
120 121 122 |
# File 'app/display.rb', line 120 def disable @enabled = false end |
#disabled? ⇒ Boolean
124 125 126 |
# File 'app/display.rb', line 124 def disabled? !@enabled end |
#enable ⇒ Object
128 129 130 |
# File 'app/display.rb', line 128 def enable @enabled = true end |
#enabled? ⇒ 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 |