Class: Tricle::Presenters::Report
- Inherits:
-
Object
- Object
- Tricle::Presenters::Report
- Defined in:
- lib/tricle/presenters/report.rb
Instance Attribute Summary collapse
-
#sections ⇒ Object
readonly
Returns the value of attribute sections.
Instance Method Summary collapse
- #add_group(title = nil) ⇒ Object
- #add_list(klass, opts = {}, &block) ⇒ Object
- #add_metric(klass, opts = {}) ⇒ Object
- #add_section(section) ⇒ Object
-
#initialize ⇒ Report
constructor
A new instance of Report.
Constructor Details
#initialize ⇒ Report
Returns a new instance of Report.
10 11 12 |
# File 'lib/tricle/presenters/report.rb', line 10 def initialize @sections = [] end |
Instance Attribute Details
#sections ⇒ Object (readonly)
Returns the value of attribute sections.
8 9 10 |
# File 'lib/tricle/presenters/report.rb', line 8 def sections @sections end |
Instance Method Details
#add_group(title = nil) ⇒ Object
19 20 21 22 |
# File 'lib/tricle/presenters/report.rb', line 19 def add_group(title=nil) group = Tricle::Presenters::Group.new(title) self.add_section(group) end |
#add_list(klass, opts = {}, &block) ⇒ Object
34 35 36 37 |
# File 'lib/tricle/presenters/report.rb', line 34 def add_list(klass, opts = {}, &block) list = Tricle::List.new(klass, opts, &block) self.add_section(list) end |
#add_metric(klass, opts = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/tricle/presenters/report.rb', line 24 def add_metric(klass, opts = {}) last_section = self.sections.last unless last_section.is_a?(Tricle::Presenters::Group) last_section = self.add_group end # TODO don't assume they want to add this metric to the last group? last_section.add_metric(klass, opts) end |
#add_section(section) ⇒ Object
14 15 16 17 |
# File 'lib/tricle/presenters/report.rb', line 14 def add_section(section) self.sections << section section end |