Class: LazyDoc::Commands::ExtractCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/lazy_doc/commands/extract_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_extractObject (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