Class: LazyDoc::Commands::ViaCommand

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ ViaCommand

Returns a new instance of ViaCommand.



5
6
7
# File 'lib/lazy_doc/commands/via_command.rb', line 5

def initialize(path)
  @path = [path].flatten
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/lazy_doc/commands/via_command.rb', line 3

def path
  @path
end

Instance Method Details

#execute(document) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/lazy_doc/commands/via_command.rb', line 9

def execute(document)
  path.inject(document) do |sub_document, attribute|
    attribute_identifier = determine_attribute_identifier(attribute, sub_document)

    sub_document[attribute_identifier]
  end
end