Class: Shufu::Command
- Inherits:
-
Object
- Object
- Shufu::Command
- Defined in:
- lib/shufu/command.rb
Instance Method Summary collapse
- #arguments(schema, values, args) ⇒ Object
-
#initialize(schema) ⇒ Command
constructor
A new instance of Command.
- #to_s(values) ⇒ String
Constructor Details
#initialize(schema) ⇒ Command
Returns a new instance of Command.
6 7 8 |
# File 'lib/shufu/command.rb', line 6 def initialize(schema) @schema = schema end |
Instance Method Details
#arguments(schema, values, args) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/shufu/command.rb', line 22 def arguments(schema, values, args) schema.each do |k, v| if v.is_a?(Hash) args = arguments(v, values, args).prepend(k) else args << Argument.new(name: k, type: v).to_s(values[k]) if values[k] end end args end |
#to_s(values) ⇒ String
14 15 16 |
# File 'lib/shufu/command.rb', line 14 def to_s(values) arguments(@schema, values, []).join(" ") end |