Class: Tricle::List
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#metric ⇒ Object
readonly
Returns the value of attribute metric.
Instance Method Summary collapse
-
#initialize(klass, opts = {}, &block) ⇒ List
constructor
A new instance of List.
- #items_markup(start_at, end_at) ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(klass, opts = {}, &block) ⇒ List
Returns a new instance of List.
7 8 9 10 |
# File 'lib/tricle/presenters/list.rb', line 7 def initialize(klass, opts = {}, &block) @metric = klass.new(opts) @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
5 6 7 |
# File 'lib/tricle/presenters/list.rb', line 5 def block @block end |
#metric ⇒ Object (readonly)
Returns the value of attribute metric.
5 6 7 |
# File 'lib/tricle/presenters/list.rb', line 5 def metric @metric end |
Instance Method Details
#items_markup(start_at, end_at) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tricle/presenters/list.rb', line 16 def items_markup(start_at, end_at) markup = '' items = self.metric.items_for_range(start_at, end_at) items.each do |item| val = self.block.call(item) markup << %{<tr><td class="list-item" colspan="4">#{val}</td></tr>} end markup end |
#title ⇒ Object
12 13 14 |
# File 'lib/tricle/presenters/list.rb', line 12 def title self.metric.[:title] || self.metric.title end |