Class: Configuration
- Inherits:
-
Object
- Object
- Configuration
- Defined in:
- lib/ntm/configuration.rb
Overview
require “tape”
Instance Attribute Summary collapse
-
#depth ⇒ Object
Returns the value of attribute depth.
-
#path ⇒ Object
Returns the value of attribute path.
-
#state ⇒ Object
Returns the value of attribute state.
-
#tape ⇒ Object
Returns the value of attribute tape.
Instance Method Summary collapse
- #dup ⇒ Object
-
#initialize(options = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #to_s ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Configuration
6 7 8 9 10 11 |
# File 'lib/ntm/configuration.rb', line 6 def initialize( = {}) @tape = [:tape] || Tape.new @state = [:state].to_i @depth = [:depth].to_i || 1 @path = [] end |
Instance Attribute Details
#depth ⇒ Object
Returns the value of attribute depth.
4 5 6 |
# File 'lib/ntm/configuration.rb', line 4 def depth @depth end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/ntm/configuration.rb', line 4 def path @path end |
#state ⇒ Object
Returns the value of attribute state.
4 5 6 |
# File 'lib/ntm/configuration.rb', line 4 def state @state end |
#tape ⇒ Object
Returns the value of attribute tape.
4 5 6 |
# File 'lib/ntm/configuration.rb', line 4 def tape @tape end |
Instance Method Details
#dup ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/ntm/configuration.rb', line 18 def dup conf = Configuration.new conf.state = @state conf.tape = @tape.dup conf.depth = @depth conf.path = @path.dup conf end |
#to_s ⇒ Object
13 14 15 16 |
# File 'lib/ntm/configuration.rb', line 13 def to_s conf = @tape.instance_variable_get(:@content).dup conf.insert(@tape.head_position, "[q#{@state}]").collect!{|e| e ? e : Tape::BLANK }.join end |