Module: VisualizeRuby::Touchable
Instance Attribute Summary collapse
-
#touched ⇒ Object
readonly
Returns the value of attribute touched.
Instance Method Summary collapse
- #post_initialize(**args) ⇒ Object
- #step_display ⇒ Object
- #touch(color, step: nil) ⇒ Object
- #touched_display ⇒ Object
Instance Attribute Details
#touched ⇒ Object (readonly)
Returns the value of attribute touched.
28 29 30 |
# File 'lib/visualize_ruby/touchable.rb', line 28 def touched @touched end |
Instance Method Details
#post_initialize(**args) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/visualize_ruby/touchable.rb', line 3 def post_initialize(**args) self.class.add_names(:touched_display, :step_display) @steps = [] @touched = 0 super if defined? super end |
#step_display ⇒ Object
22 23 24 25 26 |
# File 'lib/visualize_ruby/touchable.rb', line 22 def step_display unless @steps.empty? "step: #{@steps.join(", ")}" end end |
#touch(color, step: nil) ⇒ Object
10 11 12 13 14 |
# File 'lib/visualize_ruby/touchable.rb', line 10 def touch(color, step: nil) @steps << step .merge!(color: color) @touched += 1 end |
#touched_display ⇒ Object
16 17 18 19 20 |
# File 'lib/visualize_ruby/touchable.rb', line 16 def touched_display unless [0, 1].include?(@touched) "(called: #{@touched})" end end |