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.



536
537
538
539
540
# File 'lib/command-set/results.rb', line 536

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#closed_begin_list(list) ⇒ Object

Presenter callback: a list opened, tree order



566
567
568
569
570
571
572
573
574
# File 'lib/command-set/results.rb', line 566

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



580
581
582
583
584
# File 'lib/command-set/results.rb', line 580

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



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

def closed_item(item); end

#finishObject



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

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

#saw_begin_list(list) ⇒ Object

Presenter callback: a list has just started



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

def saw_begin_list(list); end

#saw_end_list(list) ⇒ Object

Presenter callback: a list has just ended



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

def saw_end_list(list); end

#saw_item(item) ⇒ Object

Presenter callback: an item has just been added



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

def saw_item(item); end

#setupObject



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

def setup; end

#switch_to(name) ⇒ Object



548
549
550
# File 'lib/command-set/results.rb', line 548

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