Class: Tabry::Machine
- Inherits:
-
Object
- Object
- Tabry::Machine
- Defined in:
- lib/tabry/machine.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Class Method Summary collapse
-
.run(config, tokens) ⇒ Object
Returns a state.
Instance Method Summary collapse
-
#initialize(config) ⇒ Machine
constructor
A new instance of Machine.
- #run(tokens) ⇒ Object
Constructor Details
#initialize(config) ⇒ Machine
21 22 23 24 |
# File 'lib/tabry/machine.rb', line 21 def initialize(config) @config = config @state = State.new(mode: :subcommand, subcommand_stack: [], args: [], flags: {}, help: false, dashdash: false) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
12 13 14 |
# File 'lib/tabry/machine.rb', line 12 def config @config end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
12 13 14 |
# File 'lib/tabry/machine.rb', line 12 def state @state end |
Class Method Details
.run(config, tokens) ⇒ Object
Returns a state
15 16 17 18 19 |
# File 'lib/tabry/machine.rb', line 15 def self.run(config, tokens) machine = new(config) machine.run(tokens) machine.state end |
Instance Method Details
#run(tokens) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/tabry/machine.rb', line 26 def run(tokens) tokens.each do |token| step(token) Tabry::Util.debug "AFTER token #{token.inspect}" Tabry::Util.debug "STATE: #{state.inspect}" end end |