Class: CTioga2::Graphics::Legends::LegendProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/ctioga2/graphics/legends/provider.rb

Overview

This class is in charge of providing a legend for the given dataset. Most of its job is simply to collect –legend arguments from the command-line.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLegendProvider

Returns a new instance of LegendProvider.



34
35
36
37
# File 'lib/ctioga2/graphics/legends/provider.rb', line 34

def initialize
  @current_legend = nil
  @auto_legend = false
end

Instance Attribute Details

#auto_legendObject

Whether we automatically give a name to curves or not.



32
33
34
# File 'lib/ctioga2/graphics/legends/provider.rb', line 32

def auto_legend
  @auto_legend
end

#current_legendObject

The legend to be used for the next curve, if applicable



29
30
31
# File 'lib/ctioga2/graphics/legends/provider.rb', line 29

def current_legend
  @current_legend
end

Instance Method Details

#dataset_legend(dataset) ⇒ Object

Returns a legend suitable for the next curve.



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ctioga2/graphics/legends/provider.rb', line 40

def dataset_legend(dataset)
  if @current_legend
    l = @current_legend
    @current_legend = nil
    return l
  elsif @auto_legend
    return "\\texttt{#{Utils::tex_quote_string(dataset.name)}}"
  else
    return nil
  end
end