Class: Command::Results::StrategyFormatter::FormatStrategy

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/command-set/results.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, formatter) ⇒ FormatStrategy

Returns a new instance of FormatStrategy.



541
542
543
544
545
# File 'lib/command-set/results.rb', line 541

def initialize(name, formatter)
  @name = name
  @formatter = formatter
  setup
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



551
552
553
# File 'lib/command-set/results.rb', line 551

def name
  @name
end

Instance Method Details

#closed_begin_list(list) ⇒ Object

Presenter callback: a list opened, tree order



571
572
573
574
575
576
577
578
579
# File 'lib/command-set/results.rb', line 571

def closed_begin_list(list); 
  unless list.options[:strategy_start] == self or list.options[:format_advice].nil?
    switch_to(list.options[:format_advice][:type])
    if (next_strat = @formatter.current_strategy) != self
      list.options[:strategy_start] = next_strat
      next_strat.closed_begin_list(list)
    end
  end
end

#closed_end_list(list) ⇒ Object

Presenter callback: an list closed, tree order



585
586
587
588
589
# File 'lib/command-set/results.rb', line 585

def closed_end_list(list); 
  if list.options[:strategy_start] == self
    finish
  end
end

#closed_item(item) ⇒ Object

Presenter callback: an item added, tree order



582
# File 'lib/command-set/results.rb', line 582

def closed_item(item); end

#finishObject



557
558
559
# File 'lib/command-set/results.rb', line 557

def finish
  @formatter.pop_strategy(self.name)
end

#saw_begin_list(list) ⇒ Object

Presenter callback: a list has just started



562
# File 'lib/command-set/results.rb', line 562

def saw_begin_list(list); end

#saw_end_list(list) ⇒ Object

Presenter callback: a list has just ended



568
# File 'lib/command-set/results.rb', line 568

def saw_end_list(list); end

#saw_item(item) ⇒ Object

Presenter callback: an item has just been added



565
# File 'lib/command-set/results.rb', line 565

def saw_item(item); end

#setupObject



547
# File 'lib/command-set/results.rb', line 547

def setup; end

#switch_to(name) ⇒ Object



553
554
555
# File 'lib/command-set/results.rb', line 553

def switch_to(name)
  @formatter.push_strategy(name)
end