Class: EasyType::CommandBuilder
- Inherits:
-
Object
- Object
- EasyType::CommandBuilder
- Defined in:
- lib/easy_type/command_builder.rb
Instance Attribute Summary (collapse)
-
- (Object) after_results
readonly
Returns the value of attribute after_results.
-
- (Object) before_results
readonly
Returns the value of attribute before_results.
-
- (Object) command
Returns the value of attribute command.
-
- (Object) line
Returns the value of attribute line.
-
- (Object) options
readonly
Returns the value of attribute options.
Instance Method Summary (collapse)
- - (Object) <<(line)
- - (Object) after(command = nil)
- - (Object) before(command = nil)
- - (Object) execute
-
- (CommandBuilder) initialize(context, command, line = '', options = {})
constructor
A new instance of CommandBuilder.
Constructor Details
- (CommandBuilder) initialize(context, command, line = '', options = {})
Returns a new instance of CommandBuilder
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/easy_type/command_builder.rb', line 6 def initialize(context, command, line = '', = {}) @context = context @command = translate_to_method(command) @before = [] @after = [] @line = line @before_results = [] @after_results = [] @options = end |
Instance Attribute Details
- (Object) after_results (readonly)
Returns the value of attribute after_results
4 5 6 |
# File 'lib/easy_type/command_builder.rb', line 4 def after_results @after_results end |
- (Object) before_results (readonly)
Returns the value of attribute before_results
4 5 6 |
# File 'lib/easy_type/command_builder.rb', line 4 def before_results @before_results end |
- (Object) command
Returns the value of attribute command
3 4 5 |
# File 'lib/easy_type/command_builder.rb', line 3 def command @command end |
- (Object) line
Returns the value of attribute line
3 4 5 |
# File 'lib/easy_type/command_builder.rb', line 3 def line @line end |
- (Object) options (readonly)
Returns the value of attribute options
4 5 6 |
# File 'lib/easy_type/command_builder.rb', line 4 def @options end |
Instance Method Details
- (Object) <<(line)
17 18 19 20 |
# File 'lib/easy_type/command_builder.rb', line 17 def <<(line) @line << ' ' << line self end |
- (Object) after(command = nil)
31 32 33 34 35 36 37 38 |
# File 'lib/easy_type/command_builder.rb', line 31 def after(command = nil) if command @after << command self else @after end end |
- (Object) before(command = nil)
22 23 24 25 26 27 28 29 |
# File 'lib/easy_type/command_builder.rb', line 22 def before(command = nil) if command @before << command self else @before end end |
- (Object) execute
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/easy_type/command_builder.rb', line 40 def execute @before.each do | before| @before_results << @command.call(before, @options) end value = @command.call(@line, @options ) if @line @after.each do | after| @after_results << @command.call(after, @options) end value end |