Class: LazyDoc::Commands::ExtractCommand
- Inherits:
-
Object
- Object
- LazyDoc::Commands::ExtractCommand
- Defined in:
- lib/lazy_doc/commands/extract_command.rb
Instance Attribute Summary collapse
-
#attribute_to_extract ⇒ Object
readonly
Returns the value of attribute attribute_to_extract.
Instance Method Summary collapse
- #execute(value) ⇒ Object
-
#initialize(attribute_to_extract) ⇒ ExtractCommand
constructor
A new instance of ExtractCommand.
Constructor Details
#initialize(attribute_to_extract) ⇒ ExtractCommand
Returns a new instance of ExtractCommand.
6 7 8 |
# File 'lib/lazy_doc/commands/extract_command.rb', line 6 def initialize(attribute_to_extract) @attribute_to_extract = attribute_to_extract end |
Instance Attribute Details
#attribute_to_extract ⇒ Object (readonly)
Returns the value of attribute attribute_to_extract.
4 5 6 |
# File 'lib/lazy_doc/commands/extract_command.rb', line 4 def attribute_to_extract @attribute_to_extract end |
Instance Method Details
#execute(value) ⇒ Object
10 11 12 |
# File 'lib/lazy_doc/commands/extract_command.rb', line 10 def execute(value) attribute_to_extract.nil? ? value : value.map { |element| element[attribute_to_extract.to_s] } end |